From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Problem writing my first export filter Date: Wed, 21 Aug 2013 09:48:51 +0200 Message-ID: <87y57v8ows.fsf@gmail.com> References: <871u5nst7x.wl%jamshark70@dewdrop-world.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC39s-0001qU-Q1 for emacs-orgmode@gnu.org; Wed, 21 Aug 2013 03:48:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VC39j-0003hU-V2 for emacs-orgmode@gnu.org; Wed, 21 Aug 2013 03:48:48 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:59923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC39j-0003hM-Oy for emacs-orgmode@gnu.org; Wed, 21 Aug 2013 03:48:39 -0400 Received: by mail-we0-f179.google.com with SMTP id t58so78156wes.38 for ; Wed, 21 Aug 2013 00:48:39 -0700 (PDT) In-Reply-To: <871u5nst7x.wl%jamshark70@dewdrop-world.net> (James Harkins's message of "Wed, 21 Aug 2013 09:55:30 +0800") 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: James Harkins Cc: orgmode Hello, James Harkins writes: > I just tried the following, so that I could maintain a list of special cases where org's default latex export doesn't do what I want. > > (setq hjh-org-latex-macros '(("`em" "'em"))) > > (defun hjh-latex-filter-macros (text backend info) > "hjh: Replace special cases listed in hjh-org-latex-macros." > (when (org-export-derived-backend-p backend 'latex) > (dolist (element hjh-org-latex-macros) > (replace-regexp-in-string (car element) (car (cdr element)) text)))) > > First I tried > > (setq org-export-filter-plain-text-functions '(hjh-latex-filter-macros)) > > -- no result: `em passes through unchanged. So then I tried clearing plain-text-functions and using final-output-functions instead. Same thing: the filter didn't do anything. > > I suppose I'm missing something simple. Your filter returns nil (due to the `dolist') and is therefore ignored. You have to make sure it returns the new string: (defun hjh-latex-filter-macros (text backend info) "hjh: Replace special cases listed in hjh-org-latex-macros." (when (org-export-derived-backend-p backend 'latex) (dolist (element hjh-org-latex-macros text) (setq text (replace-regexp-in-string (car element) (nth 1 element) text))))) Regards, -- Nicolas Goaziou