From: Sebastian Rose <sebastian_rose@gmx.de>
To: emacs-orgmode@gnu.org
Subject: Re: Re: Using yasnippet with org Mode
Date: Tue, 25 Nov 2008 00:51:35 +0100 [thread overview]
Message-ID: <8763mcisxk.fsf@kassiopeya.MSHEIMNETZ> (raw)
In-Reply-To: <492A7521.7040504@manor-farm.org> (Ian Barton's message of "Mon, 24 Nov 2008 09:34:25 +0000")
Ian,
this is my yasnippets setup:
.emacs
=> --->8----------------------------->8----------------------------->8---
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "/home/sebastian/emacs/snippets/")
;; I use the WIN key for my own bindings, since I didn't use Windows for
;; ages, and I don't plan to :-)
;; H-y is convenient on german keyboard (like M-z on english/US
;; keyboard):
(defun sr-yas-in-org ()
"Define H-y as yas/expand in org"
(define-key org-mode-map [(hyper ?y)] 'yas/expand))
(add-hook 'org-mode-hook 'sr-yas-in-org)
<= ---8<-----------------------------8<-----------------------------8<---
Setup of the snippets tree beneath /home/sebastian/emacs/snippets/:
.
`-- fundamental-mode
|-- cc-mode
| |-- c++-mode
| `-- c-mode
|-- css-mode
|-- html-mode
|-- java-mode
|-- message-mode
|-- org-mode
|-- perl-mode
| `-- cperl-mode
|-- php-mode
`-- picture-mode
As you can see, all modes inherit the snippets from fundamental
mode.
Example:
There's a `box' snippet in fundamental-mode which I may use in all
modes. It lives in a file named `box' in fundamental-mode and produces
an output like this:
,---------------.
! this is a box |
`---------------´
Since I have _no_ file named `box' in `org-mode', expanding "box" in an
Org-file looks just the same:
,----------------------.
! This is a box in org |
`----------------------´
For some modes, I overwrite it, simply by adding a file name `box' in
the appropriate subdirectory. This is the result of expanding
`php-mode/box' in a Php-file:
// ------------- //
// This is a box //
// ------------- //
... and in `picture-mode/box':
: +-----------------------+
: | A box in picture-mode |
: +-----------------------+
The former is what used, if I expand the `org-mode/ditaa' snippet in an
org-file, and press C-c '
#+begin_ditaa asdf.png -o
: +-----------------------+
: | A box in picture-mode |
: +-----------------------+
#+end_ditaa
In picture-mode, I have several boxes. I may choose one using the arrow
keys, if all their filenames start with 'box':
picture-mode/box:
+------------------------+
| A box in pictqure-mode |
+------------------------+
picture-mode/box.stippled-rounded:
/---------\
| Rounded |
\---------/
picture-mode/box.stippled:
+--------=-+
| Stippled |
+----------+
picture-mode/box.stippled-rounded:
/--------------------=-\
| Rounded and stippled |
\----------------------/
box:
=> --->8----------------------------->8----------------------------->8---
#name : ! box |
# --
,${1:$(make-string (string-width text) ?\-)}--.
! ${1:SubTitle} |
\`${1:$(make-string (string-width text) ?\-)}--´
$0
<= ---8<-----------------------------8<-----------------------------8<---
picture-mode/box (you have to draw the closing `|' yourself):
=> --->8----------------------------->8----------------------------->8---
#name : | straight |
# --
+${1:$(make-string (string-width text) ?\-)}--+
| ${1:Entity} |$0
+${1:$(make-string (string-width text) ?\-)}--+
<= ---8<-----------------------------8<-----------------------------8<---
picture-mode/box.rounded:
=> --->8----------------------------->8----------------------------->8---
#name : | rounded |
# --
/${1:$(make-string (string-width text) ?\-)}--\\
| ${1:Entity} |$0
\\${1:$(make-string (string-width text) ?\-)}--/
<= ---8<-----------------------------8<-----------------------------8<---
One of my most used ones is this here in `php-mode/debug':
=> --->8----------------------------->8----------------------------->8---
#contributor : Sebastian Rose <sebastian_rose@gmx.de>
#name : echo "<pre>"; print_r( ...
# --
echo "<pre><b>\\\$$1:</b><br />"; print_r(\$$1); echo "<br />".__FILE__.", line ".__LINE__."</pre>";$0 exit;
<= ---8<-----------------------------8<-----------------------------8<---
You get the idea...
Regards,
Sebastian
Ian Barton <lists@manor-farm.org> writes:
>> As for using yasnippets with tab, the following successfully binds tab
>> to yas/expand when I start emacs with
>>
>> emacs -Q (skips loading customization)
>>
>> and then evaluate the following elisp to load yasnippets and org-mode
>>
>> (load "~/emacs/elisp/util/yasnippet.el")
>> (yas/initialize)
>> (yas/load-directory "~/emacs/snippets")
>> (add-to-list 'load-path "~/emacs/org")
>> (require 'org)
>> (add-hook 'org-mode-hook
>> (lambda ()
>> ;; yasnippet
>> (make-variable-buffer-local 'yas/trigger-key)
>> (setq yas/trigger-key [tab])
>> (define-key yas/keymap [tab] 'yas/next-field-group)))
>>
>> This works for me using a fairly recent Emacs 23 from cvs.
>>
>
> Thanks, I have tried that, but it didn't work for me:) I am using Emacs 22.2.1
> (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
> of 2008-09-05 on vernadsky, modified by Ubuntu. I have also tried binding
> Yasnippet to the F1 key, which isn't used by anything else. Whilst this works in
> text mode, it doesn't in org mode.
>
> I'll ask in the Yasnippet list and see if they can suggest anything.
>
> Ian.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.: +49 (0)511 - 36 58 472
Fax: +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http: www.emma-stil.de
next prev parent reply other threads:[~2008-11-24 23:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-23 19:23 Using yasnippet with org Mode Ian Barton
2008-11-23 21:11 ` Eric Schulte
2008-11-23 21:17 ` Tassilo Horn
2008-11-23 22:43 ` Eric Schulte
2008-11-24 9:34 ` Ian Barton
2008-11-24 23:51 ` Sebastian Rose [this message]
2008-11-24 14:46 ` Re: Using yasnippet with org Mode [Solved] Ian Barton
2008-11-24 15:38 ` Re: Using yasnippet with org Mode Eric Schulte
2008-11-24 0:45 ` Oliver Charles
2008-11-24 15:40 ` Eric Schulte
2008-11-25 15:44 ` Org mode snippets WAS: " Jonathan Arkell
2009-09-19 5:06 ` Using yasnippet with org Mode (C-i works TAB doesn't) Jeff Kowalczyk
2009-09-19 13:03 ` Nicolas Goaziou
2009-09-20 14:16 ` Eric Schulte
2009-09-21 17:18 ` Carsten Dominik
2009-09-22 15:52 ` Nicolas Goaziou
2009-09-22 19:22 ` Eric Schulte
2009-09-19 13:46 ` Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8763mcisxk.fsf@kassiopeya.MSHEIMNETZ \
--to=sebastian_rose@gmx.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.