From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: [patch] also tangle headlines that begin with lower case string "comment" [8.2.5h (release_8.2.5h-680-g12df70 @ /home/youngfrog/sources/org-mode/lisp/)]
Date: Wed, 05 Mar 2014 20:08:58 +0100 [thread overview]
Message-ID: <87ha7cjwdx.fsf@gmail.com> (raw)
In-Reply-To: <87zjl4wsz7.fsf@yahoo.fr> (Nicolas Richard's message of "Wed, 05 Mar 2014 16:44:12 +0100")
Hello,
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
> I take the opportuinty to ask if we should try and make this function
> use org-element instead.
>
> My naïve approach doesn't work:
>
> #+begin_src emacs-lisp
> (save-excursion
> (org-back-to-heading t)
> (let ((elt (org-element-at-point)))
> (while (and elt
> (not
> (org-element-property :commentedp elt)))
> (setq elt
> (org-element-property :parent elt)))
> elt))
> #+end_src
>
> because an heading doesn't know what its parent heading is (the property
> is nil). This can be fixed by doing:
>
> #+begin_src emacs-lisp
> (defun org-babel-under-commented-heading-p ()
> "Return t if currently under a commented heading."
> (unless (org-before-first-heading-p)
> (save-excursion
> (org-back-to-heading t)
> (let ((elt (org-element-at-point)))
> (while (and elt
> (not
> (org-element-property :commentedp elt)))
> (setq elt
> (and (org-up-heading-safe)
> (org-element-at-point))))
> elt))))
> #+end_src
>
>
> byt I'm not sure it is very pretty. Opinions ?
Of course, `org-element-at-point' can parse headlines, but if speed is
a factor, since headline syntax is not context-dependent, it is often
worth considering using regexps.
Also, don't forget `org-with-limited-levels' when you need to tell
a headline from an inlinetask.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2014-03-05 19:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 15:44 Bug: [patch] also tangle headlines that begin with lower case string "comment" [8.2.5h (release_8.2.5h-680-g12df70 @ /home/youngfrog/sources/org-mode/lisp/)] Nicolas Richard
2014-03-05 19:08 ` Nicolas Goaziou [this message]
2014-03-05 21:55 ` Nicolas Richard
2014-03-05 21:56 ` Nicolas Richard
2014-03-05 22:27 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ha7cjwdx.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=theonewiththeevillook@yahoo.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.