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: Fri, 28 Nov 2014 23:15:38 +0200 Organization: LINKOV.NET Message-ID: <8761dzxc05.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> <87egsqzy74.fsf@mail.linkov.net> <877fyhfno0.fsf@mail.linkov.net> <3dcedc6e-0613-4af5-a061-02395bc9a506@default> <87y4qw5elz.fsf@mail.linkov.net> <54782455.3020206@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417209449 5508 80.91.229.3 (28 Nov 2014 21:17:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Nov 2014 21:17:29 +0000 (UTC) Cc: 19170@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 28 22:17: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 1XuSum-0006Fz-9h for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Nov 2014 22:17:20 +0100 Original-Received: from localhost ([::1]:46041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuSul-0007Aw-SJ for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Nov 2014 16:17:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuSud-0007Ad-Nx for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 16:17:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuSuU-00075b-RK for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 16:17:11 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuSuU-00075I-ON for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 16:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XuSuT-0005qQ-Q3 for bug-gnu-emacs@gnu.org; Fri, 28 Nov 2014 16:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Nov 2014 21:17:01 +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.141720941322447 (code B ref 19170); Fri, 28 Nov 2014 21:17:01 +0000 Original-Received: (at 19170) by debbugs.gnu.org; 28 Nov 2014 21:16:53 +0000 Original-Received: from localhost ([127.0.0.1]:48705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XuSuL-0005pz-69 for submit@debbugs.gnu.org; Fri, 28 Nov 2014 16:16:53 -0500 Original-Received: from ps18281.dreamhost.com ([69.163.222.226]:43742 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XuSuI-0005pr-3k for 19170@debbugs.gnu.org; Fri, 28 Nov 2014 16:16:51 -0500 Original-Received: from localhost.linkov.net (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 1AC53348328E6E; Fri, 28 Nov 2014 13:16:49 -0800 (PST) In-Reply-To: <54782455.3020206@gmx.at> (martin rudalics's message of "Fri, 28 Nov 2014 08:29:25 +0100") 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:96713 Archived-At: > You mean when the window referenced by `last-selected-window' is > deleted? The one returned by (get-mru-window t t t) I presume. In any > case `window-use-time' allows to order all windows by the time when they > were selected. Thank you, Martin. This is exactly what we need. diff --git a/lisp/vc/compare-w.el b/lisp/vc/compare-w.el index 25d4cf7..8e5cf11 100644 --- a/lisp/vc/compare-w.el +++ b/lisp/vc/compare-w.el @@ -140,9 +140,37 @@ out all highlighting later with the command `compare-windows-dehighlight'." (defvar compare-windows-overlays2 nil) (defvar compare-windows-sync-point nil) +(defcustom compare-windows-get-window-function 'compare-windows-get-recent-window + "Function that provides the window to compare with." + :type '(choice + (function-item :tag "Most recently used window" + compare-windows-get-recent-window) + (function-item :tag "Next window" + compare-windows-get-next-window) + (function :tag "Your function")) + :group 'compare-windows + :version "25.0") + +(defun compare-windows-get-recent-window () + (let ((w2 (get-mru-window 'visible t t))) + (if (eq w2 (selected-window)) + (error "No other window")) + w2)) + +(defun compare-windows-get-next-window () + (let ((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")) + w2)) + ;;;###autoload (defun compare-windows (ignore-whitespace) - "Compare text in current window with text in next window. + "Compare text in current window with text in another window. +The option `compare-windows-get-window-function' defines how +to get another window. + Compares the text starting at point in each window, moving over text in each one as far as they match. @@ -179,11 +207,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 (funcall compare-windows-get-window-function)) (setq p2 (window-point w2) b2 (window-buffer w2)) (setq opoint2 p2) @@ -255,12 +279,15 @@ on third call it again advances points to the next difference and so on." (recenter (car compare-windows-recenter)) (with-selected-window w2 (recenter (cadr compare-windows-recenter)))) ;; If points are still not synchronized, then ding - (when (and (= p1 opoint1) (= p2 opoint2)) - ;; Display error message when current points in two windows - ;; are unmatched and next matching points can't be found. - (compare-windows-dehighlight) - (ding) - (message "No more matching points")))))) + (if (and (= p1 opoint1) (= p2 opoint2)) + (progn + ;; Display error message when current points in two windows + ;; are unmatched and next matching points can't be found. + (compare-windows-dehighlight) + (ding) + (message "No more matching points with %s" b2)) + (message "Match with %s" b2))) + (message "Difference with %s" b2)))) ;; Move forward over whatever might be called whitespace. ;; compare-windows-whitespace is a regexp that matches whitespace. @@ -303,7 +330,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 (funcall compare-windows-get-window-function)) (b2 (window-buffer w2)) (point-max2 (with-current-buffer b2 (point-max))) (op2 (window-point w2))