From: Marc-Oliver Ihm <marc-oliver.ihm@online.de>
To: emacs-orgmode@gnu.org
Subject: [code] Small elisp snippet to search among toplevel headlines in a file
Date: Sat, 04 Feb 2012 19:29:51 +0100 [thread overview]
Message-ID: <jgjtes$pvv$1@dough.gmane.org> (raw)
Hello,
I have one big org-file for a lot of smaller projects,
each of them represented by a toplevel item.
And I have difficulties finding them quickly:
In most cases I know a buzzword from the headline;
however, if I do a search-forward I normally find
some other text within the body of an unrelated project
further above in the file; and only after several
repetitions of search I find the toplevel heading
(i.e. the project) I was looking for.
To make it easier to search only among toplevel headings
(i.e. among the the titles of my projects),
I wrote this small piece of elisp,
which lives in my initialization-file (e.g. .emacs):
(define-key org-mode-map
[(f11)]
(lambda () (interactive)
(progn
(occur (concat "^\\* .*"
(read-from-minibuffer
"Occur for toplevel headlines containing: "))
nil)
(pop-to-buffer "*Occur*")
(use-local-map (copy-keymap (current-local-map)))
(local-set-key (kbd "RET")
(lambda () (interactive)
(progn
(occur-mode-goto-occurrence)
(delete-other-windows)))))))
To find a project I just press f11 (please choose your own key) and
enter a keyword to do an occur for this keyword. Normally several toplevel
headings are found and the right one is chosen by typing return.
I hope, that someone might find this useful too.
with kind regards, Marc-Oliver Ihm
next reply other threads:[~2012-02-04 18:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-04 18:29 Marc-Oliver Ihm [this message]
2012-02-05 4:03 ` [code] Small elisp snippet to search among toplevel headlines in a file Jude DaShiell
2012-02-06 6:46 ` Leo Alekseyev
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='jgjtes$pvv$1@dough.gmane.org' \
--to=marc-oliver.ihm@online.de \
--cc=emacs-orgmode@gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).