11

Both =foo= and ~foo~ seem to be used in org for inline bits of code. How do they differ? Which should I use, and when?

For example, from the ORG-NEWS file:

If you want to exclude a headline from export while using its contents
for setting options, use =:noexport:= (see =org-export-exclude-tags=.)

...

The key sequences =C-c C-n= and =C-c C-p= are now bound to
~org-next-visible-heading~ and ~org-previous-visible-heading~ respectively,
rather than the =outline-mode= versions of these functions.  The Org
version of these functions skips over inline tasks (and even-level
headlines when ~org-odd-levels-only~ is set).

There isn't an obvious pattern here: org-export-exclude-tags and org-odd-levels-only are both variables, and org-next-visible-heading and outline-mode are both functions.

Do either of these syntaxes support jumping to *Help* buffers the way `foo' does in docstrings?

  • I have had the same question for many years. I ended up never using ~ .. ~, and instead using = .. = for everything verbatim, including inline code snippets. – Kaushal Modi Apr 26 '16 at 15:05
  • 1
    Look at stackoverflow.com/questions/18991981/… for the difference when exporting – CantrianBear Apr 26 '16 at 15:15
6

From the Org info page on "Emphasis and monospace" we have

`=verbatim=' and `~code~'

In your examples the functions and variables are pieces of elisp code, so ~...~ is appropriate. The uses of =...= you cite are for key sequences and text for the user to place in the org buffer, i.e. markup rather than code. However, the markup of =outline-mode= is borderline between the two categories.

3

It's suitable to interpretation. I've been redefining e.g. ~C-f~ to export to <kbd>C-f</kbd> in HTML, and e.g. =forward-char= to <code>forward-char</code>.

(setq org-html-text-markup-alist
      '((bold . "<b>%s</b>")
        (code . "<kbd>%s</kbd>")
        (italic . "<i>%s</i>")
        (strike-through . "<del>%s</del>")
        (underline . "<span class=\"underline\">%s</span>")
        (verbatim . "<code>%s</code>")))

But their default names are indeed code and verbatim, just like the other answer says.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.