From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc-Oliver Ihm Subject: [code] Small elisp snippet to search among toplevel headlines in a file Date: Sat, 04 Feb 2012 19:29:51 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:34939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtkN6-0006zt-H9 for emacs-orgmode@gnu.org; Sat, 04 Feb 2012 13:30:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtkN5-0008VD-IS for emacs-orgmode@gnu.org; Sat, 04 Feb 2012 13:30:00 -0500 Received: from plane.gmane.org ([80.91.229.3]:37944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtkN5-0008Ug-DL for emacs-orgmode@gnu.org; Sat, 04 Feb 2012 13:29:59 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RtkN2-0002Qo-HB for emacs-orgmode@gnu.org; Sat, 04 Feb 2012 19:29:56 +0100 Received: from p54a89166.dip0.t-ipconnect.de ([84.168.145.102]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 04 Feb 2012 19:29:56 +0100 Received: from marc-oliver.ihm by p54a89166.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 04 Feb 2012 19:29:56 +0100 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: emacs-orgmode@gnu.org 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