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.
This commit is contained in:
Luniya DW 2026-05-26 22:39:05 +02:00 committed by Stefan Monnier
parent 31ee325352
commit 36c6908616
2 changed files with 35 additions and 40 deletions

View file

@ -475,20 +475,17 @@ 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)
`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))
@ -517,12 +514,12 @@ With no argument, this command toggles
(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)))
(remove-hook 'reftex-mode-hook #'reftex-isearch-minor-mode))
;; Force mode line redisplay.
(set-buffer-modified-p (buffer-modified-p))))
(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

View file

@ -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"