auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Suggested patch for AUCTeX


From: Stefan Monnier
Subject: [AUCTeX-devel] Suggested patch for AUCTeX
Date: Sun, 02 Nov 2014 01:02:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Here's a patch mostly based on byte-compiler warnings.


        Stefan


diff --git a/bib-cite.el b/bib-cite.el
index 612641c..f1a113b 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -1,7 +1,7 @@
 ;;; bib-cite.el --- test
 ;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file.
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005, 
2014
 ;; Free Software Foundation
 
 ;; Author:    Peter S. Galbraith <address@hidden>
@@ -724,9 +724,6 @@ These are usually month abbreviations (or journals) defined 
in a style file."
   "*Regular expression for \\ref LaTeX commands that have a matching \\label.
 A opening curly bracket is appended to the regexp.")
 
-(defvar bib-cite-is-XEmacs
-  (not (null (save-match-data (string-match "XEmacs\\|Lucid" emacs-version)))))
-
 (defvar bib-cite-minor-mode nil)
 
 (defvar bib-highlight-mouse-keymap (make-sparse-keymap)
@@ -762,11 +759,11 @@ runs bib-find, and [mouse-3] runs bib-display."
        (progn
          (bib-cite-setup-highlight-mouse-keymap)
          (bib-highlight-mouse)
-         (when bib-cite-is-XEmacs
+         (when (featurep 'xemacs)
            (make-local-hook 'after-change-functions))
          (add-hook 'after-change-functions
                    'bib-cite-setup-mouse-function nil t)))
-    (if bib-cite-is-XEmacs
+    (if (featurep 'xemacs)
        (progn
          (or (local-variable-p 'current-menubar (current-buffer))
              (set-buffer-menubar current-menubar))
@@ -775,7 +772,7 @@ runs bib-find, and [mouse-3] runs bib-display."
    ;;;Undo the minor-mode
     ;; mouse overlay
     (cond
-     (bib-cite-is-XEmacs
+     ((featurep 'xemacs)
       (while bib-ext-list
        (delete-extent (car bib-ext-list))
        (setq bib-ext-list (cdr bib-ext-list))))
@@ -786,7 +783,7 @@ runs bib-find, and [mouse-3] runs bib-display."
        ;; FIXME Hope no other package is using them in this buffer!
        (remove-text-properties (point-min) (point-max)
                                '(mouse-face t local-map t)))))
-    (if bib-cite-is-XEmacs
+    (if (featurep 'xemacs)
        (delete-menu-item '("BCite"))))))
 
 ;;This must be eval'ed when the LaTeX mode is in use.
@@ -803,7 +800,7 @@ runs bib-find, and [mouse-3] runs bib-display."
    ;;;        display the bib-cite stuff (or a subset of it).
        (let ((m (copy-keymap (current-local-map))))
          (cond
-          (bib-cite-is-XEmacs
+          ((featurep 'xemacs)
            (set-keymap-name m 'bib-highlight-mouse-keymap)
            (cond
             ;;action-key stuff from Vladimir Alexiev <address@hidden>
@@ -849,7 +846,7 @@ runs bib-find, and [mouse-3] runs bib-display."
   "Unconditionally turn on Bib Cite mode."
   (bib-cite-minor-mode 1))
 
-(defun bib-cite-setup-mouse-function (beg end old-len)
+(defun bib-cite-setup-mouse-function (beg end _old-len)
   (save-excursion
     (save-match-data
       (save-restriction
@@ -893,7 +890,7 @@ runs bib-find, and [mouse-3] runs bib-display."
 
 ;;; Add a menu entry to bibtex.el (Perhaps I should not do this).
 (cond
- ((and (string-match "XEmacs\\|Lucid" emacs-version)
+ ((and (featurep 'xemacs)
        (or window-system
           (fboundp 'smart-menu)))      ;text menus by Bob Weiner
   ;;
@@ -927,7 +924,7 @@ runs bib-find, and [mouse-3] runs bib-display."
     (add-hook 'bibtex-mode-hook 'bib-cite-bibtex-mode-hook))
   )
 
- ((and (not (string-match "XEmacs\\|Lucid" emacs-version))
+ ((and (not (featurep 'xemacs))
        (string-equal "19" (substring emacs-version 0 2))
        (or window-system
           (fboundp 'tmm-menubar)))     ; 19.30 - Will autoload if necessary
@@ -1160,7 +1157,7 @@ by using bib-apropos sequentially."
       (if (not the-text)
          (message "Sorry, no matches found.")
        (with-output-to-temp-buffer "*Help*"
-         (mapcar 'princ (nreverse the-text)))
+         (mapc #'princ (nreverse the-text)))
        (bib-cite-fontify-help-as-bibtex)
        (if bib-novice
            (message
@@ -1236,18 +1233,19 @@ to create a bibtex file containing only the references 
used in the document."
       (put-text-property (point-min)(or limit (point-max))
                         'face 'red-bold))))
 
-(defun bib-cite-fontify-help-xemacs (defaults)
-  (if (fboundp 'font-lock-set-defaults-1) ; >= XEmcas 19.14
-      (progn
-       (set-buffer "*Help*")
-       (setq font-lock-defaults-computed nil
-             font-lock-keywords nil)
-       (font-lock-set-defaults-1
-        (and defaults (font-lock-find-font-lock-defaults defaults)))
-       (font-lock-fontify-buffer)
-       (setq font-lock-defaults-computed nil
-             font-lock-keywords nil)
-       (font-lock-set-defaults-1))))
+(when (featurep 'xemacs)
+  (defun bib-cite-fontify-help-xemacs (defaults)
+    (if (fboundp 'font-lock-set-defaults-1) ; >= XEmacs 19.14
+        (progn
+          (set-buffer "*Help*")
+          (setq font-lock-defaults-computed nil
+                font-lock-keywords nil)
+          (font-lock-set-defaults-1
+           (and defaults (font-lock-find-font-lock-defaults defaults)))
+          (font-lock-fontify-buffer)
+          (setq font-lock-defaults-computed nil
+                font-lock-keywords nil)
+          (font-lock-set-defaults-1)))))
 
 (defun bib-cite-fontify-help-as-bibtex ()
   (save-excursion
@@ -1255,7 +1253,7 @@ to create a bibtex file containing only the references 
used in the document."
      ((not (featurep 'font-lock))
       nil)                              ;No font-lock! Stop here.
      ;; font-lock under Emacs and XEmacs
-     ((string-match "XEmacs\\|Lucid" emacs-version)
+     ((featurep 'xemacs)
       ;; XEmacs
       (bib-cite-fontify-help-xemacs 'bibtex-mode))
      (t
@@ -1265,8 +1263,10 @@ to create a bibtex file containing only the references 
used in the document."
             '(bib-cite-bibtex-font-lock-keywords
               nil t ((?$ . "\"")(?\" . ".")))))
        (if font-lock-mode
-           (font-lock-mode)
+           (font-lock-mode)     ;FIXME: Is that supposed to enable or disable?
          (if (fboundp 'font-lock-unset-defaults) (font-lock-unset-defaults))
+          ;; FIXME: Why unfontify if font-lock is already off, and we fontify
+          ;; it on the next line anyway?
          (font-lock-unfontify-buffer))
        (font-lock-fontify-buffer))))))
 
@@ -1276,7 +1276,7 @@ to create a bibtex file containing only the references 
used in the document."
      ((not (featurep 'font-lock))
       nil)                              ;No font-lock! Stop here.
      ;; font-lock under Emacs and XEmacs
-     ((string-match "XEmacs\\|Lucid" emacs-version)
+     ((featurep 'xemacs)
       ;; XEmacs, not necessary to do s.th. special for font-latex, we do *not*
       ;; want the buffer-local faces!
       (bib-cite-fontify-help-xemacs 'latex-mode))
@@ -1299,8 +1299,10 @@ to create a bibtex file containing only the references 
used in the document."
                   (font-lock-mark-block-function . mark-paragraph))
               '(tex-font-lock-keywords nil nil ((?$ . "\""))))))
        (if font-lock-mode
-           (font-lock-mode)
+           (font-lock-mode)     ;FIXME: Is that supposed to enable or disable?
          (if (fboundp 'font-lock-unset-defaults) (font-lock-unset-defaults))
+          ;; FIXME: Why unfontify if font-lock is already off, and we fontify
+          ;; it on the next line anyway?
          (font-lock-unfontify-buffer))
        (font-lock-fontify-buffer))))))
 
@@ -1347,7 +1349,7 @@ See variables bib-etags-command and bib-etags-filename"
     ;;  tags-file-name set.
     ;;  To get around this.  I'm setting this variable in the TAGS buffer.
     ;; Skip this in XEmacs (Changed by Anders Stenman)
-    (if (and (not (string-match "XEmacs\\|Lucid" emacs-version))
+    (if (and (not (featurep 'xemacs))
             (get-file-buffer the-tags-file))
        (with-current-buffer (get-file-buffer the-tags-file)
          (set (make-local-variable 'tags-file-name) the-tags-file))))
@@ -1390,7 +1392,7 @@ See variables bib-etags-command and bib-etags-filename"
       ;; * peta Wed Nov  8 16:27:29 1995 -- better remove the mouse face
       ;;   properties first.
       (setq bib-ext-list nil)          ;Reconstructed below...
-      (if (string-match "XEmacs\\|Lucid" emacs-version)
+      (if (featurep 'xemacs)
          (while local-extent-list
            (setq extent (car local-extent-list))
            (if (or (extent-detached-p extent)
@@ -1415,7 +1417,7 @@ See variables bib-etags-command and bib-etags-filename"
        (setq s (match-beginning 0))
        (setq e (match-end 0))
        (cond
-        ((string-match "XEmacs\\|Lucid" emacs-version)
+        ((featurep 'xemacs)
          (setq extent (make-extent s e))
          (setq bib-ext-list (cons extent bib-ext-list))
          (set-extent-property extent 'highlight t)
@@ -1448,7 +1450,7 @@ See variables bib-etags-command and bib-etags-filename"
     (let ((modified (buffer-modified-p))
          (inhibit-read-only t))
       (cond
-       ((string-match "XEmacs\\|Lucid" emacs-version)
+       ((featurep 'xemacs)
        (while bib-ext-list
          (delete-extent (car bib-ext-list))
          (setq bib-ext-list (cdr bib-ext-list))))
@@ -1726,7 +1728,7 @@ If within a multi-file document (in auctex only)
     (if (looking-at "\n")  ;Remove first empty line...
        (delete-char 1))
     (with-output-to-temp-buffer "*Help*"
-      (princ (buffer-substring 1 (point-max))))
+      (princ (buffer-substring (point-min) (point-max))))
     (bib-cite-fontify-help-as-latex)
     (kill-buffer "*BiBTemp*"))
    (t
@@ -2307,7 +2309,7 @@ Makes sure TAGS file exists, etc."
     ;; find-tag-noselect should set the TAGS file for the new buffer
     ;; that's what C-h f visit-tags-table says...
     (cond
-     ((string-match "XEmacs\\|Lucid" emacs-version)
+     ((featurep 'xemacs)
       (find-tag tag)
       (setq new-buffer (current-buffer))
       (set-buffer the-buffer))
@@ -2420,6 +2422,10 @@ although BiBTeX doesn't allow it!"
            (setq doNext nil)))
        (mapcar 'list the-list)))))
 
+(defvar TeX-auto-save)
+(defvar TeX-auto-update)
+(defvar TeX-auto-regexp-list)
+
 ;; BibTeX-mode key def to create AUCTeX's parsing file.
 (defun bib-create-auto-file ()
   "Force the creation of the AUCTeX auto file for a bibtex buffer."
@@ -2427,8 +2433,8 @@ although BiBTeX doesn't allow it!"
   (if (not (require 'latex))
       (error "Sorry, This is only useful if you have AUCTeX"))
   (let ((TeX-auto-save t)
-       (TeX-auto-update t)
-       (TeX-auto-regexp-list BibTeX-auto-regexp-list))
+        (TeX-auto-update t)
+        (TeX-auto-regexp-list BibTeX-auto-regexp-list))
     ;; TeX-auto-write
     ;; -> calls TeX-auto-store
     ;;    -> calls TeX-auto-parse
diff --git a/context.el b/context.el
index b9ce2c0..f871c6b 100644
--- a/context.el
+++ b/context.el
@@ -64,16 +64,19 @@
 
 ;;; variables
 
-;; globals used in certain macro's.
-(defvar done-mark nil
-  "Position of point afterwards, default nil (meaning end).")
+;; Dynamically scoped vars used in certain macro's.
+;; BEWARE: We used to give them a global nil value, but this can mess up poor
+;; unrelated packages using those same vars but expecting them to be
+;; lexically scoped.
+;; So don't give them a global value, which makes sure the effect of `defvar'
+;; localized to this file!
+(defvar done-mark)     ;Position of point afterwards, default nil (meaning end)
 
-(defvar reference nil
-  "Set by `ConTeXt-section-ref', used by `ConTeXt-section-section'.")
-
-(defvar title nil
-  "Set by `ConTeXt-section-title', used by `ConTeXt-section-section'.")
+(defvar reference);Used by `ConTeXt-section-ref' and `ConTeXt-section-section'.
 
+(defvar title); Used by `ConTeXt-section-title' and `ConTeXt-section-section'.
+(defvar name)
+(defvar level)
 
 ;; others
 
@@ -302,8 +305,8 @@ The following variables can be set to customize:
                       (ConTeXt-up-section (- val)))
                      (t val)))
         (name (ConTeXt-numbered-section-name level))
-        (toc nil)
         (title "")
+         (reference nil)
         (done-mark (make-marker)))
     (newline)
     (run-hooks 'ConTeXt-numbered-section-hook)
@@ -410,9 +413,9 @@ section."
 
 The following variables are set before the hooks are run
 
-level - numeric section level, see the documentation of `ConTeXt-section'.
-name - name of the sectioning command, derived from `level'.
-title - The title of the section, default to an empty string.
+`level' - numeric section level, see the documentation of `ConTeXt-section'.
+`name' - name of the sectioning command, derived from `level'.
+`title' - The title of the section, default to an empty string.
 `done-mark' - Position of point afterwards, default nil (meaning end).
 
 The following standard hook exist -
@@ -451,13 +454,14 @@ in your .emacs file."
     ConTeXt-section-title
     ConTeXt-section-ref
     ConTeXt-section-section)
+  ;; FIXME: I can't see where this variable is used!
   "List of hooks to run when a new section is inserted.
 
 The following variables are set before the hooks are run
 
-level - numeric section level, see the documentation of `ConTeXt-section'.
-name - name of the sectioning command, derived from `level'.
-title - The title of the section, default to an empty string.
+`level' - numeric section level, see the documentation of `ConTeXt-section'.
+`name' - name of the sectioning command, derived from `level'.
+`title' - The title of the section, default to an empty string.
 `done-mark' - Position of point afterwards, default nil (meaning end).
 
 The following standard hook exist -
@@ -856,8 +860,7 @@ If INNER is non-nil, go to the point just past before
                        (ConTeXt-environment-stop-name)
                        "\\)"
                        ))
-       (level 1)
-       (pos))
+       (level 1))
     ;;jump over the \start... when at the beginning of it.
     (when (looking-at (concat (regexp-quote TeX-esc)
                              (ConTeXt-environment-start-name)))
@@ -935,13 +938,13 @@ If INNER is non-nil, go to the point just past the 
\\start... macro."
 
 ;;; Macro Argument Hooks
 
-(defun ConTeXt-optional-argument-insert (arg &optional prefix)
+(defun ConTeXt-optional-argument-insert (arg &optional _prefix)
   "Insert ARG surrounded by square brackets."
   (insert ConTeXt-optop)
   (insert arg)
   (insert ConTeXt-optcl))
 
-(defun ConTeXt-required-argument-insert (arg &optional prefix)
+(defun ConTeXt-required-argument-insert (arg &optional _prefix)
   "Insert ARG surrounded by curly braces."
   (insert TeX-grop)
   (insert arg)
@@ -1150,7 +1153,7 @@ An optional fourth (or sixth) element means always 
replace if t."
   (modify-syntax-entry ?\( "." ConTeXt-indent-syntax-table)
   (modify-syntax-entry ?\) "." ConTeXt-indent-syntax-table))
 
-(defun ConTeXt-indent-line (&optional arg)
+(defun ConTeXt-indent-line (&optional _arg)
   (with-syntax-table ConTeXt-indent-syntax-table
     ;; TODO: Rather than ignore $, we should try to be more clever about it.
     (let ((indent
@@ -1696,7 +1699,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   (easy-menu-add ConTeXt-mode-command-menu ConTeXt-mode-map)
   (setq ConTeXt-menu-changed t)
 
-  (if (= emacs-major-version 20)
+  (if (fboundp 'make-local-hook)
       (make-local-hook 'activate-menubar-hook))
   (add-hook 'activate-menubar-hook 'ConTeXt-menu-update nil t)
 
diff --git a/latex.el b/latex.el
index af1c676..d89c793 100644
--- a/latex.el
+++ b/latex.el
@@ -28,6 +28,7 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))       ;FIXME: Use cl-lib.
 (require 'tex)
 (require 'tex-style)
 
@@ -106,6 +107,13 @@ This depends on `LaTeX-insert-into-comments'."
 
 ;;; Sections
 
+;; Declare dynamically scoped vars.
+(defvar title)
+(defvar name)
+(defvar level)
+(defvar done-mark)
+(defvar toc)
+
 (defun LaTeX-section (arg)
   "Insert a template for a LaTeX section.
 Determine the type of section to be inserted, by the argument ARG.
@@ -791,7 +799,7 @@ work analogously."
 
 To insert a hook here, you must insert it in the appropiate style file.")
 
-(defun LaTeX-env-document (&optional ignore)
+(defun LaTeX-env-document (&optional _ignore)
   "Create new LaTeX document.
 Also inserts a \\documentclass macro if there's none already and
 prompts for the insertion of \\usepackage macros.
@@ -1169,6 +1177,8 @@ You may use `LaTeX-item-list' to change the routines used 
to insert the item."
       (TeX-insert-macro "item"))
     (indent-according-to-mode)))
 
+(defvar TeX-arg-item-label-p)
+
 (defun LaTeX-item-argument ()
   "Insert a new item with an optional argument."
   (let ((TeX-arg-item-label-p t))
@@ -1478,8 +1488,10 @@ The input string may include LaTeX comments and 
newlines."
                           (point))))
         ;; Add entry to output.
         ((or (string= match ",") (= (point) (point-max)))
-         (add-to-list 'opts (buffer-substring-no-properties
-                             start (1- (point))) t)
+          (let ((entry (buffer-substring-no-properties
+                        start (1- (point)))))
+            (unless (member entry opts)
+              (setq opts (append opts (list entry)))))
          (setq start (point)))
         ;; Get rid of comments.
         ((string= match "%")
@@ -1710,6 +1722,8 @@ list of defined labels."
        (LaTeX-add-labels label))
     (TeX-argument-insert label optional optional)))
 
+(defvar reftex-ref-macro-prompt)
+
 (defun TeX-arg-ref (optional &optional prompt definition)
   "Let-bind `reftex-ref-macro-prompt' to nil and pass arguments
 to `TeX-arg-label'.
@@ -1719,7 +1733,7 @@ arguments: OPTIONAL, PROMPT, and DEFINITION."
   (let ((reftex-ref-macro-prompt nil))
     (TeX-arg-label optional prompt definition)))
 
-(defun TeX-arg-index-tag (optional &optional prompt &rest args)
+(defun TeX-arg-index-tag (optional &optional prompt &rest _args)
   "Prompt for an index tag.
 This is the name of an index, not the entry.
 
@@ -1951,7 +1965,7 @@ May be reset with `\\[universal-argument] 
\\[TeX-normal-mode]'.")
 
 To insert a hook here, you must insert it in the appropiate style file.")
 
-(defun TeX-arg-document (optional &optional ignore)
+(defun TeX-arg-document (optional &optional _ignore)
   "Insert arguments to documentclass.
 OPTIONAL and IGNORE are ignored."
   (let* ((TeX-file-extensions '("cls"))
@@ -2066,7 +2080,7 @@ of the options, nil otherwise."
   (insert TeX-grop (mapconcat 'identity packages ",") TeX-grcl)
   (run-hooks 'LaTeX-after-usepackage-hook))
 
-(defun LaTeX-arg-usepackage (optional)
+(defun LaTeX-arg-usepackage (_optional)
   "Insert arguments to usepackage.
 OPTIONAL is ignored."
   (let* ((packages-options (LaTeX-arg-usepackage-read-packages-with-options))
@@ -2313,7 +2327,7 @@ the list of defined pagestyles."
   :group 'LaTeX-macro
   :type 'character)
 
-(defun TeX-arg-verb (optional &optional ignore)
+(defun TeX-arg-verb (optional &optional _ignore)
   "Prompt for delimiter and text.
 If OPTIONAL is non-nil, insert the resulting value as an optional
 argument, otherwise as a mandatory one.  IGNORE is ignored."
@@ -2461,6 +2475,8 @@ OPTIONAL is ignored."
        (LaTeX-insert-corresponding-right-macro-and-brace
         left-macro left-brace optional)))))
 
+(defvar TeX-arg-right-insert-p)
+
 (defun LaTeX-insert-left-brace (arg)
   "Insert typed left brace ARG times and possibly a correspondig right brace.
 Automatic right brace insertion is done only if no prefix ARG is given and
@@ -2940,7 +2956,8 @@ Lines starting with an item is given an extra indentation 
of
     ;; the 'invisible property.
     (dolist (ol overlays)
       (when (extent-property ol 'invisible)
-       (add-to-list 'ol-specs (list ol (extent-property ol 'invisible)))
+        (pushnew (list ol (extent-property ol 'invisible))
+                 ol-specs :test #'equal)
        (set-extent-property ol 'invisible nil)))
     (save-excursion
       (cond ((and fill-prefix
@@ -3716,8 +3733,7 @@ space does not end a sentence, so don't break a line 
there."
   (when LaTeX-fill-break-at-separators
     (let ((orig-breakpoint (point))
          (final-breakpoint (point))
-         start-point
-         math-sep)
+         start-point)
       (save-excursion
        (beginning-of-line)
        (LaTeX-back-to-indentation)
@@ -5262,9 +5278,9 @@ environmens."
   "Create an entry for the change environment menu."
   (vector (car entry) (list 'LaTeX-modify-environment (car entry)) t))
 
-(defun LaTeX-section-enable-symbol (LEVEL)
+(defun LaTeX-section-enable-symbol (level)
   "Symbol used to enable section LEVEL in the menu bar."
-  (intern (concat "LaTeX-section-" (int-to-string (nth 1 entry)) "-enable")))
+  (intern (concat "LaTeX-section-" (int-to-string level) "-enable")))
 
 (defun LaTeX-section-enable (entry)
   "Enable or disable section ENTRY from `LaTeX-section-list'."
@@ -6298,10 +6314,10 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
          (format "\\\\end{%s}"
                  (regexp-opt
                   (let (out)
-                    (mapcar (lambda (x)
-                              (when (eq (cadr x) 'LaTeX-indent-tabular)
-                                (push (car x) out)))
-                            LaTeX-indent-environment-list)
+                    (mapc (lambda (x)
+                             (when (eq (cadr x) 'LaTeX-indent-tabular)
+                               (push (car x) out)))
+                           LaTeX-indent-environment-list)
                     out)))))
      (cond ((looking-at tabular-like-end-regex)
            beg-col)
diff --git a/multi-prompt.el b/multi-prompt.el
index 25ba4c9..ed88d15 100644
--- a/multi-prompt.el
+++ b/multi-prompt.el
@@ -1,6 +1,6 @@
 ;;; multi-prompt.el --- Completing read of multiple strings
 
-;; Copyright (C) 1996, 1997, 2000, 2009 Free Software Foundation
+;; Copyright (C) 1996, 1997, 2000, 2009, 2014 Free Software Foundation
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Maintainer: address@hidden
@@ -62,7 +62,6 @@ are the arguments to `completing-read'.  See that."
     (let* ((minibuffer-local-completion-map new-map)
           (minibuffer-local-must-match-map new-map)
           (multi-prompt-found nil)
-          (done nil)
           (filter (cond (unique
                          (lambda (x)
                            (and (not (member (car x) multi-prompt-found))
@@ -119,8 +118,8 @@ are the arguments to `completing-read'.  See that."
   (interactive)
   (when  (call-interactively 'minibuffer-complete)
     (let ((content (buffer-substring-no-properties (point-min) (point-max))))
-      (when (or (not require-match)
-               (assoc content table))
+      (when (or ;; (not require-match)
+                (assoc content minibuffer-completion-table))
        (throw 'multi-prompt-next content)))))
 
 
diff --git a/preview.el b/preview.el
index 8619ffe..df64f80 100644
--- a/preview.el
+++ b/preview.el
@@ -52,8 +52,8 @@ preview-latex buffers will not survive across sessions.")))
       (require 'reporter)
     (file-error (message "Missing reporter library, probably from the mail-lib 
package:
 preview-latex's bug reporting commands will probably not work.")))
-  (require 'info)
-  (defvar error))
+  (require 'info))
+(defvar error)
 
 ;; we need the compatibility macros which do _not_ get byte-compiled.
 (eval-when-compile
@@ -506,19 +506,20 @@ of a cell used for string concatenation."
    (t (error "Bad string expansion"))))
 
 (defconst preview-expandable-string
-  ((lambda (f) (funcall f (funcall f 'sexp)))
-   (lambda (x)
-     `(choice
-       string
-       (repeat :tag "Concatenate"
-       (choice
-        string
-        (cons :tag "Separated list"
-              (choice (string :tag "Separator")
-                      (symbol :tag "Indirect separator or flag"))
-              ,x)
-        (symbol :tag "Indirect variable (no separator)")))
-       (symbol :tag "Indirect variable (with separator)"))))
+  (let ((f (lambda (x)
+             `(choice
+               string
+               (repeat :tag "Concatenate"
+                       (choice
+                        string
+                        (cons :tag "Separated list"
+                              (choice (string :tag "Separator")
+                                      (symbol :tag
+                                              "Indirect separator or flag"))
+                              ,x)
+                        (symbol :tag "Indirect variable (no separator)")))
+               (symbol :tag "Indirect variable (with separator)")))))
+    (funcall f (funcall f 'sexp)))
   "Type to be used for `preview-string-expand'.
 Just a hack until we get to learn how to do this properly.
 Recursive definitions are not popular with Emacs,
@@ -1157,7 +1158,7 @@ Place point at POSITION, else beginning of file."
   (let ((default-major-mode
          (or
           (assoc-default "x.ps" auto-mode-alist #'string-match)
-          default-major-mode))
+          (default-value 'major-mode)))
        (buff (get-file-buffer file)))
     (save-excursion
       (if buff
@@ -2267,8 +2268,7 @@ See description of `TeX-command-list' for details."
 
 (defun preview-copy-text (ov)
   "Copy the text of OV into the kill buffer."
-  (save-excursion
-    (set-buffer (overlay-buffer ov))
+  (with-current-buffer (overlay-buffer ov)
     (copy-region-as-kill (overlay-start ov) (overlay-end ov))))
 
 (defun preview-copy-mml (ov)
@@ -2665,7 +2665,7 @@ call, and in its CDR the final stuff for the placement 
hook."
          (lsnippet 0) lstart (lfile "") lline lbuffer lpoint
          lcounters
          string after-string error context-start
-         context offset
+         offset
          parsestate (case-fold-search nil)
          (run-buffer (current-buffer))
          (run-coding-system preview-coding-system)
@@ -2694,39 +2694,39 @@ call, and in its CDR the final stuff for the placement 
hook."
  !\\(?:offset(\\([---0-9]+\\))\\|\
 name(\\([^)]+\\))\\)\\|\
 ^Preview: \\([a-zA-Z]+\\) \\([^\n\r]*\\)\r?$" nil t)
-;;; Ok, here is a line by line breakdown:
-;;; match-alternative 1:
-;;; error indicator for TeX error, either style.
-;;; match-alternative 2:
-;;; The same, but file-line-error-style, matching on file name.
-;;; match-alternative 3:
-;;; Too ugly to describe in detail.  In short, we try to catch file
-;;; names built from path components that don't contain spaces or
-;;; other special characters once the file extension has started.
-;;;
-;;; Position for searching immediately after the file name so as to
-;;; not miss closing parens or something.
-;;; (match-string 3) is the file name.
-;;; match-alternative 4:
-;;; )+\( \|$\)
-;;; a closing paren followed by the end of line or a space: a just
-;;; closed file.
-;;; match-alternative 5 (wrapped into one shy group with
-;;; match-alternative 6, so that the match on first char is slightly
-;;; faster):
-;;; !offset(\([---0-9]+\))
-;;; an AUCTeX offset message. (match-string 5) is the offset itself
-;;; !name(\([^)]+\))
-;;; an AUCTeX file name message.  (match-string 6) is the file name
-;;; TODO: Actually, the latter two should probably again match only
-;;; after a space or newline, since that it what \message produces.
-;;;disabled in prauctex.def:
-;;;\(?:Ov\|Und\)erfull \\.*[0-9]*--[0-9]*
-;;;\(?:.\{79\}
-;;;\)*.*$\)\|
-;;; This would have caught overfull box messages that consist of
-;;; several lines of context all with 79 characters in length except
-;;; of the last one.  prauctex.def kills all such messages.
+;;;   Ok, here is a line by line breakdown:
+;;;   match-alternative 1:
+;;;   error indicator for TeX error, either style.
+;;;   match-alternative 2:
+;;;   The same, but file-line-error-style, matching on file name.
+;;;   match-alternative 3:
+;;;   Too ugly to describe in detail.  In short, we try to catch file
+;;;   names built from path components that don't contain spaces or
+;;;   other special characters once the file extension has started.
+;;;  
+;;;   Position for searching immediately after the file name so as to
+;;;   not miss closing parens or something.
+;;;   (match-string 3) is the file name.
+;;;   match-alternative 4:
+;;;   )+\( \|$\)
+;;;   a closing paren followed by the end of line or a space: a just
+;;;   closed file.
+;;;   match-alternative 5 (wrapped into one shy group with
+;;;   match-alternative 6, so that the match on first char is slightly
+;;;   faster):
+;;;   !offset(\([---0-9]+\))
+;;;   an AUCTeX offset message. (match-string 5) is the offset itself
+;;;   !name(\([^)]+\))
+;;;   an AUCTeX file name message.  (match-string 6) is the file name
+;;;   TODO: Actually, the latter two should probably again match only
+;;;   after a space or newline, since that it what \message produces.
+;;;  disabled in prauctex.def:
+;;;  \(?:Ov\|Und\)erfull \\.*[0-9]*--[0-9]*
+;;;  \(?:.\{79\}
+;;;  \)*.*$\)\|
+;;;   This would have caught overfull box messages that consist of
+;;;   several lines of context all with 79 characters in length except
+;;;   of the last one.  prauctex.def kills all such messages.
              (setq file (match-string-no-properties 2))
              (cond
               ((match-beginning 1)
@@ -2762,9 +2762,9 @@ name(\\([^)]+\\))\\)\\|\
                            context-start (point)
 
                            ;; And the line number to position the cursor.
-;;; variant 1: profiling seems to indicate the regexp-heavy solution
-;;; to be favorable.  Removing incomplete characters from the error
-;;; context is an absolute nuisance.
+;;;  variant 1: profiling seems to indicate the regexp-heavy solution
+;;;  to be favorable.  Removing incomplete characters from the error
+;;;  context is an absolute nuisance.
                            line (and (re-search-forward "\
 ^l\\.\\([0-9]+\\) 
\\(\\.\\.\\.\\(?:\\^*\\(?:[89a-f][0-9a-f]\\|address@hidden)\\|\
 \[0-9a-f]?\\)\\)?\\([^\n\r]*?\\)\r?
@@ -2804,11 +2804,12 @@ name(\\([^)]+\\))\\)\\|\
                                (setq slow-hook
                                      (nconc slow-hook (list lst)))))))
                        (condition-case err
-                           (save-excursion (run-hooks 'slow-hook))
+                           (save-excursion (mapc #'funcall slow-hook))
                          (error (preview-log-error err "Translation hook")))
                        (push (vector file (+ line offset)
                                      string after-string
-                                     snippet box counters) parsestate)))
+                                     snippet box counters)
+                              parsestate)))
                  ;; else normal error message
                  (forward-line)
                  (re-search-forward "^l\\.[0-9]" nil t)
@@ -2905,7 +2906,8 @@ name(\\([^)]+\\))\\)\\|\
                                                       'end
                                                       (- line lline))
                                  (forward-line (- line lline)))))
-                       (goto-line line))
+                        (goto-char (point-min))
+                        (forward-line (1- line)))
                      (setq lpoint (point))
                      (cond
                       ((search-forward (concat string after-string)
diff --git a/prv-install.el b/prv-install.el
index 52cba8f..158be5a 100644
--- a/prv-install.el
+++ b/prv-install.el
@@ -1,6 +1,6 @@
 ;;; prv-install.el --- Complicated install-time magic for preview-latex.
 
-;; Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2005, 2014  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: convenience, tex, wp
@@ -105,7 +105,7 @@ package name, and version (to be evaluated), followed by a 
file to append."
       (fset 'message si:message))
     (while (setq append-file (pop command-line-args-left))
       (when (file-exists-p generated-autoload-file)
-       (with-temp-buffer (insert-file append-file)
+       (with-temp-buffer (insert-file-contents append-file)
                          (append-to-file (point-min) (point-max)
                                          generated-autoload-file))))
     (byte-compile-file generated-autoload-file)))
diff --git a/tex-buf.el b/tex-buf.el
index a3538ba..b6a3a31 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1383,6 +1383,10 @@ The hooks are run in the region buffer, you may use the 
variable
            pos (+ pos 8))))
   file)
 
+(defvar font-lock-mode-enable-list)
+(defvar font-lock-auto-fontify)
+(defvar font-lock-defaults-alist)
+
 (defun TeX-region-create (file region original offset)
   "Create a new file named FILE with the string REGION.
 The region is taken from ORIGINAL starting at line OFFSET.
diff --git a/tex-fold.el b/tex-fold.el
index 05bd61a..af1191f 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -1,6 +1,6 @@
 ;;; tex-fold.el --- Fold TeX macros.
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011-2012
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011-2012, 2014
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
@@ -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))
@@ -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)
@@ -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)
diff --git a/tex-info.el b/tex-info.el
index a5eb493..d4b68c6 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (require 'tex)
 
 (require 'texinfo)
@@ -305,10 +307,10 @@ for @node."
       (goto-char (point-min))
       (while (re-search-forward "address@hidden" nil t)
        (skip-chars-forward " \t")
-       (add-to-list 'nodes
-                    (list (buffer-substring-no-properties
+       (pushnew (list (buffer-substring-no-properties
                            (point) (progn (skip-chars-forward "^,")
-                                          (point)))))))
+                                          (point))))
+                 nodes :test #'equal)))
     (unless active-mark
       (setq node-name (read-string "Node name: ")))
     ;; FIXME: What if key binding for `minibuffer-complete' was changed?
@@ -344,12 +346,12 @@ for @node."
 
 ;; Silence the byte-compiler from warnings for variables and functions declared
 ;; in reftex.
-(eval-when-compile
-  (defvar reftex-section-levels-all)
-  (defvar reftex-level-indent)
-  (defvar reftex-label-menu-flags)
-  (defvar reftex-tables-dirty)
+(defvar reftex-section-levels-all)
+(defvar reftex-level-indent)
+(defvar reftex-label-menu-flags)
+(defvar reftex-tables-dirty)
 
+(eval-when-compile
   (when (fboundp 'declare-function)
     (declare-function reftex-match-string "reftex" (n))
     (declare-function reftex-section-number "reftex-parse" (&optional level 
star))
@@ -604,9 +606,10 @@ value of `Texinfo-mode-hook'."
   (set (make-local-variable 'TeX-font-replace-function) 
'TeX-font-replace-macro)
   (set (make-local-variable 'TeX-style-hook-dialect) :texinfo)
 
-  (add-hook 'find-file-hooks (lambda ()
-                              (unless (file-exists-p (buffer-file-name))
-                                (TeX-master-file nil nil t))) nil t)
+  (add-hook 'find-file-hook (lambda ()
+                              (unless (file-exists-p (buffer-file-name))
+                                (TeX-master-file nil nil t)))
+            nil t)
 
   (when (and (boundp 'add-log-current-defun-function)
             (fboundp 'texinfo-current-defun-name))
diff --git a/tex.el b/tex.el
index b634a74..2eecf3a 100644
--- a/tex.el
+++ b/tex.el
@@ -1085,6 +1085,8 @@ search are checked, too."
                                               (cdr (caar (cdr elem)))))
                                           spec))))))))
 
+(defvar url-unreserved-chars)
+
 (defun TeX-evince-sync-view ()
   "Focus the focused page/paragraph in Evince with the position
 of point in emacs by using Evince's DBUS API.  Used by default
@@ -2267,6 +2269,9 @@ This is done calling `kpsewhich --expand-path' for each 
variable.
 PROGRAM is passed as the parameter for --progname.  SUBDIRS are
 subdirectories which are appended to the directories of the TeX
 trees.  Only existing directories are returned."
+  ;; FIXME: The GNU convention only uses "path" to mean "list of directories"
+  ;; and uses "filename" for the name of a file even if it contains possibly
+  ;; several elements separated by "/".
   (let (path-list path exit-status input-dir-list)
     (condition-case nil
        (dolist (var vars)
@@ -2277,9 +2282,9 @@ trees.  Only existing directories are returned."
                                          "--progname" program
                                          "--expand-path" var))))
          (when (zerop exit-status)
-           (add-to-list 'path-list path t)))
+            (pushnew path path-list :test #'equal)))
       (error nil))
-    (dolist (elt path-list)
+    (dolist (elt (nreverse path-list))
       (let ((separators (if (string-match "^[A-Za-z]:" elt)
                            "[\n\r;]"
                          "[\n\r:]")))
@@ -2291,11 +2296,11 @@ trees.  Only existing directories are returned."
              (dolist (subdir subdirs)
                (setq path (file-name-as-directory (concat item subdir)))
                (when (file-exists-p path)
-                 (add-to-list 'input-dir-list path t)))
+                  (pushnew path input-dir-list :test #'equal)))
            (setq path (file-name-as-directory item))
            (when (file-exists-p path)
-             (add-to-list 'input-dir-list path t))))))
-    input-dir-list))
+             (pushnew path input-dir-list :test #'equal))))))
+    (nreverse input-dir-list)))
 
 (defun TeX-macro-global ()
   "Return directories containing the site's TeX macro and style files."
@@ -2351,10 +2356,10 @@ These correspond to the personal TeX macros."
   (let ((path))
     ;; Put directories in an order where the more local files can
     ;; override the more global ones.
-    (mapcar (lambda (file) (when file (add-to-list 'path file t)))
-           (append (list TeX-auto-global TeX-style-global)
-                   TeX-auto-private TeX-style-private
-                   (list TeX-auto-local TeX-style-local)))
+    (mapc (lambda (file) (when file (add-to-list 'path file t)))
+          (append (list TeX-auto-global TeX-style-global)
+                  TeX-auto-private TeX-style-private
+                  (list TeX-auto-local TeX-style-local)))
     path)
   "List of directories to search for AUCTeX style files.
 Per default the list is built from the values of the variables
@@ -2607,7 +2612,7 @@ See variable `TeX-style-hook-dialect' for supported 
dialects."
                                            (TeX-master-directory))
                        style (substring style
                                         (match-beginning 2) (match-end 2))))
-               (condition-case err
+               (condition-case nil
                    (mapcar (lambda (hook)
                              (cond
                               ((functionp hook)
@@ -3550,6 +3555,10 @@ directory hierarchy, t means recurse indefinitely."
                 (const :tag "Off" nil)
                 (integer :tag "Depth" :value 1)))
 
+(defvar TeX-file-extensions)
+(defvar BibTeX-file-extensions)
+(defvar TeX-Biber-file-extensions)
+
 ;;;###autoload
 (defun TeX-auto-generate (tex auto)
   "Generate style file for TEX and store it in AUTO.
@@ -4001,10 +4010,11 @@ EXTENSIONS defaults to `TeX-file-extensions'."
   "Return a list of available TeX tree roots."
   (let (list)
     (dolist (dir (TeX-tree-expand '("$TEXMFHOME" "$TEXMFMAIN" "$TEXMFLOCAL"
-                                   "$TEXMFDIST") "latex"))
+                                   "$TEXMFDIST")
+                                  "latex"))
       (when (file-readable-p dir)
-       (add-to-list 'list dir t)))
-    list))
+        (pushnew dir list :test #'equal)))
+    (nreverse list)))
 
 (defcustom TeX-tree-roots (TeX-tree-roots)
   "List of all available TeX tree root directories."
@@ -4166,19 +4176,23 @@ If optional argument STRIP is non-nil, remove file 
extension."
            (if (null TeX-tree-roots)
                (error "No TeX trees available; configure `TeX-tree-roots'")
              ;; Expand variables.
-             (dolist (rawdir rawdirs)
-               (if (symbolp rawdir)
-                   (setq expdirs (append expdirs (eval rawdir)))
-                 (add-to-list 'expdirs rawdir t)))
-             (delete-dups expdirs)
+              (setq expdirs
+                    (delete-dups
+                     (apply #'append
+                            (mapcar (lambda (rawdir)
+                                      (if (symbolp rawdir)
+                                          (symbol-value rawdir)
+                                        (list rawdir)))
+                                    rawdirs))))
              ;; Assumption: Either all paths are absolute or all are relative.
              (if (file-name-absolute-p (car expdirs))
                  (setq dirs expdirs)
                ;; Append relative TDS subdirs to all TeX tree roots.
                (dolist (root TeX-tree-roots)
                  (dolist (dir expdirs)
-                   (add-to-list 'dirs (concat (file-name-as-directory root)
-                                              dir) t)))))
+                    (let ((dir (expand-file-name dir root)))
+                      (unless (member dir dirs)
+                        (setq dirs (append dirs (list dir)))))))))
            (append local-files (TeX-search-files dirs exts nodir strip)))))))
 
 ;;; Narrowing
@@ -5893,7 +5907,7 @@ NAME may be a package, a command, or a document."
       (when (memq major-mode (nth 1 elt))
        (let ((completions (funcall (nth 2 elt))))
          (unless (null completions)
-           (add-to-list 'docs (cons completions (nth 0 elt)))))))
+            (pushnew (cons completions (nth 0 elt)) docs :test #'equal)))))
     (if (null docs)
        (progn
          (if (executable-find "texdoc")
diff --git a/toolbar-x.el b/toolbar-x.el
index ef4edc8..8f50656 100644
--- a/toolbar-x.el
+++ b/toolbar-x.el
@@ -1,6 +1,6 @@
 ;;; toolbar-x.el --- fancy toolbar handling in Emacs and XEmacs
 
-;; Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2008, 2014 Free Software Foundation, Inc.
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -106,6 +106,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 ;; Note that this just gives a useful default.  Icons are expected to
 ;; be in subdirectory "images" or "toolbar" relative to the load-path.
 ;; Packages loading toolbarx are advised to explicitly add their own
@@ -177,8 +179,7 @@ different.  OPTION-LIST equal to nil is a good option list."
     (dotimes (i n)
       (when (> i 0)
        (setq temp-opt-list (cddr temp-opt-list)))
-      (add-to-list 'list-diff
-                  (car temp-opt-list))
+      (pushnew (car temp-opt-list) list-diff :test #'equal)
       (setq elt-in-valid (and elt-in-valid
                              (memq (car temp-opt-list)
                                    valid-options))))



reply via email to

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