How to make inline comments in Org-mode?

二次信任 提交于 2020-01-01 07:58:47

问题


In Org-mode there are several ways to make comments. But I do not know of any way to make inline comments. According to the manual

regions surrounded by ‘#+BEGIN_COMMENT’ ... ‘#+END_COMMENT’ will not be exported.

But this is only true if the said region starts a line.

In the following

#+TITLE: Test

text #+BEGIN_COMMENT comment 1 #+END_COMMENT text

text
#+BEGIN_COMMENT comment 2 #+END_COMMENT text

only comment 2 is treated as a comment. It exports (e.g. C-e A) as

text #+BEGIN_COMMENT comment 1 #+END_COMMENT text

text

Also, org-toggle-comment does not work for making inline comments by using it on regions and comment-region does not even create a comment.

So, how can I make inline comments in Org-mode?


回答1:


Jonathan Leech-Pepin's comment on your question on \printbibliography gave me an idea. You can use a macro for inline comments. Note that you need trailing space after the comment definition.

#+macro: comment  

...

{{{comment(here is a comment)}}}

EDIT: Since this is supposed to be a macro odd input may screw things up. I'm a little surprised that

{{{comment(here is a)}} comment)}}}

works for me, although

{{{comment(here is a comment) more}}}

does not. I would assume that anything other than fairly simple text would be fairly fragile if they decide to change the way they parse macros in the future.




回答2:


Another way will be to use the export snippets (defined in Org Syntax (draft), search for "Export Snippets"), like so:

This is the @@comment:This is an inline comment@@ original text.

I used the word comment where the export backend should be just for clarity, you can use any other word (besides the backend you're exporting to).



来源:https://stackoverflow.com/questions/9212737/how-to-make-inline-comments-in-org-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!