From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Re: Re: Using yasnippet with org Mode Date: Tue, 25 Nov 2008 00:51:35 +0100 Message-ID: <8763mcisxk.fsf@kassiopeya.MSHEIMNETZ> References: <4929ADBB.6050809@manor-farm.org> <871vx2f8qs.fsf@gmail.com> <87wseu9m62.fsf@thinkpad.tsdh.de> <87od06dpx0.fsf@gmail.com> <492A7521.7040504@manor-farm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L4lAj-0000J6-QL for emacs-orgmode@gnu.org; Mon, 24 Nov 2008 18:48:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L4lAh-0000Iu-Tf for emacs-orgmode@gnu.org; Mon, 24 Nov 2008 18:48:52 -0500 Received: from [199.232.76.173] (port=49759 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4lAh-0000Ir-P1 for emacs-orgmode@gnu.org; Mon, 24 Nov 2008 18:48:51 -0500 Received: from mail.gmx.net ([213.165.64.20]:57590) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1L4lAg-0006DW-Vd for emacs-orgmode@gnu.org; Mon, 24 Nov 2008 18:48:51 -0500 In-Reply-To: <492A7521.7040504@manor-farm.org> (Ian Barton's message of "Mon, 24 Nov 2008 09:34:25 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Ian, this is my yasnippets setup: .emacs =3D> --->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) <=3D ---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 | `---------------=C2=B4 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 | `----------------------=C2=B4 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: +--------=3D-+ | Stippled | +----------+ picture-mode/box.stippled-rounded: /--------------------=3D-\ | Rounded and stippled | \----------------------/ box: =3D> --->8----------------------------->8----------------------------->8--- #name : ! box | # -- ,${1:$(make-string (string-width text) ?\-)}--. ! ${1:SubTitle} | \`${1:$(make-string (string-width text) ?\-)}--=C2=B4 $0 <=3D ---8<-----------------------------8<-----------------------------8<--- picture-mode/box (you have to draw the closing `|' yourself): =3D> --->8----------------------------->8----------------------------->8--- #name : | straight | # -- +${1:$(make-string (string-width text) ?\-)}--+ | ${1:Entity} |$0 +${1:$(make-string (string-width text) ?\-)}--+ <=3D ---8<-----------------------------8<-----------------------------8<--- picture-mode/box.rounded: =3D> --->8----------------------------->8----------------------------->8--- #name : | rounded | # -- /${1:$(make-string (string-width text) ?\-)}--\\ | ${1:Entity} |$0 \\${1:$(make-string (string-width text) ?\-)}--/ <=3D ---8<-----------------------------8<-----------------------------8<--- One of my most used ones is this here in `php-mode/debug': =3D> --->8----------------------------->8----------------------------->8--- #contributor : Sebastian Rose #name : echo "
"; print_r( ...
# --
echo "
\\\$$1:
"; print_r(\$$1); echo "
".__FILE__.", = line ".__LINE__."
";$0 exit; <=3D ---8<-----------------------------8<-----------------------------8<--- You get the idea... Regards,=20 Sebastian Ian Barton 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 2= 2.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 w= orks 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