[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH] Add user option to disable location in bookmarks
From: |
Drew Adams |
Subject: |
RE: [PATCH] Add user option to disable location in bookmarks |
Date: |
Sat, 20 Jun 2020 23:34:05 +0000 (UTC) |
> > You don't specify what the actual problem is. How does a bookmark
> > interfere with save-place? Maybe provide a step-by-step recipe to
> > show the problem, starting from `emacs -Q' (no init file).
>
> ‘bookmark-set’ saves the position--by which I mean point and context
> strings--with no option (that I can find) of not saving it. When using
> ‘bookmark-jump’, point will always be moved to that position, ignoring
> the position from save-place.
That's not a recipe.
A bookmark can do anything. It can even make use of
save-place or any save-place info.
You can create whatever kind of bookmark you need, if
you need something special. See
`bookmark-make-record-function', and see how it's used
in the Elisp sources to create different kinds of
bookmarks.
`bookmark-set' uses `bookmark-make-record', which calls
the function value of `bookmark-make-record-function'.
It's only the default value of variable
`bookmark-make-record-function' that does what you say.
If the default `bookmark-make-record-function' doesn't
do what's needed for save-place, then maybe save-place
should define its own type of bookmark.
Or probably all it needs to do is `add-hook' for
`bookmark-after-jump-hook', just as it does for
`find-file-hook', `dired-initial-position-hook', and
`kill-emacs-hook'. IOW, after jumping to the position
that you bookmarked, move to the save-place position.
It's you who bookmarked a given position. And likely
you do sometimes want to return to that position. But
if there's a more recent position in that file, which
save-place has saved for you, then just use that one,
via `bookmark-after-jump-hook'.
(And again, a bookmark need not have a location. If
you use the default make-record function then yes,
the bookmark saves a position.)
> > Just what behavior are you looking for? Do you not want to open the
> > file at all? (If so, what do you want the bookmark to do with the
> > file, instead of opening it?)
> >
> > If you want the bookmark to open the file, where do you want the
> > cursor to be in it - at what position?
>
> My patch allows the user to choose whether or not the bookmark record
> should be in control of the position.
The bookmark record has already chosen that. Just
use a different kind of record. Why have an option
that acts in a blanket manner on all bookmarks, to
ignore their position?
If this is about save-place then save-place should
do the right thing. See above. If there's an option
to be added in that regard, it's a save-place option:
`save-place-ignore-bookmark-position'. The hook
function (see above) can move to the save-place place
if the option is non-nil, and just do nothing if it's
nil.
> > A bookmark can target a file in any way you want, including (but not
> > limited to) opening it at a given position. You can easily bookmark a
> > file so that the bookmark opens it with the cursor at position 1, for
> > example. (And you need not visit a file in order to bookmark it.)
> >
> > Finally, a bookmark need not have any `location' field.
>
> I understand this. I think it would be useful to have a simple
> accessible way to effectively disable the point manipulation part of
> bookmarks. It’s not exactly convenient to edit the bookmark file by
> hand every time a bookmark is created just to disable this feature.
No one suggested that you edit a bookmark file.
Your cure isn't localized to the ill. If this is a
good option to give users, to let save-place override
bookmark locations, just like it does for Dired and
`find-file', then that option belongs to save-place.