diff options
| author | Juri Linkov | 2014-12-05 02:50:41 +0200 |
|---|---|---|
| committer | Juri Linkov | 2014-12-05 02:50:41 +0200 |
| commit | 96e6fd3c155b1851e0acd477789535a45b8d3187 (patch) | |
| tree | 1cb4805387151ded241ba914dec61ad5c5787e81 | |
| parent | d08f4f8fc5219324ac352c6d89f0db5c6a18ce32 (diff) | |
| download | emacs-96e6fd3c155b1851e0acd477789535a45b8d3187.tar.gz emacs-96e6fd3c155b1851e0acd477789535a45b8d3187.zip | |
Compare with the most recently used window by default.
* lisp/vc/compare-w.el (compare-windows-get-window-function):
New defcustom.
(compare-windows-get-recent-window)
(compare-windows-get-next-window): New functions.
(compare-windows, compare-windows-sync-default-function):
Use `compare-windows-get-window-function' instead of `next-window'.
(compare-windows): Add diff/match messages with region boundaries.
Fixes: debbugs:19170
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/vc/compare-w.el | 61 |
3 files changed, 62 insertions, 14 deletions
| @@ -329,6 +329,10 @@ and comments. | |||
| 329 | the color range from `vc-annotate-color-map' is applied to the | 329 | the color range from `vc-annotate-color-map' is applied to the |
| 330 | background or to the foreground. | 330 | background or to the foreground. |
| 331 | 331 | ||
| 332 | *** compare-windows now compares text with the most recently used window | ||
| 333 | instead of the next window. The new option `compare-windows-get-window-function' | ||
| 334 | allows to customize this. | ||
| 335 | |||
| 332 | ** Calculator: decimal display mode uses "," groups, so it's more | 336 | ** Calculator: decimal display mode uses "," groups, so it's more |
| 333 | fitting for use in money calculations; factorial works with | 337 | fitting for use in money calculations; factorial works with |
| 334 | non-integer inputs. | 338 | non-integer inputs. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 19a30202f3b..26572c3649f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2014-12-05 Juri Linkov <juri@linkov.net> | ||
| 2 | |||
| 3 | Compare with the most recent window by default. | ||
| 4 | * vc/compare-w.el (compare-windows-get-window-function): New defcustom. | ||
| 5 | (compare-windows-get-recent-window) | ||
| 6 | (compare-windows-get-next-window): New functions. | ||
| 7 | (compare-windows, compare-windows-sync-default-function): | ||
| 8 | Use `compare-windows-get-window-function' instead of `next-window'. | ||
| 9 | (compare-windows): Add diff/match messages with region boundaries. | ||
| 10 | (Bug#19170) | ||
| 11 | |||
| 1 | 2014-12-04 Stefan Monnier <monnier@iro.umontreal.ca> | 12 | 2014-12-04 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 13 | ||
| 3 | * subr.el (filter): Remove. Use `cl-remove-if-not' or `seq-filter'. | 14 | * subr.el (filter): Remove. Use `cl-remove-if-not' or `seq-filter'. |
diff --git a/lisp/vc/compare-w.el b/lisp/vc/compare-w.el index 25d4cf77f53..3b8293cda24 100644 --- a/lisp/vc/compare-w.el +++ b/lisp/vc/compare-w.el | |||
| @@ -140,9 +140,43 @@ out all highlighting later with the command `compare-windows-dehighlight'." | |||
| 140 | (defvar compare-windows-overlays2 nil) | 140 | (defvar compare-windows-overlays2 nil) |
| 141 | (defvar compare-windows-sync-point nil) | 141 | (defvar compare-windows-sync-point nil) |
| 142 | 142 | ||
| 143 | (defcustom compare-windows-get-window-function 'compare-windows-get-recent-window | ||
| 144 | "Function that provides the window to compare with." | ||
| 145 | :type '(choice | ||
| 146 | (function-item :tag "Most recently used window" | ||
| 147 | compare-windows-get-recent-window) | ||
| 148 | (function-item :tag "Next window" | ||
| 149 | compare-windows-get-next-window) | ||
| 150 | (function :tag "Your function")) | ||
| 151 | :group 'compare-windows | ||
| 152 | :version "25.0") | ||
| 153 | |||
| 154 | (defun compare-windows-get-recent-window () | ||
| 155 | "Return the most recently used window. | ||
| 156 | First try to get the most recently used window on a visible frame, | ||
| 157 | then try to get a window on an iconified frame, and finally | ||
| 158 | consider all existing frames." | ||
| 159 | (or (get-mru-window 'visible t t) | ||
| 160 | (get-mru-window 0 t t) | ||
| 161 | (get-mru-window t t t))) | ||
| 162 | |||
| 163 | (defun compare-windows-get-next-window () | ||
| 164 | "Return the window next in the cyclic ordering of windows. | ||
| 165 | In the selected frame contains only one window, consider windows | ||
| 166 | on all visible frames." | ||
| 167 | (let ((w2 (next-window))) | ||
| 168 | (if (eq w2 (selected-window)) | ||
| 169 | (setq w2 (next-window (selected-window) nil 'visible))) | ||
| 170 | (if (eq w2 (selected-window)) | ||
| 171 | (error "No other window")) | ||
| 172 | w2)) | ||
| 173 | |||
| 143 | ;;;###autoload | 174 | ;;;###autoload |
| 144 | (defun compare-windows (ignore-whitespace) | 175 | (defun compare-windows (ignore-whitespace) |
| 145 | "Compare text in current window with text in next window. | 176 | "Compare text in current window with text in another window. |
| 177 | The option `compare-windows-get-window-function' defines how | ||
| 178 | to get another window. | ||
| 179 | |||
| 146 | Compares the text starting at point in each window, | 180 | Compares the text starting at point in each window, |
| 147 | moving over text in each one as far as they match. | 181 | moving over text in each one as far as they match. |
| 148 | 182 | ||
| @@ -179,11 +213,7 @@ on third call it again advances points to the next difference and so on." | |||
| 179 | 'compare-windows-sync-regexp | 213 | 'compare-windows-sync-regexp |
| 180 | compare-windows-sync))) | 214 | compare-windows-sync))) |
| 181 | (setq p1 (point) b1 (current-buffer)) | 215 | (setq p1 (point) b1 (current-buffer)) |
| 182 | (setq w2 (next-window)) | 216 | (setq w2 (funcall compare-windows-get-window-function)) |
| 183 | (if (eq w2 (selected-window)) | ||
| 184 | (setq w2 (next-window (selected-window) nil 'visible))) | ||
| 185 | (if (eq w2 (selected-window)) | ||
| 186 | (error "No other window")) | ||
| 187 | (setq p2 (window-point w2) | 217 | (setq p2 (window-point w2) |
| 188 | b2 (window-buffer w2)) | 218 | b2 (window-buffer w2)) |
| 189 | (setq opoint2 p2) | 219 | (setq opoint2 p2) |
| @@ -212,7 +242,7 @@ on third call it again advances points to the next difference and so on." | |||
| 212 | ;; optionally skip over it. | 242 | ;; optionally skip over it. |
| 213 | (and skip-func-1 | 243 | (and skip-func-1 |
| 214 | (save-excursion | 244 | (save-excursion |
| 215 | (let (p1a p2a w1 w2 result1 result2) | 245 | (let (p1a p2a result1 result2) |
| 216 | (setq result1 (funcall skip-func-1 opoint1)) | 246 | (setq result1 (funcall skip-func-1 opoint1)) |
| 217 | (setq p1a (point)) | 247 | (setq p1a (point)) |
| 218 | (set-buffer b2) | 248 | (set-buffer b2) |
| @@ -255,12 +285,15 @@ on third call it again advances points to the next difference and so on." | |||
| 255 | (recenter (car compare-windows-recenter)) | 285 | (recenter (car compare-windows-recenter)) |
| 256 | (with-selected-window w2 (recenter (cadr compare-windows-recenter)))) | 286 | (with-selected-window w2 (recenter (cadr compare-windows-recenter)))) |
| 257 | ;; If points are still not synchronized, then ding | 287 | ;; If points are still not synchronized, then ding |
| 258 | (when (and (= p1 opoint1) (= p2 opoint2)) | 288 | (if (and (= p1 opoint1) (= p2 opoint2)) |
| 259 | ;; Display error message when current points in two windows | 289 | (progn |
| 260 | ;; are unmatched and next matching points can't be found. | 290 | ;; Display error message when current points in two windows |
| 261 | (compare-windows-dehighlight) | 291 | ;; are unmatched and next matching points can't be found. |
| 262 | (ding) | 292 | (compare-windows-dehighlight) |
| 263 | (message "No more matching points")))))) | 293 | (ding) |
| 294 | (message "No more matches with %s" b2)) | ||
| 295 | (message "Diff -%s,%s +%s,%s with %s" opoint2 p2 opoint1 p1 b2))) | ||
| 296 | (message "Match -%s,%s +%s,%s with %s" opoint2 p2 opoint1 p1 b2)))) | ||
| 264 | 297 | ||
| 265 | ;; Move forward over whatever might be called whitespace. | 298 | ;; Move forward over whatever might be called whitespace. |
| 266 | ;; compare-windows-whitespace is a regexp that matches whitespace. | 299 | ;; compare-windows-whitespace is a regexp that matches whitespace. |
| @@ -303,7 +336,7 @@ on third call it again advances points to the next difference and so on." | |||
| 303 | (defun compare-windows-sync-default-function () | 336 | (defun compare-windows-sync-default-function () |
| 304 | (if (not compare-windows-sync-point) | 337 | (if (not compare-windows-sync-point) |
| 305 | (let* ((w1 (selected-window)) | 338 | (let* ((w1 (selected-window)) |
| 306 | (w2 (next-window w1)) | 339 | (w2 (funcall compare-windows-get-window-function)) |
| 307 | (b2 (window-buffer w2)) | 340 | (b2 (window-buffer w2)) |
| 308 | (point-max2 (with-current-buffer b2 (point-max))) | 341 | (point-max2 (with-current-buffer b2 (point-max))) |
| 309 | (op2 (window-point w2)) | 342 | (op2 (window-point w2)) |