Subject: RE: [External] : bug#48179: bookmark-fontify [PATCH]

From: Drew Adams <[email-masked]>
Date: Fri, 7 May 2021 16:22:09 +0000

>> setting multiple bookmarks in the same file works
>> without problems with the built-in bookmark.el,
>> as far as I can tell?  (You just have to give the
>> bookmarks different names.)

First, a correction of that, assuming I understand
what it wants to say.  You can have any number of
bookmarks in the same file, and even with the same
location in the file.  And they need _NOT_ have
different names.

[This is true for both vanilla bookmark.el and
 Bookmark+.  But in vanilla all but the first
 bookmark with the same name are unused/unavailable.
 With Bookmark+ you can use all bookmarks that have
 the same name.

 For instance, you can have two bookmarks named
 `foo.el', each named for a file named `foo.el',
 where those files are in different directories.
 That's the case for autofile bookmarks, for
 example.]

> That's true, but, as you wrote, the user has
> to come up new names.

See above - the names need NOT be different.

Secondly, if your point is about a user always
needing to come up with names whenever s?he
_wants_ different names (underlining "wants",
because that's not an Emacs requirement):

Sometimes you _want_ to name a bookmark.
Sometimes you might prefer not to have to do that,
and instead just hit a key to set a bookmark -
no prompting for a name, no need to even hit `RET'
to accept a default name at a prompt.

With Bookmark+, by default `C-x x RET' does that.
No prompting - autonaming.

(Bookmarking keys are on a keymap that's bound,
by default, to `C-x x'.  You can instead of course
put that command on a shorter key.)

That's `bmkp-toggle-autonamed-bookmark-set/delete':

  If there is an autonamed bookmark at point, delete
   it, else create one.

  The bookmark created has no region.  Its name is
  formatted according to option
  `bmkp-autoname-bookmark-function'.

  With a prefix arg, delete *ALL* autonamed bookmarks
  for this buffer.

  Non-interactively, act at POSITION, not point.
  If nil, act at point.

So one key to either create or delete an autonamed
bookmark at point.  And a prefix arg deletes all.

> This is done automatically in bm-bookmarks, which
> inserts the corresponding line as the name.

Bookmark+ lets users customize the autonaming, using
option `bmkp-autoname-bookmark-function':

  Function to automatically name a bookmark at point
   (cursor position).

  It should accept a buffer position as its (first)
   argument.
  The name returned should match the application of
  `bmkp-autoname-format' to the buffer name.

The default value of the option does this:

  Return a bookmark name using POSITION and the current
   buffer name.

  The name is composed as follows:
   POSITION followed by a space and then the buffer name.
   The position value is prefixed with zeros to comprise
     9 characters.
   For example, for POSITION value 31416 and current buffer
     `my-buffer', the name returned would be
     `000031416 my-buffer'.

It's trivial to define a function that returns any
kind of name you want, including using the text of
the current line as the name.

The name of an autonamed bookmark matches option
`bmkp-autoname-format', which is a format string.
By default, the format string accepts a buffer name.
The default value is "^[0-9]\\{9\\} %B".  So a
default bookmark name is the position followed by
the buffer name.

> The disadvantage is that bm-bookmarks can't 
> easily bookmark blank lines.

That's a problem only for BM's particular way of
naming.  The default Bookmark+ naming doesn't have
that problem, for example.

What's important is that users themselves can
easily define the automatic naming they want.  And
that they can create bookmarks both by autonaming
and by providing names explicitly.

> It seems to me that all the bookmarks, bm, built-in (including
> emacs-28), bookmark+, have disadvantages. Personally, I would use
> bookmark+ if were not for the fact that it writes unprompted to ~/.emacs.

I don't know what you mean by that.  Could you
elaborate?

1. It never writes to ~/.emacs, unless you've defined
   that as the bookmark file you want to write to.

2. It never writes to your bookmark file unprompted
   unless you've configured it to do so.  You do that
   in the same way as for vanilla bookmark.el: option
   `bookmark-save-flag'.  Set that option to `nil'
   and bookmarks will never be saved except when you
   explicitly ask to save, e.g. when using command
   `bookmark-save'.