I'm new to org-mode. I'm liking it so far. The one growing pain that I have is missing Markdown-style block quotes: I would like to start a line with >
to quote it. How would I go about writing an extension (or better yet, finding one already written!) that would let me use that syntax?
-
2You do realize that by doing this you're forfeiting interoperability with other Org users, don't you? Also, how much support are you looking for? Syntax highlighting? Indentation? Export? Parse?– wasamasaSep 14, 2018 at 7:52
-
@wasamasa Thanks for the disclaimer. :) Yes, I’m aware of the trade-offs involved. Highlighting and export would be nice. I don’t know about “parsing”... Ideally, it would be an alternate syntax for defining quotes: everything would work just as if it had been defined as a plain block quote.– Ashton WiersdorfSep 14, 2018 at 16:20
-
2Org has an API that allows you to parse Org buffers. Ideally you'd want it to consider an email-quoted block the same as a regular block quote. What I'm pointing at is that Org isn't designed at all to be extended this way.– wasamasaSep 14, 2018 at 19:04
3 Answers
UPDATE:
As of org-mode 9.2, the org-structure-template system has changed.
Inserting a template is now done via C-c C-,
.
To add a shortcut for emacs-lisp in this new system, use the following snippet:
(add-to-list 'org-structure-template-alist
'("se" . "src emacs-lisp"))
Not really an answer to the question directly, but also too much for a comment:
I'd advise against modifying your org-mode
setup like that. It moves away from what org
is, and could lead to issues in the future.
You can, however, easily insert quotes by typing <q
and hitting TAB
, which expands a template. Many templates can be used this way, like <s
for codeblocks.
Explore this functionality further with C-h
v
org-structure-template-alist
RET
.
Adding your own templates is a breeze as well. I added a template for an elisp codeblock like so:
(add-to-list 'org-structure-template-alist
'("se" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"))
The ?
indicates where the point should move upon expansion.
Now <se
TAB
expands into such a block.
-
Thanks! That is helpful. I’ll upvote, but not accept because it’s not a direct answer. But thank you very much! :) Sep 14, 2018 at 16:21
-
2Haha... after almost a year I've gotten way more used to the org way of doing things. Thank you very much for your comment. I'm glad you pointed me away from making crazy incompatible edits. Sep 24, 2019 at 13:22
This answer is becoming more a comment (third edit). If you feel it should be deleted, I have no problem in doing that.
I was looking for this functionality, in order to do in org mode what I do in a web based email system: quick comments to fragments of a long text. As I was using the template expansion based on <q
, I found slow to add #+begin_quote ... #+end_quote
many times. I think, it was not possible to
add (fast) "quote" markers to surround an existing text, a kill/yank was needed. However, in the current version of org mode (see EFLS answer), it's possible (just marking the existing text), it has a default key binding C-x C-,
, and it's fast, :)
JFTR, someone could also found useful to add a colon and a space :
to the beginig of each line, using rectangle-mark-mode
and then string-rectangle
or some of the "replace" functions. Then, interleave comments without the leading colon.
It exports in latex as a verbatim
environment, and in HTML as a pre
tag.
add (require 'org-tempo)
to your init.el
file
then use the following shortcuts by typing the less-than symbol <
, the letter
and then TAB
:
a ‘#+BEGIN_EXPORT ascii’ … ‘#+END_EXPORT’
c ‘#+BEGIN_CENTER’ … ‘#+END_CENTER’
C ‘#+BEGIN_COMMENT’ … ‘#+END_COMMENT’
e ‘#+BEGIN_EXAMPLE’ … ‘#+END_EXAMPLE’
E ‘#+BEGIN_EXPORT’ … ‘#+END_EXPORT’
h ‘#+BEGIN_EXPORT html’ … ‘#+END_EXPORT’
l ‘#+BEGIN_EXPORT latex’ … ‘#+END_EXPORT’
q ‘#+BEGIN_QUOTE’ … ‘#+END_QUOTE’
s ‘#+BEGIN_SRC’ … ‘#+END_SRC’
v ‘#+BEGIN_VERSE’ … ‘#+END_VERSE’