AUCTeX Sync -- Update all elisp to v11.92
[packages] / xemacs-packages / auctex / tex-fold.el
index 05bd61a..356c268 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tex-fold.el --- Fold TeX macros.
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011-2012
+;; Copyright (C) 2004-2008, 2011-2012, 2014, 2017
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
@@ -28,7 +28,7 @@
 ;;; Commentary:
 
 ;; This file provides support for hiding and unhiding TeX, LaTeX,
-;; ContTeXt, Texinfo and similar macros and environments inside of
+;; ConTeXt, Texinfo and similar macros and environments inside of
 ;; AUCTeX.
 ;;
 ;; Caveats:
@@ -44,6 +44,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (when (featurep 'xemacs)
   (require 'overlay))
 (require 'tex)
@@ -334,8 +336,8 @@ for macros and 'math for math macros."
                          ((eq type 'math) TeX-fold-math-spec-list-internal)
                          (t TeX-fold-macro-spec-list-internal)))
        (dolist (i (cadr item))
-         (add-to-list 'fold-list (list i (car item)))
-         (add-to-list 'item-list i)))
+          (pushnew (list i (car item)) fold-list :test #'equal)
+         (pushnew i item-list :test #'equal)))
       (when item-list
        (setq regexp (cond ((and (eq type 'env)
                                 (eq major-mode 'context-mode))
@@ -466,7 +468,7 @@ Return non-nil if an item was found and folded, nil otherwise."
                                   ((eq type 'env)
                                    (concat (regexp-quote TeX-esc)
                                            "begin[ \t]*{"
-                                           "\\([A-Za-z]+\\)}"))
+                                           "\\([A-Za-z*]+\\)}"))
                                   (t
                                    (concat (regexp-quote TeX-esc)
                                            "\\([A-Za-z@*]+\\)"))))
@@ -708,7 +710,7 @@ breaks will be replaced by spaces."
     (dolist (ov (overlays-at (point)))
       (when (and (eq (overlay-get ov 'category) 'TeX-fold)
                 (numberp (overlay-get ov 'TeX-fold-display-string-spec)))
-       (add-to-list 'overlays ov)))
+       (pushnew ov overlays)))
     (when overlays
       ;; Sort list according to descending starts.
       (setq overlays (sort (copy-sequence overlays)
@@ -763,7 +765,7 @@ Return non-nil if a removal happened, nil otherwise."
   "Expand instances of {<num>}, [<num>], <<num>>, and (<num>).
 Replace them with the respective macro argument."
   (let ((spec-list (split-string spec "||"))
-       (delims '((?{ . ?}) (?[ . ?]) (?< . ?>) (?\( . ?\))))
+       (delims '((?\{ . ?\}) (?\[ . ?\]) (?< . ?>) (?\( . ?\))))
        index success)
     (catch 'success
       ;; Iterate over alternatives.
@@ -808,7 +810,8 @@ That means, put respective properties onto overlay OV."
                           (n 1))
                       (while (setq arg (TeX-fold-macro-nth-arg
                                         n ov-start ov-end))
-                        (add-to-list 'arg-list (car arg) t)
+                         (unless (member (car arg) arg-list)
+                           (setq arg-list (append arg-list (list (car arg)))))
                         (setq n (1+ n)))
                       (or (condition-case nil
                               (apply spec arg-list)