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