unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 48179@debbugs.gnu.org
Subject: bug#48179: bookmark-fontify [PATCH]
Date: Wed, 5 May 2021 12:30:38 -0400	[thread overview]
Message-ID: <20210505163038.bq4oupkuiago6kcd@E15-2016.optimum.net> (raw)
In-Reply-To: <8735v1jrit.fsf@tcd.ie>

On 2021-05-05 13:26, Basil L. Contovounesios wrote:
> Lars Ingebrigtsen <larsi@gnus.org> writes:
> > "Basil L. Contovounesios" <contovob@tcd.ie> writes:
> >
> >> If you 'C-x r m' more than once in the same file, the first overlay
> >> remains even after deleting the bookmark.  Shouldn't the first overlay
> >> be deleted when its bookmark position is overwritten?
> >
> > You mean when giving the bookmark the same name?
>
> Yes, sorry, I meant multiple 'C-x r m RET' in the same buffer.
>
> > (You can have several bookmarks in the same file with different
> > names.)
> >
> > Yes, that would make sense.
>
> Thanks,

Basil, I went to start doing more work on this and see you made a commit
in the interim so let me coordinate before we end up cross-commiting
(For me, this is especially important since I'm working with debian v27.1
locally and applying patches to v28 which you seem to using locally).

1) For function bookmark--unfontify

   If more than one buffer in the list can be acted upon, then variable
   'found' @line ~472 should be set nil at this point. If only one
   buffer in the list can be acted upon, then @line ~469 should either
   check variable 'found' or @line ~476 should set the list nil, both
   easier using the prior pop idiom than the dolist idiom.

2) For function bookmark-delete-all

   This seems to be a new function in v28, that I don't have locally. I
   see it when performing a diff. Because it takes a (reasonable and
   efficient) 'short-cut' method, it won't delete any fontified
   overlays, so it needs a variation of function bookmark--unfontify:

   (defun bookmark--unfontify-all ()
     "Remove all bookmarks' colorized overlays.
   This function is meant to be called by function
   `bookmark-delete-all'."
     (dolist (buf (buffer-list))
       (with-current-buffer buf
         (save-restriction
           (widen)
           (remove-overlays (point-min) (point-max) 'category 'bookmark)))))

3) For function bookmark-set-internal

   Additional logic is required in order to account for argument
   variable  'overwrite-or-push'. If I'm understanding those features
   correctly, @lines ~875-878 should be amended to something like:

            ((eq overwrite-or-push 'overwrite)
             (when (setq prior-bm (bookmark-get-bookmark str t))
               (bookmark--unfontify prior-bm))
             (bookmark-store str (cdr record) nil))
            ((eq overwrite-or-push 'push)
             (when (setq prior-bm (bookmark-get-bookmark str t))
               (bookmark--unfontify prior-bm))
             (bookmark-store str (cdr record) t))

   For the above snippet, variable 'prior-bm' should be defined locally
   scoped @line ~861

4) I was expecting to find some sort of bookmark hook function in
   variable 'find-file-hooks'. The idea would be thatd when a file is
   read it's stored bookmarks are immediately fontified.

   (defun bookmark--find-file-hook-function ()
     "Fontify all bookmarks in newly found file."
     (let (pos overlay)
       (dolist (bm  (mapcar 'cdr bookmark-alist))
         (when (and (equal buffer-file-name
                           (expand-file-name (or (cdr (assq 'filename bm)) "")))
                    (setq pos (cdr (assq 'position bm))))
           (save-excursion
             (goto-char pos)
             (setq overlay (make-overlay (point-at-bol)
                                         (min (point-max) (1+ (point-at-eol)))))
             (overlay-put overlay 'category 'bookmark)
             (overlay-put overlay 'face 'bookmark-face))))))

That should go some way to account for your catch and some other
scenarios. There may be others that crop up.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





  reply	other threads:[~2021-05-05 16:30 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03  0:13 bug#48179: bookmark-fontify [PATCH] Boruch Baum
2021-05-03  0:40 ` bug#48179: [External] : " Drew Adams
2021-05-03  1:20   ` Boruch Baum
2021-05-03  1:25     ` Drew Adams
2021-05-04  0:35       ` Stefan Kangas
2021-05-04 16:37         ` bug#48179: [External] : " Drew Adams
2021-05-03  7:54 ` Lars Ingebrigtsen
2021-05-03  9:12   ` Boruch Baum
2021-05-03  9:19     ` Lars Ingebrigtsen
2021-05-03  9:58       ` Boruch Baum
2021-05-04  8:59         ` Lars Ingebrigtsen
2021-05-04  9:02           ` Lars Ingebrigtsen
2021-05-04  9:58             ` Basil L. Contovounesios
2021-05-05  8:13               ` Lars Ingebrigtsen
2021-05-05 12:26                 ` Basil L. Contovounesios
2021-05-05 16:30                   ` Boruch Baum [this message]
2021-05-06  8:57                     ` Lars Ingebrigtsen
2021-05-06 10:31                       ` Boruch Baum
2021-05-06 18:52                         ` Basil L. Contovounesios
2021-05-06 18:52                     ` Basil L. Contovounesios
2021-05-06 19:13                       ` Boruch Baum
2021-05-06 19:41                         ` Basil L. Contovounesios
2021-05-05 17:08                   ` Boruch Baum
2021-05-06  8:58                     ` Lars Ingebrigtsen
2021-05-06 10:38                       ` Boruch Baum
2021-05-06 18:53                         ` Basil L. Contovounesios
2021-05-06 11:03                       ` Boruch Baum
2021-05-04 18:38             ` Boruch Baum
2021-05-05  8:15               ` Lars Ingebrigtsen
2021-05-05 10:48                 ` Boruch Baum
2021-05-05 16:43                   ` bug#48179: [External] : " Drew Adams
2021-05-06  8:53                   ` Lars Ingebrigtsen
2021-05-05 15:39           ` Bastien
2021-05-05 17:25             ` Boruch Baum
2021-05-05 18:54               ` Eli Zaretskii
2021-05-06  8:54               ` Lars Ingebrigtsen
2021-05-06  9:57               ` Bastien
2021-05-06 10:12                 ` Colin Baxter
2021-05-06 10:59                 ` Boruch Baum
2021-05-06  8:49             ` Colin Baxter
2021-05-06  8:55               ` Lars Ingebrigtsen
2021-05-06  9:41                 ` Colin Baxter
2021-05-06 10:24                 ` Boruch Baum
2021-05-06 10:46                   ` Colin Baxter
2021-05-06 10:52                     ` Colin Baxter
2021-05-07 11:22                     ` Lars Ingebrigtsen
2021-05-07 13:52                       ` Colin Baxter
2021-05-07 16:22                         ` bug#48179: [External] : " Drew Adams
2021-05-07 18:48                           ` Colin Baxter
2021-05-08  0:25                             ` Drew Adams
2021-06-06  0:27 ` bug#48179: bookmark-fontify disable by default Y. E.
2021-06-06  3:30   ` Pankaj Jangid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505163038.bq4oupkuiago6kcd@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=48179@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).