From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#19170: 25.0.50; enhancement request: `compare-windows' use across frames Date: Wed, 26 Nov 2014 00:56:30 +0200 Organization: LINKOV.NET Message-ID: <87egsqzy74.fsf@mail.linkov.net> References: <32848088-e8db-46dc-b9c7-f53bc46bb4e1@default> <87egss9r7v.fsf@mail.linkov.net> <2f6cb7a6-e050-4909-9b54-d651523bb5d5@default> <87egss86a8.fsf@mail.linkov.net> <87egsr0xjt.fsf@mail.linkov.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416956430 15884 80.91.229.3 (25 Nov 2014 23:00:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 23:00:30 +0000 (UTC) Cc: 19170@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 26 00:00:22 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XtP5o-0003yN-BY for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Nov 2014 00:00:20 +0100 Original-Received: from localhost ([::1]:59843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtP5n-0004Cv-Nf for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Nov 2014 18:00:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtP5e-0004Co-6U for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 18:00:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtP5X-0003LI-UY for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 18:00:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtP5X-0003Ki-RX for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 18:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XtP5X-0003e7-Ef for bug-gnu-emacs@gnu.org; Tue, 25 Nov 2014 18:00:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Nov 2014 23:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19170-submit@debbugs.gnu.org id=B19170.141695635313920 (code B ref 19170); Tue, 25 Nov 2014 23:00:03 +0000 Original-Received: (at 19170) by debbugs.gnu.org; 25 Nov 2014 22:59:13 +0000 Original-Received: from localhost ([127.0.0.1]:45333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtP4i-0003cR-4S for submit@debbugs.gnu.org; Tue, 25 Nov 2014 17:59:12 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.222.226]:60684 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtP4f-0003cF-RA for 19170@debbugs.gnu.org; Tue, 25 Nov 2014 17:59:10 -0500 Original-Received: from localhost.linkov.net (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 71531348328E6C; Tue, 25 Nov 2014 14:59:06 -0800 (PST) In-Reply-To: (Drew Adams's message of "Tue, 25 Nov 2014 14:00:25 -0800 (PST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96577 Archived-At: > And yes, we need only record the previously selected window, > not a whole access history (at least for this command). Below is the smallest patch that implements this feature. It refactors the next-window choosing logic into a separate function that you can redefine using define-advice if you want to define own logic. By default, it provides a special command `compare-windows-set-next-window' that you can bind to an own key and use to define the next window that `compare-windows' will use, then move back to the original window and execute `compare-windows' normally (with or without its current argument to ignore whitespace). diff --git a/lisp/vc/compare-w.el b/lisp/vc/compare-w.el index 25d4cf7..a8a0a17 100644 --- a/lisp/vc/compare-w.el +++ b/lisp/vc/compare-w.el @@ -140,6 +140,22 @@ out all highlighting later with the command `compare-windows-dehighlight'." (defvar compare-windows-overlays2 nil) (defvar compare-windows-sync-point nil) +(defvar compare-windows-next-window nil) + +(defun compare-windows-set-next-window () + (interactive) + (setq compare-windows-next-window (selected-window))) + +(defun compare-windows-get-next-window () + (let ((w2 (if (window-live-p compare-windows-next-window) + compare-windows-next-window + (next-window)))) + (if (eq w2 (selected-window)) + (setq w2 (next-window (selected-window) nil 'visible))) + (if (eq w2 (selected-window)) + (error "No other window")) + w2)) + ;;;###autoload (defun compare-windows (ignore-whitespace) "Compare text in current window with text in next window. @@ -179,11 +195,7 @@ on third call it again advances points to the next difference and so on." 'compare-windows-sync-regexp compare-windows-sync))) (setq p1 (point) b1 (current-buffer)) - (setq w2 (next-window)) - (if (eq w2 (selected-window)) - (setq w2 (next-window (selected-window) nil 'visible))) - (if (eq w2 (selected-window)) - (error "No other window")) + (setq w2 (compare-windows-get-next-window)) (setq p2 (window-point w2) b2 (window-buffer w2)) (setq opoint2 p2) @@ -303,7 +315,7 @@ on third call it again advances points to the next difference and so on." (defun compare-windows-sync-default-function () (if (not compare-windows-sync-point) (let* ((w1 (selected-window)) - (w2 (next-window w1)) + (w2 (compare-windows-get-next-window)) (b2 (window-buffer w2)) (point-max2 (with-current-buffer b2 (point-max))) (op2 (window-point w2))