From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: How to get list item depth within the exporter framework? Date: Mon, 27 Jul 2015 10:51:10 -0700 Message-ID: <87h9opa3qp.fsf@berkeley.edu> References: <87h9oq2evj.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJmZ0-0002w8-Ag for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 13:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJmYw-0001Ed-04 for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 13:51:46 -0400 Received: from plane.gmane.org ([80.91.229.3]:51395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJmYv-0001ER-PW for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 13:51:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZJmYm-0008Jb-By for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 19:51:32 +0200 Received: from c-67-169-117-151.hsd1.ca.comcast.net ([67.169.117.151]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jul 2015 19:51:32 +0200 Received: from richard.lawrence by c-67-169-117-151.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jul 2015 19:51:32 +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: emacs-orgmode@gnu.org Hi Marcin, Marcin Borkowski writes: > as I mentioned, I'm writing a simple exporter. However, I stumbled on > something apparently simple. How to get the current list level within > org-whatever-item transcoder? I ran into this problem once; the solution I found was to just walk up the AST via org-export-get-parent until you run out of parents. Something like this should work (untested, and probably needs to be tweaked, as my Elisp is a little rusty): (defun find-depth (element) "Find the depth of a (list) element during export." (let ((parent (org-export-get-parent element))) (case (org-element-type parent) ('item (1+ (find-depth parent))) ('plain-list (find-depth (org-export-get-parent parent))) (t 1)))) Hope that helps! Best, Richard