From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Automatically escaping single spaces Date: Tue, 19 Mar 2013 17:05:48 +0100 Message-ID: <874ng7l6hv.fsf@pank.iue.private> References: <20130318134024.GC27876@kuru.dyndns-at-home.com> <87r4jcvy2v.fsf@gmail.com> <0C7B7610-34DF-47E5-970C-6CBBF3DDC8EF@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:35557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHz37-0004PD-1a for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 12:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHz32-0000v9-A5 for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 12:06:04 -0400 Received: from plane.gmane.org ([80.91.229.3]:59461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHz31-0000un-46 for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 12:05:59 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UHz3K-0001hS-Tr for emacs-orgmode@gnu.org; Tue, 19 Mar 2013 17:06:18 +0100 Received: from 192.167.90.137 ([192.167.90.137]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Mar 2013 17:06:18 +0100 Received: from rasmus by 192.167.90.137 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Mar 2013 17:06:18 +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: emacs-orgmode@gnu.org Ivan Andrus writes: > Oops, forgot to reply to the list. > > On Mar 18, 2013, at 9:59 PM, Aaron Ecay wrote: > >> Hi Suvayu, >> >> I’ve had on my list of rainy day ideas for a while writing a function >> for org-export-filter-plain-text-functions that would implement >> something like this. It should be as simple as doing a text replace, >> either on “. [^ ]” sequences in general or only spaces after a given >> list of abbreviations. The advantage of the second approach is that it >> could catch the case where “e.g.” is at the end of a line in the org >> document. (You’d also have to remove the newline: translate “e.g.\nfoo” >> into “e.g.\ foo”). Another advantage to pre-specifying is that you might >> want a non-breaking space in “Fig.~1” but a breakable space in “e.g.\ foo”; >> so you could keep two lists. > > FWIW, You shouldn't have to worry about newlines. If Emacs is setup > properly they should never appear except at sentence boundaries. Which > is to say, autofill and fill-paragraph know not to break lines in the > middle of a sentence after punctuation. If the user adds a newline > manually you can assume they meant it to be a new sentence. IIRC the > variable at play is `sentence-end-double-space'. I use something like this: #+BEGIN_SRC emacs-lisp (defun rasmus/latex-filter-double-space (text backend info) "Tries to export \"S1. S2\" as \"S1.~S2\", while letting \"S1. S2\" be exported without tilde" (when (memq backend '(beamer latex)) (replace-regexp-in-string "\\(\\. \\)\\{1\\}\\([^ ]\\)" ".~\\2" text))) (add-to-list 'org-export-filter-final-output-functions 'rasmus/latex-filter-double-space) #+END_SRC The list approach sounds better, I guess. . . Indeed it does not catch end of line stuff. Here's a test case #+BEGIN_SRC org #+NAME:ref #+BEGIN_SRC emacs-lisp (replace-regexp "\\(\\. \\)\\{1\\}\\([^ ]\\)" ".~\\2") #+END_SRC * Test fig. 1 isn't here. Here is double space. Fig. 2 does not work fig. [[ref]] is also works #+END_SRC which translate to #+BEGIN_SRC latex \section[Test]{Test} \label{sec-1} fig.~1 isn't here. Here is double space. Fig. 2 does not work fig.~\ref{ref} is also works #+END_SRC –Rasmus -- Hvor meget poesi tror De kommer ud af et glas isvand?