From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Re: ox-beamer and CUSTOM_ID Date: Thu, 15 Oct 2015 22:20:38 +0200 Message-ID: References: <87pp0izi1f.fsf@nicolasgoaziou.fr> <87h9luzgyd.fsf@nicolasgoaziou.fr> <874mhuze22.fsf@nicolasgoaziou.fr> <87vbaaxvia.fsf@nicolasgoaziou.fr> <87k2qpy85j.fsf@nicolasgoaziou.fr> <87wpuowmrn.fsf@nicolasgoaziou.fr> <87oafz6hgx.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0149ca2eb77c1a05222a6a5a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmp1I-0001LM-3O for emacs-orgmode@gnu.org; Thu, 15 Oct 2015 16:21:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmp1G-0003lp-MY for emacs-orgmode@gnu.org; Thu, 15 Oct 2015 16:21:00 -0400 Received: from mail-ob0-x236.google.com ([2607:f8b0:4003:c01::236]:32791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmp1G-0003lh-GF for emacs-orgmode@gnu.org; Thu, 15 Oct 2015 16:20:58 -0400 Received: by obbwb3 with SMTP id wb3so48238381obb.0 for ; Thu, 15 Oct 2015 13:20:58 -0700 (PDT) In-Reply-To: <87oafz6hgx.fsf@nicolasgoaziou.fr> 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: Fabrice Popineau , "emacs-orgmode@gnu.org" --089e0149ca2eb77c1a05222a6a5a Content-Type: text/plain; charset=UTF-8 My small patch worked only for labels with colon. With more extensive testing, I can propose this one against maint : diff --git a/vendor/org-mode/lisp/ox-beamer.el b/vendor/org-mode/lisp/ox-beamer.el index 73d8a76..ee4f0d7 100644 --- a/vendor/org-mode/lisp/ox-beamer.el +++ b/vendor/org-mode/lisp/ox-beamer.el @@ -335,11 +335,11 @@ property, or a fallback value built from headline's number. This function assumes HEADLINE will be treated as a frame." (let ((opt (org-element-property :BEAMER_OPT headline))) (if (and (stringp opt) - (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt)) + (string-match "\\(?:^\\|,\\)label={?\\(.*?\\)}?\\(?:$\\|,\\)" opt)) (match-string 1 opt) (or (and (plist-get info :latex-prefer-user-labels) (org-element-property :CUSTOM_ID headline)) - (format "{sec:%s}" + (format "sec:%s" (org-export-get-reference headline info)))))) (defun org-beamer--frame-level (headline info) @@ -444,8 +444,9 @@ used as a communication channel." (or (string-match "\\(^\\|,\\)label=" beamer-opt) (string-match "allowframebreaks" beamer-opt))) (list - (format "label=%s" - (org-beamer--get-label headline info))))))) + (let* ((label (org-beamer--get-label headline info)) + (fmt (if (string-match ":" label) "label={%s}" "label=%s"))) + (format fmt label))))))) ;; Change options list into a string. (org-beamer--normalize-argument (mapconcat This way, the org-beamer--get-label function always returns a label without braces. Check especially the regexp. I hope I haven't introduce bad matches. When the frame with the label is written, braces are added if needed. Regards, Fabrice 2015-10-15 21:48 GMT+02:00 Nicolas Goaziou : > Fabrice Popineau writes: > > > Oh! I got it. > > > > The problem is that beamer expects braces around a label with colon when > > you setup the label > > but *not when you ref it* : > > > > \begin{frame}[label={sec:orgheadline1}]{Frame 1} > > bla bla bla bla bla bla bla bla bla bla bla bla > > \end{frame} > > > > \againframe{sec:orgheadline1} > > > > The braces at setup are required by the keyval package which is used to > > parse the options. > > However, the label is called sec:orgheadline1 and not {sec:orgheadline1}. > > But at the moment, ox-beamer outputs : > > > > \againframe{{sec:orgheadline1}} > > > > I fixed it unintentionally by using my own label without colon. > > > > So basically you need this: > > > > diff --git a/vendor/org-mode/lisp/ox-beamer.el > > b/vendor/org-mode/lisp/ox-beamer.el > > index 24dcf19..75b51df 100644 > > --- a/vendor/org-mode/lisp/ox-beamer.el > > +++ b/vendor/org-mode/lisp/ox-beamer.el > > @@ -621,7 +623,7 @@ as a communication channel." > > (org-export-resolve-id-link link > > info)))) > > ;; Now use user-defined label provided in TARGET > > ;; headline, or fallback to standard one. > > - (format "{%s}" (org-beamer--get-label target > > info))))))) > > + (format "%s" (org-beamer--get-label target > info))))))) > > ;; Case 2: Creation of an appendix is requested. > > ((equal environment "appendix") > > (concat "\\appendix" > > Thanks for the debugging. Do you want to provide a patch against maint > for this ? Note that your library needs to be updated. > > Regards, > --089e0149ca2eb77c1a05222a6a5a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
My small patch worked only for labels with colon.
With= more extensive testing, I can propose this one against maint :
<= br>
diff --git a/vendor/org-mode/lisp/ox-beamer.el b/vendor/= org-mode/lisp/ox-beamer.el
index 73d8a76..ee4f0d7 100644
--- a/vendor/org-mode/lisp/ox-beamer.el
+++ b/vendor/org-mode/l= isp/ox-beamer.el
@@ -335,11 +335,11 @@ property, or a fallback va= lue built from headline's number.=C2=A0 This
=C2=A0function a= ssumes HEADLINE will be treated as a frame."
=C2=A0 =C2=A0(l= et ((opt (org-element-property :BEAMER_OPT headline)))
=C2=A0 =C2= =A0 =C2=A0(if (and (stringp opt)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(string-match "\\(?:^\\|,\\)label=3D\\(.*?\\)\\(?:$\\|,\\= )" opt))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(string-= match "\\(?:^\\|,\\)label=3D{?\\(.*?\\)}?\\(?:$\\|,\\)" opt))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (match-string 1 opt)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(or (and (plist-get info :latex-prefer-user-labels)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-element-= property :CUSTOM_ID headline))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 (for= mat "{sec:%s}"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (format &q= uot;sec:%s"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (org-export-get-reference headline info))))))

=
=C2=A0(defun org-beamer--frame-level (headline info)
@= @ -444,8 +444,9 @@ used as a communication channel."
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or (string-match "\\(^\\|,\\)l= abel=3D" beamer-opt)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (string-match "allowframebreaks" beamer-opt)= ))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0(list
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (format "label=3D%s"
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-beamer--get-label headline i= nfo)))))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (let* ((label (org-beamer--get-label headline info= ))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(fmt (if (string-match ":= " label) "label=3D{%s}" "label=3D%s")))
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (format fmt label)))))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 ;; Change options list into a string.
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-beamer--normalize-argument<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(mapconcat=

This way, the org-beamer--get-label functio= n always returns a label without braces.
Check especially the reg= exp. I hope I haven't introduce bad matches.

W= hen the frame with the label is written, braces are added if needed.
<= div>
Regards,

Fabrice

2015-10-15 21:48= GMT+02:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:
Fab= rice Popineau <fabrice.pop= ineau@gmail.com> writes:

> Oh! I got it.
>
> The problem is that beamer expects braces around a label with colon wh= en
> you setup the label
> but *not when you ref it* :
>
> \begin{frame}[label=3D{sec:orgheadline1}]{Frame 1}
> bla bla bla bla bla bla bla bla bla bla bla bla
> \end{frame}
>
> \againframe{sec:orgheadline1}
>
> The braces at setup are required by the keyval package which is used t= o
> parse the options.
> However, the label is called sec:orgheadline1 and not {sec:orgheadline= 1}.
> But at the moment, ox-beamer outputs :
>
> \againframe{{sec:orgheadline1}}
>
> I fixed it unintentionally by using my own label without colon.
>
> So basically you need this:
>
> diff --git a/vendor/org-mode/lisp/ox-beamer.el
> b/vendor/org-mode/lisp/ox-beamer.el
> index 24dcf19..75b51df 100644
> --- a/vendor/org-mode/lisp/ox-beamer.el
> +++ b/vendor/org-mode/lisp/ox-beamer.el
> @@ -621,7 +623,7 @@ as a communication channel."
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-export-= resolve-id-link link
> info))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0;; Now use user-defined label provided in TARGET
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0;; headline, or fallback to standard one.
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(format "{%s}" (org-beamer--get-label target
> info)))))))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0(format "%s" (org-beamer--get-label target info)))))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Case 2: Creation of an appendix is= requested.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((equal environment "appendix&qu= ot;)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(concat "\\appendix"

Thanks for the debugging. Do you want to provide a patch agains= t maint
for this ? Note that your library needs to be updated.

Regards,

--089e0149ca2eb77c1a05222a6a5a--