[Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Carsten Dominik carsten.domi...@gmail.com writes: could I ask you to update the FAQ with this issue? It still doesn't work with org-indent-mode on, though. I guess the FAQ will have to specify to disable it before using yasnippet (which is a sad thing as both are providing great features). -- Nicolas Goaziou ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Carsten Dominik carsten.domi...@gmail.com writes: Hi Eric, could I ask you to update the FAQ with this issue? done, should update to Worg within the hour -- Eric ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Hi Eric, could I ask you to update the FAQ with this issue? Thanks. - Carsten On Sep 20, 2009, at 3:16 PM, Eric Schulte wrote: Nicolas Goaziou n.goaz...@gmail.com writes: Jeff Kowalczyk j...@yahoo.com writes: (add-hook 'org-mode-hook (lambda () (org-set-local 'yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) According to the yasnippet FAQ (or is it on its forum), it should be (add-hook 'org-mode-hook #'(lambda () (setq yas/fallback-behavior `(apply ,(lookup-key org-mode-map [tab]))) (local-set-key [tab] 'yas/expand))) Anyway, there is one major problem left, it doesn't work with org-indent-mode as, when you press TAB to get to the next field of a snippet, you are sent to the first headline in the org file. I have yet to find a workaround about that. After upgrading to the newest version of yasnippet I was dismayed to find it no longer working in my own org-mode files. After some painful trial and error I found that the following setup works for me. --8---cut here---start-8--- (defun yas/org-very-safe-expand () (let ((yas/fallback-behavior 'return-nil)) (yas/expand))) (add-hook 'org-mode-hook (lambda () ;; yasnippet (using the new org-cycle hooks) (make-variable-buffer-local 'yas/trigger-key) (setq yas/trigger-key [tab]) (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand) (define-key yas/keymap [tab] 'yas/next-field))) --8---cut here---end---8--- -- Eric Regards, ___ 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 ___ 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
[Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Jeff Kowalczyk j...@yahoo.com writes: (add-hook 'org-mode-hook (lambda () (org-set-local 'yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) According to the yasnippet FAQ (or is it on its forum), it should be (add-hook 'org-mode-hook #'(lambda () (setq yas/fallback-behavior `(apply ,(lookup-key org-mode-map [tab]))) (local-set-key [tab] 'yas/expand))) Anyway, there is one major problem left, it doesn't work with org-indent-mode as, when you press TAB to get to the next field of a snippet, you are sent to the first headline in the org file. I have yet to find a workaround about that. Regards, -- Nicolas Goaziou ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Nicolas Goaziou n.goaz...@gmail.com writes: Jeff Kowalczyk j...@yahoo.com writes: (add-hook 'org-mode-hook (lambda () (org-set-local 'yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) According to the yasnippet FAQ (or is it on its forum), it should be (add-hook 'org-mode-hook #'(lambda () (setq yas/fallback-behavior `(apply ,(lookup-key org-mode-map [tab]))) (local-set-key [tab] 'yas/expand))) Anyway, there is one major problem left, it doesn't work with org-indent-mode as, when you press TAB to get to the next field of a snippet, you are sent to the first headline in the org file. I have yet to find a workaround about that. After upgrading to the newest version of yasnippet I was dismayed to find it no longer working in my own org-mode files. After some painful trial and error I found that the following setup works for me. --8---cut here---start-8--- (defun yas/org-very-safe-expand () (let ((yas/fallback-behavior 'return-nil)) (yas/expand))) (add-hook 'org-mode-hook (lambda () ;; yasnippet (using the new org-cycle hooks) (make-variable-buffer-local 'yas/trigger-key) (setq yas/trigger-key [tab]) (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand) (define-key yas/keymap [tab] 'yas/next-field))) --8---cut here---end---8--- -- Eric Regards, ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
Hmm, The following works for me --8---cut here---start-8--- (add-hook 'org-mode-hook (lambda () (make-variable-buffer-local 'yas/trigger-key) (setq yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) --8---cut here---end---8--- but what you already have looks more like the suggestion in the FAQ at http://orgmode.org/worg/org-faq.php#YASnippet, so I wouldn't be surprised if my setup doesn't work for you either... I'm also using the org git master, and emacs 23 git master, so maybe the problem is related to a recent change in the yasnippet repo? Best -- Eric Jeff Kowalczyk j...@yahoo.com writes: With Emacs 23.1, org git master, and yasnippet svn trunk, I have the problem that the TAB key does not expand snippets, but C-i does. I'm using the Org Manual's recommended configuration to address the conflict, see init.el lines matching org|yas below: (load-file ~/.emacs.d/vendor/yasnippet/yasnippet.el) (yas/initialize) (yas/load-directory ~/.emacs.d/vendor/yasnippet/snippets) (global-set-key \C-cl 'org-store-link) (global-set-key \C-ca 'org-agenda) (setq org-log-done 'time) (setq org-special-ctrl-k t) (org-remember-insinuate) (setq org-directory ~/org/) (setq org-default-notes-file (concat org-directory /notes.org)) (define-key global-map \C-cr 'org-remember) (setq org-clock-into-drawer t) (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree)) (add-hook 'org-mode-hook (lambda () (org-set-local 'yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) I normally have ido enabled, but I disabled it with no change in the behavior. Thanks for any suggestions. Jeff ___ 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 ___ 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
[Orgmode] Re: Using yasnippet with org Mode (C-i works TAB doesn't)
With Emacs 23.1, org git master, and yasnippet svn trunk, I have the problem that the TAB key does not expand snippets, but C-i does. I'm using the Org Manual's recommended configuration to address the conflict, see init.el lines matching org|yas below: (load-file ~/.emacs.d/vendor/yasnippet/yasnippet.el) (yas/initialize) (yas/load-directory ~/.emacs.d/vendor/yasnippet/snippets) (global-set-key \C-cl 'org-store-link) (global-set-key \C-ca 'org-agenda) (setq org-log-done 'time) (setq org-special-ctrl-k t) (org-remember-insinuate) (setq org-directory ~/org/) (setq org-default-notes-file (concat org-directory /notes.org)) (define-key global-map \C-cr 'org-remember) (setq org-clock-into-drawer t) (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree)) (add-hook 'org-mode-hook (lambda () (org-set-local 'yas/trigger-key [tab]) (define-key yas/keymap [tab] 'yas/next-field-group))) I normally have ido enabled, but I disabled it with no change in the behavior. Thanks for any suggestions. Jeff ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode
A solution for using yasnippets in org-mode (from the yasnippets mailing list) Make sure you have snippets defined for org-mode. If you want to use the snippets from text-mode in org-mode, you can make an empty directory named org-mode in the text-mode directory where you put your text mode snippets. ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode
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
Re: [Orgmode] Re: Using yasnippet with org Mode
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 [EMAIL PROTECTED] #name : echo pre; print_r( ... # -- echo preb\\\$$1:/bbr /; print_r(\$$1); echo br /.__FILE__., line .__LINE__./pre;$0 exit; = ---8-8-8--- You get the idea... Regards, Sebastian Ian Barton [EMAIL PROTECTED] 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
[Orgmode] Re: Using yasnippet with org Mode
Eric Schulte [EMAIL PROTECTED] writes: Hi Eric, I think maybe your lambda should not be quoted, try Since lambda evaluates to itself, that doesn't make any difference. , | ELISP (lambda () nil) | (lambda nil nil) | ELISP (quote (lambda () nil)) | (lambda nil nil) ` I suspect yasnippet doesn't play nice with org because both are passionate key hijackers. I'd try to bind yas/expand to some other key, maybe M-TAB in org-mode. Bye, Tassilo ___ 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
Re: [Orgmode] Re: Using yasnippet with org Mode
Tassilo Horn [EMAIL PROTECTED] writes: Eric Schulte [EMAIL PROTECTED] writes: Hi Eric, I think maybe your lambda should not be quoted, try Since lambda evaluates to itself, that doesn't make any difference. Thanks Tassilo, I didn't realize that was the case 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. Hope this helps -- Eric ___ 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