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

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

RE: Bookmark Plus: Bookmarking "locate"d files


From: Drew Adams
Subject: RE: Bookmark Plus: Bookmarking "locate"d files
Date: Tue, 3 Feb 2015 14:08:42 -0800 (PST)

> I follow a regular process in my note-taking and can create a locate command
> that returns a complete list of my note org files within a portion of my
> directory heirarchy. I had hoped the results of (locate) would count as an
> occur/compilation buffer; it even partially works as a dired buffer. But
> whenever I try the dired bookmark command after marking the results, I am
> told the command is only available in dired or dired-derived modes (which, I
> was sure, the results of locate were).
> 
> In following http://www.emacswiki.org/emacs/BookmarkPlus#toc33, How can I
> bookmark such a list of files? Is it a bug that I cannot do it from the
> "locate" buffer?

I don't use Org (shameful confession, I know), and I'm not familiar
with such buffers.  But if the buffer normally exists or you can
easily re-create it, then you can of course just bookmark it
normally.  You can also put the code to re-create it in a function
bookmark (or in a separate command).

But it sounds like your question is more about something like what
`C-c C-M-b' does in occur mode or compilation mode: create bookmarks
for the targets of all of the hits.  (This is similar to what `M-b'
does in Dired: bookmark each of the marked files.)

If so, then you would need to create a command similar to the commands
that `C-c C-M-b' is bound to there: `bmkp-occur-target-set-all' and
`bmkp-compilation-target-set-all'.  You can see that the code for
those two commands is pretty much the same.  This is the meat of it:

(while (ignore-errors (occur-next) t) ; "No more matches" ends loop
  (ignore-errors (bmkp-occur-target-set prefix)) ; Ignore killed buf
  (setq count  (1+ count)))

That iterates over the hits, setting a bookmark for each one.
You need a function that gives you the next hit, similar to
`occur-next' and `compilation-next-error'.  Probably your Org
buffer's mode has such a function.

And you need a function analogous to `bmkp-occur-target-set',
to set a single such bookmark.  For that, you need a function
that follows a hit, similar to `occur-mode-find-occurrence' (and
`find-file-noselect' for compilation mode).  Probably your buffer's
mode has that too.

Try something similar for your context.  Let me know what you find.

(In principle, `next-error', with `next-error-function', provides
a single, unified way to get the next hit but there are sometimes
particularities to take into account, I think.  Anyway, Bookmark+
supports older Emacs versions that do not unify this.)



reply via email to

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