* org-export-latex-final-hook not working
@ 2016-06-24 9:01 Giacomo M
2016-06-24 9:11 ` Rasmus
2016-06-24 9:11 ` Nicolas Goaziou
0 siblings, 2 replies; 6+ messages in thread
From: Giacomo M @ 2016-06-24 9:01 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Dear all,
I am using emacs with this configuration file:
#+BEGIN_SRC emacs-lisp
(setq load-path (append (file-expand-wildcards "~/.emacs.d/elpa/*") load-path))
(require 'org)
(require 'org-ref)
(require 'ox-extra)
(ox-extras-activate '(ignore-headlines))
(defun remove-orgmode-latex-labels ()
"Remove labels generated by org-mode"
(interactive)
(let ((case-fold-search nil))
(goto-char 1)
(replace-regexp "\\\\label{sec.*}" "")
)
)
(add-hook 'org-export-latex-final-hook 'remove-orgmode-latex-labels)
#+END_SRC
to load the latest orgmode from melpa and install a hook to remove
unwanted section labels on latex export.
If you open/create any .org file and export it to latex buffer or file,
the hook function is not called. if I visit the buffer and call
remove-orgmode-latex-labels, section labels are removed.
Where is the mistake?
Thanks,
Giacomo
GNU Emacs 24.5.1 (x86_64-w64-mingw32)
Org-mode version 8.3.4 (8.3.4-47-gaf853d-elpa)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-export-latex-final-hook not working
2016-06-24 9:01 org-export-latex-final-hook not working Giacomo M
@ 2016-06-24 9:11 ` Rasmus
2016-06-24 9:22 ` Giacomo M
2016-06-24 9:11 ` Nicolas Goaziou
1 sibling, 1 reply; 6+ messages in thread
From: Rasmus @ 2016-06-24 9:11 UTC (permalink / raw)
To: emacs-orgmode
Giacomo M <jackjackk@gmail.com> writes:
> Dear all,
>
> I am using emacs with this configuration file:
>
> #+BEGIN_SRC emacs-lisp
> (setq load-path (append (file-expand-wildcards "~/.emacs.d/elpa/*") load-path))
> (require 'org)
> (require 'org-ref)
> (require 'ox-extra)
> (ox-extras-activate '(ignore-headlines))
> (defun remove-orgmode-latex-labels ()
> "Remove labels generated by org-mode"
> (interactive)
> (let ((case-fold-search nil))
> (goto-char 1)
> (replace-regexp "\\\\label{sec.*}" "")
> )
> )
> (add-hook 'org-export-latex-final-hook 'remove-orgmode-latex-labels)
> #+END_SRC
There's no such hook.
See org-export-filter-body-functions and
org-export-filter-final-output-functions.
--
Evidence suggests Snowden used a powerful tool called monospaced fonts
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-export-latex-final-hook not working
2016-06-24 9:01 org-export-latex-final-hook not working Giacomo M
2016-06-24 9:11 ` Rasmus
@ 2016-06-24 9:11 ` Nicolas Goaziou
1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2016-06-24 9:11 UTC (permalink / raw)
To: Giacomo M; +Cc: emacs-orgmode@gnu.org
Hello,
Giacomo M <jackjackk@gmail.com> writes:
> I am using emacs with this configuration file:
>
> #+BEGIN_SRC emacs-lisp
> (setq load-path (append (file-expand-wildcards "~/.emacs.d/elpa/*") load-path))
> (require 'org)
> (require 'org-ref)
> (require 'ox-extra)
> (ox-extras-activate '(ignore-headlines))
> (defun remove-orgmode-latex-labels ()
> "Remove labels generated by org-mode"
> (interactive)
> (let ((case-fold-search nil))
> (goto-char 1)
> (replace-regexp "\\\\label{sec.*}" "")
> )
> )
> (add-hook 'org-export-latex-final-hook 'remove-orgmode-latex-labels)
> #+END_SRC
>
> to load the latest orgmode from melpa and install a hook to remove
> unwanted section labels on latex export.
>
> If you open/create any .org file and export it to latex buffer or file,
> the hook function is not called. if I visit the buffer and call
> remove-orgmode-latex-labels, section labels are removed.
>
> Where is the mistake?
There is no such thing as `org-export-latex-final-hook'. You may want to
use `org-export-filter-final-output-functions'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-export-latex-final-hook not working
2016-06-24 9:11 ` Rasmus
@ 2016-06-24 9:22 ` Giacomo M
2016-06-24 9:33 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Giacomo M @ 2016-06-24 9:22 UTC (permalink / raw)
To: emacs-orgmode
Il 24/06/2016 11:11, Rasmus ha scritto:
> Giacomo M <jackjackk@gmail.com> writes:
>
>
>
>> Dear all,
>>
>> I am using emacs with this configuration file:
>>
>> #+BEGIN_SRC emacs-lisp
>> (setq load-path (append (file-expand-wildcards "~/.emacs.d/elpa/*") load-path))
>> (require 'org)
>> (require 'org-ref)
>> (require 'ox-extra)
>> (ox-extras-activate '(ignore-headlines))
>> (defun remove-orgmode-latex-labels ()
>> "Remove labels generated by org-mode"
>> (interactive)
>> (let ((case-fold-search nil))
>> (goto-char 1)
>> (replace-regexp "\\\\label{sec.*}" "")
>> )
>> )
>> (add-hook 'org-export-latex-final-hook 'remove-orgmode-latex-labels)
>> #+END_SRC
> There's no such hook.
>
> See org-export-filter-body-functions and
> org-export-filter-final-output-functions.
>
Thanks.
I found an example for html by Rasmus on the mailing list. Just adapting
it to my case works.
#+BEGIN_SRC emacs-lisp
(defun jackjackk/org-latex-remove-section-labels (string backend info)
"Remove section labels generated by org-mode"
(when (and (org-export-derived-backend-p backend 'latex)
(string-match "\\\\label{sec:.*}" string))
(replace-regexp-in-string "\\\\label{sec:.*}" "" string)))
(add-to-list 'org-export-filter-final-output-functions
'jackjackk/org-latex-remove-section-labels)
#+END_SRC
Best,
Giacomo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-export-latex-final-hook not working
2016-06-24 9:22 ` Giacomo M
@ 2016-06-24 9:33 ` Nicolas Goaziou
2016-06-24 11:02 ` Giacomo M
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-06-24 9:33 UTC (permalink / raw)
To: Giacomo M; +Cc: emacs-orgmode
Giacomo M <jackjackk@gmail.com> writes:
> I found an example for html by Rasmus on the mailing list. Just adapting
> it to my case works.
>
> #+BEGIN_SRC emacs-lisp
> (defun jackjackk/org-latex-remove-section-labels (string backend info)
> "Remove section labels generated by org-mode"
> (when (and (org-export-derived-backend-p backend 'latex)
> (string-match "\\\\label{sec:.*}" string))
> (replace-regexp-in-string "\\\\label{sec:.*}" "" string)))
FWIW, I suggest
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "\\\\label{sec:.*?}" "" string)))
A greedy regexp may give you surprises.
Regards,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: org-export-latex-final-hook not working
2016-06-24 9:33 ` Nicolas Goaziou
@ 2016-06-24 11:02 ` Giacomo M
0 siblings, 0 replies; 6+ messages in thread
From: Giacomo M @ 2016-06-24 11:02 UTC (permalink / raw)
To: emacs-orgmode
Il 24/06/2016 11:33, Nicolas Goaziou ha scritto:
> Giacomo M <jackjackk@gmail.com> writes:
>
>> I found an example for html by Rasmus on the mailing list. Just adapting
>> it to my case works.
>>
>> #+BEGIN_SRC emacs-lisp
>> (defun jackjackk/org-latex-remove-section-labels (string backend info)
>> "Remove section labels generated by org-mode"
>> (when (and (org-export-derived-backend-p backend 'latex)
>> (string-match "\\\\label{sec:.*}" string))
>> (replace-regexp-in-string "\\\\label{sec:.*}" "" string)))
> FWIW, I suggest
>
> (when (org-export-derived-backend-p backend 'latex)
> (replace-regexp-in-string "\\\\label{sec:.*?}" "" string)))
>
> A greedy regexp may give you surprises.
>
> Regards,
Thanks, always learning something!
Giacomo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-24 11:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-24 9:01 org-export-latex-final-hook not working Giacomo M
2016-06-24 9:11 ` Rasmus
2016-06-24 9:22 ` Giacomo M
2016-06-24 9:33 ` Nicolas Goaziou
2016-06-24 11:02 ` Giacomo M
2016-06-24 9:11 ` Nicolas Goaziou
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).