help-gnu-emacs
[Top][All Lists]
Advanced

[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 07:41:25 -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
> (my earlier suggestion was code that changes the
> target-file names in the bookmarks, but that's not
> great) - e.g. code that's kicked off by a bespoke
> file-move command.  (But then you have to remember
> to use that command to move such files...)
> 
> However you look at it, the target file is separate
> from bookmarks that refer to it - that's the nature
> of the thing.  Something has to let either the
> bookmarks themselves or the bookmark-handling code
> know where you moved the target file.

Let me add this:

If your use case is limited to being in the same
directory as the file targeted by your bookmark(s),
then you can just use `default-directory' in your
handler, as the directory in which to look up the
file name (ignoring any recorded directory).

This could be the case, e.g., if you always accessed
your bookmarks from the file itself (e.g., at their
highlighted locations there).  That's the case we've
been discussing, at least in part.

It's also possible to use `default-directory' if
you want to use a relative file name that includes
more than just the non-directory part.  E.g., if
your file is in a subdir of `default-directory`
(current pwd), then you could look it up using
the relevant part of the recorded absolute file
name.  (Or your new bookmark type could record
only such a relevant part as the target location.)

This could be the case if you access the bookmarks
from a parent or other directory (relative file
names can include `../' etc.), but you'll know
where you'll access them from, so the handler can
assume that directory - no need to look it up
somewhere.

There are various possibilities, depending on just
what you might want to do.



reply via email to

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