From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Alekseyev Subject: Re: [code] Small elisp snippet to search among toplevel headlines in a file Date: Mon, 6 Feb 2012 00:46:33 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:49730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuILU-000776-PP for emacs-orgmode@gnu.org; Mon, 06 Feb 2012 01:46:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RuILT-0002oU-1w for emacs-orgmode@gnu.org; Mon, 06 Feb 2012 01:46:36 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:50211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuILS-0002oI-TY for emacs-orgmode@gnu.org; Mon, 06 Feb 2012 01:46:35 -0500 Received: by pbaa12 with SMTP id a12so5255943pba.0 for ; Sun, 05 Feb 2012 22:46:33 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Marc-Oliver Ihm Cc: emacs-orgmode@gnu.org 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 wr= ote: > Another possible idea may be to write project titles in bold while on > headlines. =A0That 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 >> =A0 [(f11)] >> =A0 (lambda () (interactive) >> =A0 =A0 (progn >> =A0 =A0 =A0 (occur (concat "^\\* .*" >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(read-from-minibuffer >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Occur for toplevel headline= s containing: ")) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0nil) >> =A0 =A0 =A0 (pop-to-buffer "*Occur*") >> =A0 =A0 =A0 (use-local-map (copy-keymap (current-local-map))) >> =A0 =A0 =A0 (local-set-key (kbd "RET") >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(lambda () (interactive) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(progn >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(occur-mode-goto-occu= rrence) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(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 toplev= el >> 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 > > >