auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] support for xemacs


From: Ikumi Keita
Subject: Re: [AUCTeX-devel] support for xemacs
Date: Fri, 17 Mar 2017 00:26:34 +0900

Hi Arash,

>>>>> Arash Esbati <address@hidden> writes:
> I wanted to fix the places where I used this function.  For empheq.el, I
> tried this solution:

> diff --git a/style/empheq.el b/style/empheq.el
> index 9b822898..7ed33fda 100644
> --- a/style/empheq.el
> +++ b/style/empheq.el
> @@ -227,8 +227,17 @@ number of ampersands if possible."
>        (when (looking-at "[ \t\n\r%]*\\[")
>         (forward-sexp))
>        (re-search-forward "[ \t\n\r%]*{\\([^}]+\\)}")
> -      (setq match (replace-regexp-in-string "[ \t\n\r%]" ""
> -                                           (match-string-no-properties 1)))
> +      (setq match
> +           (if (featurep 'xemacs)
> +               (let ((x (match-string-no-properties 1)))
> +                 (with-temp-buffer
> +                   (insert x)
> +                   (goto-char (point-max))
> +                   (while (re-search-backward "[ \t\n\r%]" nil t)
> +                     (replace-match ""))
> +                   (buffer-string)))
> +             (replace-regexp-in-string "[ \t\n\r%]" ""
> +                                       (match-string-no-properties 1))))
>        (if (string-match "=" match)
>           (progn
>             (setq amsenv (car (split-string match "=")))

As I said before, xemacs has a similar function `replace-in-string'.  So
how about an approach defining compatibility function like this?  If
the use of `replace-regexp-in-string' doesn't require its optional
arguments, the compatibility function does the job.

diff --git a/style/empheq.el b/style/empheq.el
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -227,7 +227,7 @@
       (when (looking-at "[ \t\n\r%]*\\[")
        (forward-sexp))
       (re-search-forward "[ \t\n\r%]*{\\([^}]+\\)}")
-      (setq match (replace-regexp-in-string "[ \t\n\r%]" ""
+      (setq match (TeX-replace-regexp-in-string "[ \t\n\r%]" ""
                                            (match-string-no-properties 1)))
       (if (string-match "=" match)
          (progn
diff --git a/tex.el b/tex.el
--- a/tex.el
+++ b/tex.el
@@ -762,7 +762,10 @@
             (/ outer-priority 2))
            ((and inner-priority outer-priority)
             (+ (/ (- outer-priority inner-priority) 2) inner-priority))
-           (t TeX-overlay-priority-step)))) )
+           (t TeX-overlay-priority-step))))
+  (defun TeX-replace-regexp-in-string (regexp rep string)
+    "Compatibility function mimicking `replace-regexp-in-string' for XEmacs."
+    (replace-in-string string regexp rep)) )
 
 ;; require crm here, because we often do
 ;;
@@ -900,7 +903,9 @@
             (/ outer-priority 2))
            ((and inner-priority outer-priority)
             (+ (/ (- outer-priority inner-priority) 2) inner-priority))
-           (t TeX-overlay-priority-step)))) )
+           (t TeX-overlay-priority-step))))
+
+  (defalias #'TeX-replace-regexp-in-string #'replace-regexp-in-string) )
 
 (defun TeX-delete-dups-by-car (alist &optional keep-list)
   "Return a list of all elements in ALIST, but each car only once.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]