[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Temporary notes in Emacs buffers?

From: Drew Adams
Subject: RE: Temporary notes in Emacs buffers?
Date: Thu, 2 Jan 2020 23:00:53 -0800 (PST)

> > You can define a bookmark handler for any type of
> > bookmark.  The handler could ignore the directory
> > part of the recorded file name, and get the needed
> > directory from somewhere else, e.g., from a global
> > variable or a function.  (It has to come from
> > somewhere.)
> >
> > E.g., a variable could have an alist
> > value with keys for your different whatevers (even
> > nondir-filename keys) and with dirs as the values.
> >
> > But then you'd have to update the variable value
> > when you move the targeted files.  As I said before,
> > you can write code that does something like that [...]
> Can't I just use a file or directory local variable
> for that part? That would be a trivial solution
> for the problem.

You can.  I think I mentioned that.  You can put
the new location of the file anywhere you like,
for a bookmark to pick up and use.

Is it trivial for you to update a variable value
whenever you move the target file?  If so, then
Bob's your uncle - just use a bookmark handler
that uses the variable value to provide the dir.

The point is that the code that handles a bookmark
has to get that info from somewhere.

Currently it gets it from the bookmark (as an
absolute file name), but it could get it anywhere.

If you're sure to be in the same dir as the target
file when you use a bookmark to it, then you can
have the handler just use `default-directory' - no
need for any variable or whatever.

If not, but if some other rule applies for knowing
the location of the file relative to the place
where you invoke the bookmark, then you can code
that in the handler.

If not - e.g., if you put the new location in a
var or whatever, then the handler can get it there.

There's no miracle.  The bookmark is separate from
the target file.  As a consequence, you need to
provide some connection between the two, which
will remain valid when you move the file - a rule,
a lookup,... - something.

> The problem is that the bookmark file can't know
> where I may have moved a file to

Bookmark, not bookmark file.  It's not about
the bookmark file.  (I may have misspoken and
given the wrong impression about that.)

If the bookmark you invoke can assume that the
target file will always be in some location
relative to where it's invoked (e.g. same dir),
or if the file location can be obtained somehow,
then there's no problem - how to obtain it just
needs to be coded in the bookmark's handler.

If the handler can assume that the file's dir
will always be in some variable, or obtainable
by some function, then it can use that info.

> -- but I'm very unlikely to move the bookmark
> file very often.

It's not about where the bookmark file is.
It's about how the bookmark is accessed (from
where), and how it gets the target location.

> So I would prefer a solution where the file
> knows where to ask for its bookmarks and
> annotations, and the bookmark mechanism has
> the data and the mean to deliver it.

See above.  It's up to you to define that
mechanism - how "the file knows" and "asks".

Various means are available for linking the
bookmark and its target file logically.  But
they do need to be linked, in some way.  How
you do that depends on your use case.  I can
only say that, because the bookmark and its
target file are separate, some linkage is


I suggest that the general discussion of
your and Marcin's questions be continued in
this thread, and that if there's a more
detailed discussion to be had about how to
do what you want using bookmarks we do that
off-list, as it might be a distraction.
Just a suggestion.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]