From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: ignoreheading in LaTeX export Date: Thu, 27 Mar 2014 22:51:27 +0100 Message-ID: <87lhvvjoo0.fsf@gmx.us> References: <87y4zwrpp9.fsf@gmail.com> <87d2h7srdj.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTIBA-00011E-Vl for emacs-orgmode@gnu.org; Thu, 27 Mar 2014 17:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTIB4-00006O-Ve for emacs-orgmode@gnu.org; Thu, 27 Mar 2014 17:49:40 -0400 Received: from plane.gmane.org ([80.91.229.3]:48586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTIB4-00006D-O3 for emacs-orgmode@gnu.org; Thu, 27 Mar 2014 17:49:34 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WTIB3-0003kS-Iw for emacs-orgmode@gnu.org; Thu, 27 Mar 2014 22:49:33 +0100 Received: from dynamic-adsl-94-39-218-180.clienti.tiscali.it ([94.39.218.180]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Mar 2014 22:49:33 +0100 Received: from rasmus by dynamic-adsl-94-39-218-180.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Mar 2014 22:49:33 +0100 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 Alan Schmitt writes: > Nicolas Goaziou writes: > >> I suggest to use the dedicated MATCH argument for `org-map-entries': >> >> (defun as/delete-ignored-heading (backend) >> "Remove every headline with a tag `ignoreheading' in the >> current buffer. BACKEND is the export back-end being used, as >> a symbol." >> (org-map-entries >> (lambda () (delete-region (point) (progn (forward-line) (point)))) >> "+ignoreheading")) > > Thank you, this works, with a big caveat (which makes this approach > broken for me): with the following ECM > > * No Export :noexport: > > test > > * Heading 1 :ignoreheading: > > foo > > * Heading 2 > > bar > > the text under "Heading 1" is no longer present. I suspect the heading is > removed before the ":noexport:" is processed, which captures the text as > well (which is bad: the reason for the heading in the first place is to > end the ":noexport:" block). I went back to the stack-overflow > suggestion. This is why you would want to use a filter rather than a hook (i.e. you only want to retain the Org structure when exporting). Here's a slightly modified version of the filter I use. It sucks, but ignoreheading is quite hard to get right, especially outside of LaTeX. Note the comment in the first defun! If you are unhappy with that limitation you can use a regexp to look for ignoreheading in the first line of org-ignoreheading function. I think I even have an old version somewhere that uses a regexp. (defun rasmus/get-org-headline-string-element (headline backend info) "Return the org element representation of an element. Will NOT work with headlines like this one, that has no text-properties * =verb=" (let ((prop-point (next-property-change 0 headline))) (if prop-point (plist-get (text-properties-at prop-point headline) :parent)))) (defun rasmus/org-latex-ignoreheading (headline backend info) "Strip headline from HEADLINE if it has tag ignoreheading. Somewhat broken for ascii. . . " (when (org-export-derived-backend-p backend 'latex 'ascii) (let ((tags (org-element-property :tags (rasmus/get-org-headline-string-element headline backend info)))) (when (and tags (member-ignore-case "ignoreheading" tags)) (string-match "\\`.*\n.*\n" headline) (replace-match "" nil nil headline))))) (add-to-list 'org-export-filter-headline-functions 'rasmus/org-latex-ignoreheading) —Rasmus -- Sådan en god dansk lagereddike kan man slet ikke bruge mere