From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gabriel do Nascimento Ribeiro Newsgroups: gmane.emacs.bugs Subject: bug#45946: [PATCH] Re: bug#45946: 28.0.50; hl-line-sticky-flag not working Date: Sat, 23 Jan 2021 16:11:04 -0300 Message-ID: References: <83bldi74yn.fsf@gnu.org> <8335ys5b08.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31353"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 45946@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 23 20:12:20 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3OKZ-00083Y-M1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jan 2021 20:12:19 +0100 Original-Received: from localhost ([::1]:59048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3OKY-00045d-Js for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jan 2021 14:12:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OKI-00044R-48 for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:12:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l3OKH-0001DP-QI for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:12:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l3OKH-0004pf-Lp for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gabriel do Nascimento Ribeiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jan 2021 19:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45946 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161142909918544 (code B ref -1); Sat, 23 Jan 2021 19:12:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Jan 2021 19:11:39 +0000 Original-Received: from localhost ([127.0.0.1]:35316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3OJu-0004p2-IO for submit@debbugs.gnu.org; Sat, 23 Jan 2021 14:11:39 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:53042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3OJs-0004ou-KF for submit@debbugs.gnu.org; Sat, 23 Jan 2021 14:11:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OJs-0003zL-Eq for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:11:36 -0500 Original-Received: from mail-oln040092011020.outbound.protection.outlook.com ([40.92.11.20]:47759 helo=NAM04-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OJi-000127-Nr for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:11:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KrWJBTRTHiXEf7nmA1+wxmY7nW4Hv26ICkDlqSt+kG6XGgBNiVfsbgGsO2icxpg7BCOnxtD23Y1YIv/VMZ7CYp1kB7IoxBwRg8iFuaV8V11FR/09dFuf1Wa7dYKUnoVoqJOirXkxW5MoH5vPdsqBpivbaXMaRNx0LTkQ//k27uxV4e8H66TOC9yEZ0tCC6GADyS57i/vMWCtXK2fR1BMQ3DALiFoszzlz6+8C2KDD+Jd9Y67m5BlRoZVv2wNg1mrKyJ8YI5ef5bv0p27O1daMV8ZyyQkdf/QcyjMJjoTl73LOY1JBMLRJEl9fCPK4EpS/s131lfNwwQDgjyiDcCtqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D+Vx3oViy+0GnKQwwefQRRdOi6GSqRLMjum4F6jmIo4=; b=mDBEodzvoUTLm6QIqXKQOc6ihZdsplgVdmVd4ixbfFBf3fHmpl8HMDkGBpBDpjVLgJSPgHOvWuSAkjT8BDSsa7H3AMURFm2fHJQ/lauRsXPuHwbjImzxEiulgr+clx30tahgGmnTk8GmLDazIOS8NxK51i0v9oHFZuk2sTo4qKaJnqlKMbJmSZstdJDc3ZpjCgMbC49a103bjbsa6J96MQoFCy2eVWJbys49sMS1KZUjdQl1TlOJKfQT0PYPAYJAH+LDidnAAbaW3PO2X6vmiYmuRHx5gEaIgnJhkzPhYe/lAiV/wd2E9qalq/BOwclySOZe36Ef169eRPu5QfALXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D+Vx3oViy+0GnKQwwefQRRdOi6GSqRLMjum4F6jmIo4=; b=l7eYOrSdoutxgeX+/EpcOmJJsF4NwEs+vPUqWlFNvN7fZpjhW3/S206vEZ9feJLQ7CFL7z6lp89U3NKnqJ64Rq05i2zhPSVKjaR8Bg4zCxHXkJl3Uy6wiaDvdN6Gop2Kwa+Qff6055HKbVxUFqfPyejnqzEDxdIW6t7aYscx3u5RAdcUb90PcZUO5uT20PgNuDkx2j3jPd6O0vaTbURWssQOC9HEogBM/6wP0bVdAw8rHjDlDRZSB/S5OQHv3bzU2gxGQmJ5Ml86QqWvh1U9s1JDeNPPRRkGoiwoAS2mDttxJXkQAXzr2PXCIOCrGChn9xGVBHlmIKJkrzNkoEWw4g== Original-Received: from CO1NAM04FT059.eop-NAM04.prod.protection.outlook.com (10.152.90.55) by CO1NAM04HT020.eop-NAM04.prod.protection.outlook.com (10.152.91.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Sat, 23 Jan 2021 19:11:23 +0000 Original-Received: from CH2PR01MB5879.prod.exchangelabs.com (2a01:111:e400:7e4d::4e) by CO1NAM04FT059.mail.protection.outlook.com (2a01:111:e400:7e4d::449) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Sat, 23 Jan 2021 19:11:22 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:F65DBA695F5184D50822029DBB54A9ECD8C30FF2FF54AFD29D1F0A2E8664472A; UpperCasedChecksum:66D2C1AA906F237CB29822CF78BB7DB4A024BEE633B3B45CB4013DC863843C26; SizeAsReceived:7762; Count:45 Original-Received: from CH2PR01MB5879.prod.exchangelabs.com ([fe80::d51d:8cbe:370a:39ac]) by CH2PR01MB5879.prod.exchangelabs.com ([fe80::d51d:8cbe:370a:39ac%7]) with mapi id 15.20.3763.014; Sat, 23 Jan 2021 19:11:22 +0000 In-Reply-To: <8335ys5b08.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Jan 2021 10:10:47 +0200") X-TMN: [amoiQSMsRs+wU/WRgNkw0e+Xv29vHd2CGrhddOmdYmGO49n+RfDKEHkA9oj0gk9u] X-ClientProxiedBy: CP5P284CA0041.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:96::10) To CH2PR01MB5879.prod.exchangelabs.com (2603:10b6:610:3c::12) X-Microsoft-Original-Message-ID: <87czxvqxiv.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from precision5540 (2804:431:c7f3:76d5:872e:57fa:d470:5789) by CP5P284CA0041.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Sat, 23 Jan 2021 19:11:21 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 45 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 102bdb9f-a765-4424-8c03-08d8bfd2ab99 X-MS-TrafficTypeDiagnostic: CO1NAM04HT020: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JXcsYO+3UZNrUzGn/ndGiQJNXOP67eUZaxZzwCRt/n44cnXJSNRzEj5jGbXy6RifM049Bmzopy1QXipRyt4G80PRGCT77SUEsQslY5FRK3kHP1XELZWVy6hGswDUDqFXQ+MZ4dwSrzA0aPT6MiDn3bVH9NvyiWN/GP+9qxlKqNPJH9IGJXRVbr8o7QkXhwUNxmRP0tqBAUhavLGNSuBJzf/qT6MXp7kJgdrKBkWG0IygnL/o6HWmSzygEbxB5+er X-MS-Exchange-AntiSpam-MessageData: F5ltSsHLDTI96kxrhbjSplYQmvbuOBWWQMJW4OLXvrESY+O8S69Zxdn5V4Hvci5usJj0dLh0beeXqTAo0DPNAzEfzmcc55ePqZcWahiiS9N/cJCNo5mn32gxv097UJflHGpp7Av1kQrq/Uh/zC9yGykNUww6X2x2FXgD0S8caD5GLkdxNYOwBdZ6UufQ1sEXFzN0gxvh6xof/y+Qkt1ACw== X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-Network-Message-Id: 102bdb9f-a765-4424-8c03-08d8bfd2ab99 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2021 19:11:22.8522 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: CO1NAM04FT059.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM04HT020 Received-SPF: pass client-ip=40.92.11.20; envelope-from=gabriel376@hotmail.com; helo=NAM04-SN1-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:198459 Archived-At: --=-=-= Content-Type: text/plain > > Thanks, this LGTM, but could you please accompany the changes with the > ChangeLog-style commit log message (see CONTRIBUTE about the details)? > > Also, this patch is close to the limit that we can accept without > copyright assignment. So I'd suggest that you start the legal > paperwork rolling at this time, to allow us to accept your future > contributions. Would you like me to send to you the legal form to > fill? Patch updated with appropriate ChangeLog-style commit log message. I have already concluded the assignment process with FSF. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-single-post-command-hook-on-hl-line-modes.patch >From c0293a572df799eb5cd03dd404c7fc364b6831d0 Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Sat, 23 Jan 2021 15:38:42 -0300 Subject: [PATCH] Use single post-command-hook on hl-line modes * lisp/hl-line.el (hl-line-mode, global-hl-line-mode): Ensure that maybe-unhighlight is called after line is highlighted (bug#45946). (hl-line-unhighlight, global-hl-line-unhighlight): Set overlay variable to nil after overlay is deleted. --- lisp/hl-line.el | 58 +++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/lisp/hl-line.el b/lisp/hl-line.el index 73870f9579..82952e934b 100644 --- a/lisp/hl-line.el +++ b/lisp/hl-line.el @@ -45,11 +45,7 @@ ;; An overlay is used. In the non-sticky cases, this overlay is ;; active only on the selected window. A hook is added to ;; `post-command-hook' to activate the overlay and move it to the line -;; about point. To get the non-sticky behavior, `hl-line-unhighlight' -;; is added to `pre-command-hook' as well. This function deactivates -;; the overlay unconditionally in case the command changes the -;; selected window. (It does so rather than keeping track of changes -;; in the selected window). +;; about point. ;; You could make variable `global-hl-line-mode' buffer-local and set ;; it to nil to avoid highlighting specific buffers, when the global @@ -91,9 +87,9 @@ hl-line-face (set symbol value) (dolist (buffer (buffer-list)) (with-current-buffer buffer - (when hl-line-overlay + (when (overlayp hl-line-overlay) (overlay-put hl-line-overlay 'face hl-line-face)))) - (when global-hl-line-overlay + (when (overlayp global-hl-line-overlay) (overlay-put global-hl-line-overlay 'face hl-line-face)))) (defcustom hl-line-sticky-flag t @@ -141,9 +137,7 @@ hl-line-mode `hl-line-highlight' on `post-command-hook' in this case. When `hl-line-sticky-flag' is nil, Hl-Line mode highlights the -line about point in the selected window only. In this case, it -uses the function `hl-line-maybe-unhighlight' in -addition to `hl-line-highlight' on `post-command-hook'." +line about point in the selected window only." :group 'hl-line (if hl-line-mode (progn @@ -151,12 +145,10 @@ hl-line-mode (add-hook 'change-major-mode-hook #'hl-line-unhighlight nil t) (hl-line-highlight) (setq hl-line-overlay-buffer (current-buffer)) - (add-hook 'post-command-hook #'hl-line-highlight nil t) - (add-hook 'post-command-hook #'hl-line-maybe-unhighlight nil t)) + (add-hook 'post-command-hook #'hl-line-highlight nil t)) (remove-hook 'post-command-hook #'hl-line-highlight t) (hl-line-unhighlight) - (remove-hook 'change-major-mode-hook #'hl-line-unhighlight t) - (remove-hook 'post-command-hook #'hl-line-maybe-unhighlight t))) + (remove-hook 'change-major-mode-hook #'hl-line-unhighlight t))) (defun hl-line-make-overlay () (let ((ol (make-overlay (point) (point)))) @@ -168,17 +160,19 @@ hl-line-highlight "Activate the Hl-Line overlay on the current line." (if hl-line-mode ; Might be changed outside the mode function. (progn - (unless hl-line-overlay + (unless (overlayp hl-line-overlay) (setq hl-line-overlay (hl-line-make-overlay))) ; To be moved. (overlay-put hl-line-overlay 'window (unless hl-line-sticky-flag (selected-window))) - (hl-line-move hl-line-overlay)) + (hl-line-move hl-line-overlay) + (hl-line-maybe-unhighlight)) (hl-line-unhighlight))) (defun hl-line-unhighlight () "Deactivate the Hl-Line overlay on the current line." - (when hl-line-overlay - (delete-overlay hl-line-overlay))) + (when (overlayp hl-line-overlay) + (delete-overlay hl-line-overlay) + (setq hl-line-overlay nil))) (defun hl-line-maybe-unhighlight () "Maybe deactivate the Hl-Line overlay on the current line. @@ -191,8 +185,7 @@ hl-line-maybe-unhighlight (not (eq curbuf hlob)) (not (minibufferp))) (with-current-buffer hlob - (when (overlayp hl-line-overlay) - (delete-overlay hl-line-overlay)))) + (hl-line-unhighlight))) (when (and (overlayp hl-line-overlay) (eq (overlay-buffer hl-line-overlay) curbuf)) (setq hl-line-overlay-buffer curbuf)))) @@ -205,8 +198,8 @@ global-hl-line-mode highlights the line about the current buffer's point in all live windows. -Global-Hl-Line mode uses the functions `global-hl-line-highlight' -and `global-hl-line-maybe-unhighlight' on `post-command-hook'." +Global-Hl-Line mode uses the function `global-hl-line-highlight' +on `post-command-hook'." :global t :group 'hl-line (if global-hl-line-mode @@ -214,25 +207,24 @@ global-hl-line-mode ;; In case `kill-all-local-variables' is called. (add-hook 'change-major-mode-hook #'global-hl-line-unhighlight) (global-hl-line-highlight-all) - (add-hook 'post-command-hook #'global-hl-line-highlight) - (add-hook 'post-command-hook #'global-hl-line-maybe-unhighlight)) + (add-hook 'post-command-hook #'global-hl-line-highlight)) (global-hl-line-unhighlight-all) (remove-hook 'post-command-hook #'global-hl-line-highlight) - (remove-hook 'change-major-mode-hook #'global-hl-line-unhighlight) - (remove-hook 'post-command-hook #'global-hl-line-maybe-unhighlight))) + (remove-hook 'change-major-mode-hook #'global-hl-line-unhighlight))) (defun global-hl-line-highlight () "Highlight the current line in the current window." (when global-hl-line-mode ; Might be changed outside the mode function. (unless (window-minibuffer-p) - (unless global-hl-line-overlay + (unless (overlayp global-hl-line-overlay) (setq global-hl-line-overlay (hl-line-make-overlay))) ; To be moved. (unless (member global-hl-line-overlay global-hl-line-overlays) (push global-hl-line-overlay global-hl-line-overlays)) (overlay-put global-hl-line-overlay 'window (unless global-hl-line-sticky-flag (selected-window))) - (hl-line-move global-hl-line-overlay)))) + (hl-line-move global-hl-line-overlay) + (global-hl-line-maybe-unhighlight)))) (defun global-hl-line-highlight-all () "Highlight the current line in all live windows." @@ -243,8 +235,9 @@ global-hl-line-highlight-all (defun global-hl-line-unhighlight () "Deactivate the Global-Hl-Line overlay on the current line." - (when global-hl-line-overlay - (delete-overlay global-hl-line-overlay))) + (when (overlayp global-hl-line-overlay) + (delete-overlay global-hl-line-overlay) + (setq global-hl-line-overlay nil))) (defun global-hl-line-maybe-unhighlight () "Maybe deactivate the Global-Hl-Line overlay on the current line. @@ -256,9 +249,8 @@ global-hl-line-maybe-unhighlight (bufferp ovb) (not (eq ovb (current-buffer))) (not (minibufferp))) - (with-current-buffer ovb - (when (overlayp global-hl-line-overlay) - (delete-overlay global-hl-line-overlay)))))) + (with-current-buffer ovb + (global-hl-line-unhighlight))))) global-hl-line-overlays)) (defun global-hl-line-unhighlight-all () -- 2.27.0 --=-=-=--