[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: next-error use cases

From: Juri Linkov
Subject: Re: next-error use cases
Date: Thu, 12 Apr 2018 23:27:16 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

Since we removed the rule of visibility of next-error-function buffers
as a criteria for deciding what navigation to use for next-error,
so e.g. next-error in *Occur* or *Diff* that is the current buffer
and a single visible buffer on the frame will still use the last next-error
buffer that might be e.g. *compilation* or *grep* buffer buried long ago,
now we need to support the same way to switch next-error navigation as
already is possible in *compilation* and *grep* by typing RET or ‘C-c C-c’
that sets next-error-last-buffer in next-error-internal among other things.

Tried to pass goto-source commands thru next-error-internal that works fine
for change-log-goto-source but has problems in diff-goto-source
because next-error-internal has no arguments but diff-goto-source
expects ‘other-file’ as an arg.

Another solution is to call a special function like next-error-internal
explicitly from all such goto-source commands.  This function could also
set next-error-last-buffer to the current buffer.

Anyway here is the patch that shows the problem with the first solution:

diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index 175c82f..671f971 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -471,6 +471,9 @@ change-log-goto-source
 comma-separated list.  If no suitable tag can be found nearby,
 try to visit the file for the change under `point' instead."
+  (next-error-internal))
+(defun change-log-goto-source-internal ()
   (if (and (eq last-command 'change-log-goto-source)
       (setq change-log-find-tail
@@ -539,7 +542,7 @@ change-log-next-error
   ;; if we found a place to visit...
   (when (looking-at change-log-file-names-re)
     (let (change-log-find-window)
-      (change-log-goto-source)
+      (change-log-goto-source-internal)
       (when change-log-find-window
        ;; Select window displaying source file.
        (select-window change-log-find-window)))))
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index ef13f55..2a70563 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1349,7 +1349,7 @@ diff-next-error
   (pop-to-buffer (current-buffer))
   (if reset (goto-char (point-min)))
   (diff-hunk-next arg)
-  (diff-goto-source))
+  (diff-goto-source-internal))
 (defvar whitespace-style)
 (defvar whitespace-trailing-regexp)
@@ -1874,6 +1874,11 @@ diff-goto-source
   ;; the old location, and else to the new (i.e. as if reverting).
   ;; This is a convenient detail when using smerge-diff.
   (if event (posn-set-point (event-end event)))
+  (if other-file
+      (diff-goto-source-internal other-file)
+    (next-error-internal)))
+(defun diff-goto-source-internal (&optional other-file)
   (let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
     (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
                  (diff-find-source-location other-file rev)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]