all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019)
@ 2024-04-19  5:19 Karl Fogel
  2024-04-19  8:01 ` bug#70019: " Dani Moncayo
  2024-04-19  8:01 ` Dani Moncayo
  0 siblings, 2 replies; 16+ messages in thread
From: Karl Fogel @ 2024-04-19  5:19 UTC (permalink / raw)
  To: Emacs Developers; +Cc: 70019, Dani Moncayo

[-- Attachment #1: Type: text/plain, Size: 309 bytes --]

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


[-- Attachment #2: Fix two bugs in removing bookmark fringe marks (bug#70019) --]
[-- Type: text/plain, Size: 2768 bytes --]

From a7c9618efdd423134990c22d62513eac50ab98e3 Mon Sep 17 00:00:00 2001
From: Karl Fogel <kfogel@red-bean.com>
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


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* bug#70019: 30.0.50; bookmark-set: fringe icon (again)
@ 2024-03-26 20:30 Dani Moncayo
  2024-04-19  5:19 ` bug#70019: [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019) Karl Fogel
  0 siblings, 1 reply; 16+ messages in thread
From: Dani Moncayo @ 2024-03-26 20:30 UTC (permalink / raw)
  To: 70019

Recipe from "emacs -Q":

1. Open the Emacs manual [C-h r].
2. Set a named bookmark in some line of the *info* node [C-x r m f o o RET].
3. Go to another *info* node and repeat step #2 there (with the same
bookmark name).

When I do this, I still see a "bookmark" icon in the fringe of the
first *info* node (wrong, since the bookmark now refers to another
place).

Also, if I delete the bookmark (from the "*Bookmark List*" buffer), I
still see the icons in the fringe on both *info* nodes.

--
Dani Moncayo

In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2024-03-26 built on C11-Q8YAKWONJX0
Repository revision: 351d98535dc10f8338b8a418e331cc0af488087b
Repository branch: master
Windowing system distributor 'Microsoft Corporation', version 11.0.12010000
System Description: Ubuntu 23.10

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2
XPM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-04-22 22:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19  5:19 [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019) Karl Fogel
2024-04-19  8:01 ` bug#70019: " Dani Moncayo
2024-04-19  8:01 ` Dani Moncayo
2024-04-20  0:54   ` Karl Fogel
2024-04-20  6:50     ` Dani Moncayo
2024-04-22  3:51       ` Karl Fogel
2024-04-22  6:26         ` bug#70019: " Dani Moncayo
2024-04-22  6:26         ` Dani Moncayo
2024-04-22  7:40           ` bug#70019: " Eli Zaretskii
2024-04-22 22:21             ` Karl Fogel
2024-04-22 22:21             ` Karl Fogel
2024-04-22  7:40           ` Eli Zaretskii
2024-04-22  3:51       ` Karl Fogel
2024-04-20  6:50     ` Dani Moncayo
2024-04-20  0:54   ` Karl Fogel
  -- strict thread matches above, loose matches on Subject: below --
2024-03-26 20:30 bug#70019: 30.0.50; bookmark-set: fringe icon (again) Dani Moncayo
2024-04-19  5:19 ` bug#70019: [PATCH] Fix two bugs in removing bookmark fringe marks (bug#70019) Karl Fogel

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.