First of all: This is Emacs. It's not a bug, it's a setting!
Secondly, @glucas is correct in saying that you need to modify org-emphasis-regexp-components
to get what you want. However, I'd like to suggest two modifications to his (@Malabarba's) code and provide a bit more context:
You don't need to copy the entire value of org-emphasis-regexp-components
to your init-file to modify a single component. For your use case the following is sufficient:
(setcar (nthcdr 2 org-emphasis-regexp-components) " \t\r\n,\"")
You don't have to modify org-emphasis-regexp-components
before loading org-mode
via (require 'org)
. Just add the following line after your modifications:
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
More context
In case you want to customize other aspects of how emphasis markup works in org-mode
, know this:
The value of org-emphasis-regexp-components
is a list with five entries.
The first entry controls which characters are allowed to immediately precede markup characters. If you want to be able to have something like why=hello=
render correctly, you'll need to modify this entry.
(setcar org-emphasis-regexp-components "...")
The second entry controls which characters are allowed to immediately follow markup characters. If you want to be able to have something like =hello=there
render correctly, you'll need to modify this entry.
(setcar (nthcdr 1 org-emphasis-regexp-components) "...")
The third entry specifies the characters that are not allowed as border characters, i.e., characters that immediately follow an opening markup character or precede a closing markup character. You'll need to modify this to make things like ='hello'=
render correctly.
(setcar (nthcdr 2 org-emphasis-regexp-components) "...")
The fourth entry lists characters that are allowed in the body of your marked up string, i.e., characters that appear between the border characters. You'll rarely need to modify this; by default, any character is allowed as a body character.
(setcar (nthcdr 3 org-emphasis-regexp-components) "...")
The fifth entry specifies how many newlines are allowed inside a marked up expression. By default, org-mode
allows a single newline. So if you want to be able to add markup to text that spans more than two consecutive lines, you'll need to modify this entry.
(setcar (nthcdr 4 org-emphasis-regexp-components) N)
... where N
is the number of newlines you want to allow.
Related posts
People seem to run into this issue fairly frequently. Aside from the post you mentioned, there are at least two more questions on StackOverflow that deal with very similar issues:
"Symbol's value as variable is void: org-emphasis-regexp-components"
even if I place those two lines all the way at the bottom of my.emacs
file. Any thoughts on why that could be the case? – Amelio Vazquez-Reina Jul 13 '15 at 13:17(require 'org)
in your.emacs
file before making any customizations toorg-emphasis-regexp-components
? – itsjeyd Jul 13 '15 at 20:24(require 'org)
. Strangely enough, I was still able to work with org files without problem. Maybe that's because they were already open and I was using the desktop feature? (which I believes recalls what package to load on what buffer)? – Amelio Vazquez-Reina Jul 14 '15 at 17:36(require 'org)
in your init-file to be able to use it. If you don't, Emacs will load it automatically when you: (a) open an.org
file for the first time in the current session, or (b) enable the mode manually viaM-x
org-mode
for the first time in the current session, or (c) when it restores a saved desktop that includes at least one.org
file. (contd.) – itsjeyd Jul 15 '15 at 05:51org-mode
automatically just because you put some customizations for it in your init-file. That's why you need to(require 'org)
before customizing any of its variables. Without fully loading the mode, Emacs won't know what to do with variables likeorg-emphasis-regexp-components
; they are not defined when Emacs first encounters them, hence theSymbol's value as variable is void
message. – itsjeyd Jul 15 '15 at 05:58init.el
file, you close all org buffers, close Emacs and then start it again and reopen the org buffer of that file. Total wipe, otherwise no go. – Zelphir Kaltstahl Sep 22 '19 at 11:30