From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#33065: [PATCH]: Eliminate obtrusive ghost cursors in follow mode in GUIs. Date: Tue, 16 Oct 2018 16:20:58 +0000 Message-ID: <20181016162058.GA5722@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1539707312 5890 195.159.176.226 (16 Oct 2018 16:28:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 Oct 2018 16:28:32 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) To: 33065@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 16 18:28:28 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCSCp-0001Qi-Mw for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Oct 2018 18:28:27 +0200 Original-Received: from localhost ([::1]:59095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCSEw-0004SS-2y for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Oct 2018 12:30:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCSEd-0004Nl-G1 for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:30:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCSEW-0001AJ-RS for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:30:17 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCSEM-00014b-Qe for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:30:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gCSEM-0001Mt-KR for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Oct 2018 16:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33065 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15397073445152 (code B ref -1); Tue, 16 Oct 2018 16:30:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Oct 2018 16:29:04 +0000 Original-Received: from localhost ([127.0.0.1]:53866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCSDP-0001L2-Li for submit@debbugs.gnu.org; Tue, 16 Oct 2018 12:29:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCSDO-0001KW-AX for submit@debbugs.gnu.org; Tue, 16 Oct 2018 12:29:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCSDI-0007p3-6n for submit@debbugs.gnu.org; Tue, 16 Oct 2018 12:28:57 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:54965) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gCSDI-0007ok-0j for submit@debbugs.gnu.org; Tue, 16 Oct 2018 12:28:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCSDG-00043W-Ul for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:28:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCSDC-0007f3-RY for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:28:54 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34168 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gCSDC-0007dp-IQ for bug-gnu-emacs@gnu.org; Tue, 16 Oct 2018 12:28:50 -0400 Original-Received: (qmail 54558 invoked by uid 3782); 16 Oct 2018 16:28:48 -0000 Original-Received: from acm.muc.de (p5B14712A.dip0.t-ipconnect.de [91.20.113.42]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 16 Oct 2018 18:28:47 +0200 Original-Received: (qmail 9678 invoked by uid 1000); 16 Oct 2018 16:20:58 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:151312 Archived-At: Hello, Emacs. In X Windows (amd probably other GUIs), when follow mode is active, and the cursor passes from one follow window to another, an objectionable hollow block cursor is left behind. (At least, I personally find it objectionable. :-) The following patch (to the master branch) ameliorates this by creating buffer local values of cursor-in-non-selected-windows and setting these to nil when one of the buffer's windows is selected. This is, of course, controlled by a boolean option, which I propose to enable by default. Yes, this will need an entry in NEWS, too. Comments? diff --git a/lisp/follow.el b/lisp/follow.el index e2d3a11b65..c04e787919 100644 --- a/lisp/follow.el +++ b/lisp/follow.el @@ -311,6 +311,17 @@ follow-auto (remove-hook 'find-file-hook 'follow-find-file-hook)) (set-default symbol value))) +(defcustom follow-hide-ghost-cursors t ; Maybe this should be nil. + "When non-nil, Follow mode attempts to hide the obtrusive cursors +in the non-selected windows of a window group. + +This variable takes effect when `follow-mode' is initialized. + +Due to limitations in Emacs, this only operates on the followers +of the current window." + :type 'boolean + :group 'follow) + (defvar follow-cache-command-list '(next-line previous-line forward-char backward-char right-char left-char) "List of commands that don't require recalculation. @@ -427,6 +438,8 @@ follow-mode (when isearch-lazy-highlight (setq-local isearch-lazy-highlight 'all-windows)) + (when follow-hide-ghost-cursors + (setq-local cursor-in-non-selected-windows nil)) (setq window-group-start-function 'follow-window-start) (setq window-group-end-function 'follow-window-end) @@ -456,6 +469,8 @@ follow-mode (kill-local-variable 'window-group-end-function) (kill-local-variable 'window-group-start-function) + (kill-local-variable 'cursor-in-non-selected-windows) + (remove-hook 'ispell-update-post-hook 'follow-post-command-hook t) (remove-hook 'replace-update-post-hook 'follow-post-command-hook t) (remove-hook 'isearch-update-post-hook 'follow-post-command-hook t) @@ -1262,6 +1277,10 @@ follow-avoid-tail-recenter ;;; Pre Display Function +(defvar follow-prev-buffer nil + "The current buffer at the last call to `follow-adjust-window' or nil. +follow-mode is not necessarily enabled in this buffer.") + ;; This function is added to `pre-display-function' and is thus called ;; before each redisplay operation. It supersedes (2018-09) the ;; former use of the post command hook, and now does the right thing @@ -1310,6 +1329,24 @@ follow-post-command-hook (defun follow-adjust-window (win) ;; Adjust the window WIN and its followers. (cl-assert (eq (window-buffer win) (current-buffer))) + + ;; Have we moved out of or into a follow-mode window group? + ;; If so, attend to the visibility of the cursors. + (when (not (eq (current-buffer) follow-prev-buffer)) + ;; Do we need to switch off cursor handling in the previous buffer? + (when (buffer-live-p follow-prev-buffer) + (with-current-buffer follow-prev-buffer + (when (and follow-mode + (local-variable-p 'cursor-in-non-selected-windows)) + (setq cursor-in-non-selected-windows + (default-value 'cursor-in-non-selected-windows))))) + ;; Do we need to switch on cursor handling in the current buffer? + (when (and follow-mode + (local-variable-p 'cursor-in-non-selected-windows)) + (setq cursor-in-non-selected-windows nil)) + (when (buffer-live-p (current-buffer)) + (setq follow-prev-buffer (current-buffer)))) + (when (and follow-mode (not (window-minibuffer-p win))) (let ((windows (follow-all-followers win))) -- Alan Mackenzie (Nuremberg, Germany).