From mboxrd@z Thu Jan 1 00:00:00 1970 From: Myles English Subject: Re: org-goto-local-search-headings usage? Date: Wed, 16 May 2012 21:37:53 +0100 Message-ID: <87396zeuam.fsf@gmail.com> References: <87obpp31ln.fsf@ed.ac.uk> <4409.1337096935@alphaville> <87havhp2w9.fsf@gmail.com> <8801.1337117593@alphaville> <8896.1337118269@alphaville> <877gwcl8oe.fsf@gmail.com> <87txzgjhsi.fsf@gmail.com> Reply-To: emacs-orgmode Mode , Myles English Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:60369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUkto-0002hn-My for emacs-orgmode@gnu.org; Wed, 16 May 2012 16:32:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUktk-0007bd-Lo for emacs-orgmode@gnu.org; Wed, 16 May 2012 16:32:44 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:41966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUktk-0007ah-DW for emacs-orgmode@gnu.org; Wed, 16 May 2012 16:32:40 -0400 Received: by wgbds1 with SMTP id ds1so5522151wgb.0 for ; Wed, 16 May 2012 13:32:37 -0700 (PDT) In-Reply-To: <87txzgjhsi.fsf@gmail.com> (Nicolas Goaziou's message of "Wed, 16 May 2012 16:56:45 +0200") 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: Nicolas Goaziou Cc: emacs-orgmode Mode >> On Wed, 16 May 2012 16:56:45 +0200, Nicolas Goaziou said: > I highly suggest to use (org-element-parse-buffer 'headline) instead of > plain (org-element-parse-buffer), since you really don't need to spend > time parsing the buffer down to the smallest object. > Also, you should check :raw-value property instead of :title, since the > latter is a secondary string (a list containing strings and objects) > which, as such, will never match a string. :raw-value, on the other > hand, is always a string and doesn't require the (stringp title) test. Thanks for your advice, and thanks too for org-element! I can't believe that no one else needs a function to goto a heading, and I am sure to need it again myself so did this: (require 'org-element) (defun my-goto-heading(file heading-text) "Visit file `file' and goto headline `heading-text'" (find-file file) (org-element-map (org-element-parse-buffer 'headline) 'headline (lambda (x) (if (string= (org-element-property :raw-value x) heading-text) (goto-char (org-element-property :begin x)) nil)) nil t)) ;; stop at first find and use it like this, so that whenever I need to remind myself of what to do and how to do it I press (M-x gtd) : (defun gtd() (interactive) (my-goto-heading "~/org/org/gtd.org" "My workflow") (reposition-window) (org-show-entry) (org-show-subtree) (org-agenda-list)) > Regards, > -- > Nicolas Goaziou -- `--[ Myles ]