emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-goto-local-search-headings usage?


From: Myles English
Subject: Re: [O] org-goto-local-search-headings usage?
Date: Wed, 16 May 2012 21:37:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]