Re: [O] Replacing property-name hangs Emacs
Thorsten Jolitz tjol...@gmail.com writes: Hi List, seems to be an Org problem: when doing query-replace or replace-string on the name of a headline property, Emacs hangs with 100pc CPU and I have to restart. MWE and emacs -Q not possible, sorry, I tried... PS Org-mode version 8.3beta (release_8.3beta-44-g05be57 @ /usr/share/emacs/24.3/lisp/org/lisp/) GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2) of 2014-06-11 on var-lib-archbuild-staging-x86_64-jgc Here is a copy of what I sent to the emacs-help list, this seems to be an Org parser problem (or a configuration problem - cannot reproduce it with emacs -Q): #+begin_quote Try sending the Emacs process a SIGUSR2, this forces it into the (Lisp level) debugger. Maybe you then can see what it does. You mean like this: kill -s usr2 4352 (get the PID with 'ps -e | grep emacs') or, equivalently (?) pkill --signal usr2 emacs nice tip, thanks, I hope I remember this! Here is the beginning of the file where I want to replace :resource_id: with :name: by doing , | M-%: resource_id RET name RET ` Emacs hangs already at the 2nd (piano) entry. #+begin_src org * Instruments ** rhythm-section *** harmony guitar :PROPERTIES: :name: guitar :abbrev: g :END: piano :PROPERTIES: :name: piano :abbrev: p :END: *** rhythm bass :PROPERTIES: :resource_id: bass :abbrev: b :END: drums :PROPERTIES: :resource_id: drums :abbrev: dr :END: ** horns :PROPERTIES: :resource_id: horns :abbrev: hrs :END: #+end_src here is the backtrace I get, it seems to be an Org-mode (cache?) problem - should I move this report to the Org mailing list? Debugger entered--Lisp error: (quit) looking-at(^\\(\\*+\\)\\(?: +\\(TODO\\|NEXT\\|DONE\\|WAITING\\|HOLD\\|CANCELLED\\|PHONE\\)\\)?\\(?: +\\(\\[#.\\]\\)\\)?\\(?: +\\(.*?\\)\\)??\\(?:[ ]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ ]*$) org-heading-components() org-element-headline-parser(116 t) org-element--current-element(116 element nil nil) byte-code(\212\214~\210^Hb\210 \205..\306\307!\204..\n\205..\310^H\311\.\312^K..\f;\203+.\313\314.\f#\2021.\315\fA@.\*..\311\211../^K\204`.\316.0\317 \211.1.2\320.1P.3\321 ,\203V.\311y\210\322\311w\210\323 \210\202?.^H..U\203\217.\324\325.4\203\211.\326^K..\f;\203^?.\313\314.\f#\202\205.\315\fA@.\*\202\212.^K\\210\202?.\327\316.0\317 \211.1.2\320.1P+..\316#\203\263.\311y\210\322\311w\210\323 \210\202?.^Kd^HU\203\277.^HS\202\300.^H..5\330^K..\f;\203\324.\313\314.\f#\202\332.\315\fA@.\*\206\340...b\210\331.5..\f;\203\364.\313\314.\f#\202\372.\315\fA@.\*\211.6^HX\205%..6b\205%.\326.5..\f;\203..\313\314.\f#\202!.\315\fA@.\*\211.5)\204\342..5\203.m\2038..5.\202..5.`./*\331\f..\f;\203P.\313\314.\f#\202V.\315\fA@.\*\206q.\212\316.0\317 \211.1.2\320.1P.3\332 \210,`)\f\311.7.8.6.4\203\251.`^HU\203\215.\324\325.8\\210\202\251..9\211.9\205\240.\333 \206\240.\334.9\335 \)\203\251.\324\336\311\\210\f\204\370.\337.6\304.7\340.8..\f;\203\305.\313\314.\f#\202\313.\315\fA@.\*$\211.\326.8.:.\211.;\203\345.\341\f\311..:$\202\362.\fA\342\fA@..:#\240\210\f+\210\343\f!\210\331\f..\f;\203 .\313\314.\f#\202..\315\fA@.\*\f\211.:\204 .\f;\205(.\344\202(.\f@9\205(.\f@).;\211.^HX\203A.d.U\204A..b\210\202\376..;.=\204Q.\324\325\f\\210\202\376.\330\f..\f;\203b.\313\314.\f#\202h.\315\fA@.\*\345\f..\f;\203z.\313\314.\f#\202\200.\315\fA@.\*..?.4\204\276..?\205\365..\205\365..?^HW\204\252..?^HU\205\365..;\346?\205\365..^HV\204\276..^HU\205\365.d^HU\205\365../\206\305..?b\210\311./\347.;\350\\203\326.\351\202\353.\347.;\352\\203\342.\353\202\353.\347.;\354\\205\353.\355.7\f.8.\211.6*\204\376.\324\325\f\\210*\311.\202y. [pos org-element-use-cache orgstruct-mode cached element property derived-mode-p org-mode org-element--cache-find nil :begin get-text-property 0 plist-get t org-get-limited-outline-regexp ^ outline-previous-heading . \n beginning-of-line throw exit :parent re-search-backward :contents-begin :end outline-next-heading input-pending-p time-less-p current-time interrupt org-element--current-element :structure org-add-props plist-put org-element--cache-put plain-text :contents-end (plain-list table) eql plain-list item property-drawer node-property table table-row begin next org-called-with-limited-levels org-outline-regexp ...] 9) org-element--parse-to(120 t nil) byte-code(^H\306H\307U\203\f.\310\311\215\210^H\306H\312U\203U.^H\307H
Re: [O] Emacs with Org 8?
Nicolas Richard theonewiththeevillook at yahoo.fr writes: snip Alternatively you can update to Org 8 via elpa. (M-x list-packages). snip Thanks :) I really wanted to move to Org 8, but I'd been putting off upgrading for months, as I thought it was a complicated procedure, which would take a lot of time to figure out. Turns out it only took a few minutes, with everything explained here: http://orgmode.org/elpa.html :)
[O] [BUG] in org-element (was Re: Replacing property-name hangs Emacs)
Thorsten Jolitz tjol...@gmail.com writes: This turned out to be an Org-mode bug. Org-mode version 8.3beta (release_8.3beta-44-g05be57 @ /usr/share/emacs/24.3/lisp/org/lisp/) GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2) of 2014-06-11 on var-lib-archbuild-staging-x86_64-jgc Here is the recipe: 1. emacs -Q 2. M-x find-file instruments.org (content posted below) 3. M-% resource_id RET name RET 4. hit space quickly (- accept) until Emacs hangs (100pc CPU) PS content of instruments.org: #+begin_src org * Instruments ** rhythm-section *** harmony guitar :PROPERTIES: :resource_id: guitar :abbrev: g :END: piano :PROPERTIES: :resource_id: piano :abbrev: p :END: *** rhythm bass :PROPERTIES: :resource_id: bass :abbrev: b :END: drums :PROPERTIES: :resource_id: drums :abbrev: dr :END: ** horns :PROPERTIES: :resource_id: horns :abbrev: hrs :END: *** brass trumpet :PROPERTIES: :resource_id: trumpet :abbrev: tr :pitch:+2 :END: trombone :PROPERTIES: :resource_id: trombone :abbrev: tmb :END: *** woodwinds sopran-sax :PROPERTIES: :resource_id: sopran-sax :abbrev: ss :END: alt-sax :PROPERTIES: :resource_id: alt-sax :abbrev: as :pitch:-3 :END: tenor-sax :PROPERTIES: :resource_id: tenor-sax :abbrev: ts :pitch:+2 :END: bariton-sax :PROPERTIES: :resource_id: bariton-sax :abbrev: bs :END: flute :PROPERTIES: :resource_id: flute :abbrev: fl :END: *** voices sopran-voice :PROPERTIES: :resource_id: sopran-voice :abbrev: svoc :END: alt-voice :PROPERTIES: :resource_id: alt-voice :abbrev: avoc :END: tenor_voice :PROPERTIES: :resource_id: tenor-voice :abbrev: tvoc :END: bariton-voice :PROPERTIES: :resource_id: bariton-voice :abbrev: bvoc :END: *** strings violin :PROPERTIES: :resource_id: violin :abbrev: v :END: Cello :PROPERTIES: :resource_id: cello :abbrev: c :END: #+end_src Backtrace: Debugger entered--Lisp error: (quit) (progn (goto-char end) (skip-chars-backward . \n) (forward-line) (point)) (and contents-begin (progn (goto-char end) (skip-chars-backward . \n) (forward-line) (point))) (let* ((components (org-heading-components)) (level (nth 1 components)) (todo (nth 2 components)) (todo-type (and todo (if (member todo org-done-keywords) (quote done) (quote todo (tags (let ((raw-tags (nth 5 components))) (and raw-tags (org-split-string raw-tags : (raw-value (or (nth 4 components) )) (commentedp (let ((case-fold-search nil)) (string-match (format ^%s\\( \\|$\\) org-comment-string) raw-value))) (archivedp (member org-archive-tag tags)) (footnote-section-p (and org-footnote-section (string= org-footnote-section raw-value))) (standard-props (let ((end (save-excursion (let* ... ...) (point))) plist) (save-excursion (while (and (null plist) (re-search-forward org-property-start-re end t)) (let (...) (if ... ...))) plist))) (time-props (save-excursion (forward-line) (if (looking-at org-planning-or-clock-line-re) (progn (let (... plist) (while ... ... ... ...) plist) (begin (point)) (end (min (save-excursion (org-end-of-subtree t t)) limit)) (pos-after-head (progn (forward-line) (point))) (contents-begin (save-excursion (skip-chars-forward . \n end) (and (/= (point) end) (line-beginning-position (contents-end (and contents-begin (progn (goto-char end) (skip-chars-backward . \n) (forward-line) (point) (if commentedp (progn (let ((case-fold-search nil)) (setq raw-value (replace-regexp-in-string (concat (regexp-quote org-comment-string) \\(?: \\|$\\)) raw-value) (if archivedp (progn (setq tags (delete org-archive-tag tags (let ((headline (list (quote headline) (nconc (list :raw-value raw-value :begin begin :end end :pre-blank (if ... 0 ...) :contents-begin contents-begin :contents-end contents-end :level level :priority (nth 3 components) :tags tags :todo-keyword todo :todo-type todo-type :post-blank (count-lines ... end) :footnote-section-p footnote-section-p :archivedp archivedp :commentedp commentedp) time-props standard-props (let ((alt-title (org-element-property :ALT_TITLE headline))) (if alt-title (progn (org-element-put-property headline :alt-title (if raw-secondary-p alt-title (org-element-parse-secondary-string alt-title ... headline)) (org-element-put-property headline :title (if raw-secondary-p raw-value (org-element-parse-secondary-string raw-value (org-element-restriction (quote headline)) headline) (save-excursion (let* ((components (org-heading-components)) (level (nth 1 components)) (todo (nth 2 components)) (todo-type (and todo
Re: [O] Emacs with Org 8?
SabreWolfy sabrewo...@gmail.com writes: Nicolas Richard theonewiththeevillook at yahoo.fr writes: snip Alternatively you can update to Org 8 via elpa. (M-x list-packages). snip Thanks :) I really wanted to move to Org 8, but I'd been putting off upgrading for months, as I thought it was a complicated procedure, which would take a lot of time to figure out. Turns out it only took a few minutes, with everything explained here: http://orgmode.org/elpa.html :) http://orgmode.org/worg/org-8.0.html Keep this page in mind in case you encounter problems - some variables have changed names e.g., and the whole export mechanism was revamped: you may come up against an upgrade problem some time *after* you upgrade :-) -- Nick
[O] export to latex without labels
Hello experts, I've been fiddling around for a while now with the following problem: When I export something from org to latex I get plenty of \labels that I never refer to. I'd like to get rid of all those labels. I found some code [1] that uses a hook that does not work in orgmode anymore. So I tried to adapt that code to the new orgmode way with org-export-filter-final-functions: (defun ks/org-latex-remove-labels (backend info) Remove labels generated by org-mode (when (org-export-derived-backend-p backend 'latex) (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ) ))) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-final-output-functions 'ks/org-latex-remove-labels)) When I now try to export something from org to latex, I get the following error message: Wrong number of arguments: (lambda (backend) Remove labels generated by org-mode (if (org-export-derived-backend-p backend (quote latex)) (progn (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ), 3 I am just an emacs user, not a programmer, and I have no idea what's wrong and what I have to change to make it work. Can anyone give me a hint? TIA, Salome [1] http://stackoverflow.com/questions/18076328/org-mode-export-to-latex-suppress-generation-of-labels
Re: [O] still seeing semi-regular lockups
FWIW, I'm still getting regular lockups with the cache. I'll dig into it further when I have time. I'm still being locked up from time to time, maybe less than before I guess. What I said was that I never got the deadly problem of Lisp nesting exceeds `max-lisp-eval-depth, and the fix had been a life saver for me.
Re: [O] export to latex without labels
Salome Södergran\ salome.soederg...@gmx.ch writes: Hello experts, I've been fiddling around for a while now with the following problem: When I export something from org to latex I get plenty of \labels that I never refer to. I'd like to get rid of all those labels. I found some code [1] that uses a hook that does not work in orgmode anymore. So I tried to adapt that code to the new orgmode way with org-export-filter-final-functions: (defun ks/org-latex-remove-labels (backend info) Remove labels generated by org-mode (when (org-export-derived-backend-p backend 'latex) (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ) ))) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-final-output-functions 'ks/org-latex-remove-labels)) When I now try to export something from org to latex, I get the following error message: Wrong number of arguments: (lambda (backend) Remove labels generated by org-mode (if (org-export-derived-backend-p backend (quote latex)) (progn (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ), 3 I am just an emacs user, not a programmer, and I have no idea what's wrong and what I have to change to make it work. Can anyone give me a hint? TIA, Salome The error message is telling you that the wrong number of arguments were passed to your filter function. If you look at the doctoring of org-export-filter-final-output-functions, you'll see that functions in this filter are passed three arguments (note the 3 at the end of your error message), but your function only accepts two. Once you've sorted that out, you'll see that the argument you're missing is an argument representing the full exported string. That means that `replace-regexp' is probably the wrong function to be using inside your function. Actually, if you look at the docstring of replace-regexp, that was the wrong function to be using anyway :) It recommends using a combination of re-search-forward and replace-match in lisp functions. Since you've got a string, try replace-regexp-in-string instead! See the docstring... Lastly, it's possible that you could use a more narrowly-targeted filter for this particular case (rather than filter-final-output, which doesn't kick in until everything else is done). When exporting to latex, the element that turns into \label is a target, and that happens in org-latex-target. The corresponding filter is org-export-filter-target-functions, so you might consider putting your function in that variable instead. That could be much simpler: the function would take three arguments, the second of which is the backend, as a symbol. You could just check if the symbol was 'latex, and have the function return an empty string. The function body could be as simple as: (defun org-latex-remove-labels (string backend data) (if (org-export-derived-backend-p backend 'latex) string)) I haven't tested this for unexpected consequences, mind you... Really really lastly, does it really matter if there are unused \labels in the output? E
Re: [O] export to latex without labels
Eric Abrahamsen e...@ericabrahamsen.net writes: Salome Södergran\ salome.soederg...@gmx.ch writes: Hello experts, I've been fiddling around for a while now with the following problem: When I export something from org to latex I get plenty of \labels that I never refer to. I'd like to get rid of all those labels. I found some code [1] that uses a hook that does not work in orgmode anymore. So I tried to adapt that code to the new orgmode way with org-export-filter-final-functions: (defun ks/org-latex-remove-labels (backend info) Remove labels generated by org-mode (when (org-export-derived-backend-p backend 'latex) (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ) ))) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-final-output-functions 'ks/org-latex-remove-labels)) When I now try to export something from org to latex, I get the following error message: Wrong number of arguments: (lambda (backend) Remove labels generated by org-mode (if (org-export-derived-backend-p backend (quote latex)) (progn (let ((case-fold-search nil)) (goto-char 1) (replace-regexp label{sec-[0-9][^}]*} ), 3 I am just an emacs user, not a programmer, and I have no idea what's wrong and what I have to change to make it work. Can anyone give me a hint? TIA, Salome The error message is telling you that the wrong number of arguments were passed to your filter function. If you look at the doctoring of org-export-filter-final-output-functions, you'll see that functions in this filter are passed three arguments (note the 3 at the end of your error message), but your function only accepts two. Once you've sorted that out, you'll see that the argument you're missing is an argument representing the full exported string. That means that `replace-regexp' is probably the wrong function to be using inside your function. Actually, if you look at the docstring of replace-regexp, that was the wrong function to be using anyway :) It recommends using a combination of re-search-forward and replace-match in lisp functions. Since you've got a string, try replace-regexp-in-string instead! See the docstring... Lastly, it's possible that you could use a more narrowly-targeted filter for this particular case (rather than filter-final-output, which doesn't kick in until everything else is done). When exporting to latex, the element that turns into \label is a target, and that happens in org-latex-target. The corresponding filter is org-export-filter-target-functions, so you might consider putting your function in that variable instead. That could be much simpler: the function would take three arguments, the second of which is the backend, as a symbol. You could just check if the symbol was 'latex, and have the function return an empty string. The function body could be as simple as: (defun org-latex-remove-labels (string backend data) (if (org-export-derived-backend-p backend 'latex) string)) I haven't tested this for unexpected consequences, mind you... Really really lastly, does it really matter if there are unused \labels in the output? Hmm, that might have been too much information. What I'm proposing is just this: (defun ks/org-latex-remove-labels (string backend info) Remove labels generated by org-mode (if (org-export-derived-backend-p backend 'latex) string)) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-target-functions 'ks/org-latex-remove-labels))
Re: [O] export to latex without labels
Eric Abrahamsen e...@ericabrahamsen.net writes: Salome Södergran\ salome.soederg...@gmx.ch writes: Hello experts, I've been fiddling around for a while now with the following problem: When I export something from org to latex I get plenty of \labels that I never refer to. I'd like to get rid of all those labels. ... ... Really really lastly, does it really matter if there are unused \labels in the output? What he said: stop worrying and (let org export) label everything :-) In a similar vein, in N. David Mermin's *wonderful* book Boojums all the way through, there is a chapter entitled What's wrong with these equations? (the article is available on line at http://www.ai.mit.edu/courses/6.899/papers/mermin.pdf - but the whole book is worth reading) where he mentions Fisher's rule: number *every* equation in your manuscript. -- Nick
[O] Help with export filter?
Aloha all, Inspired by discussions and code on the mailing list, I managed to cobble together the headline filter below. It works in that the pdf output from LaTeX export is exactly what I want. I'm thrilled! It has one unwanted side effect. In the tex file, a headline tagged with either :newpage: or :clearpage: includes some extra baggage, like this: \newpage \section*{Introduction\hfill{}\textsc{}} \label{sec-5} I tried setting the option tags:nil, but then my export tags had no effect. Can someone suggest how I can avoid the \hfill etc.? Or, am I picking nits here? * Filter headline tags #+name: filter-headline-tags #+BEGIN_SRC emacs-lisp :results silent (defun tsd-filter-headline-tags (contents backend info) Ignore headlines with tag `ignoreheading' and/or start LaTeX section with `newpage' or `clearpage' command. (cond ((and (org-export-derived-backend-p backend 'latex) (string-match \\`.*newpage.*\n (downcase contents)) (string-match \\`.*ignoreheading.*\n (downcase contents))) (replace-match newpage\n nil nil contents)) ((and (org-export-derived-backend-p backend 'latex) (string-match \\`.*clearpage.*\n (downcase contents)) (string-match \\`.*ignoreheading.*\n (downcase contents))) (replace-match clearpage\n nil nil contents)) ((and (org-export-derived-backend-p backend 'latex 'html 'ascii) (string-match \\`.*ignoreheading.*\n (downcase contents))) (replace-match nil nil contents)) ((and (org-export-derived-backend-p backend 'latex) (string-match \\(\\`.*\\)newpage\\(.*\n\\) (downcase contents))) (replace-match newpage\n\\1\\2 nil nil contents)) ((and (org-export-derived-backend-p backend 'latex) (string-match \\(\\`.*\\)clearpage\\(.*\n\\) (downcase contents))) (replace-match clearpage\n\\1\\2 nil nil contents #+END_SRC All the best, Tom -- T.S. Dye Colleagues, Archaeologists 735 Bishop St, Suite 315, Honolulu, HI 96813 Tel: 808-529-0866, Fax: 808-529-0884 http://www.tsdye.com
Re: [O] export to latex without labels
Hi Eric, Eric Abrahamsen e...@ericabrahamsen.net writes: The error message is telling you that the wrong number of arguments were passed to your filter function. If you look at the doctoring of org-export-filter-final-output-functions, you'll see that functions in this filter are passed three arguments (note the 3 at the end of your error message), but your function only accepts two. Once you've sorted that out, you'll see that the argument you're missing is an argument representing the full exported string. That means that `replace-regexp' is probably the wrong function to be using inside your function. Actually, if you look at the docstring of replace-regexp, that was the wrong function to be using anyway :) It recommends using a combination of re-search-forward and replace-match in lisp functions. Since you've got a string, try replace-regexp-in-string instead! See the docstring... Lastly, it's possible that you could use a more narrowly-targeted filter for this particular case (rather than filter-final-output, which doesn't kick in until everything else is done). When exporting to latex, the element that turns into \label is a target, and that happens in org-latex-target. The corresponding filter is org-export-filter-target-functions, so you might consider putting your function in that variable instead. That could be much simpler: the function would take three arguments, the second of which is the backend, as a symbol. You could just check if the symbol was 'latex, and have the function return an empty string. The function body could be as simple as: (defun org-latex-remove-labels (string backend data) (if (org-export-derived-backend-p backend 'latex) string)) I haven't tested this for unexpected consequences, mind you... Really really lastly, does it really matter if there are unused \labels in the output? [...] Hmm, that might have been too much information. What I'm proposing is just this: (defun ks/org-latex-remove-labels (string backend info) Remove labels generated by org-mode (if (org-export-derived-backend-p backend 'latex) string)) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-target-functions 'ks/org-latex-remove-labels)) Thank you so much for your explanations! That was NOT too much information but exactly what I'd been hoping for. It's this sort of information that helps me to come to a better understanding of emacs. I have tested your suggestion with just no result whatsoever. But with the help of your explanations I've managed to change my bit of code accordingly and now it works: (defun ks/org-latex-remove-labels (string backend info) Remove labels generated by org-mode (when (org-export-derived-backend-p backend 'latex) (let ((case-fold-search nil)) (goto-char 1) (replace-regexp-in-string label{sec-[0-9][^}]*}\n string) ))) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-final-output-functions 'ks/org-latex-remove-labels)) Thanks again! Salome
Re: [O] export to latex without labels
Salome Soedergran salome.soederg...@gmx.ch writes: Hi Eric, Eric Abrahamsen e...@ericabrahamsen.net writes: The error message is telling you that the wrong number of arguments were passed to your filter function. If you look at the doctoring of org-export-filter-final-output-functions, you'll see that functions in this filter are passed three arguments (note the 3 at the end of your error message), but your function only accepts two. Once you've sorted that out, you'll see that the argument you're missing is an argument representing the full exported string. That means that `replace-regexp' is probably the wrong function to be using inside your function. Actually, if you look at the docstring of replace-regexp, that was the wrong function to be using anyway :) It recommends using a combination of re-search-forward and replace-match in lisp functions. Since you've got a string, try replace-regexp-in-string instead! See the docstring... Lastly, it's possible that you could use a more narrowly-targeted filter for this particular case (rather than filter-final-output, which doesn't kick in until everything else is done). When exporting to latex, the element that turns into \label is a target, and that happens in org-latex-target. The corresponding filter is org-export-filter-target-functions, so you might consider putting your function in that variable instead. That could be much simpler: the function would take three arguments, the second of which is the backend, as a symbol. You could just check if the symbol was 'latex, and have the function return an empty string. The function body could be as simple as: (defun org-latex-remove-labels (string backend data) (if (org-export-derived-backend-p backend 'latex) string)) I haven't tested this for unexpected consequences, mind you... Really really lastly, does it really matter if there are unused \labels in the output? [...] Hmm, that might have been too much information. What I'm proposing is just this: (defun ks/org-latex-remove-labels (string backend info) Remove labels generated by org-mode (if (org-export-derived-backend-p backend 'latex) string)) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-target-functions 'ks/org-latex-remove-labels)) Thank you so much for your explanations! That was NOT too much information but exactly what I'd been hoping for. It's this sort of information that helps me to come to a better understanding of emacs. I have tested your suggestion with just no result whatsoever. But with the help of your explanations I've managed to change my bit of code accordingly and now it works: Yes, that's the danger with totally untested suggestions :) Turns out the \labels are hard-coded, and the target stuff is something else entirely. Glad you got it working, despite that! (defun ks/org-latex-remove-labels (string backend info) Remove labels generated by org-mode (when (org-export-derived-backend-p backend 'latex) (let ((case-fold-search nil)) (goto-char 1) (replace-regexp-in-string label{sec-[0-9][^}]*}\n string) ))) (eval-after-load 'ox-latex '(add-to-list 'org-export-filter-final-output-functions 'ks/org-latex-remove-labels)) Thanks again! Salome