summaryrefslogtreecommitdiff
path: root/lisp/textmodes/reftex-toc.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-03-17 23:32:39 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2021-03-17 23:32:39 -0400
commit485622bbd1afad4c1e39a245cf57605208ca606f (patch)
tree8388854d1b0eaa4e82f55862149c9def4ca1ccc6 /lisp/textmodes/reftex-toc.el
parentc28ba117782cd825b2a4dd6ffcc0206ecf36898e (diff)
downloademacs-485622bbd1afad4c1e39a245cf57605208ca606f.tar.gz
* lisp/textmodes: Use lexical-binding
* lisp/textmodes/enriched.el: Use lexical-binding. (enriched-mode): Use `delete-dups` to avoid `add-to-list` on a local variable. * lisp/textmodes/makeinfo.el: Use lexical-binding. (makeinfo-region): Remove unused var `filename-or-header`. * lisp/textmodes/refbib.el: Use lexical-binding. (r2b-put-field): Remove unused var `multi-line`. (r2b-barf-output): Remove unused var `match`. * lisp/textmodes/refer.el: Use lexical-binding. (refer-find-entry-internal): Remove unused vars `old-buffer` and `found`. * lisp/textmodes/reftex-auc.el: Use lexical-binding. (LaTeX-add-bibitems): Declare function. (reftex-plug-into-AUCTeX): Use `add-function` and `advice-add` so we can properly unplug. * lisp/textmodes/reftex-cite.el: Use lexical-binding. (reftex-create-bibtex-file): Remove unused var `file`. (reftex--found-list): Declare var. (reftex-offer-bib-menu): Rename local var to `reftex--found-list`. * lisp/textmodes/reftex-dcr.el: Use lexical-binding. (reftex-use-itimer-in-xemacs): Delete XEmacs-only var. (reftex-toggle-auto-view-crossref): Delete XEmacs-only code. (reftex-start-itimer-once): Delete XEmacs-only function. * lisp/textmodes/reftex-global.el: Use lexical-binding. (reftex-isearch-push-state-function): Use a closure instead of `(lambda). * lisp/textmodes/reftex-index.el: Use lexical-binding. (mark-active, transient-mark-mode): Delete var declarations. (reftex-index-mode-map): Remove XEmacs-only code. Use `mapc` so we can use closures instead of hand-built lambdas. (reftex-index-next, reftex-index-previous): Tweak interactive spec to remove unused prefix arg and mark it as a motion command. (reftex-index-phrases-font-lock-keywords) (reftex-index-phrases-font-lock-keywords): Move initialization into declaration. (reftex-index-initialize-phrases-buffer, reftex-index-phrases-mode) reftex-index-phrases-apply-to-region: Remove XEmacs-only code. (TeX-master): Remove redundant declaration. (reftex--chars-first): Rename dynvar from `chars-first`. Adjust all uses. * lisp/textmodes/reftex-parse.el: Use lexical-binding. * lisp/textmodes/reftex-ref.el: Use lexical-binding. (reftex-label): Remove always-nil var `text`. (reftex-refstyle): Declare before first use. (<toplevel>): Use closures rather than `eval` when building commands from `reftex-ref-style-alist`. * lisp/textmodes/reftex-sel.el: Use lexical-binding. (reftex-select-label-mode-map, reftex-select-bib-mode-map): Use `mapc` so we can use closures instead of hand-built lambdas. (reftex-select-label-mode, reftex-select-bib-mode): Remove XEmacs-only code. (reftex-select-data, reftex-select-prompt, reftex-refstyle): Move declaration before first use. (reftex--found-list, reftex--cb-flag, reftex--last-data) (reftex--call-back, reftex--help-string): Move declaration before use, and rename by adding `reftext--` prefix. Adjust all uses in this file. For `reftex--found-list` adjust corresponding uses in `reftex-cite.el`. (reftex-select-item): Explicitly let-bind them. Remove XEmacs-only code. * lisp/textmodes/reftex-toc.el: Use lexical-binding. (reftex-toc-mode-map, reftex-toc-mode, reftex-toc-restore-region) (reftex-toc-next, reftex-toc-previous, reftex-toc-next-heading) (reftex-toc-previous-heading, reftex-toggle-auto-toc-recenter (reftex-make-separate-toc-frame): Remove XEmacs-only code. * lisp/textmodes/reftex-vars.el: Use lexical-binding. * lisp/textmodes/reftex.el: Use lexical-binding. (reftex-mode-map, reftex-mode, reftex-fontify-select-label-buffer) (reftex-verified-face): Remove XEmacs-only code. (reftex-region-active-p, reftex-overlay-put, reftex-move-overlay) (reftex-make-overlay, reftex-get-buffer-visiting, reftex-delete-overlay): Redefine as obsolete aliases. Replace all callers. (current-message): Remove XEmacs-only definition. * lisp/textmodes/remember.el: Use lexical-binding. * lisp/textmodes/table.el (<toplevel>): Use closures rather than `(lambda) to build commands. * lisp/textmodes/texinfmt.el: Use lexical-binding. (texinfo-example-start): Declare var. (texinfo-format-region, texinfo-format-buffer-1): Remove unused var `last-input-buffer`. (texinfo-format-scan): Use `dlet` to bind `whitespace-silent`. (texinfo-optional-braces-discard, texinfo-format-parse-line-args) (texinfo-format-parse-args): Remove unused var `start`. (texinfo-multitable-widths): Remove unused var `start-of-templates`. (texinfo-multitable-item): Strength-reduce `eval` to `symbol-value`. (texinfo-alias): Remove unused vars `start` and `args`. (texinfo-defun-type symbol-property): Change the car to help the type symbol rather than an expression returning it. (texinfo-format-deffn): Remove corresponding `eval`. (texinfo-clear): Remove unused var `value`. (texinfo-format-ifeq): Remove unused var `end`. * lisp/textmodes/texinfo.el: Use lexical-binding. (tex-show-print-queue): Declare function. * lisp/textmodes/texnfo-upd.el: Use lexical-binding. (texinfo-start-menu-description): Remove unused var `end`. (texinfo-insert-node-lines): Remove unused var `beginning-marker`. (texinfo-multiple-files-update): Remove unused vars `next-node-name` and `previous-node-name`. * lisp/textmodes/two-column.el: Use lexical-binding.
Diffstat (limited to 'lisp/textmodes/reftex-toc.el')
-rw-r--r--lisp/textmodes/reftex-toc.el114
1 files changed, 45 insertions, 69 deletions
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 3b9f970a3d2..b5643491338 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -1,4 +1,4 @@
-;;; reftex-toc.el --- RefTeX's table of contents mode
+;;; reftex-toc.el --- RefTeX's table of contents mode -*- lexical-binding: t; -*-
;; Copyright (C) 1997-2000, 2003-2021 Free Software Foundation, Inc.
@@ -32,8 +32,7 @@
(defvar reftex-toc-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
- 'reftex-toc-mouse-goto-line-and-hide)
+ (define-key map [(mouse-2)] #'reftex-toc-mouse-goto-line-and-hide)
(define-key map [follow-link] 'mouse-face)
(substitute-key-definition
@@ -41,34 +40,34 @@
(substitute-key-definition
'previous-line 'reftex-toc-previous map global-map)
- (define-key map "n" 'reftex-toc-next)
- (define-key map "p" 'reftex-toc-previous)
- (define-key map "?" 'reftex-toc-show-help)
- (define-key map " " 'reftex-toc-view-line)
- (define-key map "\C-m" 'reftex-toc-goto-line-and-hide)
- (define-key map "\C-i" 'reftex-toc-goto-line)
- (define-key map "\C-c>" 'reftex-toc-display-index)
- (define-key map "r" 'reftex-toc-rescan)
- (define-key map "R" 'reftex-toc-Rescan)
- (define-key map "q" 'reftex-toc-quit) ;
- (define-key map "k" 'reftex-toc-quit-and-kill)
- (define-key map "f" 'reftex-toc-toggle-follow) ;
- (define-key map "a" 'reftex-toggle-auto-toc-recenter)
- (define-key map "d" 'reftex-toc-toggle-dedicated-frame)
- (define-key map "F" 'reftex-toc-toggle-file-boundary)
- (define-key map "i" 'reftex-toc-toggle-index)
- (define-key map "l" 'reftex-toc-toggle-labels)
- (define-key map "t" 'reftex-toc-max-level)
- (define-key map "c" 'reftex-toc-toggle-context)
- ;; (define-key map "%" 'reftex-toc-toggle-commented)
- (define-key map "\M-%" 'reftex-toc-rename-label)
- (define-key map "x" 'reftex-toc-external)
- (define-key map "z" 'reftex-toc-jump)
- (define-key map "." 'reftex-toc-show-calling-point)
- (define-key map "\C-c\C-n" 'reftex-toc-next-heading)
- (define-key map "\C-c\C-p" 'reftex-toc-previous-heading)
- (define-key map ">" 'reftex-toc-demote)
- (define-key map "<" 'reftex-toc-promote)
+ (define-key map "n" #'reftex-toc-next)
+ (define-key map "p" #'reftex-toc-previous)
+ (define-key map "?" #'reftex-toc-show-help)
+ (define-key map " " #'reftex-toc-view-line)
+ (define-key map "\C-m" #'reftex-toc-goto-line-and-hide)
+ (define-key map "\C-i" #'reftex-toc-goto-line)
+ (define-key map "\C-c>" #'reftex-toc-display-index)
+ (define-key map "r" #'reftex-toc-rescan)
+ (define-key map "R" #'reftex-toc-Rescan)
+ (define-key map "q" #'reftex-toc-quit) ;
+ (define-key map "k" #'reftex-toc-quit-and-kill)
+ (define-key map "f" #'reftex-toc-toggle-follow) ;
+ (define-key map "a" #'reftex-toggle-auto-toc-recenter)
+ (define-key map "d" #'reftex-toc-toggle-dedicated-frame)
+ (define-key map "F" #'reftex-toc-toggle-file-boundary)
+ (define-key map "i" #'reftex-toc-toggle-index)
+ (define-key map "l" #'reftex-toc-toggle-labels)
+ (define-key map "t" #'reftex-toc-max-level)
+ (define-key map "c" #'reftex-toc-toggle-context)
+ ;; (define-key map "%" #'reftex-toc-toggle-commented)
+ (define-key map "\M-%" #'reftex-toc-rename-label)
+ (define-key map "x" #'reftex-toc-external)
+ (define-key map "z" #'reftex-toc-jump)
+ (define-key map "." #'reftex-toc-show-calling-point)
+ (define-key map "\C-c\C-n" #'reftex-toc-next-heading)
+ (define-key map "\C-c\C-p" #'reftex-toc-previous-heading)
+ (define-key map ">" #'reftex-toc-demote)
+ (define-key map "<" #'reftex-toc-promote)
(easy-menu-define
reftex-toc-menu map
@@ -130,9 +129,7 @@ Here are all local bindings.
\\{reftex-toc-mode-map}"
(set (make-local-variable 'transient-mark-mode) t)
- (when (featurep 'xemacs)
- (set (make-local-variable 'zmacs-regions) t))
- (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert)
+ (set (make-local-variable 'revert-buffer-function) #'reftex-toc-revert)
(set (make-local-variable 'reftex-toc-include-labels-indicator) "")
(set (make-local-variable 'reftex-toc-max-level-indicator)
(if (= reftex-toc-max-level 100)
@@ -146,15 +143,9 @@ Here are all local bindings.
" T<" 'reftex-toc-max-level-indicator ">"
" -%-"))
(setq truncate-lines t)
- (when (featurep 'xemacs)
- ;; XEmacs needs the call to make-local-hook
- (make-local-hook 'post-command-hook)
- (make-local-hook 'pre-command-hook))
(make-local-variable 'reftex-last-follow-point)
- (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
- (add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t)
- (when (featurep 'xemacs)
- (easy-menu-add reftex-toc-menu reftex-toc-mode-map)))
+ (add-hook 'post-command-hook #'reftex-toc-post-command-hook nil t)
+ (add-hook 'pre-command-hook #'reftex-toc-pre-command-hook nil t))
(defvar reftex-last-toc-file nil
"Stores the file name from which `reftex-toc' was called. For redo command.")
@@ -420,7 +411,6 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(defun reftex-toc-next (&optional _arg)
"Move to next selectable item."
(interactive)
- (when (featurep 'xemacs) (setq zmacs-region-stays t))
(setq reftex-callback-fwd t)
(or (eobp) (forward-char 1))
(goto-char (or (next-single-property-change (point) :data)
@@ -428,21 +418,18 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(defun reftex-toc-previous (&optional _arg)
"Move to previous selectable item."
(interactive)
- (when (featurep 'xemacs) (setq zmacs-region-stays t))
(setq reftex-callback-fwd nil)
(goto-char (or (previous-single-property-change (point) :data)
(point))))
(defun reftex-toc-next-heading (&optional arg)
"Move to next table of contents line."
(interactive "p")
- (when (featurep 'xemacs) (setq zmacs-region-stays t))
(end-of-line)
(re-search-forward "^ " nil t arg)
(beginning-of-line))
(defun reftex-toc-previous-heading (&optional arg)
"Move to previous table of contents line."
(interactive "p")
- (when (featurep 'xemacs) (setq zmacs-region-stays t))
(re-search-backward "^ " nil t arg))
(defun reftex-toc-toggle-follow ()
"Toggle follow (other window follows with context)."
@@ -662,7 +649,7 @@ point."
(let* ((reftex--start-line (+ (count-lines (point-min) (point))
(if (bolp) 1 0)))
(reftex--mark-line
- (if (reftex-region-active-p)
+ (if (region-active-p)
(save-excursion (goto-char (mark))
(+ (count-lines (point-min) (point))
(if (bolp) 1 0)))))
@@ -671,7 +658,7 @@ point."
beg end entries data sections nsec msg)
(setq msg
(catch 'exit
- (if (reftex-region-active-p)
+ (if (region-active-p)
;; A region is dangerous, check if we have a brand new scan,
;; to make sure we are not missing any section statements.
(if (not (reftex-toc-check-docstruct))
@@ -712,7 +699,7 @@ point."
nil ; we have permission, do nothing
(error "Abort")) ; abort, we don't have permission
;; Do the changes
- (mapc 'reftex-toc-promote-action entries)
+ (mapc #'reftex-toc-promote-action entries)
;; Rescan the document and rebuilt the toc buffer
(save-window-excursion
(reftex-toc-Rescan))
@@ -734,10 +721,8 @@ point."
(forward-line (1- point-line)))
(when mpos
(set-mark mpos)
- (if (featurep 'xemacs)
- (zmacs-activate-region)
- (setq mark-active t
- deactivate-mark nil)))))
+ (setq mark-active t
+ deactivate-mark nil))))
(defun reftex-toc-promote-prepare (x delta)
"Look at a TOC entry and see if we could pro/demote it.
@@ -918,7 +903,7 @@ label prefix determines the wording of a reference."
(setq match
(let ((where (car toc))
(file (nth 1 toc)))
- (if (or (not no-revisit) (reftex-get-buffer-visiting file))
+ (if (or (not no-revisit) (find-buffer-visiting file))
(progn
(switch-to-buffer-other-window
(reftex-get-file-buffer-force file nil))
@@ -981,7 +966,7 @@ label prefix determines the wording of a reference."
reftex-section-levels-all)))
"[[{]?"))))
((or (not no-revisit)
- (reftex-get-buffer-visiting file))
+ (find-buffer-visiting file))
;; Marker is lost. Use the backup method.
(switch-to-buffer-other-window
(reftex-get-file-buffer-force file nil))
@@ -1035,18 +1020,12 @@ section."
(interactive)
(if reftex-toc-auto-recenter-timer
(progn
- (if (featurep 'xemacs)
- (delete-itimer reftex-toc-auto-recenter-timer)
- (cancel-timer reftex-toc-auto-recenter-timer))
+ (cancel-timer reftex-toc-auto-recenter-timer)
(setq reftex-toc-auto-recenter-timer nil)
(message "Automatic recentering of TOC window was turned off"))
(setq reftex-toc-auto-recenter-timer
- (if (featurep 'xemacs)
- (start-itimer "RefTeX Idle Timer for recenter"
- 'reftex-recenter-toc-when-idle
- reftex-idle-time reftex-idle-time t)
- (run-with-idle-timer
- reftex-idle-time t 'reftex-recenter-toc-when-idle)))
+ (run-with-idle-timer
+ reftex-idle-time t #'reftex-recenter-toc-when-idle))
(message "Automatic recentering of TOC window was turned on")))
(defun reftex-toc-toggle-dedicated-frame ()
@@ -1090,15 +1069,12 @@ always show the current section in connection with the option
(switch-to-buffer "*toc*")
(select-frame current-frame)
(cond ((fboundp 'x-focus-frame)
- (x-focus-frame current-frame))
- ((and (featurep 'xemacs) ; `focus-frame' is a nop in Emacs.
- (fboundp 'focus-frame))
- (focus-frame current-frame)))
+ (x-focus-frame current-frame)))
(select-window current-window)
(when (eq reftex-auto-recenter-toc 'frame)
(unless reftex-toc-auto-recenter-timer
(reftex-toggle-auto-toc-recenter))
- (add-hook 'delete-frame-functions 'reftex-toc-delete-frame-hook)))))
+ (add-hook 'delete-frame-functions #'reftex-toc-delete-frame-hook)))))
(defun reftex-toc-delete-frame-hook (frame)
(if (and reftex-toc-auto-recenter-timer