auctex-commit
[Top][All Lists]
Advanced

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

[AUCTeX-commit] Changes to auctex/tex-fold.el,v


From: Ralf Angeli
Subject: [AUCTeX-commit] Changes to auctex/tex-fold.el,v
Date: Sat, 10 Feb 2007 15:59:19 +0000

CVSROOT:        /cvsroot/auctex
Module name:    auctex
Changes by:     Ralf Angeli <angeli>    07/02/10 15:59:19

Index: tex-fold.el
===================================================================
RCS file: /cvsroot/auctex/auctex/tex-fold.el,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- tex-fold.el 21 Jan 2007 07:01:32 -0000      1.56
+++ tex-fold.el 10 Feb 2007 15:59:19 -0000      1.57
@@ -92,6 +92,14 @@
                        (repeat :tag "Macros" (string))))
   :group 'TeX-fold)
 
+(defvar TeX-fold-macro-spec-list-internal nil
+  "Internal list of display strings and macros to fold.
+Is updated when the TeX Fold mode is being activated and then
+contains all constructs to fold for the given buffer or mode
+respectively, i.e. contents of both `TeX-fold-macro-spec-list'
+and <mode-prefix>-fold-macro-spec-list.")
+(make-variable-buffer-local 'TeX-fold-macro-spec-list-internal)
+
 (defcustom TeX-fold-env-spec-list
   '(("[comment]" ("comment")))
   "List of display strings and environments to fold."
@@ -100,30 +108,29 @@
                        (repeat :tag "Environments" (string))))
   :group 'TeX-fold)
 
-(defcustom TeX-fold-math-spec-list
-  (delete nil
-         (mapcar (lambda (elt)
-                   (let ((tex-token (nth 1 elt))
-                         (submenu   (nth 2 elt))
-                         (unicode   (nth 3 elt))
-                         uchar noargp)
-                     (when (integerp unicode) (setq uchar (decode-char 'ucs 
unicode)))
-                     (when (listp submenu) (setq submenu (nth 1 submenu)))
-                     (setq noargp
-                           (not (string-match
-                                 (concat "^" (regexp-opt '("Constructs" 
"Accents")))
-                                 submenu)))
-                     (when (and (stringp tex-token) (integerp uchar) noargp)
-                       `(,(char-to-string uchar) (,tex-token)))))
-                 `((nil "to" "" 8594)
-                   (nil "gets" "" 8592)
-                   ,@LaTeX-math-default)))
+(defvar TeX-fold-env-spec-list-internal nil
+  "Internal list of display strings and environments to fold.
+Is updated when the TeX Fold mode is being activated and then
+contains all constructs to fold for the given buffer or mode
+respectively, i.e. contents of both `TeX-fold-env-spec-list'
+and <mode-prefix>-fold-env-spec-list.")
+(make-variable-buffer-local 'TeX-fold-env-spec-list-internal)
+
+(defcustom TeX-fold-math-spec-list nil
   "List of display strings and math macros to fold."
   :type '(repeat (group (choice (string :tag "Display String")
                                (integer :tag "Number of argument" :value 1))
                        (repeat :tag "Math Macros" (string))))
   :group 'TeX-fold)
 
+(defvar TeX-fold-math-spec-list-internal nil
+  "Internal list of display strings and math macros to fold.
+Is updated when the TeX Fold mode is being activated and then
+contains all constructs to fold for the given buffer or mode
+respectively, i.e. contents of both `TeX-fold-math-spec-list'
+and <mode-prefix>-fold-math-spec-list.")
+(make-variable-buffer-local 'TeX-fold-math-spec-list-internal)
+
 (defcustom TeX-fold-unspec-macro-display-string "[m]"
   "Display string for unspecified macros.
 This string will be displayed if a single macro is being hidden
@@ -282,12 +289,13 @@
 for macros and 'math for math macros."
   (save-excursion
     (let (fold-list item-list regexp)
-      (dolist (item (cond ((eq type 'env) TeX-fold-env-spec-list)
-                         ((eq type 'math) TeX-fold-math-spec-list)
-                         (t TeX-fold-macro-spec-list)))
+      (dolist (item (cond ((eq type 'env) TeX-fold-env-spec-list-internal)
+                         ((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)))
+      (when item-list
       (setq regexp (cond ((and (eq type 'env)
                               (eq major-mode 'context-mode))
                          (concat (regexp-quote TeX-esc)
@@ -333,7 +341,7 @@
                     (item-end (TeX-fold-item-end item-start type))
                     (ov (TeX-fold-make-overlay item-start item-end type
                                                display-string-spec)))
-               (TeX-fold-hide-item ov)))))))))
+                 (TeX-fold-hide-item ov))))))))))
 
 (defun TeX-fold-region-comment (start end)
   "Fold all comments in region from START to END."
@@ -424,9 +432,9 @@
                            (if (fboundp 'match-string-no-properties)
                                (match-string-no-properties 1)
                              (match-string 1))))
-              (fold-list (cond ((eq type 'env) TeX-fold-env-spec-list)
-                               ((eq type 'math) TeX-fold-math-spec-list)
-                               (t TeX-fold-macro-spec-list)))
+              (fold-list (cond ((eq type 'env) TeX-fold-env-spec-list-internal)
+                               ((eq type 'math) 
TeX-fold-math-spec-list-internal)
+                               (t TeX-fold-macro-spec-list-internal)))
               fold-item
               (display-string-spec
                (or (catch 'found
@@ -449,7 +457,7 @@
 (defun TeX-fold-comment-do ()
   "Hide the comment on which point currently is located.
 This is the function doing the work for `TeX-fold-comment'.  It
-is an internal function communication with return values rather
+is an internal function communicating with return values rather
 than with messages for the user.
 Return non-nil if a comment was found and folded, nil otherwise."
   (if (and (not (TeX-in-comment)) (not (TeX-in-line-comment)))
@@ -803,7 +811,7 @@
 ;;; Misc
 
 ;; Copy and adaption of `cvs-partition' from pcvs-util.el in GNU Emacs
-;; on 2004-07-05 to make latex-fold.el mainly self-contained.
+;; on 2004-07-05 to make tex-fold.el mainly self-contained.
 (defun TeX-fold-partition-list (p l)
   "Partition a list L into two lists based on predicate P.
 The function returns a `cons' cell where the `car' contains
@@ -834,7 +842,18 @@
       (progn
        (set (make-local-variable 'search-invisible) t)
        (add-hook 'post-command-hook 'TeX-fold-post-command nil t)
-       (add-hook 'LaTeX-fill-newline-hook 'TeX-fold-update-at-point nil t))
+       (add-hook 'LaTeX-fill-newline-hook 'TeX-fold-update-at-point nil t)
+       ;; Update the `TeX-fold-*-spec-list-internal' variables.
+       (dolist (elt '("macro" "env" "math"))
+         (set (intern (format "TeX-fold-%s-spec-list-internal" elt))
+              ;; Append the value of `TeX-fold-*-spec-list' to the
+              ;; mode-specific `<mode-prefix>-fold-*-spec-list' variable.
+              (append (symbol-value (intern (format "TeX-fold-%s-spec-list"
+                                                    elt)))
+                      (let ((symbol (intern (format "%s-fold-%s-spec-list"
+                                                    (TeX-mode-prefix) elt))))
+                        (when (boundp symbol)
+                          (symbol-value symbol)))))))
     (kill-local-variable 'search-invisible)
     (remove-hook 'post-command-hook 'TeX-fold-post-command t)
     (remove-hook 'LaTeX-fill-newline-hook 'TeX-fold-update-at-point t)




reply via email to

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