From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [patch, ox-latex] captions and latex-environments Date: Mon, 20 Mar 2017 15:34:42 +0100 Message-ID: <87efxsuid9.fsf@gmx.us> References: <87k27pv38z.fsf@gmx.us> <87bmt1v2xs.fsf@gmx.us> <87tw6se5a3.fsf@nicolasgoaziou.fr> <874lystfyh.fsf@gmx.us> <87a88kdtvz.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpyOZ-00071T-Qx for emacs-orgmode@gnu.org; Mon, 20 Mar 2017 10:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpyOV-0002vy-Sy for emacs-orgmode@gnu.org; Mon, 20 Mar 2017 10:34:51 -0400 Received: from mout.gmx.net ([212.227.17.22]:53459) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cpyOV-0002vI-JJ for emacs-orgmode@gnu.org; Mon, 20 Mar 2017 10:34:47 -0400 In-Reply-To: <87a88kdtvz.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Sat, 18 Mar 2017 10:44:39 +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" To: mail@nicolasgoaziou.fr Cc: emacs-orgmode@gnu.org Hi, Nicolas Goaziou writes: >>> Since environments do not necessary start with \begin{...}, I think the >>> following is better >>> >>> (and (string-match ...) >>> (match-string ...)) >> >> Don't the element `latex-environment' always start \begin{.}? >> Cf. org-element--latex-begin-environment. > > At the moment, they do, but I have a patch somewhere to make "\[...\]" > an element instead of an object (e.g., to avoid filling it). It was > accepted, but it some similar change could happen. I'm just suggesting > to make it more robust right from the start. OK. AFAIR, org-element--latex-begin-environment shouldn't be used in other libraries. >> Another danger is that someone writes something like, >> >> \begin{center} >> \begin{table} >> ... > > You can start the regexp with "\\`[ \t]*..." The point is, that the env. will be center rather than table. So the code would detect the wrong environment. >> + 'table) >> + ((string-match-p "figure" env) 'image) >> + ((or (string-match-p "\\(\\(lst\\)?listing\\|verbatim\\|minted\\)"= env) >> + (string-match-p >> + (regexp-opt >> + (mapcar (lambda (str) >> + (let ((s (cadr str))) >> + (if (string-match latex-begin-re s) > > You removed `latex-begin-re' binding so this is going to fail. Thanks. >> + (match-string 2 s) >> + s))) >> + org-latex-custom-lang-environments)) > > I'm not sure it is necessary. AFAIU, > `org-latex-custom-lang-environments' already provides a way to insert > captions. The matching process above seems fragile. I agree this is fragile, and I=E2=80=99m happy to remove that part of the matching. The support of captions in custom-lang-environments is not really the point here. The point of this patch is to be able to add captions to latex-environments. E.g. externally generated files, e.g. tables, to be included. Rasmus --=20 I hear there's rumors on the, uh, Internets. . .