From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-latex-classes with functions, incomplete doc Date: Sun, 10 Feb 2013 19:20:31 +0100 Message-ID: <877gmgf2ts.fsf@gmail.com> References: <87txpkrvzi.fsf@sophokles.streitblatt.de> <87bobsf68g.fsf@gmail.com> <87zjzcqcq8.fsf@sophokles.streitblatt.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4bWF-0001kE-Rs for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 13:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4bWC-0006HV-Kj for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 13:20:51 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4bWC-0006HJ-Cj for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 13:20:48 -0500 Received: by mail-wi0-f180.google.com with SMTP id hi8so2422732wib.13 for ; Sun, 10 Feb 2013 10:20:47 -0800 (PST) In-Reply-To: <87zjzcqcq8.fsf@sophokles.streitblatt.de> (Florian Beck's message of "Sun, 10 Feb 2013 18:51:11 +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: Florian Beck Cc: emacs-orgmode@gnu.org Florian Beck writes: > Ok, I tried this. There is a problem, however. This is what I came up > with: > > #+BEGIN_SRC emacs-lisp > (defun fb/org-latex-headline (headline contents info) > (let* ((full-section (org-latex-headline headline contents info)) I suggest (org-export-with-backend 'latex headline contents info) to not depend on the actual name of the translator. > (toc-title (if (plist-get info :toc-title) > (org-element-property :toc-title headline))) There's no :toc-title property in the communication channel. The exhaustive list of its properties is written in ox.el, at "The Communication Channel" section. > (section-regex "\\`\\\\\\(sub\\)*\\(section\\|paragraph\\){") > (new-section > (when (and toc-title > (string-match section-regex full-section)) > (let ((subs (match-string 1 full-section)) > (section (match-string 2 full-section)) > (rest (substring full-section (match-end 0)))) > (concat > "\\" subs section "[" > ;; replace brackets (from `org-latex-headline') > (replace-regexp-in-string > "\\[" "(" > (replace-regexp-in-string > "\\]" ")" > toc-title)) > "]{" rest))))) > (or new-section > full-section))) > #+END_SRC > > As you can see, the solution is much more convoluted. Because you're not using the proper tool. If you just want to modify the string returned by the `latex' back-end, use a filter. You will have access to the transcoded headline (in LaTeX format, as a string) and the communication channel. #+begin_src emacs-lisp (defun fb/my-headline-transformation (headline backend info) (when (eq backend 'latex) ;; Here HEADLINE is the output from `latex' back-end, as a string. ... )) (add-to-list 'org-export-filter-headline-functions 'fb/my-headline-transformation) #+end_src What I suggest gives you access to the headline as parsed data. This is much more powerful, but a completely different task. > IMO, the probem is this: the translation is (mostly) application of > content to a template (a format string), but these templates are build > (mostly, sectioning is actually an exception) inside the default > translation functions. It would be much easier, when this template would > be accessible from "outside", like this: There are already many ways to alter output from a back-end. It's just a matter of using the right tool. Regards, -- Nicolas Goaziou