From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher League Newsgroups: gmane.emacs.bugs Subject: bug#49725: [PATCH] Unfontify previous location when overwriting bookmark Date: Sat, 24 Jul 2021 20:28:41 -0400 Message-ID: <875ywzkzie.fsf@contrapunctus.net> 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="21475"; mail-complaints-to="usenet@ciao.gmane.io" To: 49725@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 25 02:29:10 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 1m7S10-0005P9-7m for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Jul 2021 02:29:10 +0200 Original-Received: from localhost ([::1]:46878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7S0z-0007Di-9V for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Jul 2021 20:29:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7S0s-0007DJ-S4 for bug-gnu-emacs@gnu.org; Sat, 24 Jul 2021 20:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m7S0s-0000OV-KR for bug-gnu-emacs@gnu.org; Sat, 24 Jul 2021 20:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m7S0s-00038q-9q for bug-gnu-emacs@gnu.org; Sat, 24 Jul 2021 20:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Christopher League Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Jul 2021 00:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49725 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.162717293512060 (code B ref -1); Sun, 25 Jul 2021 00:29:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jul 2021 00:28:55 +0000 Original-Received: from localhost ([127.0.0.1]:47230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7S0l-00038S-33 for submit@debbugs.gnu.org; Sat, 24 Jul 2021 20:28:55 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7S0h-00038I-TJ for submit@debbugs.gnu.org; Sat, 24 Jul 2021 20:28:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7S0h-0007D6-MI for bug-gnu-emacs@gnu.org; Sat, 24 Jul 2021 20:28:51 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:45813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7S0e-0000Cq-Hs for bug-gnu-emacs@gnu.org; Sat, 24 Jul 2021 20:28:51 -0400 Original-Received: (Authenticated sender: league@contrapunctus.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A8B0360002 for ; Sun, 25 Jul 2021 00:28:43 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.195; envelope-from=league@contrapunctus.net; helo=relay3-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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:210673 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This issue with =E2=80=98bookmark-fontify=E2=80=99 came up (within a broader discussion) on the list in May, in particular by Bastien in +message-id:<8735v0w5fv.fsf@bzg.fr>. It's obtrusive with the way =E2=80=98org-refile=E2=80=99 and =E2=80=98org-capture=E2=80=99 use bookmark= s, but still bothersome outside of org. It's not yet fixed in current master. To reproduce, make sure =E2=80=98bookmark-fontify=E2=80=99 is t (the defaul= t in master) and =E2=80=98bookmark-face=E2=80=99 is noticeable (orange backgroun= d by default). Then: emacs -Q ;; Visit any file with >20 lines, e.g.: M-x find-library RET bookmark RET ;; Set bookmark to current line C-x r m RET ;; Go elsewhere and overwrite same bookmark: C-u C-u C-n C-x r m RET When we set or jump to a bookmark, that line gets fontified in the buffer. Move down a few lines, and set the bookmark again with the same name. This will (by default) overwrite the previous location, but now *both* locations are displayed using bookmark-face. When a bookmark is deleted with =E2=80=98bookmark-delete=E2=80=99 or within =E2=80=98bookmark-bmenu-list=E2=80=99 (C-x r l), its location gets unfontif= ied. But when just overwritten, the font overlay remains. In the fix, I tried to split and edit the nearby comment for clarity as well. Feedback welcome, thanks. CL --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-When-bookmark-is-overwritten-unfontify-its-previous-.patch >From cd1539cb298372f47dc8160ff271e4d8a6f96012 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Sat, 24 Jul 2021 18:17:07 -0400 Subject: [PATCH] When bookmark is overwritten, unfontify its previous position * lisp/bookmark.el (bookmark-store): When the bookmark-fontify option is non-nil, setting or jumping to bookmarks will colorize them using `bookmark-face'. With this change, overwriting a bookmark will remove the fontification at its former position. --- lisp/bookmark.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 52b96fd203..ff9b8ab138 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -561,10 +561,14 @@ old one." (set-text-properties 0 (length stripped-name) nil stripped-name) (if (and (not no-overwrite) (bookmark-get-bookmark stripped-name 'noerror)) - ;; already existing bookmark under that name and - ;; no prefix arg means just overwrite old bookmark - ;; Use the new (NAME . ALIST) format. - (setcdr (bookmark-get-bookmark stripped-name) alist) + ;; Already existing bookmark under that name and + ;; no prefix arg means just overwrite old bookmark. + (let ((bm (bookmark-get-bookmark stripped-name))) + ;; First clean up if previously location was fontified. + (when bookmark-fontify + (bookmark--unfontify bm)) + ;; Modify using the new (NAME . ALIST) format. + (setcdr bm alist)) ;; otherwise just cons it onto the front (either the bookmark ;; doesn't exist already, or there is no prefix arg. In either -- 2.31.1 --=-=-=--