emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* add entries to *emphasis-alist
@ 2012-08-17 12:26 Philipp Kroos
  2012-08-17 19:01 ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Kroos @ 2012-08-17 12:26 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

is it still possible to add items to the emphasis alists?
I'm preparing a presentation with orgmode/beamer and try to get a markup 
for alert using '@'.
According to some (old..) thread 
(http://lists.gnu.org/archive/html/emacs-orgmode/2010-01/msg00592.html)
I added an entry to org-emhasis-alist and
org-export-latex-emphasis-alist, see below.
Unfortunately, this is not working, '@noise@' is exported to '@noise@' 
literally.
I had a quick look at the source in org-latex.el and if I understand it 
correctly, the fontification is done in org-export-latex-fontify 
according to matches with org-emph-re, defined in org.el. But 
org-emph-re doesn't match with '@'- consequently, the markup is ignored.  

So do I have to redefine org-emph-re as well or is there any other trick?
I'm using the current org from git.

Thanks all!


;; this is how I add the entries to the lists
  (setq org-emphasis-alist
        (append org-emphasis-alist
                '(("@" org-warning "<b>" "</b>"))))
  (setq org-export-latex-emphasis-alist
        (append org-export-latex-emphasis-alist
                '(("@" "\\alert{%s}" nil))))

;; this is a minimal example
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [presentation]
#+BEAMER_FRAME_LEVEL: 1

* Testsection
** with some important @noise@

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-17 12:26 add entries to *emphasis-alist Philipp Kroos
@ 2012-08-17 19:01 ` Sebastien Vauban
  2012-08-17 19:50   ` Nick Dokos
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2012-08-17 19:01 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Philipp,

Philipp Kroos wrote:
> is it still possible to add items to the emphasis alists?
> I'm preparing a presentation with orgmode/beamer and try to get a markup 
> for alert using '@'.
> According to some (old..) thread 
> (http://lists.gnu.org/archive/html/emacs-orgmode/2010-01/msg00592.html)
> I added an entry to org-emhasis-alist and
> org-export-latex-emphasis-alist, see below.
> Unfortunately, this is not working, '@noise@' is exported to '@noise@' 
> literally.
> I had a quick look at the source in org-latex.el and if I understand it 
> correctly, the fontification is done in org-export-latex-fontify 
> according to matches with org-emph-re, defined in org.el. But 
> org-emph-re doesn't match with '@'- consequently, the markup is ignored.  
>
> So do I have to redefine org-emph-re as well or is there any other trick?
> I'm using the current org from git.
>
> Thanks all!
>
>
> ;; this is how I add the entries to the lists
>   (setq org-emphasis-alist
>         (append org-emphasis-alist
>                 '(("@" org-warning "<b>" "</b>"))))
>   (setq org-export-latex-emphasis-alist
>         (append org-export-latex-emphasis-alist
>                 '(("@" "\\alert{%s}" nil))))
>
> ;; this is a minimal example
> #+LaTeX_CLASS: beamer
> #+LaTeX_CLASS_OPTIONS: [presentation]
> #+BEAMER_FRAME_LEVEL: 1
>
> * Testsection
> ** with some important @noise@

You have to make that customization *before* loading Org in your .emacs file.
Weird, never really understood why, but that's like that.

Best regards,
Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-17 19:01 ` Sebastien Vauban
@ 2012-08-17 19:50   ` Nick Dokos
  2012-08-19 11:01     ` Philipp Kroos
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2012-08-17 19:50 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

> You have to make that customization *before* loading Org in your .emacs file.
> Weird, never really understood why, but that's like that.
> 

The point is that the value of org-emphasis-alist (as well as the value
of org-emphasis-regexp-components) is used in order to calculate the
value of org-emph-re by calling the function org-set-emph-re afterwards:
it's org-emph-re that's used for the all the gory calculations, not
org-emphasis-alist, which just provides a nicer interface.

So if you arrange to call the org-set-emph-re function afterwards, you
can change org-emphasis-alist at any time. Customize makes it easy, in
that it does that automatically (see the :set property
of org-emphasis-alist).

If you do the setq before loading org, then what happens is that when the
defcustom is encountered, the value of the :set property (a function) is
called: the modified value of org-emphasis-alist is then used to calculate
org-emph-re, instead of the original default. If you do it after, none
of that happens and it's as if you never changed it.

Nick

PS BTW, the docstring for the variable says: "Use customize to modify
   this, or restart Emacs after changing it" but I'm not sure that's
   correct: if you change the variable in one session, the value is not
   going to be propagated to the next session, unless you use customize
   or put the setq in .emacs. In the latter case, it's not going to work
   unless you do it the way Seb describes: set it before loading Org.
   So restarting emacs is *not* enough. Am I missing something?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-17 19:50   ` Nick Dokos
@ 2012-08-19 11:01     ` Philipp Kroos
  2012-08-19 11:38       ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Kroos @ 2012-08-19 11:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2131 bytes --]

It worked using customize, thanks. And thanks for the explanation, Nick.
At least my approach to set the value would not work at all without an 
explicit call to org-set-emph-re, since it relied on the variable being 
already defined.
It might be of minor interest, anyway, I've attached a patch-suggestion 
that would clearify the usage sufficiently, at least for me...

Best regards, Philipp


On Fri, Aug 17, 2012 at 03:50:35PM -0400, Nick Dokos wrote:
> Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
> 
> > You have to make that customization *before* loading Org in your .emacs file.
> > Weird, never really understood why, but that's like that.
> > 
> 
> The point is that the value of org-emphasis-alist (as well as the value
> of org-emphasis-regexp-components) is used in order to calculate the
> value of org-emph-re by calling the function org-set-emph-re afterwards:
> it's org-emph-re that's used for the all the gory calculations, not
> org-emphasis-alist, which just provides a nicer interface.
> 
> So if you arrange to call the org-set-emph-re function afterwards, you
> can change org-emphasis-alist at any time. Customize makes it easy, in
> that it does that automatically (see the :set property
> of org-emphasis-alist).
> 
> If you do the setq before loading org, then what happens is that when the
> defcustom is encountered, the value of the :set property (a function) is
> called: the modified value of org-emphasis-alist is then used to calculate
> org-emph-re, instead of the original default. If you do it after, none
> of that happens and it's as if you never changed it.
> 
> Nick
> 
> PS BTW, the docstring for the variable says: "Use customize to modify
>    this, or restart Emacs after changing it" but I'm not sure that's
>    correct: if you change the variable in one session, the value is not
>    going to be propagated to the next session, unless you use customize
>    or put the setq in .emacs. In the latter case, it's not going to work
>    unless you do it the way Seb describes: set it before loading Org.
>    So restarting emacs is *not* enough. Am I missing something?
> 
> 

[-- Attachment #2: org-emphasis-alist-doc.patch --]
[-- Type: text/plain, Size: 753 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 3bf338d..c70d94d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3770,7 +3770,9 @@ characters, the face to be used by font-lock for highlighting in Org-mode
 Emacs buffers, and the HTML tags to be used for this.
 For LaTeX export, see the variable `org-export-latex-emphasis-alist'.
 For DocBook export, see the variable `org-export-docbook-emphasis-alist'.
-Use customize to modify this, or restart Emacs after changing it."
+The value of org-emphasis-alist is used to calculate a regular expression
+during startup; changing it manually may not have an effect.
+You should use customize to modify this. Otherwise, see `org-set-emph-re'."
   :group 'org-appearance
   :set 'org-set-emph-re
   :type '(repeat

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-19 11:01     ` Philipp Kroos
@ 2012-08-19 11:38       ` Nicolas Goaziou
  2012-08-19 12:53         ` Philipp Kroos
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2012-08-19 11:38 UTC (permalink / raw)
  To: Philipp Kroos; +Cc: emacs-orgmode

Hello,

Philipp Kroos <Philipp.Kroos@t-online.de> writes:

> It worked using customize, thanks. And thanks for the explanation, Nick.
> At least my approach to set the value would not work at all without an 
> explicit call to org-set-emph-re, since it relied on the variable being 
> already defined.
> It might be of minor interest, anyway, I've attached a patch-suggestion 
> that would clearify the usage sufficiently, at least for me...

At some point, emphasis markers will be hard-coded anyway. Though, it
will be easy to change their meaning during the export process.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-19 11:38       ` Nicolas Goaziou
@ 2012-08-19 12:53         ` Philipp Kroos
  2012-08-19 15:25           ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Kroos @ 2012-08-19 12:53 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

Well, sorry..
Before sending the mail I read the documentation on
http://orgmode.org/worg/org-contribute.html#sec-4
regarding correct submission of patches... and did it wrong.
So just for the records, here it is again.
Hopefully, if I can contribute a `real' patch someday, the format will 
be right ;)

Regards, philipp

On Sun, Aug 19, 2012 at 01:38:10PM +0200, Nicolas Goaziou wrote:
> Hello,
> 
> Philipp Kroos <Philipp.Kroos@t-online.de> writes:
> 
> > It worked using customize, thanks. And thanks for the explanation, Nick.
> > At least my approach to set the value would not work at all without an 
> > explicit call to org-set-emph-re, since it relied on the variable being 
> > already defined.
> > It might be of minor interest, anyway, I've attached a patch-suggestion 
> > that would clearify the usage sufficiently, at least for me...
> 
> At some point, emphasis markers will be hard-coded anyway. Though, it
> will be easy to change their meaning during the export process.
> 
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

[-- Attachment #2: 0001-Minor-change-of-documentation.patch --]
[-- Type: text/plain, Size: 1289 bytes --]

From 6bd616854ccb981693c2178c5a9c0378cf3954aa Mon Sep 17 00:00:00 2001
From: Philipp Kroos <Philipp.Kroos@t-online.de>
Date: Sun, 19 Aug 2012 14:34:56 +0200
Subject: [PATCH] Minor change of documentation

* lisp/org.el org-emphasis-alist: Clearified the documentation

The value is not changeable with a setq-form, the
customization-interface should be used. The change describes that.

TINYCHANGE
---
 lisp/org.el | 4 +++-
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/lisp/org.el b/lisp/org.el
index 3bf338d..c70d94d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3770,7 +3770,9 @@ characters, the face to be used by font-lock for highlighting in Org-mode
 Emacs buffers, and the HTML tags to be used for this.
 For LaTeX export, see the variable `org-export-latex-emphasis-alist'.
 For DocBook export, see the variable `org-export-docbook-emphasis-alist'.
-Use customize to modify this, or restart Emacs after changing it."
+The value of org-emphasis-alist is used to calculate a regular expression
+during startup; changing it manually may not have an effect.
+You should use customize to modify this. Otherwise, see `org-set-emph-re'."
   :group 'org-appearance
   :set 'org-set-emph-re
   :type '(repeat
-- 
1.7.11.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: add entries to *emphasis-alist
  2012-08-19 12:53         ` Philipp Kroos
@ 2012-08-19 15:25           ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2012-08-19 15:25 UTC (permalink / raw)
  To: Philipp Kroos; +Cc: emacs-orgmode

Hi Philipp,

Philipp Kroos <Philipp.Kroos@t-online.de> writes:

> Well, sorry..
> Before sending the mail I read the documentation on
> http://orgmode.org/worg/org-contribute.html#sec-4
> regarding correct submission of patches... and did it wrong.
> So just for the records, here it is again.

Thanks for the patch.  As Nicolas said, emphasis markers will be
hardcoded at some point, so we don't want to encourage users to tweak
this in the meantime.  I'll add a note about this in the release notes
of Org 7.9.  I'll not apply the patch, as it exposes the user to things
we don't really want him to explore, such as `org-set-emph-re'... the
current docstring is fine to me.

> Hopefully, if I can contribute a `real' patch someday, the format will 
> be right ;)

No doubt :)  

Ps: Think of using `C-x 4 a' to get a proper ChangeLog entry.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-19 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 12:26 add entries to *emphasis-alist Philipp Kroos
2012-08-17 19:01 ` Sebastien Vauban
2012-08-17 19:50   ` Nick Dokos
2012-08-19 11:01     ` Philipp Kroos
2012-08-19 11:38       ` Nicolas Goaziou
2012-08-19 12:53         ` Philipp Kroos
2012-08-19 15:25           ` Bastien

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).