unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Drew Adams <drew.adams@oracle.com>
Cc: 19170@debbugs.gnu.org
Subject: bug#19170: 25.0.50; enhancement request: `compare-windows' use across frames
Date: Wed, 26 Nov 2014 00:56:30 +0200	[thread overview]
Message-ID: <87egsqzy74.fsf@mail.linkov.net> (raw)
In-Reply-To: <c208aa30-cee6-4851-a599-6fea5c5a305a@default> (Drew Adams's message of "Tue, 25 Nov 2014 14:00:25 -0800 (PST)")

> 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))





  reply	other threads:[~2014-11-25 22:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 19:24 bug#19170: 25.0.50; enhancement request: `compare-windows' use across frames Drew Adams
2014-11-24 22:19 ` Juri Linkov
2014-11-24 22:34   ` Drew Adams
2014-11-25  0:13     ` Drew Adams
2014-11-25  0:37     ` Juri Linkov
2014-11-25  4:09       ` Drew Adams
2014-11-25 21:39         ` Juri Linkov
2014-11-25 22:00           ` Drew Adams
2014-11-25 22:56             ` Juri Linkov [this message]
2014-11-25 23:40               ` Drew Adams
2014-11-27  0:57                 ` Juri Linkov
2014-11-27  3:18                   ` Drew Adams
2014-11-28  0:54                     ` Juri Linkov
2014-11-28  7:29                       ` martin rudalics
2014-11-28 15:31                         ` Drew Adams
2014-11-28 21:15                         ` Juri Linkov
2014-11-28 22:20                           ` Drew Adams
2014-11-29  0:50                             ` Juri Linkov
2014-11-29  1:53                               ` Drew Adams
2014-12-05  0:51                                 ` Juri Linkov
2014-11-28 15:25                       ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egsqzy74.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=19170@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).