unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: torys.anderson@gmail.com, emacs list <help-gnu-emacs@gnu.org>
Subject: RE: Bookmark Plus: Bookmarking "locate"d files
Date: Tue, 3 Feb 2015 14:08:42 -0800 (PST)	[thread overview]
Message-ID: <7a4b475d-785c-44f9-ad98-1cc99dc62cc9@default> (raw)
In-Reply-To: <87zj8ug0v6.fsf@gmail.com>

> 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	other threads:[~2015-02-03 22:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 21:07 Bookmark Plus: Bookmarking "locate"d files Tory S. Anderson
2015-02-03 22:08 ` Drew Adams [this message]

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=7a4b475d-785c-44f9-ad98-1cc99dc62cc9@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=torys.anderson@gmail.com \
    /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).