mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
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:
parent
31ee325352
commit
36c6908616
2 changed files with 35 additions and 40 deletions
|
|
@ -440,7 +440,7 @@ Also checks if buffers visiting the files are in read-only mode."
|
||||||
(t
|
(t
|
||||||
(setq nxt-buff
|
(setq nxt-buff
|
||||||
(funcall isearch-next-buffer-function
|
(funcall isearch-next-buffer-function
|
||||||
(current-buffer)))
|
(current-buffer)))
|
||||||
(if (not nxt-buff)
|
(if (not nxt-buff)
|
||||||
(progn
|
(progn
|
||||||
(error "Wrap backward"))
|
(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.
|
;; NB this is a global autoload - see reftex.el.
|
||||||
;;;###autoload
|
;;;###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.
|
"When on, isearch searches the whole document, not only the current file.
|
||||||
This minor mode allows isearch to search through all the files of
|
This minor mode allows isearch to search through all the files of
|
||||||
the current TeX document.
|
the current TeX document.
|
||||||
|
|
||||||
With no argument, this command toggles
|
With no argument, this command toggles
|
||||||
`reftex-isearch-minor-mode'. With a prefix argument ARG, turn
|
`reftex-isearch-minor-mode'. With a prefix argument ARG, turn
|
||||||
`reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off."
|
`reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off.
|
||||||
(interactive "P")
|
This behaviour is derived from `define-minor-mode'."
|
||||||
(let ((old-reftex-isearch-minor-mode reftex-isearch-minor-mode))
|
:lighter "/I"
|
||||||
(setq reftex-isearch-minor-mode
|
:global t
|
||||||
(not (or (and (null arg) reftex-isearch-minor-mode)
|
(if reftex-isearch-minor-mode
|
||||||
(<= (prefix-numeric-value arg) 0))))
|
(progn
|
||||||
(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))
|
|
||||||
(dolist (crt-buf (buffer-list))
|
(dolist (crt-buf (buffer-list))
|
||||||
(with-current-buffer crt-buf
|
(with-current-buffer crt-buf
|
||||||
(when reftex-mode
|
(when reftex-mode
|
||||||
(if (boundp 'multi-isearch-next-buffer-function)
|
(if (boundp 'multi-isearch-next-buffer-function)
|
||||||
(kill-local-variable 'multi-isearch-next-buffer-function)
|
(setq-local multi-isearch-next-buffer-function
|
||||||
(kill-local-variable 'isearch-wrap-function)
|
#'reftex-isearch-switch-to-next-file)
|
||||||
(kill-local-variable 'isearch-search-fun-function)
|
(setq-local isearch-wrap-function
|
||||||
(kill-local-variable 'isearch-push-state-function)
|
#'reftex-isearch-wrap-function)
|
||||||
(kill-local-variable 'isearch-next-buffer-function))
|
(setq-local isearch-search-fun-function
|
||||||
(setq reftex-isearch-minor-mode nil))))
|
(lambda () #'reftex-isearch-isearch-search))
|
||||||
(remove-hook 'reftex-mode-hook #'reftex-isearch-minor-mode)))
|
(setq-local isearch-push-state-function
|
||||||
;; Force mode line redisplay.
|
#'reftex-isearch-push-state-function)
|
||||||
(set-buffer-modified-p (buffer-modified-p))))
|
(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
|
;;; reftex-global.el ends here
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
;; 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
|
(easy-menu-define reftex-mode-menu reftex-mode-map
|
||||||
"Menu used in RefTeX mode."
|
"Menu used in RefTeX mode."
|
||||||
`("Ref"
|
`("Ref"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue