Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
668 views
in Technique[技术] by (71.8m points)

emacs - How to escape double quote?

In org mode, if I want to format text a monospace verbatim, i.e. ~...~, if it is inside quotes: ~"..."~, it is not formatted (left as is).

Also, are quotes a reserved symbol, if so, what do they mean? (they don't seem to affect the generated HTML / inside Emacs display).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The culprit in this case is the regular expression in org-emph-re org-verbatim-re, responsible for determining if a sequence of characters in the document is to be set verbatim or not.

org-verbatim-re is a variable defined in `org.el'. Its value is "([ ('"{]|^)(([=~])([^
,"']|[^
,"'].?(?: .?){0,1}[^
,"'])3)([- .,:!?;'")}]|$)"

quotes and double quotes are explicitly forbidden inside verbatim characters =~ by

[^ 

,"']|[^ 

,"']

I found discussions dating back 3 years comming to the conclusion that you have to tinker with this regular expression and set the variable org-emph-re/org-verbatim-re to something that matches your wishes in your emacs setup (maybe a file local variable works as well). You can experiment by excluding double quotes from the excluding character classes and outside matches as in

"([ ('{]|^)(([*/_=~+])([^
,']|[^
,'].?(?: .?){0,1}[^
,'])3)([- .,:!?;')}]|$)"

but looking at that regex, heaven knows what happens to complex documents -- you have to try...

Edit: as it happens, if I evalute the following as region, quotes inside = are exported correctly, but nothing else is :-), I investigate further when I have more time.

(setq org-emph-re "([ ('{]|^)(([*/_=~+])([^ ,']|[^ ,'].?(?: .?){0,1}[^ ,'])3)([- .,:!?;')}]|$)")

Edit 2:: Got it to work by changing org.el directly:

Change the line following (defvar org-emphasis-regexp-components from '(" ('"{" "- .,:!?;'")}" " ,"'" "." 1) to '(" ('{" "- .,:!?;')}" " ,'" "." 1) and recompile org then restart emacs.

This was a defcustom prior to the 8.0 release, it isn't anymore, so you have to live with this manual modification.

regards, Tom


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...