From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Re: Getting beginning postiion of a description list Date: Fri, 16 Jan 2015 08:31:05 +0100 Message-ID: <87ppafgp1i.fsf@yahoo.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YC1N7-0005SN-Ip for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 02:31:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YC1N0-0001By-Uy for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 02:31:09 -0500 Received: from mxin.ulb.ac.be ([164.15.128.112]:33012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YC1N0-0001Bi-Pc for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 02:31:02 -0500 In-Reply-To: (Calvin Young's message of "Wed, 14 Jan 2015 20:28:52 -0800") 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: Calvin Young Cc: emacs-orgmode@gnu.org Calvin Young 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. -- Nicolas Richard