[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [Babel] Macro for begin_src?

From: Matt Lundin
Subject: [Orgmode] Re: [Babel] Macro for begin_src?
Date: Sat, 17 Apr 2010 12:52:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Erik Iverson <address@hidden> writes:

>> http://doc.norang.ca/org-mode.html#Yasnippets
>> If anyone else has a different macro set up, I'm still interested in
>> hearing your solutions.
> Nope, yasnippet is the way to go I think!

There are quite a few other options. IMO, installing yasnippet is
overkill if you are only using it for comment blocks in org-mode.

1. The first and simplest option is built into org-mode. Simply type:

<s [TAB] or [M-TAB]

This will automatically expand to:

--8<---------------cut here---------------start------------->8---

--8<---------------cut here---------------end--------------->8---

For a full list of completions, type "C-h v

2. The second option is to save the text to a register:

(set-register ?b "#+begin_src\n\n#+end_src")

Then type C-x r i b to insert the source block.

(info "(emacs) Registers")

3. You can use abbrev mode for dynamic expansion:

 - Activate the abbrev minor-mode in org-mode:

   + M-x abbrev-mode

   + permanently: (add-hook 'org-mode-hook (lambda () (abbrev-mode 1)))

 - In org-mode, type something like "sbp" for a perl source block.

 - Immediately after "sbp" type C-x a i l.

 - Enter the expansion: #+begin_src perl[C-q C-j][C-q C-j]#+end_src

   + Note: the C-q C-j creates a new line in the minibuffer

 - Now, whenever, you type sbp[Space, RET, TAB, etc.] in an org-mode
   buffer, the src block will magically appear.

 - If you want more complex completion (like yasnippet) you can combine
   abbrev mode with skeletons.

    - (info "(emacs) Abbrevs") and
    - http://www.emacswiki.org/emacs/SkeletonMode


reply via email to

[Prev in Thread] Current Thread [Next in Thread]