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: [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019) Date: Fri, 19 Apr 2024 00:19:45 -0500 Message-ID: <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="7741"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70019@debbugs.gnu.org, Dani Moncayo To: Emacs Developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 19 07:20:37 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 1rxgfs-0001ny-Hh for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Apr 2024 07:20:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxgf9-0004Yb-SY; Fri, 19 Apr 2024 01:19:51 -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 1rxgf8-0004YM-Kt for emacs-devel@gnu.org; Fri, 19 Apr 2024 01:19:50 -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 1rxgf7-0002PE-3K for emacs-devel@gnu.org; Fri, 19 Apr 2024 01:19:50 -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:Subject:Cc:To:From:Sender:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=bzqmvxVC3ZR48VweWSJFyliJgJ7jeZzon4E0VTuNyhU=; t=1713503988; x=1714713588; b=HDgQPgI1R/gdAbC2H4a9Mxq0dJEgyIvl78EDtNpnCgURmPDTUmC9xjV/yh7bS7ugZY1npNcrrw2 KE08nitO8sk0XjTgzvl/SE7R215CrY/bCfUiqeAnR5i/TRr8PzYF7gYyXwq4F9dKH0euiP9N/MH2F +/3NPbzJ5KULaHHG6FshJgMvSlg9k81IUWkeql+N6n2xKLtS1HDFTlPyemSVbC386t9Qi6hF9X4fE aV6w1hgxqPUDxIngQB3af3TvR4HnTZBpfbKVhC2I3ccAWo29XmOU6dKEVcpBM5S6AS+4IEIWnGQBc wE0yLZNhee83E4eD4dpJyDSKh7UgJZp//qtw==; Original-Received: from 99-112-125-163.lightspeed.cicril.sbcglobal.net ([99.112.125.163]:51234 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 1rxgf5-002lIM-02; Fri, 19 Apr 2024 05:19:47 +0000 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:317832 Archived-At: --=-=-= Content-Type: text/plain; format=flowed I'd appreciate some review on this patch. I've no prior experience with fringe mark code (someone else added fringe mark support to bookmark.el). This should fix bug#70019 and a separate-but-sort-of-related bug. I'll wait at least a few days for comments/review before committing. Best regards, -Karl --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Fix-two-bugs-in-removing-bookmark-fringe-marks.patch Content-Description: Fix two bugs in removing bookmark fringe marks (bug#70019) >From a7c9618efdd423134990c22d62513eac50ab98e3 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 affected bookmarks in Info "dir" nodes. * lisp/bookmark.el (bookmark--remove-fringe-mark): Fix bug#70019 by temporarily widening in order to ensure we fetch the right overlays. Also, don't tamper with the filename as received from the bookmark object, since we will compare the received filename against one generated dynamically by the same means (`bookmark-buffer-file-name') to determine whether or not we're in the right buffer. --- lisp/bookmark.el | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index bf2357207d8..5d01fe24991 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -515,15 +515,30 @@ 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))))) + (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)))))))))) -- 2.43.0 --=-=-=--