From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Myles English <mylesenglish@gmail.com>
Cc: Yagnesh Raghava Yakkala <hi@yagnesh.org>, emacs-orgmode@gnu.org
Subject: Re: org-e-latex: ignoreheading is not working any more.
Date: Wed, 21 Nov 2012 14:21:25 +0100 [thread overview]
Message-ID: <87r4nndrca.fsf@gmail.com> (raw)
In-Reply-To: <87a9ubi134.fsf@gmail.com> (Myles English's message of "Wed, 21 Nov 2012 12:37:19 +0000")
Hello,
Myles English <mylesenglish@gmail.com> writes:
> Hi Yagnesh,
>
> Yagnesh Raghava Yakkala writes:
>> I have been using example setting suggested by Nicolas
>> (http://article.gmane.org/gmane.emacs.orgmode/55972) to tell exporter to skip
>> particular headline (with ignoreheading tag).
>>
>> It seems recent commit made this setup obsolete. could anybody suggest me the
>> alternative setting for this.?
There are only two changes:
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-e-latex-translate-table '(headline . my-e-latex-headline))
#+END_SRC
is obsolete since `org-e-latex-translate-table' variable has been
removed. If you want to install a new translator, you have to create
a derived back-end, which is easy (see the example at the end of that
link).
Also, the hook will now be called with an argument: the back-end used as
a symbol.
Otherwise, the thread is still valid.
> I've been using this, (I notice it is significantly longer than the
> example in the link above so it may be overkill):
>
> #+BEGIN_SRC emacs-lisp
> (defun my-export-delete-headlines-tagged-noheading(heading-text)
> "Goto headline `heading-text'"
> (let ((wasfound t))
> (while wasfound
> (progn (org-element-map
> (org-element-parse-buffer 'headline)
> 'headline
> (lambda (x)
> (if (member "noheading" (org-element-property :tags x))
> (progn
> (goto-char (org-element-property :begin x))
> (delete-region (point)
> (progn
> (forward-line 1)
> (point)))
> (goto-char (point-min)))
> (setq wasfound nil)))
> nil
> t)) ;; stop at first find,
> nil) ;; start again from the top of the buffer
> (goto-char (point-min))))
>
> (add-to-list 'org-export-before-processing-hook
> 'my-export-delete-headlines-tagged-noheading)
> #+END_SRC
Each time you delete an headline, you parse the full buffer again, so,
yes, it will be slow. You can simply reverse list returned by
`org-element-map' (but don't stop at first find) and walk that list,
deleting matching headlines along the way.
#+begin_src emacs-lisp
(defun my-export-delete-headlines-tagged-noheading (backend)
(dolist (hl (nreverse (org-element-map (org-element-parse-buffer 'headline)
'headline
'identity)))
(when (member "noheading" (org-element-property :tags hl))
(goto-char (org-element-property :begin hl))
(delete-region (point) (progn (forward-line) (point))))))
#+end_src
Another option is to use `org-map-entries', which doesn't require to
reverse the results (and doesn't use Org Element). This is left as an
exercise.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2012-11-21 13:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-20 23:43 org-e-latex: ignoreheading is not working any more Yagnesh Raghava Yakkala
2012-11-21 12:37 ` Myles English
2012-11-21 13:21 ` Nicolas Goaziou [this message]
2012-11-21 15:15 ` Myles English
2013-01-08 15:40 ` Sebastian Hofer
2013-01-09 15:17 ` Nicolas Goaziou
2013-01-09 19:18 ` Sebastian Hofer
2013-01-10 18:44 ` Nicolas Goaziou
2013-01-10 19:04 ` Sebastian Hofer
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=87r4nndrca.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=hi@yagnesh.org \
--cc=mylesenglish@gmail.com \
/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.