Are there any plans to create the "back to the future" package, with
stuff that older XEmacsen need for forward compatibility? I've synced
up xemacs-base/easy-mmode.el with Emacs 21.3, and it works great with
current 21.5 CVS. However, older XEmacsen won't be able to use it, due
to 2 missing functions, and an older version of a 3rd.
In particular, I need to make the xemacs-base package depend on the
future package, and the future package needs to contain something like
this:
------------------------------------------------------------------------
;; This function is defined in subr.el for XEmacs >= 21.5.7
(if (not (fboundp 'propertize))
(defun propertize (string &rest properties)
"Return a copy of STRING with text properties added.
First argument is the string to copy.
Remaining arguments form a sequence of PROPERTY VALUE pairs for text
properties to add to the result."
(let ((str (copy-sequence string)))
(add-text-properties 0 (length str)
properties
str)
str)))
;; This function is defined in subr.el for XEmacs >= 21.5.12
(if (not (fboundp 'replace-regexp-in-string))
(defun replace-regexp-in-string (regexp rep string &optional
fixedcase literal subexp start)
"Replace all matches for REGEXP with REP in STRING.
Return a new string containing the replacements.
Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
arguments with the same names of function `replace-match'. If START
is non-nil, start replacements at that index in STRING.
REP is either a string used as the NEWTEXT arg of `replace-match' or a
function. If it is a function it is applied to each match to generate
the replacement passed to `replace-match'; the match-data at this
point are such that match 0 is the function's argument.
To replace only the first match (if any), make REGEXP match up to \\'
and replace a sub-expression, e.g.
(replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo
foo\" nil nil 1)
=> \" bar foo\"
"
(let ((l (length string))
(start (or start 0))
matches str mb me)
(save-match-data
(while (and (< start l) (string-match regexp string start))
(setq mb (match-beginning 0)
me (match-end 0))
;; If we matched the empty string, make sure we advance by one char
(when (= me mb) (setq me (min l (1+ mb))))
;; Generate a replacement for the matched substring.
;; Operate only on the substring to minimize string consing.
;; Set up match data for the substring for replacement;
;; presumably this is likely to be faster than munging the
;; match data directly in Lisp.
(string-match regexp (setq str (substring string mb me)))
(setq matches
(cons (replace-match (if (stringp rep)
rep
(funcall rep (match-string 0 str)))
fixedcase literal str subexp)
(cons (substring string start mb) ; unmatched prefix
matches)))
(setq start me))
;; Reconstruct a string from the pieces.
(setq matches (cons (substring string start l) matches)) ; leftover
(apply #'concat (nreverse matches))))))
;; This function is defined in core.
;; It has the 3rd argument in XEmacs >= 21.5.16.
(when (eq (function-max-args #'pos-visible-in-window-p) 2)
(fset 'pos-visible-in-window-p
`(lambda (&optional pos window partially)
"Returns t if position POS is currently on the frame in WINDOW.
Returns nil if that position is scrolled vertically out of view.
If a character is only partially visible, nil is returned, unless the
optional argument PARTIALLY is non-nil.
POS defaults to point in WINDOW's buffer; WINDOW, to the selected window."
(funcall ,(symbol-function 'pos-visible-in-window-p) pos window))))
------------------------------------------------------------------------
Once that is in place, we can put the easy-mmode.el patch into place.
I've seen several Lisp packages now that use the new functionality, so
we need this patch before they can be ported to XEmacs.
--
Jerry James
http://www.ittc.ku.edu/~james/