summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMark Oteiza <mvoteiza@udel.edu>2016-11-19 13:34:24 -0500
committerMark Oteiza <mvoteiza@udel.edu>2016-11-19 13:41:09 -0500
commitb19e05b13192f72991b65b4b352e09c807fd581c (patch)
treece0ef9ef2f92c7740b7f75410a7c387717ee557f /lisp
parent92b3528cf3e6d366086e89b9a909f0c81614a064 (diff)
downloademacs-b19e05b13192f72991b65b4b352e09c807fd581c.tar.gz
Port RefTeX to cl-lib
* lisp/textmodes/reftex-auc.el: * lisp/textmodes/reftex-cite.el: Use cl-lib. (reftex-do-citation, reftex-create-bibtex-file): Substitute cl-lib macros. * lisp/textmodes/reftex-dcr.el: Use cl-lib. (reftex-view-regexp-match): Substitute cl-lib macro. * lisp/textmodes/reftex-global.el: Use cl-lib. (reftex-find-duplicate-labels, reftex-renumber-simple-labels): (reftex-translate): Substitute cl-lib macros. * lisp/textmodes/reftex-index.el: Use cl-lib. (reftex-index, reftex-index-select-tag, reftex-index-mode-map): (reftex-index-next-phrase, reftex-index-phrases-info): (reftex-query-index-phrase): Substitute cl-lib macros. * lisp/textmodes/reftex-parse.el: Use cl-lib. (reftex-parse-from-file, reftex-where-am-I, reftex-what-macro): (reftex-nth-arg, reftex-init-section-numbers, reftex-section-number): Substitute cl-lib macros. * lisp/textmodes/reftex-ref.el: Use cl-lib. (reftex-uniquify-label, reftex-offer-label-menu): Substitute cl-lib macros. * lisp/textmodes/reftex-sel.el: Use cl-lib. (reftex-select-shared-map): Set keymap parent to special-mode-map. Flatten loop and remove digits and hyphen definitions from the map. (reftex-select-label-mode-map): (reftex-select-bib-mode-map): Use cl-lib macro, and flatten other loop. (reftex-insert-docstruct, reftex-select-unmark): Use cl-lib macros. * lisp/textmodes/reftex-vars.el (reftex-vref-is-default): Use cl-pushnew. * lisp/textmodes/reftex.el: Use cl-lib. (reftex-docstruct-symbol): Use cl-incf. (reftex-ref-style-toggle): Replace add-to-list with append. (reftex-compile-variables): Use cl-lib macros, and functions with compiler macros. cl-first is just an alias. (reftex-parse-args, reftex-scanning-info-available-p): (reftex-select-external-document, reftex-get-file-buffer-force): Use cl-lib macros. (reftex-isearch-minor-mode): Replace add-to-list with append.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/textmodes/reftex-auc.el2
-rw-r--r--lisp/textmodes/reftex-cite.el6
-rw-r--r--lisp/textmodes/reftex-dcr.el4
-rw-r--r--lisp/textmodes/reftex-global.el8
-rw-r--r--lisp/textmodes/reftex-index.el30
-rw-r--r--lisp/textmodes/reftex-parse.el24
-rw-r--r--lisp/textmodes/reftex-ref.el6
-rw-r--r--lisp/textmodes/reftex-sel.el102
-rw-r--r--lisp/textmodes/reftex-vars.el6
-rw-r--r--lisp/textmodes/reftex.el66
10 files changed, 121 insertions, 133 deletions
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index 505df5d3424..8efe8a2ec19 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'reftex)
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index 20cfedc503d..fd7915ccc76 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'reftex)
@@ -744,7 +744,7 @@ While entering the regexp, completion on knows citation keys is possible.
(if (> arg 1)
(progn
(skip-chars-backward "}")
- (decf arg)
+ (cl-decf arg)
(reftex-do-citation arg))
(forward-char 1)))
@@ -1210,7 +1210,7 @@ created files in the variables `reftex-create-bibtex-header' or
;; check for crossref entries
(let* ((attr-list (reftex-parse-bibtex-entry nil beg end))
(xref-key (cdr (assoc "crossref" attr-list))))
- (if xref-key (pushnew xref-key keys)))
+ (if xref-key (cl-pushnew xref-key keys)))
;; check for string references
(let* ((raw-fields (reftex-parse-bibtex-entry nil beg end t))
(string-fields (reftex-get-string-refs raw-fields)))
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index f1d4d6fcba8..65742f36f78 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(declare-function bibtex-beginning-of-entry "bibtex" ())
@@ -424,7 +424,7 @@ Calling this function several times find successive citation locations."
(if match
(progn
(put 'reftex-view-regexp-match :props newprop)
- (put 'reftex-view-regexp-match :cnt (incf cnt))
+ (put 'reftex-view-regexp-match :cnt (cl-incf cnt))
(reftex-highlight 0 (match-beginning highlight-group)
(match-end highlight-group))
(add-hook 'pre-command-hook 'reftex-highlight-shall-die)
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index d2500510443..c8c62a0d944 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(provide 'reftex-global)
(require 'reftex)
;;;
@@ -154,7 +154,7 @@ No active TAGS table is required."
(while dlist
(when (and (car (car dlist))
(cdr (car dlist)))
- (incf cnt)
+ (cl-incf cnt)
(insert (mapconcat 'identity (car dlist) "\n ") "\n"))
(pop dlist))
(goto-char (point-min))
@@ -223,7 +223,7 @@ one with the `xr' package."
(if (assoc label translate-alist)
(error "Duplicate label %s" label))
(setq new-label (concat (match-string 1 (car entry))
- (int-to-string (incf (cdr nr-cell)))))
+ (int-to-string (cl-incf (cdr nr-cell)))))
(push (cons label new-label) translate-alist)
(or (string= label new-label) (setq changed-sequence t))))
@@ -302,7 +302,7 @@ one with the `xr' package."
(error "Abort")))
(reftex-unhighlight 1)))
((and test cell)
- (incf n))
+ (cl-incf n))
((and (not test) cell)
;; Replace
(goto-char (match-beginning 1))
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 3cea589a9cf..4dd190d2b0f 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(declare-function texmathp "ext:texmathp" ())
(require 'reftex)
@@ -128,7 +128,7 @@ will prompt for other arguments."
;; Insert the macro and ask for any additional args
(insert macro)
- (loop for i from 1 to nargs do
+ (cl-loop for i from 1 to nargs do
(setq opt (member i opt-args)
value (cond ((= nindex i) key)
((equal ntag i) tag1)
@@ -214,16 +214,16 @@ will prompt for other arguments."
i -1
val nil)
(catch 'exit
- (while (and (< (incf i) len) (null val))
+ (while (and (< (cl-incf i) len) (null val))
(unless (assq (aref tag i) tag-alist)
(push (list (aref tag i)
tag
(concat (substring tag 0 i)
- "[" (substring tag i (incf i)) "]"
+ "[" (substring tag i (cl-incf i)) "]"
(substring tag i)))
tag-alist)
(throw 'exit t)))
- (push (list (+ ?0 (incf cnt)) tag
+ (push (list (+ ?0 (cl-incf cnt)) tag
(concat "[" (int-to-string cnt) "]:" tag))
tag-alist)))
(setq tag-alist (nreverse tag-alist))
@@ -317,10 +317,10 @@ will prompt for other arguments."
(define-key map "c" 'reftex-index-toggle-context)
;; The capital letters and the exclamation mark
- (loop for key across (concat "!" reftex-index-section-letters) do
- (define-key map (vector (list key))
- (list 'lambda '() '(interactive)
- (list 'reftex-index-goto-letter key))))
+ (cl-loop for key across (concat "!" reftex-index-section-letters) do
+ (define-key map (vector (list key))
+ (list 'lambda '() '(interactive)
+ (list 'reftex-index-goto-letter key))))
(easy-menu-define reftex-index-menu map
"Menu for Index buffer"
@@ -1426,7 +1426,7 @@ Here are all local bindings.
(interactive "p")
(reftex-index-phrases-parse-header t)
(while (> arg 0)
- (decf arg)
+ (cl-decf arg)
(end-of-line)
(if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
(progn
@@ -1655,11 +1655,11 @@ this function repeatedly."
(widen)
(goto-char (point-min))
(while (re-search-forward re1 nil t)
- (incf ntimes1))
+ (cl-incf ntimes1))
(goto-char (point-min))
(while (re-search-forward re2 nil t)
(push (cons (count-lines 1 (point)) (match-string 1)) superphrases)
- (incf ntimes2))))
+ (cl-incf ntimes2))))
(save-current-buffer
(while (setq file (pop files))
(setq buf (reftex-get-file-buffer-force file))
@@ -1672,7 +1672,7 @@ this function repeatedly."
(let ((case-fold-search reftex-index-phrases-case-fold-search))
(while (re-search-forward re nil t)
(or (reftex-in-comment)
- (incf nmatches)))))))))
+ (cl-incf nmatches)))))))))
(with-output-to-temp-buffer "*Help*"
(princ (format " Phrase: %s\n" phrase))
(princ (format " Macro key: %s\n" char))
@@ -1682,7 +1682,7 @@ this function repeatedly."
(index-key
(let ((iks index-keys) (cnt 0) ik)
(while (setq ik (pop iks))
- (princ (format "Index entry %d: %s\n" (incf cnt) ik)))))
+ (princ (format "Index entry %d: %s\n" (cl-incf cnt) ik)))))
(repeat
(princ (format " Index entry: %s\n" phrase)))
(t
@@ -1943,7 +1943,7 @@ both ends."
(cond ((member char '(?y ?Y ?\ ))
;; Yes!
(replace-match rpl t t)
- (incf replace-count)
+ (cl-incf replace-count)
;; See if we should insert newlines to shorten lines
(and reftex-index-phrases-wrap-long-lines
(reftex-index-phrases-fixup-line beg end))
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 1d6fa311d5f..9180bea3d3b 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'reftex)
@@ -306,7 +306,7 @@ of master file."
(when reftex-support-index
(setq index-entry (reftex-index-info file))
(when index-entry
- (add-to-list 'reftex--index-tags (nth 1 index-entry))
+ (cl-pushnew (nth 1 index-entry) reftex--index-tags :test #'equal)
(push index-entry docstruct))))
((match-end 11)
@@ -608,7 +608,7 @@ if the information is exact (t) or approximate (nil)."
found)
(save-excursion
(while (not rtn)
- (incf cnt)
+ (cl-incf cnt)
(setq found (re-search-backward (reftex-everything-regexp) nil t))
(setq rtn
(cond
@@ -672,7 +672,7 @@ if the information is exact (t) or approximate (nil)."
(when (and (eq (car (car list)) 'index)
(string= (nth 2 index-info)
(nth 2 (car list))))
- (incf n)
+ (cl-incf n)
(setq dist (abs (- (point) (nth 4 (car list)))))
(if (or (not last-dist) (< dist last-dist))
(setq last-dist dist last (car list))))
@@ -841,8 +841,8 @@ considered an argument of macro \\macro."
(let ((forward-sexp-function nil))
(backward-sexp) t)
(error nil)))
- (if (eq (following-char) ?\[) (incf cnt-opt))
- (incf cnt))
+ (if (eq (following-char) ?\[) (cl-incf cnt-opt))
+ (cl-incf cnt))
(setq pos (point))
(when (and (or (= (following-char) ?\[)
(= (following-char) ?\{))
@@ -984,18 +984,18 @@ OPT-ARGS is a list of argument numbers which are optional."
(while (< cnt n)
(while (and (member cnt opt-args)
(eq (following-char) ?\{))
- (incf cnt))
+ (cl-incf cnt))
(when (< cnt n)
(unless (and (condition-case nil
(or (forward-list 1) t)
(error nil))
(reftex-move-to-next-arg)
- (incf cnt))
+ (cl-incf cnt))
(setq cnt 1000))))
(while (and (memq cnt opt-args)
(eq (following-char) ?\{))
- (incf cnt)))
+ (cl-incf cnt)))
(if (and (= n cnt)
(> (skip-chars-forward "{\\[") 0))
(reftex-context-substring)
@@ -1057,7 +1057,7 @@ When point is just after a { or [, limit string to matching parenthesis"
(- (string-to-char number-string) ?A -1))
(aset reftex-section-numbers i (string-to-number number-string)))
(pop numbers))
- (decf i)))
+ (cl-decf i)))
(put 'reftex-section-numbers 'appendix appendix))
;;;###autoload
@@ -1081,7 +1081,7 @@ When LEVEL is non-nil, increase section numbers on that level."
(if (or (not partspecial)
(not (= idx 1)))
(aset reftex-section-numbers idx 0))
- (incf idx))))
+ (cl-incf idx))))
(if partspecial
(setq string (concat "Part " (reftex-roman-number
(aref reftex-section-numbers 0))))
@@ -1091,7 +1091,7 @@ When LEVEL is non-nil, increase section numbers on that level."
(if (not (and partspecial (not (equal string ""))))
(setq string (concat string (if (not (string= string "")) "." "")
(int-to-string n))))
- (incf idx))
+ (cl-incf idx))
(save-match-data
(if (string-match "\\`\\([@0]\\.\\)+" string)
(setq string (replace-match "" nil nil string)))
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index f5a784bf63d..fdde4aa0541 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'reftex)
(require 'reftex-parse)
@@ -374,7 +374,7 @@ also applies `reftex-translate-to-ascii-function' to the string."
(sep (or separator "")))
(while (assoc (concat label sep (int-to-string num))
(symbol-value reftex-docstruct-symbol))
- (incf num))
+ (cl-incf num))
(setcdr cell num)
(concat label sep (int-to-string num))))))
@@ -566,7 +566,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
(reftex-erase-buffer))
(unless (eq major-mode 'reftex-select-label-mode)
(reftex-select-label-mode))
- (add-to-list 'selection-buffers (current-buffer))
+ (cl-pushnew (current-buffer) selection-buffers)
(setq truncate-lines t)
(setq mode-line-format
(list "---- " 'mode-line-buffer-identification
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index 02caa67e9a8..d3a7ee49804 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -24,7 +24,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'reftex)
@@ -32,6 +32,7 @@
;; and reftex-select-bib-mode-map.
(defvar reftex-select-shared-map
(let ((map (make-sparse-keymap)))
+ (set-keymap-parent map special-mode-map)
(substitute-key-definition
'next-line 'reftex-select-next map global-map)
(substitute-key-definition
@@ -41,31 +42,23 @@
(substitute-key-definition
'newline 'reftex-select-accept map global-map)
- (loop for x in
- '((" " . reftex-select-callback)
- ("n" . reftex-select-next)
- ([(down)] . reftex-select-next)
- ("p" . reftex-select-previous)
- ([(up)] . reftex-select-previous)
- ("f" . reftex-select-toggle-follow)
- ("\C-m" . reftex-select-accept)
- ([(return)] . reftex-select-accept)
- ("q" . reftex-select-quit)
- ("." . reftex-select-show-insertion-point)
- ("?" . reftex-select-help))
- do (define-key map (car x) (cdr x)))
+ (define-key map " " 'reftex-select-callback)
+ (define-key map "n" 'reftex-select-next)
+ (define-key map [(down)] 'reftex-select-next)
+ (define-key map "p" 'reftex-select-previous)
+ (define-key map [(up)] 'reftex-select-previous)
+ (define-key map "f" 'reftex-select-toggle-follow)
+ (define-key map "\C-m" 'reftex-select-accept)
+ (define-key map [(return)] 'reftex-select-accept)
+ (define-key map "q" 'reftex-select-quit)
+ (define-key map "." 'reftex-select-show-insertion-point)
+ (define-key map "?" 'reftex-select-help)
;; The mouse-2 binding
(if (featurep 'xemacs)
(define-key map [(button2)] 'reftex-select-mouse-accept)
(define-key map [(mouse-2)] 'reftex-select-mouse-accept)
(define-key map [follow-link] 'mouse-face))
-
-
- ;; Digit arguments
- (loop for key across "0123456789" do
- (define-key map (vector (list key)) 'digit-argument))
- (define-key map "-" 'negative-argument)
map))
(define-obsolete-variable-alias
@@ -74,28 +67,25 @@
(let ((map (make-sparse-keymap)))
(set-keymap-parent map reftex-select-shared-map)
- (loop for key across "aAcgFlrRstx#%" do
- (define-key map (vector (list key))
- (list 'lambda '()
- "Press `?' during selection to find out about this key."
- '(interactive) (list 'throw '(quote myexit) key))))
-
- (loop for x in
- '(("b" . reftex-select-jump-to-previous)
- ("z" . reftex-select-jump)
- ("v" . reftex-select-cycle-ref-style-forward)
- ("V" . reftex-select-cycle-ref-style-backward)
- ("m" . reftex-select-mark)
- ("u" . reftex-select-unmark)
- ("," . reftex-select-mark-comma)
- ("-" . reftex-select-mark-to)
- ("+" . reftex-select-mark-and)
- ([(tab)] . reftex-select-read-label)
- ("\C-i" . reftex-select-read-label)
- ("\C-c\C-n" . reftex-select-next-heading)
- ("\C-c\C-p" . reftex-select-previous-heading))
- do
- (define-key map (car x) (cdr x)))
+ (cl-loop for key across "aAcgFlrRstx#%" do
+ (define-key map (vector (list key))
+ (list 'lambda '()
+ "Press `?' during selection to find out about this key."
+ '(interactive) (list 'throw '(quote myexit) key))))
+
+ (define-key map "b" 'reftex-select-jump-to-previous)
+ (define-key map "z" 'reftex-select-jump)
+ (define-key map "v" 'reftex-select-cycle-ref-style-forward)
+ (define-key map "V" 'reftex-select-cycle-ref-style-backward)
+ (define-key map "m" 'reftex-select-mark)
+ (define-key map "u" 'reftex-select-unmark)
+ (define-key map "," 'reftex-select-mark-comma)
+ (define-key map "-" 'reftex-select-mark-to)
+ (define-key map "+" 'reftex-select-mark-and)
+ (define-key map [(tab)] 'reftex-select-read-label)
+ (define-key map "\C-i" 'reftex-select-read-label)
+ (define-key map "\C-c\C-n" 'reftex-select-next-heading)
+ (define-key map "\C-c\C-p" 'reftex-select-previous-heading)
map)
"Keymap used for *RefTeX Select* buffer, when selecting a label.
@@ -130,18 +120,16 @@ During a selection process, these are the local bindings.
(let ((map (make-sparse-keymap)))
(set-keymap-parent map reftex-select-shared-map)
- (loop for key across "grRaAeE" do
- (define-key map (vector (list key))
- (list 'lambda '()
- "Press `?' during selection to find out about this key."
- '(interactive) (list 'throw '(quote myexit) key))))
+ (cl-loop for key across "grRaAeE" do
+ (define-key map (vector (list key))
+ (list 'lambda '()
+ "Press `?' during selection to find out about this key."
+ '(interactive) (list 'throw '(quote myexit) key))))
- (loop for x in
- '(("\C-i" . reftex-select-read-cite)
- ([(tab)] . reftex-select-read-cite)
- ("m" . reftex-select-mark)
- ("u" . reftex-select-unmark))
- do (define-key map (car x) (cdr x)))
+ (define-key map "\C-i" 'reftex-select-read-cite)
+ (define-key map [(tab)] 'reftex-select-read-cite)
+ (define-key map "m" 'reftex-select-mark)
+ (define-key map "u" 'reftex-select-unmark)
map)
"Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
@@ -272,7 +260,7 @@ During a selection process, these are the local bindings.
;; Walk the docstruct and insert the appropriate stuff
(while (setq cell (pop all))
- (incf index)
+ (cl-incf index)
(setq from (point))
(cond
@@ -342,7 +330,7 @@ During a selection process, these are the local bindings.
(or show-commented (null comment)))
;; Yes we want this one
- (incf cnt)
+ (cl-incf cnt)
(setq prev-inserted cell)
; (if (eq offset 'attention) (setq offset cell))
@@ -728,8 +716,8 @@ Cycle in reverse order if optional argument REVERSE is non-nil."
(setq sep (nth 2 c))
(reftex-overlay-put (nth 1 c) 'before-string
(if sep
- (format "*%c%d* " sep (decf cnt))
- (format "*%d* " (decf cnt)))))
+ (format "*%c%d* " sep (cl-decf cnt))
+ (format "*%d* " (cl-decf cnt)))))
reftex-select-marked)
(message "Entry no longer marked")))
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index d1a6b87da2e..d6de53b2466 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -24,7 +24,7 @@
;;; Code:
(defvar reftex-tables-dirty)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(eval-and-compile
(defun reftex-set-dirty (symbol value)
(setq reftex-tables-dirty t)
@@ -1076,9 +1076,9 @@ used in the variable `reftex-ref-style-alist'."
;; Compatibility with obsolete variables.
(when reftex-vref-is-default
- (add-to-list 'reftex-ref-style-default-list "Varioref"))
+ (cl-pushnew "Varioref" reftex-ref-style-default-list :test #'equal))
(when reftex-fref-is-default
- (add-to-list 'reftex-ref-style-default-list "Fancyref"))
+ (cl-pushnew "Fancyref" reftex-ref-style-default-list :test #'equal))
(defcustom reftex-level-indent 2
"Number of spaces to be used for indentation per section level."
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 24fa0d145e8..adc5076daf1 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -50,7 +50,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
;; Stuff that needs to be there when we use defcustom
(require 'custom)
@@ -290,7 +290,7 @@ on the menu bar.
(defun reftex-next-multifile-index ()
;; Return the next free index for multifile symbols.
- (incf reftex-multifile-index))
+ (cl-incf reftex-multifile-index))
(defun reftex-tie-multifile-symbols ()
"Tie the buffer-local symbols to globals connected with the master file.
@@ -479,7 +479,7 @@ will deactivate it."
(unless (member style list)
(setq reftex-tables-dirty t
changed t)
- (add-to-list 'list style t)))
+ (setq list (append list (list style)))))
((eq action 'deactivate)
(when (member style list)
(setq reftex-tables-dirty t
@@ -488,7 +488,7 @@ will deactivate it."
(t
(if (member style list)
(delete style list)
- (add-to-list 'list style t))
+ (setq list (append list (list style))))
(setq reftex-tables-dirty t
changed t)))
(when changed
@@ -831,15 +831,15 @@ This enforces rescanning the buffer on next use."
reffmt (nth 1 fmt))
;; Note a new typekey
(if typekey
- (add-to-list 'reftex-typekey-list typekey))
+ (cl-pushnew typekey reftex-typekey-list :test #'equal))
(if (and typekey prefix
(not (assoc prefix reftex-prefix-to-typekey-alist)))
- (add-to-list 'reftex-prefix-to-typekey-alist
- (cons prefix typekey)))
+ (cl-pushnew (cons prefix typekey) reftex-prefix-to-typekey-alist
+ :test #'equal))
(if (and typekey prefix
(not (assoc typekey reftex-typekey-to-prefix-alist)))
- (add-to-list 'reftex-typekey-to-prefix-alist
- (cons typekey prefix)))
+ (cl-pushnew (cons typekey prefix) reftex-typekey-to-prefix-alist
+ :test #'equal))
;; Check if this is a macro or environment
(cond
((symbolp env-or-mac)
@@ -848,17 +848,17 @@ This enforces rescanning the buffer on next use."
(message "Warning: %s does not seem to be a valid function"
env-or-mac))
(setq nargs nil nlabel nil opt-args nil)
- (add-to-list 'reftex-special-env-parsers env-or-mac)
+ (cl-pushnew env-or-mac reftex-special-env-parsers)
(setq env-or-mac (symbol-name env-or-mac)))
((string-match "\\`\\\\" env-or-mac)
;; It's a macro
(let ((result (reftex-parse-args env-or-mac)))
- (setq env-or-mac (or (first result) env-or-mac)
- nargs (second result)
- nlabel (third result)
- opt-args (fourth result))
- (if nlabel (add-to-list 'macros-with-labels env-or-mac)))
- (if typekey (add-to-list 'reftex-label-mac-list env-or-mac)))
+ (setq env-or-mac (or (cl-first result) env-or-mac)
+ nargs (cl-second result)
+ nlabel (cl-third result)
+ opt-args (cl-fourth result))
+ (if nlabel (cl-pushnew env-or-mac macros-with-labels :test #'equal)))
+ (if typekey (cl-pushnew env-or-mac reftex-label-mac-list :test #'equal)))
(t
;; It's an environment
(setq nargs nil nlabel nil opt-args nil)
@@ -866,7 +866,7 @@ This enforces rescanning the buffer on next use."
((string= env-or-mac ""))
((string= env-or-mac "section"))
(t
- (add-to-list 'reftex-label-env-list env-or-mac)
+ (cl-pushnew env-or-mac reftex-label-env-list :test #'equal)
(if toc-level
(let ((string (format "begin{%s}" env-or-mac)))
(or (assoc string toc-levels)
@@ -950,7 +950,7 @@ This enforces rescanning the buffer on next use."
(not (member (aref fmt i) '(?%))))
(setq word (concat word "\\|" (regexp-quote
(substring fmt 0 (1+ i)))))
- (incf i))
+ (cl-incf i))
(cons (concat word "\\)\\=") typekey))
(nreverse reftex-words-to-typekey-alist)))
@@ -976,10 +976,10 @@ This enforces rescanning the buffer on next use."
(t t))
all-index (cdr all-index))
(let ((result (reftex-parse-args macro)))
- (setq macro (or (first result) macro)
- nargs (second result)
- nindex (third result)
- opt-args (fourth result))
+ (setq macro (or (cl-first result) macro)
+ nargs (cl-second result)
+ nindex (cl-third result)
+ opt-args (cl-fourth result))
(unless (member macro reftex-macros-with-index)
;; 0 1 2 3 4 5 6 7
(push (list macro tag prefix verify nargs nindex opt-args repeat)
@@ -1003,7 +1003,7 @@ This enforces rescanning the buffer on next use."
(mapconcat
(lambda(x)
(format "[%c] %-20.20s%s" (car x) (nth 1 x)
- (if (= 0 (mod (incf i) 3)) "\n" "")))
+ (if (= 0 (mod (cl-incf i) 3)) "\n" "")))
reftex-key-to-index-macro-alist "")))
;; Make the full list of section levels
@@ -1093,7 +1093,7 @@ This enforces rescanning the buffer on next use."
(args (substring macro (match-beginning 0)))
opt-list nlabel (cnt 0))
(while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
- (incf cnt)
+ (cl-incf cnt)
(when (eq ?\[ (string-to-char args))
(push cnt opt-list))
(when (and (match-end 1)
@@ -1158,7 +1158,7 @@ This enforces rescanning the buffer on next use."
(defun reftex-silence-toc-markers (list n)
;; Set all toc markers in the first N entries in list to nil
- (while (and list (> (decf n) -1))
+ (while (and list (> (cl-decf n) -1))
(and (eq (car (car list)) 'toc)
(markerp (nth 4 (car list)))
(set-marker (nth 4 (car list)) nil))
@@ -1289,7 +1289,7 @@ Valid actions are: readable, restore, read, kill, write."
"SELECT EXTERNAL DOCUMENT\n------------------------\n"
(mapconcat
(lambda (x)
- (format fmt (incf n) (or (car x) "")
+ (format fmt (cl-incf n) (or (car x) "")
(abbreviate-file-name (cdr x))))
xr-alist ""))
nil t))
@@ -1793,11 +1793,11 @@ When DIE is non-nil, throw an error if file not found."
;; with limited Magic
;; The magic goes away
- (letf ((format-alist nil)
- (auto-mode-alist (reftex-auto-mode-alist))
- ((default-value 'major-mode) 'fundamental-mode)
- (enable-local-variables nil)
- (after-insert-file-functions nil))
+ (cl-letf ((format-alist nil)
+ (auto-mode-alist (reftex-auto-mode-alist))
+ ((default-value 'major-mode) 'fundamental-mode)
+ (enable-local-variables nil)
+ (after-insert-file-functions nil))
(setq buf (find-file-noselect file)))
;; Is there a hook to run?
@@ -1807,7 +1807,7 @@ When DIE is non-nil, throw an error if file not found."
;; Let's see if we got a license to kill :-|
(and mark-to-kill
- (add-to-list 'reftex-buffers-to-kill buf))
+ (cl-pushnew buf reftex-buffers-to-kill))
;; Return the new buffer
buf)
@@ -2265,7 +2265,7 @@ IGNORE-WORDS List of words which should be removed from the string."
:style 'toggle
:selected `(member ,elt (reftex-ref-style-list))))
(unless (member item list)
- (add-to-list 'list item t)))
+ (setq list (append list (list item)))))
list))
("Citation Style"
,@(mapcar