emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-e-latex: ignoreheading is not working any more.
@ 2012-11-20 23:43 Yagnesh Raghava Yakkala
  2012-11-21 12:37 ` Myles English
  0 siblings, 1 reply; 9+ messages in thread
From: Yagnesh Raghava Yakkala @ 2012-11-20 23:43 UTC (permalink / raw)
  To: emacs-orgmode


Hi,

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.?

Thanks.,
--
ఎందరో మహానుభావులు అందరికి వందనములు
YYR

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Myles English @ 2012-11-21 12:37 UTC (permalink / raw)
  To: Yagnesh Raghava Yakkala; +Cc: emacs-orgmode


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.?

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

Myles

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2012-11-21 12:37 ` Myles English
@ 2012-11-21 13:21   ` Nicolas Goaziou
  2012-11-21 15:15     ` Myles English
  2013-01-08 15:40     ` Sebastian Hofer
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2012-11-21 13:21 UTC (permalink / raw)
  To: Myles English; +Cc: Yagnesh Raghava Yakkala, emacs-orgmode

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2012-11-21 13:21   ` Nicolas Goaziou
@ 2012-11-21 15:15     ` Myles English
  2013-01-08 15:40     ` Sebastian Hofer
  1 sibling, 0 replies; 9+ messages in thread
From: Myles English @ 2012-11-21 15:15 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Yagnesh Raghava Yakkala, emacs-orgmode


Hi Nicolas,

Nicolas Goaziou writes:

> 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.

[kicks self]

> #+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.

Thank you, there is lots of useful stuff to learn from in your reply, as
always.

Myles

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2012-11-21 13:21   ` Nicolas Goaziou
  2012-11-21 15:15     ` Myles English
@ 2013-01-08 15:40     ` Sebastian Hofer
  2013-01-09 15:17       ` Nicolas Goaziou
  1 sibling, 1 reply; 9+ messages in thread
From: Sebastian Hofer @ 2013-01-08 15:40 UTC (permalink / raw)
  To: emacs-orgmode

At Wed, 21 Nov 2012 14:21:25 +0100,
Nicolas Goaziou wrote:

> >> I have been using example setting suggested by Nicolas
> >> (http://article.gmane.org/gmane.emacs.orgmode/55972) to tell exporter to skip
> 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).
Hi Nicolas,

Using said code-snippet I get following error:

funcall: Wrong number of arguments: (lambda (headline contents info)
(if (member "ignoreheading" (org-element-property :tags headline))
contents (org-e-latex-headline headline contents info))), 2

Does this have to do with this next comment, or is this unrelated?

> Also, the hook will now be called with an argument: the back-end used as
> a symbol.
>
> Otherwise, the thread is still valid.

If yes I couldn't figure out which hook you were talking about. Could
you give a few more details please?

Thanks in advance
Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2013-01-08 15:40     ` Sebastian Hofer
@ 2013-01-09 15:17       ` Nicolas Goaziou
  2013-01-09 19:18         ` Sebastian Hofer
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2013-01-09 15:17 UTC (permalink / raw)
  To: Sebastian Hofer; +Cc: emacs-orgmode

Hello,

Sebastian Hofer <sebhofer@gmail.com> writes:

> Using said code-snippet I get following error:
>
> funcall: Wrong number of arguments: (lambda (headline contents info)
> (if (member "ignoreheading" (org-element-property :tags headline))
> contents (org-e-latex-headline headline contents info))), 2

Would you mind pasting again the code you're using? I have lost the
track of the thread.

> Does this have to do with this next comment, or is this unrelated?
>
>> Also, the hook will now be called with an argument: the back-end used as
>> a symbol.
>>
>> Otherwise, the thread is still valid.
>
> If yes I couldn't figure out which hook you were talking about. Could
> you give a few more details please?

I was talking about `org-export-before-processing-hook' or
`org-export-before-parsing-hook', but it should be unrelated to the
problem at hand.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2013-01-09 15:17       ` Nicolas Goaziou
@ 2013-01-09 19:18         ` Sebastian Hofer
  2013-01-10 18:44           ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Hofer @ 2013-01-09 19:18 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Sebastian Hofer, emacs-orgmode

At Wed, 09 Jan 2013 16:17:06 +0100,
Nicolas Goaziou wrote:
> 
> Hello,
> 
> Sebastian Hofer <sebhofer@gmail.com> writes:
> 
> > Using said code-snippet I get following error:
> >
> > funcall: Wrong number of arguments: (lambda (headline contents info)
> > (if (member "ignoreheading" (org-element-property :tags headline))
> > contents (org-e-latex-headline headline contents info))), 2
> 
> Would you mind pasting again the code you're using? I have lost the
> track of the thread.


Sorry, it was stupid not to do it in the first place (I posted from
gmane.com and it complained about too much quoted text). Anyway, here
is the code I was talking about (from
http://article.gmane.org/gmane.emacs.orgmode/55972):

#+BEGIN_SRC emacs-lisp
(defun my-e-latex-headline (headline contents info)
  (if (member "ignoreheading" (org-element-property :tags headline)) contents
    (org-e-latex-headline headline contents info)))
#+END_SRC

#+BEGIN_SRC emacs-lisp
(org-export-define-derived-backend dissertation e-latex
  :translate-alist ((template . my-e-latex-headline)))

(defun org-dissertation-export-to-pdf
  (&optional subtreep visible-only body-only ext-plist pub-dir)
  (interactive)
  (org-e-latex-compile
   (let ((outfile (org-export-output-file-name ".tex" subtreep pub-dir)))
     (org-export-to-file
      'dissertation outfile subtreep visible-only body-only ext-plist))))
#+END_SRC

> 
> > Does this have to do with this next comment, or is this unrelated?
> >
> >> Also, the hook will now be called with an argument: the back-end used as
> >> a symbol.
> >>
> >> Otherwise, the thread is still valid.
> >
> > If yes I couldn't figure out which hook you were talking about. Could
> > you give a few more details please?
> 
> I was talking about `org-export-before-processing-hook' or
> `org-export-before-parsing-hook', but it should be unrelated to the
> problem at hand.
>

Thanks for your help!
Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2013-01-09 19:18         ` Sebastian Hofer
@ 2013-01-10 18:44           ` Nicolas Goaziou
  2013-01-10 19:04             ` Sebastian Hofer
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2013-01-10 18:44 UTC (permalink / raw)
  To: Sebastian Hofer; +Cc: emacs-orgmode

Hello,

Sebastian Hofer <sebhofer@gmail.com> writes:

> #+BEGIN_SRC emacs-lisp
> (defun my-e-latex-headline (headline contents info)
>   (if (member "ignoreheading" (org-element-property :tags headline)) contents
>     (org-e-latex-headline headline contents info)))
> #+END_SRC

I suggest to use:

  (org-export-with-backend 'e-latex headline contents info)

instead of

  (org-e-latex-headline headline contents info)

to not depend on the name of the translator function used by the e-latex
back-end.

> #+BEGIN_SRC emacs-lisp
> (org-export-define-derived-backend dissertation e-latex
>   :translate-alist ((template . my-e-latex-headline)))

There's a typo here. It should be:

    :translate-alist ((headline . my-e-latex-headline))


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-e-latex: ignoreheading is not working any more.
  2013-01-10 18:44           ` Nicolas Goaziou
@ 2013-01-10 19:04             ` Sebastian Hofer
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Hofer @ 2013-01-10 19:04 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Sebastian Hofer, emacs-orgmode

At Thu, 10 Jan 2013 19:44:32 +0100,
Nicolas Goaziou wrote:
> 
> Hello,
> 
> Sebastian Hofer <sebhofer@gmail.com> writes:
> 
> > #+BEGIN_SRC emacs-lisp
> > (defun my-e-latex-headline (headline contents info)
> >   (if (member "ignoreheading" (org-element-property :tags headline)) contents
> >     (org-e-latex-headline headline contents info)))
> > #+END_SRC
> 
> I suggest to use:
> 
>   (org-export-with-backend 'e-latex headline contents info)
> 
> instead of
> 
>   (org-e-latex-headline headline contents info)
> 
> to not depend on the name of the translator function used by the e-latex
> back-end.
> 
> > #+BEGIN_SRC emacs-lisp
> > (org-export-define-derived-backend dissertation e-latex
> >   :translate-alist ((template . my-e-latex-headline)))
> 
> There's a typo here. It should be:
> 
>     :translate-alist ((headline . my-e-latex-headline))

That worked perfectly! Thanks!

Regards,
Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-01-10 22:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).