summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuniya DW <luniya@slugcats.moe>2026-05-26 22:39:05 +0200
committerStefan Monnier <monnier@iro.umontreal.ca>2026-05-29 17:29:52 -0400
commit36c6908616562201f87fbbe4f0f5556baa5eeac7 (patch)
tree3666dc51f6d2b7df7cd772f39d66093834f4db35
parent31ee3253523dd0c068ee5cc12c30454d4fed3961 (diff)
Refactor reftex-isearch-minor-mode to use define-minor-mode
See L88 in etc/TODO. * lisp/textmodes/reftex-global.el (reftex-isearch-minor-mode): Use `define-minor-mode`. * lisp/textmodes/reftex.el (reftex-isearch-minor-mode): Remove redundant variable definition.
-rw-r--r--lisp/textmodes/reftex-global.el73
-rw-r--r--lisp/textmodes/reftex.el2
2 files changed, 35 insertions, 40 deletions
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index e9acf91c824..54c5c97be01 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -440,7 +440,7 @@ Also checks if buffers visiting the files are in read-only mode."
(t
(setq nxt-buff
(funcall isearch-next-buffer-function
- (current-buffer)))
+ (current-buffer)))
(if (not nxt-buff)
(progn
(error "Wrap backward"))
@@ -475,54 +475,51 @@ Also checks if buffers visiting the files are in read-only mode."
;; NB this is a global autoload - see reftex.el.
;;;###autoload
-(defun reftex-isearch-minor-mode (&optional arg)
+(define-minor-mode reftex-isearch-minor-mode
"When on, isearch searches the whole document, not only the current file.
This minor mode allows isearch to search through all the files of
the current TeX document.
With no argument, this command toggles
`reftex-isearch-minor-mode'. With a prefix argument ARG, turn
-`reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off."
- (interactive "P")
- (let ((old-reftex-isearch-minor-mode reftex-isearch-minor-mode))
- (setq reftex-isearch-minor-mode
- (not (or (and (null arg) reftex-isearch-minor-mode)
- (<= (prefix-numeric-value arg) 0))))
- (unless (eq reftex-isearch-minor-mode old-reftex-isearch-minor-mode)
- (if reftex-isearch-minor-mode
- (progn
- (dolist (crt-buf (buffer-list))
- (with-current-buffer crt-buf
- (when reftex-mode
- (if (boundp 'multi-isearch-next-buffer-function)
- (setq-local multi-isearch-next-buffer-function
- #'reftex-isearch-switch-to-next-file)
- (setq-local isearch-wrap-function
- #'reftex-isearch-wrap-function)
- (setq-local isearch-search-fun-function
- (lambda () #'reftex-isearch-isearch-search))
- (setq-local isearch-push-state-function
- #'reftex-isearch-push-state-function)
- (setq-local isearch-next-buffer-function
- #'reftex-isearch-switch-to-next-file))
- (setq reftex-isearch-minor-mode t))))
- (add-hook 'reftex-mode-hook #'reftex-isearch-minor-mode))
+`reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off.
+This behaviour is derived from `define-minor-mode'."
+ :lighter "/I"
+ :global t
+ (if reftex-isearch-minor-mode
+ (progn
(dolist (crt-buf (buffer-list))
(with-current-buffer crt-buf
(when reftex-mode
(if (boundp 'multi-isearch-next-buffer-function)
- (kill-local-variable 'multi-isearch-next-buffer-function)
- (kill-local-variable 'isearch-wrap-function)
- (kill-local-variable 'isearch-search-fun-function)
- (kill-local-variable 'isearch-push-state-function)
- (kill-local-variable 'isearch-next-buffer-function))
- (setq reftex-isearch-minor-mode nil))))
- (remove-hook 'reftex-mode-hook #'reftex-isearch-minor-mode)))
- ;; Force mode line redisplay.
- (set-buffer-modified-p (buffer-modified-p))))
+ (setq-local multi-isearch-next-buffer-function
+ #'reftex-isearch-switch-to-next-file)
+ (setq-local isearch-wrap-function
+ #'reftex-isearch-wrap-function)
+ (setq-local isearch-search-fun-function
+ (lambda () #'reftex-isearch-isearch-search))
+ (setq-local isearch-push-state-function
+ #'reftex-isearch-push-state-function)
+ (setq-local isearch-next-buffer-function
+ #'reftex-isearch-switch-to-next-file))
+ (setq reftex-isearch-minor-mode t))))
+ (add-hook 'reftex-mode-hook #'reftex-isearch-minor-mode))
+ (dolist (crt-buf (buffer-list))
+ (with-current-buffer crt-buf
+ (when reftex-mode
+ (if (boundp 'multi-isearch-next-buffer-function)
+ (kill-local-variable 'multi-isearch-next-buffer-function)
+ (kill-local-variable 'isearch-wrap-function)
+ (kill-local-variable 'isearch-search-fun-function)
+ (kill-local-variable 'isearch-push-state-function)
+ (kill-local-variable 'isearch-next-buffer-function))
+ (setq reftex-isearch-minor-mode nil))))
+ (remove-hook 'reftex-mode-hook #'reftex-isearch-minor-mode))
+ ;; Force mode line redisplay.
+ (set-buffer-modified-p (buffer-modified-p)))
+
+
-(add-minor-mode 'reftex-isearch-minor-mode "/I" nil nil
- 'reftex-isearch-minor-mode)
;;; reftex-global.el ends here
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 4e2c89e87dc..c0533ada842 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -2180,8 +2180,6 @@ fonts. Currently it is only used for reftex-label-face."
;; Define a menu for the menu bar if Emacs is running under X
-(defvar-local reftex-isearch-minor-mode nil)
-
(easy-menu-define reftex-mode-menu reftex-mode-map
"Menu used in RefTeX mode."
`("Ref"