emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [code] Small elisp snippet to search among toplevel headlines in a file
@ 2012-02-04 18:29 Marc-Oliver Ihm
  2012-02-05  4:03 ` Jude DaShiell
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-Oliver Ihm @ 2012-02-04 18:29 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [code] Small elisp snippet to search among toplevel headlines in a file
  2012-02-04 18:29 [code] Small elisp snippet to search among toplevel headlines in a file Marc-Oliver Ihm
@ 2012-02-05  4:03 ` Jude DaShiell
  2012-02-06  6:46   ` Leo Alekseyev
  0 siblings, 1 reply; 3+ messages in thread
From: Jude DaShiell @ 2012-02-05  4:03 UTC (permalink / raw)
  To: Marc-Oliver Ihm; +Cc: emacs-orgmode

Another possible idea may be to write project titles in bold while on 
headlines.  That way all you need search for is the beginning of a line 
followed by a single * followed by a blank followed by the opening mark 
for bolding and if this is only done with project titles you got yourself 
an index.On Sat, 4 Feb 2012, Marc-Oliver Ihm wrote:

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

----------------------------------------------------------------
Jude <jdashiel-at-shellworld-dot-net>
<http://www.shellworld.net/~jdashiel/nj.html>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [code] Small elisp snippet to search among toplevel headlines in a file
  2012-02-05  4:03 ` Jude DaShiell
@ 2012-02-06  6:46   ` Leo Alekseyev
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Alekseyev @ 2012-02-06  6:46 UTC (permalink / raw)
  To: Marc-Oliver Ihm; +Cc: emacs-orgmode

Another possible way to do it might be to create a wrapper around
org-goto with alternative interface where you set org-goto-max-level
to 1.  I've been using org-goto (alt. interface) with ido mode for a
while, and it's great (although I haven't tried restricting headlines
to just the top level).

On Sat, Feb 4, 2012 at 10:03 PM, Jude DaShiell <jdashiel@shellworld.net> wrote:
> Another possible idea may be to write project titles in bold while on
> headlines.  That way all you need search for is the beginning of a line
> followed by a single * followed by a blank followed by the opening mark
> for bolding and if this is only done with project titles you got yourself
> an index.On Sat, 4 Feb 2012, Marc-Oliver Ihm wrote:
>
>> 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
>>
>>
>>
>>
>
> ----------------------------------------------------------------
> Jude <jdashiel-at-shellworld-dot-net>
> <http://www.shellworld.net/~jdashiel/nj.html>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-06  6:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-04 18:29 [code] Small elisp snippet to search among toplevel headlines in a file Marc-Oliver Ihm
2012-02-05  4:03 ` Jude DaShiell
2012-02-06  6:46   ` Leo Alekseyev

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