mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Use next-error-found to set next-error-last-buffer.
https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00207.html * lisp/simple.el (next-error-buffer): New buffer-local variable instead of making buffer-local next-error-last-buffer. (Bug#20489) (next-error-found-function): New defcustom. (next-error-buffer-on-selected-frame): Use t for avoid-current arg of next-error-buffer-p. (next-error-find-buffer): Add second rule for using the current next-error-buffer if it's not visited by other navigation. (next-error, next-error-internal): Call next-error-found. (next-error-found): New function with body extracted mostly from next-error. * lisp/vc/add-log.el (change-log-goto-source-internal): New function with body from change-log-goto-source. (change-log-goto-source): Call change-log-goto-source-internal and next-error-found. (change-log-next-error): Call change-log-goto-source-internal instead of change-log-goto-source. (change-log-mode): Don't set next-error-last-buffer. (Bug#28864) * lisp/vc/diff-mode.el (diff-goto-source): Call next-error-found. * lisp/progmodes/xref.el (xref-goto-xref): Call next-error-found. * lisp/replace.el (occur-mode-goto-occurrence) (occur-mode-goto-occurrence-other-window) (occur-mode-display-occurrence): Call next-error-found. (occur-next-error): Remove unnecessary with-current-buffer. (Bug#27362, bug#30646)
This commit is contained in:
parent
d12800303f
commit
0c9e3df3c2
6 changed files with 88 additions and 77 deletions
|
|
@ -1192,7 +1192,8 @@ To return to ordinary Occur mode, use \\[occur-cease-edit]."
|
|||
(defun occur-mode-goto-occurrence (&optional event)
|
||||
"Go to the occurrence on the current line."
|
||||
(interactive (list last-nonmenu-event))
|
||||
(let ((pos
|
||||
(let ((buffer (when event (current-buffer)))
|
||||
(pos
|
||||
(if (null event)
|
||||
;; Actually `event-end' works correctly with a nil argument as
|
||||
;; well, so we could dispense with this test, but let's not
|
||||
|
|
@ -1204,26 +1205,31 @@ To return to ordinary Occur mode, use \\[occur-cease-edit]."
|
|||
(occur-mode-find-occurrence))))))
|
||||
(pop-to-buffer (marker-buffer pos))
|
||||
(goto-char pos)
|
||||
(when buffer (next-error-found buffer (current-buffer)))
|
||||
(run-hooks 'occur-mode-find-occurrence-hook)))
|
||||
|
||||
(defun occur-mode-goto-occurrence-other-window ()
|
||||
"Go to the occurrence the current line describes, in another window."
|
||||
(interactive)
|
||||
(let ((pos (occur-mode-find-occurrence)))
|
||||
(let ((buffer (current-buffer))
|
||||
(pos (occur-mode-find-occurrence)))
|
||||
(switch-to-buffer-other-window (marker-buffer pos))
|
||||
(goto-char pos)
|
||||
(next-error-found buffer (current-buffer))
|
||||
(run-hooks 'occur-mode-find-occurrence-hook)))
|
||||
|
||||
(defun occur-mode-display-occurrence ()
|
||||
"Display in another window the occurrence the current line describes."
|
||||
(interactive)
|
||||
(let ((pos (occur-mode-find-occurrence))
|
||||
(let ((buffer (current-buffer))
|
||||
(pos (occur-mode-find-occurrence))
|
||||
window)
|
||||
(setq window (display-buffer (marker-buffer pos) t))
|
||||
;; This is the way to set point in the proper window.
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
(goto-char pos)
|
||||
(next-error-found buffer (current-buffer))
|
||||
(run-hooks 'occur-mode-find-occurrence-hook))))
|
||||
|
||||
(defun occur-find-match (n search message)
|
||||
|
|
@ -1253,29 +1259,20 @@ To return to ordinary Occur mode, use \\[occur-cease-edit]."
|
|||
"Move to the Nth (default 1) next match in an Occur mode buffer.
|
||||
Compatibility function for \\[next-error] invocations."
|
||||
(interactive "p")
|
||||
;; we need to run occur-find-match from within the Occur buffer
|
||||
(with-current-buffer
|
||||
;; Choose the buffer and make it current.
|
||||
(if (next-error-buffer-p (current-buffer))
|
||||
(current-buffer)
|
||||
(next-error-find-buffer nil nil
|
||||
(lambda ()
|
||||
(eq major-mode 'occur-mode))))
|
||||
|
||||
(goto-char (cond (reset (point-min))
|
||||
((< argp 0) (line-beginning-position))
|
||||
((> argp 0) (line-end-position))
|
||||
((point))))
|
||||
(occur-find-match
|
||||
(abs argp)
|
||||
(if (> 0 argp)
|
||||
#'previous-single-property-change
|
||||
#'next-single-property-change)
|
||||
"No more matches")
|
||||
;; In case the *Occur* buffer is visible in a nonselected window.
|
||||
(let ((win (get-buffer-window (current-buffer) t)))
|
||||
(if win (set-window-point win (point))))
|
||||
(occur-mode-goto-occurrence)))
|
||||
(goto-char (cond (reset (point-min))
|
||||
((< argp 0) (line-beginning-position))
|
||||
((> argp 0) (line-end-position))
|
||||
((point))))
|
||||
(occur-find-match
|
||||
(abs argp)
|
||||
(if (> 0 argp)
|
||||
#'previous-single-property-change
|
||||
#'next-single-property-change)
|
||||
"No more matches")
|
||||
;; In case the *Occur* buffer is visible in a nonselected window.
|
||||
(let ((win (get-buffer-window (current-buffer) t)))
|
||||
(if win (set-window-point win (point))))
|
||||
(occur-mode-goto-occurrence))
|
||||
|
||||
(defface match
|
||||
'((((class color) (min-colors 88) (background light))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue