From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: next-error use cases Date: Thu, 12 Apr 2018 23:27:16 +0300 Organization: LINKOV.NET Message-ID: <87r2nknpaz.fsf@mail.linkov.net> References: <87zi2esn7l.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1523564939 1823 195.159.176.226 (12 Apr 2018 20:28:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 12 Apr 2018 20:28:59 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 12 22:28:55 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6ipz-0000I6-0M for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2018 22:28:55 +0200 Original-Received: from localhost ([::1]:41053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6is3-0007Vy-Oj for ged-emacs-devel@m.gmane.org; Thu, 12 Apr 2018 16:31:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6iqu-0007Vc-OU for emacs-devel@gnu.org; Thu, 12 Apr 2018 16:29:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6iqr-0005Pp-I5 for emacs-devel@gnu.org; Thu, 12 Apr 2018 16:29:52 -0400 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:32974 helo=homiemail-a75.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6iqr-0005Nr-AI for emacs-devel@gnu.org; Thu, 12 Apr 2018 16:29:49 -0400 Original-Received: from homiemail-a75.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a75.g.dreamhost.com (Postfix) with ESMTP id AE7245EC07F for ; Thu, 12 Apr 2018 13:29:47 -0700 (PDT) Original-Received: from localhost.linkov.net (m91-129-105-236.cust.tele2.ee [91.129.105.236]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a75.g.dreamhost.com (Postfix) with ESMTPSA id 122C65EC07C for ; Thu, 12 Apr 2018 13:29:46 -0700 (PDT) In-Reply-To: <87zi2esn7l.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 08 Apr 2018 00:47:42 +0300") X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 69.163.253.7 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:224531 Archived-At: 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-err= or 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 =E2=80=98= C-c C-c=E2=80=99 that sets next-error-last-buffer in next-error-internal among other thing= s. Tried to pass goto-source commands thru next-error-internal that works fi= ne for change-log-goto-source but has problems in diff-goto-source because next-error-internal has no arguments but diff-goto-source expects =E2=80=98other-file=E2=80=99 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." (interactive) + (next-error-internal)) + +(defun change-log-goto-source-internal () (if (and (eq last-command 'change-log-goto-source) change-log-find-tail) (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)) =20 (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)))