aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2018-10-19 09:54:31 +0000
committerAlan Mackenzie2018-10-19 09:54:31 +0000
commit487931cd06fee9520e37bdb40b5340831106aea8 (patch)
tree16ec322f79a00e571e3e507807e03be6d84de958
parent2510126388c7732d6ff02bfeda59fe1af0968b1f (diff)
downloademacs-487931cd06fee9520e37bdb40b5340831106aea8.tar.gz
emacs-487931cd06fee9520e37bdb40b5340831106aea8.zip
In follow mode windows in a GUI, don't display inactive cursors
This is done by setting cursor-in-non-selected-windows buffer locally. * lisp/follow.el (follow-hide-ghost-cursors): New customizable option. (follow-mode): Create and set, or kill buffer-local copy of cursor-in-non-selected-windows when the mode gets enabled or disabled. (follow-prev-buffer): New variable. (follow-adjust-window): Manipulate cursor-in-non-selected-windows when the current buffer changes, to ensure that cursors stay visible in non-selected follow window groups. * etc/NEWS: Add an entry for this change.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/follow.el37
2 files changed, 43 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 2ebe5a16a22..f1be50babd6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -287,6 +287,12 @@ in (info "(emacs) Directory Variables")
287 287
288* Changes in Specialized Modes and Packages in Emacs 27.1 288* Changes in Specialized Modes and Packages in Emacs 27.1
289 289
290---
291** Follow mode
292In the current follow group of windows, "ghost" cursors are no longer
293displayed in the non-selected follow windows. To get the old behavior
294back, customize follow-hide-ghost-cursors to nil.
295
290** Octave mode 296** Octave mode
291The mode is automatically enabled in files that start with the 297The mode is automatically enabled in files that start with the
292'function' keyword. 298'function' keyword.
diff --git a/lisp/follow.el b/lisp/follow.el
index b44df423d60..ed7b7d2359d 100644
--- a/lisp/follow.el
+++ b/lisp/follow.el
@@ -311,6 +311,17 @@ are \" Fw\", or simply \"\"."
311 (remove-hook 'find-file-hook 'follow-find-file-hook)) 311 (remove-hook 'find-file-hook 'follow-find-file-hook))
312 (set-default symbol value))) 312 (set-default symbol value)))
313 313
314(defcustom follow-hide-ghost-cursors t ; Maybe this should be nil.
315 "When non-nil, Follow mode attempts to hide the obtrusive cursors
316in the non-selected windows of a window group.
317
318This variable takes effect when `follow-mode' is initialized.
319
320Due to limitations in Emacs, this only operates on the followers
321of the selected window."
322 :type 'boolean
323 :group 'follow)
324
314(defvar follow-cache-command-list 325(defvar follow-cache-command-list
315 '(next-line previous-line forward-char backward-char right-char left-char) 326 '(next-line previous-line forward-char backward-char right-char left-char)
316 "List of commands that don't require recalculation. 327 "List of commands that don't require recalculation.
@@ -427,6 +438,8 @@ Keys specific to Follow mode:
427 438
428 (when isearch-lazy-highlight 439 (when isearch-lazy-highlight
429 (setq-local isearch-lazy-highlight 'all-windows)) 440 (setq-local isearch-lazy-highlight 'all-windows))
441 (when follow-hide-ghost-cursors
442 (setq-local cursor-in-non-selected-windows nil))
430 443
431 (setq window-group-start-function 'follow-window-start) 444 (setq window-group-start-function 'follow-window-start)
432 (setq window-group-end-function 'follow-window-end) 445 (setq window-group-end-function 'follow-window-end)
@@ -456,6 +469,8 @@ Keys specific to Follow mode:
456 (kill-local-variable 'window-group-end-function) 469 (kill-local-variable 'window-group-end-function)
457 (kill-local-variable 'window-group-start-function) 470 (kill-local-variable 'window-group-start-function)
458 471
472 (kill-local-variable 'cursor-in-non-selected-windows)
473
459 (remove-hook 'ispell-update-post-hook 'follow-post-command-hook t) 474 (remove-hook 'ispell-update-post-hook 'follow-post-command-hook t)
460 (remove-hook 'replace-update-post-hook 'follow-post-command-hook t) 475 (remove-hook 'replace-update-post-hook 'follow-post-command-hook t)
461 (remove-hook 'isearch-update-post-hook 'follow-post-command-hook t) 476 (remove-hook 'isearch-update-post-hook 'follow-post-command-hook t)
@@ -1262,6 +1277,10 @@ non-first windows in Follow mode."
1262 1277
1263;;; Pre Display Function 1278;;; Pre Display Function
1264 1279
1280(defvar follow-prev-buffer nil
1281 "The buffer current at the last call to `follow-adjust-window' or nil.
1282follow-mode is not necessarily enabled in this buffer.")
1283
1265;; This function is added to `pre-display-function' and is thus called 1284;; This function is added to `pre-display-function' and is thus called
1266;; before each redisplay operation. It supersedes (2018-09) the 1285;; before each redisplay operation. It supersedes (2018-09) the
1267;; former use of the post command hook, and now does the right thing 1286;; former use of the post command hook, and now does the right thing
@@ -1310,6 +1329,24 @@ non-first windows in Follow mode."
1310(defun follow-adjust-window (win) 1329(defun follow-adjust-window (win)
1311 ;; Adjust the window WIN and its followers. 1330 ;; Adjust the window WIN and its followers.
1312 (cl-assert (eq (window-buffer win) (current-buffer))) 1331 (cl-assert (eq (window-buffer win) (current-buffer)))
1332
1333 ;; Have we moved out of or into a follow-mode window group?
1334 ;; If so, attend to the visibility of the cursors.
1335 (when (not (eq (current-buffer) follow-prev-buffer))
1336 ;; Do we need to switch off cursor handling in the previous buffer?
1337 (when (buffer-live-p follow-prev-buffer)
1338 (with-current-buffer follow-prev-buffer
1339 (when (and follow-mode
1340 (local-variable-p 'cursor-in-non-selected-windows))
1341 (setq cursor-in-non-selected-windows
1342 (default-value 'cursor-in-non-selected-windows)))))
1343 ;; Do we need to switch on cursor handling in the current buffer?
1344 (when (and follow-mode
1345 (local-variable-p 'cursor-in-non-selected-windows))
1346 (setq cursor-in-non-selected-windows nil))
1347 (when (buffer-live-p (current-buffer))
1348 (setq follow-prev-buffer (current-buffer))))
1349
1313 (when (and follow-mode 1350 (when (and follow-mode
1314 (not (window-minibuffer-p win))) 1351 (not (window-minibuffer-p win)))
1315 (let ((windows (follow-all-followers win))) 1352 (let ((windows (follow-all-followers win)))