unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: RE: Temporary notes in Emacs buffers?
Date: Thu, 2 Jan 2020 23:00:53 -0800 (PST)	[thread overview]
Message-ID: <53f1bb2f-c049-4e81-97cb-b63a4438b85e@default> (raw)
In-Reply-To: <87mub573g5.fsf@web.de>

> > 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
needed.

---

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.



  parent reply	other threads:[~2020-01-03  7:00 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-27 10:19 Temporary notes in Emacs buffers? Marcin Borkowski
2019-12-27 10:43 ` Mpho Jele
2019-12-27 11:51   ` tomas
2020-01-01 21:48     ` Marcin Borkowski
2019-12-27 15:54 ` Drew Adams
2020-01-02 17:49   ` Marcin Borkowski
2020-01-05  2:37   ` Michael Heerdegen
2020-01-05 17:54     ` Drew Adams
2020-01-06  5:18       ` Jean-Christophe Helary
2020-01-06 15:12         ` Drew Adams
2020-01-09  1:03           ` Michael Heerdegen
2020-01-09 23:35             ` arthur miller
2020-01-10  4:58               ` Michael Heerdegen
2020-01-10  9:30                 ` Robert Pluim
2020-01-10 10:01                   ` Michael Heerdegen
2020-01-10 17:04                   ` Drew Adams
2020-01-10  9:10               ` Unknown
2019-12-27 17:48 ` Sharon Kimble
2020-01-01  1:42 ` Michael Heerdegen
2020-01-01  4:45   ` Drew Adams
2020-01-01  5:00     ` Michael Heerdegen
2020-01-01  6:25       ` Drew Adams
2020-01-01 20:34         ` John Yates
2020-01-01 21:19           ` Drew Adams
2020-01-01 21:47           ` Marcin Borkowski
2020-01-02  1:25         ` Michael Heerdegen
2020-01-02  3:16           ` Drew Adams
2020-01-02  3:45             ` Michael Heerdegen
2020-01-02  5:30               ` Drew Adams
2020-01-02 15:41                 ` Drew Adams
2020-01-03  1:07                 ` Michael Heerdegen
2020-01-03  3:35                   ` John Yates
2020-01-03  6:38                     ` Drew Adams
2020-01-03  7:06                     ` Drew Adams
2020-01-04  6:39                     ` Michael Heerdegen
2020-01-04 16:04                       ` Drew Adams
2020-01-06 14:18                         ` John Yates
2020-01-06 14:34                           ` tomas
2020-01-06 15:19                             ` John Yates
2020-01-06 15:31                               ` tomas
2020-01-06 16:28                               ` arthur miller
2020-01-03  7:00                   ` Drew Adams [this message]
2020-01-03 13:31                   ` arthur miller
2020-01-05  2:18                     ` Michael Heerdegen
2020-01-11  7:36         ` Michael Heerdegen
2020-01-11 10:00           ` Jean-Christophe Helary
2020-01-11 11:38             ` Michael Heerdegen
2020-01-11 16:00           ` Drew Adams
2020-01-11 23:46             ` John Yates
2020-01-12  2:47               ` Drew Adams
2020-01-12  7:31             ` Michael Heerdegen
2020-01-12 16:37               ` Drew Adams
2020-01-14  7:08                 ` Michael Heerdegen
2020-01-14 17:32                   ` Drew Adams
2020-01-15 23:10                     ` Drew Adams
2020-01-02 17:48     ` Marcin Borkowski
2020-01-02 17:48   ` Marcin Borkowski
2020-01-09  3:57 ` Michael Heerdegen
2020-01-15 18:43   ` Marcin Borkowski
2020-01-20 12:40     ` Michael Heerdegen

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=53f1bb2f-c049-4e81-97cb-b63a4438b85e@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
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).