From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: Getting beginning postiion of a description list
Date: Fri, 16 Jan 2015 18:57:01 +0800 [thread overview]
Message-ID: <877fwnro1u.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87ppafgp1i.fsf@yahoo.fr
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
> Calvin Young <calvinwyoung@gmail.com> writes:
>> How do I need to massage this to give me the beginning of the whole
>> list item? Is there a recommended solution that'd work for both
>> description lists *and* plain lists?
>
> This seems to work for me:
>
> (defun yf/org-beginning-of-item ()
> (let ((element (org-element-at-point)))
> ;; 'plain-list is returned when at the beginning of the first item in the list.
> (when (eq 'plain-list (org-element-type element))
> (save-excursion
> (forward-char)
> (setq element (org-element-at-point))))
> ;; look ancestors to find an 'item element.
> (while (and element
> (not
> (eq 'item
> (org-element-type element))))
> (setq element (org-element-property :parent element)))
> (if (not element)
> (error "Not in a list item")
> (goto-char
> (+ (length (org-element-property :bullet element))
> (org-element-property :begin element))))))
>
> Probably one could use the list API directly (from org-list.el) too.
Indeed, I'd definitely go for the org-list stuff. It's a bit confusing
at first, because it isn't like any of the other org code, but it works
well. Try calling `org-list-struct' on a list; that will probably give
you most of what you need.
next prev parent reply other threads:[~2015-01-16 10:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 4:28 Getting beginning postiion of a description list Calvin Young
2015-01-16 2:31 ` John Kitchin
2015-01-16 5:47 ` Calvin Young
2015-01-16 7:31 ` Nicolas Richard
2015-01-16 10:57 ` Eric Abrahamsen [this message]
2015-01-16 10:58 ` 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=877fwnro1u.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-orgmode@gnu.org \
/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.