From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#33319: Support revisions in diff-goto-source Date: Thu, 08 Nov 2018 23:05:10 +0200 Organization: LINKOV.NET Message-ID: <87lg63p9fd.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1541711247 14982 195.159.176.226 (8 Nov 2018 21:07:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2018 21:07:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: 33319@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 08 22:07:23 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1gKrWJ-0003hL-UM for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Nov 2018 22:07:20 +0100 Original-Received: from localhost ([::1]:59003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKrYQ-0008WB-DJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Nov 2018 16:09:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKrYD-0008Ua-Dt for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:09:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKrY5-0003b3-CQ for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:09:14 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37673) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKrY0-0003Wu-Im for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:09:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gKrY0-00008w-5I for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:09:04 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Nov 2018 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33319 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1541711310502 (code B ref -1); Thu, 08 Nov 2018 21:09:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Nov 2018 21:08:30 +0000 Original-Received: from localhost ([127.0.0.1]:41931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKrXS-000081-1B for submit@debbugs.gnu.org; Thu, 08 Nov 2018 16:08:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKrXQ-00007p-DM for submit@debbugs.gnu.org; Thu, 08 Nov 2018 16:08:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKrXI-0002j4-L5 for submit@debbugs.gnu.org; Thu, 08 Nov 2018 16:08:21 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43207) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKrXG-0002gF-Op for submit@debbugs.gnu.org; Thu, 08 Nov 2018 16:08:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKrXC-00078S-5E for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:08:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKrX2-0002JH-Jt for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:08:10 -0500 Original-Received: from bisque.maple.relay.mailchannels.net ([23.83.214.18]:43225) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKrX0-0002Ci-8f for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:08:02 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 39FE25C3EE7 for ; Thu, 8 Nov 2018 21:07:58 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (unknown [100.96.11.179]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E94BF5C31E8 for ; Thu, 8 Nov 2018 21:07:57 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Thu, 08 Nov 2018 21:07:58 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Abiding-Bitter: 54f5460f02de02c3_1541711278036_3247692260 X-MC-Loop-Signature: 1541711278036:2702143929 X-MC-Ingress-Time: 1541711278035 Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a66.g.dreamhost.com (Postfix) with ESMTP id B27E1806D6 for ; Thu, 8 Nov 2018 13:07:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to :subject:date:message-id:mime-version:content-type; s= linkov.net; bh=y4oyGLNYizgTAl5B7/kS/Pqkkbk=; b=RY1qOm9WJOJlNEOw8 Rmf5T4Jvbl3GMxS+psjyGixYIntGL8ngRcQzn8Fk/33pO0EYDsE3TGN1ExE8iWSx vnXongNz9RaTAoWrFbuxJgJVjIlQ/Yj887y6XMWiwxQBlHVTciSnOndvG8JKfcq/ O4r8muLA/IxzaMC2Tfu72A9BHA= Original-Received: from mail.jurta.org (m91-129-107-244.cust.tele2.ee [91.129.107.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a66.g.dreamhost.com (Postfix) with ESMTPSA id 78A17806D1 for ; Thu, 8 Nov 2018 13:07:55 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a66 X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrkedugddugeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohffkfgfgggtsehmtderredtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddtjedrvdeggeenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrddutdejrddvgeegpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtohepsghughdqghhnuhdqvghmrggtshesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152176 Archived-At: --=-=-= Content-Type: text/plain Severity: wishlist Tags: patch Currently diff-goto-source with no prefix arg jumps to the new file, and with a prefix arg jumps to the old file. It does nothing special when the diff buffer is created by a version control system, because the same current file is visited by old and new. This is a useful default behavior to visit the current file and continue making changes at an approximate location of the difference. However, often this fails to find the change in old revisions. So the proposed feature is backward-compatible: in the diff buffer created by a version control system, with a prefix arg it will jump to an old revision of the file. It is very useful to look at the context of changed lines of the file as it was at the time of that old revision. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=diff-goto-source.1.patch diff --git a/etc/NEWS b/etc/NEWS index 1020a2a0ea..36ad3d82df 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -353,6 +353,11 @@ To disable it, set the new defcustom 'diff-font-lock-refine' to nil. *** File headers can be shortened, mimicking Magit's diff format. To enable it, set the new defcustom 'diff-font-lock-prettify to t. +*** In the diff buffer created by a version control system, the prefix +arg of diff-goto-source means it jumps to the old revision of the file +if point is on an old changed line, or to the new revision of the file +otherwise. + ** Browse-url *** The function 'browse-url-emacs' can now visit a URL in selected window. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index dcfbf26e86..6b7ca02440 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1728,6 +1729,7 @@ vc-diff-internal (set-buffer buffer) (diff-mode) (set (make-local-variable 'diff-vc-backend) (car vc-fileset)) + (set (make-local-variable 'diff-vc-revisions) (list rev1 rev2)) (set (make-local-variable 'revert-buffer-function) (lambda (_ignore-auto _noconfirm) (vc-diff-internal async vc-fileset rev1 rev2 verbose))) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index cf52368508..b41206296d 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -104,6 +105,9 @@ diff-font-lock-prettify (defvar diff-vc-backend nil "The VC backend that created the current Diff buffer, if any.") +(defvar diff-vc-revisions nil + "The VC revisions compared in the current Diff buffer, if any.") + (defvar diff-outline-regexp "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)") @@ -1736,7 +1740,11 @@ diff-find-source-location (match-string 1))))) (file (or (diff-find-file-name other noprompt) (error "Can't find the file"))) - (buf (find-file-noselect file))) + (revision (and other diff-vc-backend + (nth (if reverse 1 0) diff-vc-revisions))) + (buf (if revision + (vc-find-revision file revision diff-vc-backend) + (find-file-noselect file)))) ;; Update the user preference if he so wished. (when (> (prefix-numeric-value other-file) 8) (setq diff-jump-to-old-file other)) @@ -1862,7 +1870,11 @@ diff-goto-source `diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg is given) determines whether to jump to the old or the new file. If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument]) -then `diff-jump-to-old-file' is also set, for the next invocations." +then `diff-jump-to-old-file' is also set, for the next invocations. + +In the diff buffer created by a version control system, the OTHER-FILE +prefix arg means it jumps to the old revision of the file if point is +on an old changed line, or to the new revision of the file otherwise." (interactive (list current-prefix-arg last-input-event)) ;; When pointing at a removal line, we probably want to jump to ;; the old location, and else to the new (i.e. as if reverting). --=-=-=--