summaryrefslogtreecommitdiff
path: root/lisp/textmodes/reftex-toc.el
diff options
context:
space:
mode:
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