From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019) Date: Fri, 19 Apr 2024 19:54:02 -0500 Message-ID: <87zftoq2fp.fsf@red-bean.com> References: <87r0f26ia6.fsf@red-bean.com> Reply-To: Karl Fogel 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="4448"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Emacs Developers , 70019@debbugs.gnu.org To: Dani Moncayo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 20 02:54:57 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rxz0L-0000uw-D8 for ged-emacs-devel@m.gmane-mx.org; Sat, 20 Apr 2024 02:54:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxyzZ-00088W-25; Fri, 19 Apr 2024 20:54:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxyzX-00087z-CW for emacs-devel@gnu.org; Fri, 19 Apr 2024 20:54:07 -0400 Original-Received: from sanpietro.red-bean.com ([45.79.25.59]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxyzV-0002Mz-Mu for emacs-devel@gnu.org; Fri, 19 Apr 2024 20:54:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=red-bean.com; s=202005newsp; h=Content-Type:MIME-Version:Message-ID:Date: Reply-To:References:In-Reply-To:Subject:Cc:To:From:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=q4MM/FY/cmdqd4CykdLoit0CiLpbKxTpBx215XlcF0k=; t=1713574444; x=1714784044; b=T1mAw0c9pa+iy6NKKcL3uQtNh/9PCclGOd0O60zctkUeHyeKQO3Vfn65tTvsNkTNKwoOkmzUxmt JFG3FO3fOLan7i1EjAAKEzuXbcdyQQGWVojFapgm9IsrgX9I793TKtEeGxK1yMW4vcN+jKCTb4LRM ZaPhmUfVHJBTpVXa1u4/NlhH/JQiT+3hLNJsG+B63f+RY1/Eih6FR5Gx/pCPA2ZUe8SYQVtWI7ZxV V1UsWuNiXuCgiM7jd0GL5KrNGR3vWc5ZSGeqrAXoN82Qmz+aLatb1Rq0+ebHhY2oDvJ/J6DQWW6dO 6jFCfIk/CLVjs1hlHRY0Fvo8qTHwD861u1Pw==; Original-Received: from 99-112-125-163.lightspeed.cicril.sbcglobal.net ([99.112.125.163]:42126 helo=qfloss) by sanpietro.red-bean.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rxyzT-003A8c-1E; Sat, 20 Apr 2024 00:54:03 +0000 In-Reply-To: (Dani Moncayo's message of "Fri, 19 Apr 2024 10:01:42 +0200") Received-SPF: pass client-ip=45.79.25.59; envelope-from=kfogel@red-bean.com; helo=sanpietro.red-bean.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317853 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 19 Apr 2024, Dani Moncayo wrote: >I've applied the patch to my source tree and re-made my=20 >out-of-tree build. >But I still see the same problems reported in this bug ticket. >Maybe I've made some mistake... =C2=BFDon't you see the problems with=20 >the >patch applied? Nope, you didn't make any mistake. I see the problem; please try=20 this revised version, and thank you for testing. Best regards, -Karl --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Fix-two-bugs-in-removing-bookmark-fringe-marks.patch >From 705eeb968c85cf8d865c893778cc0df6a6db6034 Mon Sep 17 00:00:00 2001 From: Karl Fogel Date: Thu, 18 Apr 2024 23:49:29 -0500 Subject: [PATCH] Fix two bugs in removing bookmark fringe marks This fixes bug#70019 and a separate fringe-mark removal bug that also affected bookmarks in certain Info nodes. * lisp/bookmark.el (bookmark--remove-fringe-mark): Fix bug#70019 by temporarily widening in order to ensure we fetch the right overlays. Also, normalize both filenames before comparing, to avoid spurious failure to match. --- lisp/bookmark.el | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index bf2357207d8..06f8e24b518 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -515,18 +515,45 @@ bookmark--remove-fringe-mark (non-essential t) overlays found temp) (when (and pos filename) - (setq filename (abbreviate-file-name (expand-file-name filename))) (dolist (buf (buffer-list)) (with-current-buffer buf - (when (equal filename - (ignore-errors (bookmark-buffer-file-name))) - (setq overlays - (save-excursion - (goto-char pos) - (overlays-in (pos-bol) (1+ (pos-bol))))) - (while (and (not found) (setq temp (pop overlays))) - (when (eq 'bookmark (overlay-get temp 'category)) - (delete-overlay (setq found temp)))))))))) + (let ((bkmk-fname (ignore-errors (bookmark-buffer-file-name)))) + (when bkmk-fname + ;; Normalize both filenames before comparing, because the + ;; filename we receive from the bookmark wasn't + ;; necessarily generated by `bookmark-buffer-file-name'. + ;; For example, bookmarks set in Info nodes get a filename + ;; based on `Info-current-file', and under certain + ;; circumstances that can be an unexpanded path (e.g., + ;; when the Info page was under your home directory). + (let ((this-fname-normalized (expand-file-name filename)) + (bkmk-fname-normalized (expand-file-name bkmk-fname))) + (when (equal this-fname-normalized bkmk-fname-normalized) + (setq overlays + (save-excursion + (save-restriction + ;; Suppose bookmark "foo" was earlier set at + ;; location X in a file, but now the file is + ;; narrowed such that X is outside the + ;; restriction. Then the `goto-char' below + ;; would go to the wrong place and thus the + ;; wrong overlays would be fetched. This is + ;; why we temporarily `widen' before + ;; fetching. + ;; + ;; (This circumstance can easily arise when + ;; a bookmark was set on Info node X but now + ;; the "*info*" buffer is showing some other + ;; node Y, with X and Y physically located + ;; in the same file, as is often the case + ;; with Info nodes. See bug #70019, for + ;; example.) + (widen) + (goto-char pos) + (overlays-in (pos-bol) (1+ (pos-bol)))))) + (while (and (not found) (setq temp (pop overlays))) + (when (eq 'bookmark (overlay-get temp 'category)) + (delete-overlay (setq found temp))))))))))))) (defun bookmark-maybe-sort-alist () "Return `bookmark-alist' for display. -- 2.43.0 --=-=-=--