From 7518cb46211692ecd14e774c7c3a8b5dee0c633c Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 6 Dec 2013 12:56:02 -0500 Subject: [PATCH 01/83] rake doc:upload: check for wrong/incomplete rev --- .gitignore | 1 + Rakefile | 11 ++++++++++- doc/yas-doc-helper.el | 12 ++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c433a57..3ce1c40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ authors.txt doc/gh-pages doc/*.html +doc/html-revision pkg/ extras/imported/** !extras/imported/*/.yas-setup.el diff --git a/Rakefile b/Rakefile index 278120d..7300d6b 100644 --- a/Rakefile +++ b/Rakefile @@ -67,7 +67,16 @@ namespace :doc do Dir.glob("doc/images/*").each do |file| FileUtils.cp file, 'doc/gh-pages/images' end - rev = `git rev-parse --verify HEAD` + curRev = `git rev-parse --verify HEAD`.chomp() + expRev = IO.read('doc/html-revision').chomp() + if curRev != expRev + raise ("The HTML rev: #{expRev},\n" + + "current rev: #{curRev}!\n") + end + if !system "git diff-index --quiet HEAD" + system "git status --untracked-files=no" + raise "You have uncommitted changes!" + end Dir.chdir 'doc/gh-pages' do sh "git commit -a -m 'Automatic documentation update.\n\n" + "From #{rev.chomp()}'" diff --git a/doc/yas-doc-helper.el b/doc/yas-doc-helper.el index d504f67..495bf9e 100755 --- a/doc/yas-doc-helper.el +++ b/doc/yas-doc-helper.el @@ -114,13 +114,13 @@ ;; This lets all the org files be exported to HTML with ;; `org-publish-current-project' (C-c C-e P). -(let* ((rev (or (with-temp-buffer - (when (eq (call-process "git" nil t nil - "rev-parse" "--verify" "HEAD") 0) - (buffer-string))) - yas--version)) - (dir (if load-file-name (file-name-directory load-file-name) +(let* ((dir (if load-file-name (file-name-directory load-file-name) default-directory)) + (rev (with-temp-file (expand-file-name "html-revision" dir) + (or (when (eq (call-process "git" nil t nil + "rev-parse" "--verify" "HEAD") 0) + (buffer-string)) + (princ yas--version (current-buffer))))) (proj-plist (list :base-directory dir :publishing-directory dir From d89e837d68cd8466f5017a816e10c131fc80a992 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 10 Dec 2013 22:50:49 -0500 Subject: [PATCH 02/83] add top level menu, minimal styling --- doc/nav-menu.html.inc | 15 +++++++++++++++ doc/org-setup.inc | 2 +- doc/stylesheets/manual.css | 26 ++++++++++++++++++++++++++ doc/yas-doc-helper.el | 4 ++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 doc/nav-menu.html.inc create mode 100644 doc/stylesheets/manual.css diff --git a/doc/nav-menu.html.inc b/doc/nav-menu.html.inc new file mode 100644 index 0000000..a0d8a3e --- /dev/null +++ b/doc/nav-menu.html.inc @@ -0,0 +1,15 @@ + diff --git a/doc/org-setup.inc b/doc/org-setup.inc index 96b7028..98f7c04 100644 --- a/doc/org-setup.inc +++ b/doc/org-setup.inc @@ -4,6 +4,6 @@ #+LINK: sym file:snippet-reference.org::#%s -#+LINK_HOME: ./index.html #+OPTIONS: author:nil num:nil #+AUTHOR: +#+STYLE: diff --git a/doc/stylesheets/manual.css b/doc/stylesheets/manual.css new file mode 100644 index 0000000..f2677c5 --- /dev/null +++ b/doc/stylesheets/manual.css @@ -0,0 +1,26 @@ +nav > ul > li.center > ul { + padding: 0; +} + +nav li { + vertical-align: top; + + display: inline; + list-style-type: none; + padding: 0.5em; +} + +nav > ul > li { + display: inline-block; +} + +/* match org's css for
 */
+code {
+    background-color: #F3F5F7;
+    font-family: courier, monospace;
+}
+
+#content {
+    margin-left: 5%;
+    margin-right: 10%;
+}
diff --git a/doc/yas-doc-helper.el b/doc/yas-doc-helper.el
index 495bf9e..a782c1f 100755
--- a/doc/yas-doc-helper.el
+++ b/doc/yas-doc-helper.el
@@ -124,6 +124,10 @@
        (proj-plist
         (list
          :base-directory dir :publishing-directory dir
+         :html-preamble
+         (with-temp-buffer
+           (insert-file-contents (expand-file-name "nav-menu.html.inc" dir))
+           (buffer-string))
          :html-postamble
          (concat "

Generated by %c on %d from " rev "

\n" From 260ecf9c3a4a8960d48cedf8c9bc80fbdf925528 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 10 Dec 2013 22:52:34 -0500 Subject: [PATCH 03/83] fix a faq title --- doc/faq.org | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/faq.org b/doc/faq.org index cc889e1..79249e8 100644 --- a/doc/faq.org +++ b/doc/faq.org @@ -134,8 +134,7 @@ This is also the default value starting for that version. It skips the minor mode in buffers where it is not applicable (no snippet tables), but only once you have setup your yas-root-directory. -* How do I define an abbrev key containing characters not supported by -the filesystem? +* How do I define an abbrev key containing characters not supported by the filesystem? - *Note*: This question applies if you're still defining snippets whose key /is/ the filename. This is behavior still provided by From b944cc9b12ff88ebbe36a4de6fa73116d1fc2fb5 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 10 Dec 2013 23:02:53 -0500 Subject: [PATCH 04/83] fix rake doc:upload --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 7300d6b..53fc55e 100644 --- a/Rakefile +++ b/Rakefile @@ -79,7 +79,7 @@ namespace :doc do end Dir.chdir 'doc/gh-pages' do sh "git commit -a -m 'Automatic documentation update.\n\n" + - "From #{rev.chomp()}'" + "From #{curRev.chomp()}'" sh "git push" end end From 46b4a0267369321bad7601dd2ff08a483d9e0e91 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 10 Dec 2013 23:10:16 -0500 Subject: [PATCH 05/83] doc:upload stylesheets/*.css to gh-pages --- Rakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Rakefile b/Rakefile index 53fc55e..3f94a9a 100644 --- a/Rakefile +++ b/Rakefile @@ -67,6 +67,9 @@ namespace :doc do Dir.glob("doc/images/*").each do |file| FileUtils.cp file, 'doc/gh-pages/images' end + Dir.glob("doc/stylesheets/*.css").each do |file| + FileUtils.cp file, 'doc/gh-pages/stylesheets' + end curRev = `git rev-parse --verify HEAD`.chomp() expRev = IO.read('doc/html-revision').chomp() if curRev != expRev From 6c752a1572989a7ba1cc4879ed0671f872733485 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 12 Dec 2013 23:19:21 -0500 Subject: [PATCH 06/83] populate yas--exported-syms based on sym prefix Rename what was formerly yas--exported-syms to yas--backported-syms, and remove yas--dont-backport. --- yasnippet.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 85715fd..68908d6 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -4442,7 +4442,7 @@ and return the directory. Return nil if not found." ;;; Backward compatibility to yasnippet <= 0.7 -(defvar yas--exported-syms '(;; `defcustom's +(defvar yas--backported-syms '(;; `defcustom's ;; yas-snippet-dirs yas-prompt-functions @@ -4532,7 +4532,6 @@ and return the directory. Return nil if not found." yas-unimplemented yas-define-condition-cache yas-hippie-try-expand - yas-active-keys ;; debug definitions ;; yas-debug-snippet-vars @@ -4549,16 +4548,11 @@ and return the directory. Return nil if not found." ;; yas-call-with-snippet-dirs ;; yas-with-snippet-dirs ) - "Exported yasnippet symbols. + "Backported yasnippet symbols. -i.e. ones that I will try to keep in future yasnippet versions -and ones that other elisp libraries can more or less safely rely -upon.") +They are mapped to \"yas/*\" variants.") -(defvar yas--dont-backport '(yas-active-keys) - "Exported symbols that don't map back to \"yas/*\" variants.") - -(dolist (sym (set-difference yas--exported-syms yas--dont-backport)) +(dolist (sym yas--backported-syms) (let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym))))) (when (boundp sym) (make-obsolete-variable backported sym "yasnippet 0.8") @@ -4567,6 +4561,22 @@ upon.") (make-obsolete backported sym "yasnippet 0.8") (defalias backported sym)))) +(defvar yas--exported-syms + (let (exported) + (mapatoms (lambda (atom) + (if (and (or (and (boundp atom) + (not (get atom 'byte-obsolete-variable))) + (and (fboundp atom) + (not (get atom 'byte-obsolete-info)))) + (string-match-p "^yas-[^-]" (symbol-name atom))) + (push atom exported)))) + exported) + "Exported yasnippet symbols. + +i.e. the ones with \"yas-\" single dash prefix. I will try to +keep them in future yasnippet versions and other elisp libraries +can more or less safely rely upon them.") + (provide 'yasnippet) From 90e7595c745e38c5f473672089147f62be3f42f4 Mon Sep 17 00:00:00 2001 From: dongxiong Date: Fri, 20 Dec 2013 13:06:37 +0800 Subject: [PATCH 07/83] yas-text export twice Something different between line 4521 and line 4528? I am not sure about this. --- yasnippet.el | 1 - 1 file changed, 1 deletion(-) diff --git a/yasnippet.el b/yasnippet.el index 85715fd..49514da 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -4518,7 +4518,6 @@ and return the directory. Return nil if not found." yas-snippet-end yas-modified-p yas-moving-away-p - yas-text yas-substr yas-choose-value yas-key-to-value From 49166572c8e55ed0e20388bbfea96a88a09e7cfc Mon Sep 17 00:00:00 2001 From: Renaud AUBIN Date: Tue, 24 Dec 2013 09:57:30 +0100 Subject: [PATCH 08/83] Use https instead of ssh for submodules access To enable direct access through a proxy, the submodules url definitions need to use https instead of ssh. --- .gitmodules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 80584ea..607033b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "snippets"] - path = snippets - url = git@github.com:AndreaCrotti/yasnippet-snippets.git + path = snippets + url = https://github.com/AndreaCrotti/yasnippet-snippets.git [submodule "yasmate"] - path = yasmate - url = git@github.com:capitaomorte/yasmate.git + path = yasmate + url = https://github.com/capitaomorte/yasmate.git From c18672a227357a4fd26df99336b0a431d1f69ef5 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Tue, 24 Dec 2013 09:43:56 +0000 Subject: [PATCH 09/83] Closes #447: only call command beyond yasnippet if it exists --- yasnippet.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yasnippet.el b/yasnippet.el index 9990bc8..9348590 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -2276,7 +2276,8 @@ Common gateway for `yas-expand-from-trigger-key' and (yas--message 4 "Falling back to %s" beyond-yasnippet) (assert (or (null beyond-yasnippet) (commandp beyond-yasnippet))) (setq this-original-command beyond-yasnippet) - (call-interactively beyond-yasnippet))) + (when beyond-yasnippet + (call-interactively beyond-yasnippet)))) ((and (listp yas-fallback-behavior) (cdr yas-fallback-behavior) (eq 'apply (car yas-fallback-behavior))) From 24d7a6793285d0683ab2ebaed19ed066602f524a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 24 Dec 2013 11:14:39 -0500 Subject: [PATCH 10/83] fix typo --- doc/snippet-expansion.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/snippet-expansion.org b/doc/snippet-expansion.org index 0618d4a..876b81c 100644 --- a/doc/snippet-expansion.org +++ b/doc/snippet-expansion.org @@ -53,7 +53,7 @@ When you use [[sym:yas-global-mode][=yas-global-mode=]] you can also selectively YASnippet in some buffers by setting the buffer-local variable [[sym:yas-dont-active][=yas-dont-active=]] in the buffer's mode hook. -*** Fallback bahaviour +*** Fallback behaviour [[sym:yas-fallback-behaviour][=yas-fallback-behaviour=]] is a customization variable bound to '=call-other-command= by default. If [[sym:yas-expand][=yas-expand=]] failed to find any From 22773c77a0d67c075d682c408dc495521a2be269 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 24 Dec 2013 11:14:57 -0500 Subject: [PATCH 11/83] add a link to the symbol reference in top menu --- doc/nav-menu.html.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/nav-menu.html.inc b/doc/nav-menu.html.inc index a0d8a3e..b31ec94 100644 --- a/doc/nav-menu.html.inc +++ b/doc/nav-menu.html.inc @@ -11,5 +11,6 @@
  • Menu
  • FAQ +
  • Reference From e190b088f019ac57b7f73a2fa199ef1853c3aaac Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 24 Dec 2013 11:27:57 -0500 Subject: [PATCH 12/83] Rakefile: don't fail with EMACS=t env setting This lets it work from M-x shell. --- Rakefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 3f94a9a..efbea56 100644 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,10 @@ require 'fileutils' -$EMACS=ENV["EMACS"] || "emacs" +$EMACS = ENV["EMACS"] +if not $EMACS or $EMACS == 't' + $EMACS = "emacs" +end def find_version File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/ From df58222fe669388f5d7586896fefee29db5a8b67 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 24 Dec 2013 11:36:16 -0500 Subject: [PATCH 13/83] yas--document-symbols: respect level arg, raise to 1 --- doc/snippet-reference.org | 5 +---- doc/yas-doc-helper.el | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/snippet-reference.org b/doc/snippet-reference.org index 3dd674f..a38fca5 100644 --- a/doc/snippet-reference.org +++ b/doc/snippet-reference.org @@ -2,14 +2,11 @@ #+TITLE: Reference -* Reference - #+BEGIN_SRC emacs-lisp :exports results :results value raw -(yas--document-symbols 2 `("Interactive functions" . ,#'interactive-form) +(yas--document-symbols 1 `("Interactive functions" . ,#'interactive-form) `("Customization variables" . ,#'(lambda (sym) (and (boundp sym) (get sym 'standard-value)))) `("Useful functions" . ,#'fboundp) `("Useful variables" . ,#'boundp)) #+END_SRC - diff --git a/doc/yas-doc-helper.el b/doc/yas-doc-helper.el index a782c1f..cec818c 100755 --- a/doc/yas-doc-helper.el +++ b/doc/yas-doc-helper.el @@ -91,7 +91,8 @@ body)))) (defun yas--document-symbols (level &rest names-and-predicates) - (let ((sym-lists (make-vector (length names-and-predicates) nil))) + (let ((sym-lists (make-vector (length names-and-predicates) nil)) + (stars (make-string level ?*))) (loop for sym in yas--exported-syms do (loop for test in (mapcar #'cdr names-and-predicates) for i from 0 @@ -100,7 +101,7 @@ (return)))) (loop for slist across sym-lists for name in (mapcar #'car names-and-predicates) - concat (format "\n** %s\n" name) + concat (format "\n%s %s\n" stars name) concat (mapconcat (lambda (sym) (yas--document-symbol sym (1+ level))) slist "\n\n")))) From 78c8b5eb8058e8da523542b1b1de7e21a5b60e14 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 24 Dec 2013 11:49:24 -0500 Subject: [PATCH 14/83] yas--document-symbol: fix no transform case was causing YASnippetnippet --- doc/yas-doc-helper.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/yas-doc-helper.el b/doc/yas-doc-helper.el index cec818c..925e41b 100755 --- a/doc/yas-doc-helper.el +++ b/doc/yas-doc-helper.el @@ -67,13 +67,14 @@ (setq body (replace-regexp-in-string "\\<\\([A-Z][-A-Z0-9]+\\)\\(\\sw+\\)?\\>" #'(lambda (match) - (let* ((match1 (downcase (match-string 1 match))) + (let* ((match1 (match-string 1 match)) + (prefix (downcase match1)) (suffix (match-string 2 match)) (fmt (cond - ((member match1 args) "@%s@") + ((member prefix args) "@%s@") ((null suffix) "/%s/")))) - (if fmt (format fmt match1) - match))) + (if fmt (format fmt prefix) + match1))) body t t 1) body (replace-regexp-in-string "`\\([a-z-]+\\)'" From 12b7f82dd8cdac4dc577b6a0b6a91b71b1e61142 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Tue, 31 Dec 2013 15:33:20 +0000 Subject: [PATCH 15/83] Add Travis CI and update tests. Start a Changelog. * .travis.yml: new file * README.mdown: Add Travis CI badge. * Rakefile: use ert-run-tests-batch-and-exit. * yasnippet-tests.el (example-for-issue-404-external-emacs): Use `yas-with-snippet-dirs' to not depend on bundled snippets. (yas--call-with-temporary-redefinitions): Use `cl-labels' since no cl-flet in emacs-24.3's cl-lib.el. (loading-with-cyclic-parenthood): prog-mode doesn't exist in emacs 24.3. (yas-batch-run-tests): remove it. * yasnippet.el (require): require cl-lib during byte-compilation and load. --- .travis.yml | 23 +++++++++++++++++++++++ ChangeLog | 18 ++++++++++++++++++ README.mdown | 2 ++ Rakefile | 5 ++--- yasnippet-tests.el | 47 +++++++++++++++++++++++----------------------- yasnippet.el | 2 ++ 6 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 .travis.yml create mode 100644 ChangeLog diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..83990f6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: emacs +before_install: + - echo -e "\ndeb http://us.archive.ubuntu.com/ubuntu raring universe multiverse main" | sudo tee -a /etc/apt/sources.list + - echo -e "\ndeb http://emacs.naquadah.org/ stable/" | sudo tee -a /etc/apt/sources.list + - echo -e "\ndeb-src http://emacs.naquadah.org/ stable/" | sudo tee -a /etc/apt/sources.list + - cat /etc/apt/sources.list + - wget -q -O - http://emacs.naquadah.org/key.gpg | sudo apt-key add - + - sudo apt-get update +install: + - sudo apt-get install emacs + - sudo apt-get -t raring install libgnutls26 + - sudo apt-get install emacs-snapshot-nox + - curl -O https://raw.github.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el + - curl -O https://raw.github.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert-x.el + - curl -o cl-lib.el http://elpa.gnu.org/packages/cl-lib-0.3.el +before_script: +script: + - export EMACS=emacs; rm *.elc; rake compile; rake tests + - rm ert*.el; rm cl-lib.el + - export EMACS=emacs-snapshot; rm *.elc; rake compile; rake tests +notifications: + email: + - joaotavora@gmail.com diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..483f2ac --- /dev/null +++ b/ChangeLog @@ -0,0 +1,18 @@ +2013-12-31 João Távora + + * yasnippet.el (require): require cl-lib during byte-compilation + and load. + + * yasnippet-tests.el (example-for-issue-404-external-emacs): Use + `yas-with-snippet-dirs' to not depend on bundled snippets. + (yas--call-with-temporary-redefinitions): Use `cl-labels' since no + cl-flet in emacs-24.3's cl-lib.el. + (loading-with-cyclic-parenthood): prog-mode doesn't exist in emacs + 24.3. + (yas-batch-run-tests): remove it. + + * Rakefile: use ert-run-tests-batch-and-exit. + + * README.mdown: Add Travis CI badge. + + * .travis.yml: new file diff --git a/README.mdown b/README.mdown index da61284..4a8d597 100644 --- a/README.mdown +++ b/README.mdown @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/capitaomorte/yasnippet.png)](https://travis-ci.org/capitaomorte/yasnippet) + # Intro **YASnippet** is a template system for Emacs. It allows you to diff --git a/Rakefile b/Rakefile index efbea56..2965eb9 100644 --- a/Rakefile +++ b/Rakefile @@ -16,9 +16,8 @@ FileUtils.mkdir_p('pkg') desc "run tests in batch mode" task :tests do - batch_run_line = "(yas-batch-run-tests t)" - sh "#{$EMACS} -Q -L . -l yasnippet-tests.el -nw" + - " --batch --eval '#{batch_run_line}'" + sh "#{$EMACS} -Q -L . -l yasnippet-tests.el" + + " --batch -f ert-run-tests-batch-and-exit" end desc "create a release package" diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 4e2f1bc..d2f3c2c 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -229,20 +229,26 @@ (insert (pp-to-string `(condition-case _ (progn - (require 'yasnippet) - (yas-global-mode) - (switch-to-buffer "foo.c") - (c-mode) - (insert "#include \nmain") - (setq yas-good-grace nil) - (yas-expand) - (kill-emacs 0)) + (require 'yasnippet-tests) + (yas-with-snippet-dirs + '((".emacs.d/snippets" + ("c-mode" + ("main" . "int main ()")))) + (yas-global-mode) + (switch-to-buffer "foo.c") + (c-mode) + (insert "#include \nmain") + (setq yas-good-grace nil) + (yas-expand) + (should (string= (buffer-string) + "#include \nint main ()")) + (kill-emacs 0))) (error (kill-emacs -1))))) (write-file fixture-el-file)) (should (= 0 (call-process (concat invocation-directory invocation-name) nil nil nil - "-Q" ;; "--batch" + "-Q" "--batch" "-L" "." "-l" fixture-el-file))))) (ert-deftest middle-of-buffer-snippet-insertion () @@ -325,10 +331,10 @@ TODO: correct this bug!" ;; saving all definitions before overriding anything ensures FDEFINITION ;; errors don't cause accidental permanent redefinitions. ;; - (cl-flet ((set-fdefinitions (names functions) - (loop for name in names - for fn in functions - do (fset name fn)))) + (cl-labels ((set-fdefinitions (names functions) + (loop for name in names + for fn in functions + do (fset name fn)))) (set-fdefinitions definition-names overriding-functions) (unwind-protect (funcall function) (set-fdefinitions definition-names saved-functions))))) @@ -409,12 +415,14 @@ TODO: correct this bug!" (yas-reload-all) (with-temp-buffer (let* ((major-mode 'c-mode) - (expected '(c-mode + (expected `(c-mode cc-mode yet-another-c-mode and-also-this-one and-that-one - prog-mode + ;; prog-mode doesn't exit in emacs 24.3 + ,@(if (fboundp 'prog-mode) + '(prog-mode)) emacs-lisp-mode lisp-interaction-mode)) (observed (yas--modes-to-activate))) @@ -627,15 +635,6 @@ add the snippets associated with the given mode." ;;; Helpers ;;; -(defun yas-batch-run-tests (&optional also-external) - (interactive) - (with-temp-buffer - (yas--with-temporary-redefinitions - ((message (&rest _args) nil)) - (ert (or (and also-external t) - '(not (tag :external))) (buffer-name (current-buffer))) - (princ (buffer-string))))) - (defun yas-should-expand (keys-and-expansions) (dolist (key-and-expansion keys-and-expansions) (yas-exit-all-snippets) diff --git a/yasnippet.el b/yasnippet.el index 9348590..98ace6a 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -130,6 +130,8 @@ ;;; Code: (require 'cl) +(eval-and-compile + (require 'cl-lib)) (require 'easymenu) (require 'help-mode) From 3002043496b73693a46287e4089108502b1e4e89 Mon Sep 17 00:00:00 2001 From: Xiao Hanyu Date: Tue, 31 Dec 2013 14:52:02 +0800 Subject: [PATCH 16/83] Sync git submodule for yasmate repo --- yasmate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasmate b/yasmate index 78ef957..0543618 160000 --- a/yasmate +++ b/yasmate @@ -1 +1 @@ -Subproject commit 78ef957e6bbc2891fb644e060f504c68ac1d8c6b +Subproject commit 0543618bd34a6715918992f01161c118f136bb37 From 0f8c2ab4381449298d8bc8b8ee63524aaa8ba1ac Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Mon, 6 Jan 2014 18:03:11 +0000 Subject: [PATCH 17/83] Add `yas-after-reload-hook' and run it at the end of `yas-reload-all' See https://github.com/pezra/rspec-mode/pull/75 for the discussion leading up to this change. --- ChangeLog | 10 ++++++++++ yasnippet.el | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 483f2ac..c735533 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-06 João Távora + + * yasnippet.el (yas-reload-all): run `yas-after-reload-hook'. + (yas-after-reload-hook): add it. + 2013-12-31 João Távora * yasnippet.el (require): require cl-lib during byte-compilation @@ -16,3 +21,8 @@ * README.mdown: Add Travis CI badge. * .travis.yml: new file + + +;; Local Variables: +;; coding: utf-8 +;; End: diff --git a/yasnippet.el b/yasnippet.el index 98ace6a..269d008 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1931,10 +1931,14 @@ loading." ;; (yas-direct-keymaps-reload) + (run-hooks 'yas-after-reload-hook) (yas--message 3 "Reloaded everything%s...%s." (if interactive "" " (snippets will load just-in-time)") (if errors " (some errors, check *Messages*)" ""))))) +(defvar yas-after-reload-hook nil + "Hooks run after `yas-reload-all'.") + (defun yas--load-pending-jits () (dolist (mode (yas--modes-to-activate)) (let ((funs (reverse (gethash mode yas--scheduled-jit-loads)))) From 987942c513da38c1b174112b9e26f853fd5f1c4d Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 23 Feb 2014 15:02:37 -0500 Subject: [PATCH 18/83] update snippets submodule --- snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets b/snippets index 7638321..250814e 160000 --- a/snippets +++ b/snippets @@ -1 +1 @@ -Subproject commit 7638321285cf78a9d075fa63d5ada105aa44752e +Subproject commit 250814eef42372c419c8f954f1f6ea5cd04a8b9b From c128580598b8b548616da28930b9382e18d5394f Mon Sep 17 00:00:00 2001 From: Raimon Grau Date: Thu, 27 Feb 2014 12:34:55 +0100 Subject: [PATCH 19/83] yasnippet templates don't add newlines --- yasnippet.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasnippet.el b/yasnippet.el index 269d008..608cccf 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -185,7 +185,7 @@ as the default for storing the user's new snippets." (defvaralias 'yas/root-directory 'yas-snippet-dirs) (defcustom yas-new-snippet-default "\ -# -*- mode: snippet -*- +# -*- mode: snippet; require-final-newline: nil -*- # name: $1 # key: ${2:${1:$(yas--key-from-desc yas-text)}}${3: # binding: ${4:direct-keybinding}}${5: From 3744f92ad21860ca2fa7e008e3e4311851117ace Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 2 Mar 2014 11:18:54 -0500 Subject: [PATCH 20/83] avoid double choices reversing Both yas-choose-value the yas-prompt-functions were reversing values (cancelling each other out), instead just keep the choices in order the whole time. --- yasnippet.el | 98 +++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 608cccf..f585b88 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1542,25 +1542,24 @@ Optional PROMPT sets the prompt to use." ;; up as `yas--all-templates' I think. ;; (when (and window-system choices) - (let ((chosen - (let (menu d) ;; d for display - (dolist (c choices) - (setq d (or (and display-fn (funcall display-fn c)) - c)) - (cond ((stringp d) - (push (cons (concat " " d) c) menu)) - ((listp d) - (push (car d) menu)))) - (setq menu (list prompt (push "title" menu))) - (x-popup-menu (if (fboundp 'posn-at-point) - (let ((x-y (posn-x-y (posn-at-point (point))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - menu)))) - (or chosen - (keyboard-quit))))) + (or + (let* ((display-fn (or display-fn #'identity)) + (menu + (list prompt + (cons "title" + (mapcar (lambda (c) + (let ((d (funcall display-fn c))) + (cond ((stringp d) (cons (concat " " d) c)) + ((listp d) (car d))))) + choices))))) + (x-popup-menu (if (fboundp 'posn-at-point) + (let ((x-y (posn-x-y (posn-at-point (point))))) + (list (list (+ (car x-y) 10) + (+ (cdr x-y) 20)) + (selected-window))) + t) + menu)) + (keyboard-quit)))) (defun yas--x-pretty-prompt-templates (prompt templates) "Display TEMPLATES, grouping neatly by table name." @@ -1601,46 +1600,28 @@ Optional PROMPT sets the prompt to use." (defun yas-dropdown-prompt (_prompt choices &optional display-fn) (when (fboundp 'dropdown-list) - (let (formatted-choices - filtered-choices - d - n) - (dolist (choice choices) - (setq d (or (and display-fn (funcall display-fn choice)) - choice)) - (when (stringp d) - (push d formatted-choices) - (push choice filtered-choices))) - - (setq n (and formatted-choices (dropdown-list formatted-choices))) + (let* ((formatted-choices (if display-fn (delete-if-not display-fn choices) + choices)) + (filtered-choices (if display-fn (mapcar display-fn filtered-choices) + choices)) + (n (and formatted-choices + (dropdown-list formatted-choices)))) (if n (nth n filtered-choices) (keyboard-quit))))) (defun yas-completing-prompt (prompt choices &optional display-fn completion-fn) - (let (formatted-choices - filtered-choices - chosen - d - (completion-fn (or completion-fn - #'completing-read))) - (dolist (choice choices) - (setq d (or (and display-fn (funcall display-fn choice)) - choice)) - (when (stringp d) - (push d formatted-choices) - (push choice filtered-choices))) - (setq chosen (and formatted-choices - (funcall completion-fn prompt - formatted-choices - nil - 'require-match - nil - nil))) - (let ((position (or (and chosen - (position chosen formatted-choices :test #'string=)) - 0))) - (nth position filtered-choices)))) + (let* ((formatted-choices (if display-fn (delete-if-not display-fn choices) + choices)) + (filtered-choices (if display-fn (mapcar display-fn filtered-choices) + choices)) + (chosen (and formatted-choices + (funcall (or completion-fn #'completing-read) + prompt formatted-choices + nil 'require-match nil nil))) + (position (and chosen + (position chosen formatted-choices :test #'string=)))) + (nth (or position 0) filtered-choices))) (defun yas-no-prompt (_prompt choices &optional _display-fn) (first choices)) @@ -2808,10 +2789,11 @@ If found, the content of subexp group SUBEXP (default 0) is The last element of POSSIBILITIES may be a list of strings." (unless (or yas-moving-away-p yas-modified-p) - (setq possibilities (nreverse possibilities)) - (setq possibilities (if (listp (car possibilities)) - (append (reverse (car possibilities)) (rest possibilities)) - possibilities)) + (let* ((last-link (last possibilities)) + (last-elem (car last-link))) + (when (listp last-elem) + (setcar last-link (car last-elem)) + (setcdr last-link (cdr last-elem)))) (some #'(lambda (fn) (funcall fn "Choose: " possibilities)) yas-prompt-functions))) From 1fc858fac635e40572c2e881fca1d8fa1ed95062 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Mon, 3 Mar 2014 08:53:04 +0000 Subject: [PATCH 21/83] Remove experimental Changelog file The Changelog format is good but having a file for it is not. The same format can be had in messages by having using vc-dir and C-x 4 a. A temporary dummy changelog appears and that content goes to the git log message, which is just as good in content and much better in form. --- ChangeLog | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index c735533..0000000 --- a/ChangeLog +++ /dev/null @@ -1,28 +0,0 @@ -2014-01-06 João Távora - - * yasnippet.el (yas-reload-all): run `yas-after-reload-hook'. - (yas-after-reload-hook): add it. - -2013-12-31 João Távora - - * yasnippet.el (require): require cl-lib during byte-compilation - and load. - - * yasnippet-tests.el (example-for-issue-404-external-emacs): Use - `yas-with-snippet-dirs' to not depend on bundled snippets. - (yas--call-with-temporary-redefinitions): Use `cl-labels' since no - cl-flet in emacs-24.3's cl-lib.el. - (loading-with-cyclic-parenthood): prog-mode doesn't exist in emacs - 24.3. - (yas-batch-run-tests): remove it. - - * Rakefile: use ert-run-tests-batch-and-exit. - - * README.mdown: Add Travis CI badge. - - * .travis.yml: new file - - -;; Local Variables: -;; coding: utf-8 -;; End: From 4d220f726a5c8adf51b3a330ca53a20141c3e0aa Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Mon, 3 Mar 2014 08:53:20 +0000 Subject: [PATCH 22/83] Remove an obsolete hack notice * yasnippet.el (yas-x-prompt): Remove hack notice. --- yasnippet.el | 7 ------- 1 file changed, 7 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 608cccf..b3b5157 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1534,13 +1534,6 @@ Optional PROMPT sets the prompt to use." (defun yas-x-prompt (prompt choices &optional display-fn) "Display choices in a x-window prompt." - ;; FIXME: HACK: if we notice that one of the objects in choices is - ;; actually a `yas--template', defer to `yas--x-prompt-pretty-templates' - ;; - ;; This would be better implemented by passing CHOICES as a - ;; structured tree rather than a list. Modifications would go as far - ;; up as `yas--all-templates' I think. - ;; (when (and window-system choices) (let ((chosen (let (menu d) ;; d for display From 44701103845fc4ae660e1587748ec661dca3b98d Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 3 Mar 2014 18:20:47 -0500 Subject: [PATCH 23/83] display-fn isn't actually used for filtering --- yasnippet.el | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index f585b88..d21f3cb 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1600,28 +1600,22 @@ Optional PROMPT sets the prompt to use." (defun yas-dropdown-prompt (_prompt choices &optional display-fn) (when (fboundp 'dropdown-list) - (let* ((formatted-choices (if display-fn (delete-if-not display-fn choices) - choices)) - (filtered-choices (if display-fn (mapcar display-fn filtered-choices) - choices)) - (n (and formatted-choices - (dropdown-list formatted-choices)))) - (if n - (nth n filtered-choices) + (let* ((formatted-choices + (if display-fn (mapcar display-fn choices) choices)) + (n (dropdown-list formatted-choices))) + (if n (nth n choices) (keyboard-quit))))) (defun yas-completing-prompt (prompt choices &optional display-fn completion-fn) - (let* ((formatted-choices (if display-fn (delete-if-not display-fn choices) - choices)) - (filtered-choices (if display-fn (mapcar display-fn filtered-choices) - choices)) - (chosen (and formatted-choices - (funcall (or completion-fn #'completing-read) - prompt formatted-choices - nil 'require-match nil nil))) - (position (and chosen - (position chosen formatted-choices :test #'string=)))) - (nth (or position 0) filtered-choices))) + (let* ((formatted-choices + (if display-fn (mapcar display-fn choices) choices)) + (chosen (funcall (or completion-fn #'completing-read) + prompt formatted-choices + nil 'require-match nil nil))) + (if (eq choices formatted-choices) + chosen + (nth (or (position chosen formatted-choices :test #'string=) 0) + choices)))) (defun yas-no-prompt (_prompt choices &optional _display-fn) (first choices)) From c07db054ecac82fbb8353240648e8454e734d166 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 4 Mar 2014 21:46:05 -0500 Subject: [PATCH 24/83] yas-x-prompt: remove dead code --- yasnippet.el | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index d21f3cb..62a1d8f 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1543,22 +1543,17 @@ Optional PROMPT sets the prompt to use." ;; (when (and window-system choices) (or - (let* ((display-fn (or display-fn #'identity)) - (menu - (list prompt - (cons "title" - (mapcar (lambda (c) - (let ((d (funcall display-fn c))) - (cond ((stringp d) (cons (concat " " d) c)) - ((listp d) (car d))))) - choices))))) - (x-popup-menu (if (fboundp 'posn-at-point) - (let ((x-y (posn-x-y (posn-at-point (point))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - menu)) + (x-popup-menu + (if (fboundp 'posn-at-point) + (let ((x-y (posn-x-y (posn-at-point (point))))) + (list (list (+ (car x-y) 10) + (+ (cdr x-y) 20)) + (selected-window))) + t) + `(,prompt ("title" + ,@(mapcar* (lambda (c d) `(,(concat " " d) . ,c)) + choices + (if display-fn (mapcar display-fn choices) choices))))) (keyboard-quit)))) (defun yas--x-pretty-prompt-templates (prompt templates) From 43a501aa567d5507e9797c30ab7dc98a13565d4e Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 5 Mar 2014 22:38:46 -0500 Subject: [PATCH 25/83] remove yas--x-pretty-prompt-templates --- yasnippet.el | 51 +++++++-------------------------------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 62a1d8f..1a87e39 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1489,10 +1489,6 @@ Here's a list of currently recognized directives: ;;; Popping up for keys and templates -(defvar yas--x-pretty-prompt-templates nil - "If non-nil, attempt to prompt for templates like TextMate.") - - (defun yas--prompt-for-template (templates &optional prompt) "Interactively choose a template from the list TEMPLATES. @@ -1504,13 +1500,11 @@ Optional PROMPT sets the prompt to use." (sort templates #'(lambda (t1 t2) (< (length (yas--template-name t1)) (length (yas--template-name t2)))))) - (if yas--x-pretty-prompt-templates - (yas--x-pretty-prompt-templates "Choose a snippet" templates) - (some #'(lambda (fn) - (funcall fn (or prompt "Choose a snippet: ") - templates - #'yas--template-name)) - yas-prompt-functions)))) + (some #'(lambda (fn) + (funcall fn (or prompt "Choose a snippet: ") + templates + #'yas--template-name)) + yas-prompt-functions))) (defun yas--prompt-for-keys (keys &optional prompt) "Interactively choose a template key from the list KEYS. @@ -1556,37 +1550,6 @@ Optional PROMPT sets the prompt to use." (if display-fn (mapcar display-fn choices) choices))))) (keyboard-quit)))) -(defun yas--x-pretty-prompt-templates (prompt templates) - "Display TEMPLATES, grouping neatly by table name." - (let ((organized (make-hash-table :test #'equal)) - menu - more-than-one-table - prefix) - (dolist (tl templates) - (puthash (yas--template-table tl) - (cons tl - (gethash (yas--template-table tl) organized)) - organized)) - (setq more-than-one-table (> (hash-table-count organized) 1)) - (setq prefix (if more-than-one-table - " " "")) - (if more-than-one-table - (maphash #'(lambda (table templates) - (push (yas--table-name table) menu) - (dolist (tl templates) - (push (cons (concat prefix (yas--template-name tl)) tl) menu))) organized) - (setq menu (mapcar #'(lambda (tl) (cons (concat prefix (yas--template-name tl)) tl)) templates))) - - (setq menu (nreverse menu)) - (or (x-popup-menu (if (fboundp 'posn-at-point) - (let ((x-y (posn-x-y (posn-at-point (point))))) - (list (list (+ (car x-y) 10) - (+ (cdr x-y) 20)) - (selected-window))) - t) - (list prompt (push "title" menu))) - (keyboard-quit)))) - (defun yas-ido-prompt (prompt choices &optional display-fn) (when (and (fboundp 'ido-completing-read) (or (>= emacs-major-version 24) @@ -2224,8 +2187,8 @@ Prompt the user if TEMPLATES has more than one element, else expand immediately. Common gateway for `yas-expand-from-trigger-key' and `yas-expand-from-keymap'." (let ((yas--current-template (or (and (rest templates) ;; more than one - (yas--prompt-for-template (mapcar #'cdr templates))) - (cdar templates)))) + (yas--prompt-for-template (mapcar #'cdr templates))) + (cdar templates)))) (when yas--current-template (yas-expand-snippet (yas--template-content yas--current-template) start From 498cbe4138d74f39f7447acc9de456291c639724 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Thu, 13 Mar 2014 19:04:05 +0000 Subject: [PATCH 26/83] Closes #469: Don't use `yas--init-minor-keymap' * yasnippet.el (yas-use-menu): Don't allow `nil' value, it's useless. (yas--minor-mode-menu): Use top-level `easy-menu-define' form. (yas--init-minor-keymap): Remove definition. --- yasnippet.el | 223 ++++++++++++++++++++++++--------------------------- 1 file changed, 107 insertions(+), 116 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index f4b4751..50a6e4b 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -313,9 +313,6 @@ menu and the modes set in `yas--extra-modes' are listed. - If set to `full', every submenu is listed -- It set to nil, don't display a menu at all (this requires a - `yas-reload-all' call if the menu is already visible). - Any other non-nil value, every submenu is listed." :type '(choice (const :tag "Full" full) (const :tag "Abbreviate" abbreviate) @@ -536,127 +533,121 @@ snippet itself contains a condition that returns the symbol (defvar yas--minor-mode-menu nil "Holds the YASnippet menu.") -(defun yas--init-minor-keymap () - "Set up the `yas-minor-mode' keymap." +(defvar yas-minor-mode-map (let ((map (make-sparse-keymap))) - (when yas-use-menu - (easy-menu-define yas--minor-mode-menu - map - "Menu used when `yas-minor-mode' is active." - '("YASnippet" - "----" - ["Expand trigger" yas-expand - :help "Possibly expand tab trigger before point"] - ["Insert at point..." yas-insert-snippet - :help "Prompt for an expandable snippet and expand it at point"] - ["New snippet..." yas-new-snippet - :help "Create a new snippet in an appropriate directory"] - ["Visit snippet file..." yas-visit-snippet-file - :help "Prompt for an expandable snippet and find its file"] - "----" - ("Snippet menu behaviour" - ["Visit snippets" (setq yas-visit-from-menu t) - :help "Visit snippets from the menu" - :active t :style radio :selected yas-visit-from-menu] - ["Expand snippets" (setq yas-visit-from-menu nil) - :help "Expand snippets from the menu" - :active t :style radio :selected (not yas-visit-from-menu)] - "----" - ["Show all known modes" (setq yas-use-menu 'full) - :help "Show one snippet submenu for each loaded table" - :active t :style radio :selected (eq yas-use-menu 'full)] - ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) - :help "Show only snippet submenus for the current active modes" - :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) - ("Indenting" - ["Auto" (setq yas-indent-line 'auto) - :help "Indent each line of the snippet with `indent-according-to-mode'" - :active t :style radio :selected (eq yas-indent-line 'auto)] - ["Fixed" (setq yas-indent-line 'fixed) - :help "Indent the snippet to the current column" - :active t :style radio :selected (eq yas-indent-line 'fixed)] - ["None" (setq yas-indent-line 'none) - :help "Don't apply any particular snippet indentation after expansion" - :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] - "----" - ["Also auto indent first line" (setq yas-also-auto-indent-first-line - (not yas-also-auto-indent-first-line)) - :help "When auto-indenting also, auto indent the first line menu" - :active (eq yas-indent-line 'auto) - :style toggle :selected yas-also-auto-indent-first-line] - ) - ("Prompting method" - ["System X-widget" (setq yas-prompt-functions - (cons 'yas-x-prompt - (remove 'yas-x-prompt - yas-prompt-functions))) - :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-x-prompt)] - ["Dropdown-list" (setq yas-prompt-functions - (cons 'yas-dropdown-prompt - (remove 'yas-dropdown-prompt - yas-prompt-functions))) - :help "Use a special dropdown list" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-dropdown-prompt)] - ["Ido" (setq yas-prompt-functions - (cons 'yas-ido-prompt - (remove 'yas-ido-prompt - yas-prompt-functions))) - :help "Use an ido-style minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-ido-prompt)] - ["Completing read" (setq yas-prompt-functions - (cons 'yas-completing-prompt - (remove 'yas-completing-prompt - yas-prompt-functions))) - :help "Use a normal minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-completing-prompt)] - ) - ("Misc" - ["Wrap region in exit marker" - (setq yas-wrap-around-region - (not yas-wrap-around-region)) - :help "If non-nil automatically wrap the selected text in the $0 snippet exit" - :style toggle :selected yas-wrap-around-region] - ["Allow stacked expansions " - (setq yas-triggers-in-field - (not yas-triggers-in-field)) - :help "If non-nil allow snippets to be triggered inside other snippet fields" - :style toggle :selected yas-triggers-in-field] - ["Revive snippets on undo " - (setq yas-snippet-revival - (not yas-snippet-revival)) - :help "If non-nil allow snippets to become active again after undo" - :style toggle :selected yas-snippet-revival] - ["Good grace " - (setq yas-good-grace - (not yas-good-grace)) - :help "If non-nil don't raise errors in bad embedded elisp in snippets" - :style toggle :selected yas-good-grace] - ) - "----" - ["Load snippets..." yas-load-directory - :help "Load snippets from a specific directory"] - ["Reload everything" yas-reload-all - :help "Cleanup stuff, reload snippets, rebuild menus"] - ["About" yas-about - :help "Display some information about YASnippet"]))) - - ;; Now for the stuff that has direct keybindings - ;; (define-key map [(tab)] 'yas-expand) (define-key map (kbd "TAB") 'yas-expand) (define-key map "\C-c&\C-s" 'yas-insert-snippet) (define-key map "\C-c&\C-n" 'yas-new-snippet) (define-key map "\C-c&\C-v" 'yas-visit-snippet-file) - map)) - -(defvar yas-minor-mode-map (yas--init-minor-keymap) + map) "The keymap used when `yas-minor-mode' is active.") +(easy-menu-define yas--minor-mode-menu + yas-minor-mode-map + "Menu used when `yas-minor-mode' is active." + '("YASnippet" + "----" + ["Expand trigger" yas-expand + :help "Possibly expand tab trigger before point"] + ["Insert at point..." yas-insert-snippet + :help "Prompt for an expandable snippet and expand it at point"] + ["New snippet..." yas-new-snippet + :help "Create a new snippet in an appropriate directory"] + ["Visit snippet file..." yas-visit-snippet-file + :help "Prompt for an expandable snippet and find its file"] + "----" + ("Snippet menu behaviour" + ["Visit snippets" (setq yas-visit-from-menu t) + :help "Visit snippets from the menu" + :active t :style radio :selected yas-visit-from-menu] + ["Expand snippets" (setq yas-visit-from-menu nil) + :help "Expand snippets from the menu" + :active t :style radio :selected (not yas-visit-from-menu)] + "----" + ["Show all known modes" (setq yas-use-menu 'full) + :help "Show one snippet submenu for each loaded table" + :active t :style radio :selected (eq yas-use-menu 'full)] + ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) + :help "Show only snippet submenus for the current active modes" + :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) + ("Indenting" + ["Auto" (setq yas-indent-line 'auto) + :help "Indent each line of the snippet with `indent-according-to-mode'" + :active t :style radio :selected (eq yas-indent-line 'auto)] + ["Fixed" (setq yas-indent-line 'fixed) + :help "Indent the snippet to the current column" + :active t :style radio :selected (eq yas-indent-line 'fixed)] + ["None" (setq yas-indent-line 'none) + :help "Don't apply any particular snippet indentation after expansion" + :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] + "----" + ["Also auto indent first line" (setq yas-also-auto-indent-first-line + (not yas-also-auto-indent-first-line)) + :help "When auto-indenting also, auto indent the first line menu" + :active (eq yas-indent-line 'auto) + :style toggle :selected yas-also-auto-indent-first-line] + ) + ("Prompting method" + ["System X-widget" (setq yas-prompt-functions + (cons 'yas-x-prompt + (remove 'yas-x-prompt + yas-prompt-functions))) + :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-x-prompt)] + ["Dropdown-list" (setq yas-prompt-functions + (cons 'yas-dropdown-prompt + (remove 'yas-dropdown-prompt + yas-prompt-functions))) + :help "Use a special dropdown list" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-dropdown-prompt)] + ["Ido" (setq yas-prompt-functions + (cons 'yas-ido-prompt + (remove 'yas-ido-prompt + yas-prompt-functions))) + :help "Use an ido-style minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-ido-prompt)] + ["Completing read" (setq yas-prompt-functions + (cons 'yas-completing-prompt + (remove 'yas-completing-prompt + yas-prompt-functions))) + :help "Use a normal minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-completing-prompt)] + ) + ("Misc" + ["Wrap region in exit marker" + (setq yas-wrap-around-region + (not yas-wrap-around-region)) + :help "If non-nil automatically wrap the selected text in the $0 snippet exit" + :style toggle :selected yas-wrap-around-region] + ["Allow stacked expansions " + (setq yas-triggers-in-field + (not yas-triggers-in-field)) + :help "If non-nil allow snippets to be triggered inside other snippet fields" + :style toggle :selected yas-triggers-in-field] + ["Revive snippets on undo " + (setq yas-snippet-revival + (not yas-snippet-revival)) + :help "If non-nil allow snippets to become active again after undo" + :style toggle :selected yas-snippet-revival] + ["Good grace " + (setq yas-good-grace + (not yas-good-grace)) + :help "If non-nil don't raise errors in bad embedded elisp in snippets" + :style toggle :selected yas-good-grace] + ) + "----" + ["Load snippets..." yas-load-directory + :help "Load snippets from a specific directory"] + ["Reload everything" yas-reload-all + :help "Cleanup stuff, reload snippets, rebuild menus"] + ["About" yas-about + :help "Display some information about YASnippet"])) + (defvar yas--extra-modes nil "An internal list of modes for which to also lookup snippets. From d809e886e0034f6130f077c80356a143aff3752c Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Thu, 13 Mar 2014 20:23:05 +0100 Subject: [PATCH 27/83] Revert "Closes #469: Don't use `yas--init-minor-keymap'" This reverts commit 498cbe4138d74f39f7447acc9de456291c639724. --- yasnippet.el | 223 +++++++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 107 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 50a6e4b..f4b4751 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -313,6 +313,9 @@ menu and the modes set in `yas--extra-modes' are listed. - If set to `full', every submenu is listed +- It set to nil, don't display a menu at all (this requires a + `yas-reload-all' call if the menu is already visible). + Any other non-nil value, every submenu is listed." :type '(choice (const :tag "Full" full) (const :tag "Abbreviate" abbreviate) @@ -533,120 +536,126 @@ snippet itself contains a condition that returns the symbol (defvar yas--minor-mode-menu nil "Holds the YASnippet menu.") -(defvar yas-minor-mode-map +(defun yas--init-minor-keymap () + "Set up the `yas-minor-mode' keymap." (let ((map (make-sparse-keymap))) + (when yas-use-menu + (easy-menu-define yas--minor-mode-menu + map + "Menu used when `yas-minor-mode' is active." + '("YASnippet" + "----" + ["Expand trigger" yas-expand + :help "Possibly expand tab trigger before point"] + ["Insert at point..." yas-insert-snippet + :help "Prompt for an expandable snippet and expand it at point"] + ["New snippet..." yas-new-snippet + :help "Create a new snippet in an appropriate directory"] + ["Visit snippet file..." yas-visit-snippet-file + :help "Prompt for an expandable snippet and find its file"] + "----" + ("Snippet menu behaviour" + ["Visit snippets" (setq yas-visit-from-menu t) + :help "Visit snippets from the menu" + :active t :style radio :selected yas-visit-from-menu] + ["Expand snippets" (setq yas-visit-from-menu nil) + :help "Expand snippets from the menu" + :active t :style radio :selected (not yas-visit-from-menu)] + "----" + ["Show all known modes" (setq yas-use-menu 'full) + :help "Show one snippet submenu for each loaded table" + :active t :style radio :selected (eq yas-use-menu 'full)] + ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) + :help "Show only snippet submenus for the current active modes" + :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) + ("Indenting" + ["Auto" (setq yas-indent-line 'auto) + :help "Indent each line of the snippet with `indent-according-to-mode'" + :active t :style radio :selected (eq yas-indent-line 'auto)] + ["Fixed" (setq yas-indent-line 'fixed) + :help "Indent the snippet to the current column" + :active t :style radio :selected (eq yas-indent-line 'fixed)] + ["None" (setq yas-indent-line 'none) + :help "Don't apply any particular snippet indentation after expansion" + :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] + "----" + ["Also auto indent first line" (setq yas-also-auto-indent-first-line + (not yas-also-auto-indent-first-line)) + :help "When auto-indenting also, auto indent the first line menu" + :active (eq yas-indent-line 'auto) + :style toggle :selected yas-also-auto-indent-first-line] + ) + ("Prompting method" + ["System X-widget" (setq yas-prompt-functions + (cons 'yas-x-prompt + (remove 'yas-x-prompt + yas-prompt-functions))) + :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-x-prompt)] + ["Dropdown-list" (setq yas-prompt-functions + (cons 'yas-dropdown-prompt + (remove 'yas-dropdown-prompt + yas-prompt-functions))) + :help "Use a special dropdown list" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-dropdown-prompt)] + ["Ido" (setq yas-prompt-functions + (cons 'yas-ido-prompt + (remove 'yas-ido-prompt + yas-prompt-functions))) + :help "Use an ido-style minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-ido-prompt)] + ["Completing read" (setq yas-prompt-functions + (cons 'yas-completing-prompt + (remove 'yas-completing-prompt + yas-prompt-functions))) + :help "Use a normal minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-completing-prompt)] + ) + ("Misc" + ["Wrap region in exit marker" + (setq yas-wrap-around-region + (not yas-wrap-around-region)) + :help "If non-nil automatically wrap the selected text in the $0 snippet exit" + :style toggle :selected yas-wrap-around-region] + ["Allow stacked expansions " + (setq yas-triggers-in-field + (not yas-triggers-in-field)) + :help "If non-nil allow snippets to be triggered inside other snippet fields" + :style toggle :selected yas-triggers-in-field] + ["Revive snippets on undo " + (setq yas-snippet-revival + (not yas-snippet-revival)) + :help "If non-nil allow snippets to become active again after undo" + :style toggle :selected yas-snippet-revival] + ["Good grace " + (setq yas-good-grace + (not yas-good-grace)) + :help "If non-nil don't raise errors in bad embedded elisp in snippets" + :style toggle :selected yas-good-grace] + ) + "----" + ["Load snippets..." yas-load-directory + :help "Load snippets from a specific directory"] + ["Reload everything" yas-reload-all + :help "Cleanup stuff, reload snippets, rebuild menus"] + ["About" yas-about + :help "Display some information about YASnippet"]))) + + ;; Now for the stuff that has direct keybindings + ;; (define-key map [(tab)] 'yas-expand) (define-key map (kbd "TAB") 'yas-expand) (define-key map "\C-c&\C-s" 'yas-insert-snippet) (define-key map "\C-c&\C-n" 'yas-new-snippet) (define-key map "\C-c&\C-v" 'yas-visit-snippet-file) - map) - "The keymap used when `yas-minor-mode' is active.") + map)) -(easy-menu-define yas--minor-mode-menu - yas-minor-mode-map - "Menu used when `yas-minor-mode' is active." - '("YASnippet" - "----" - ["Expand trigger" yas-expand - :help "Possibly expand tab trigger before point"] - ["Insert at point..." yas-insert-snippet - :help "Prompt for an expandable snippet and expand it at point"] - ["New snippet..." yas-new-snippet - :help "Create a new snippet in an appropriate directory"] - ["Visit snippet file..." yas-visit-snippet-file - :help "Prompt for an expandable snippet and find its file"] - "----" - ("Snippet menu behaviour" - ["Visit snippets" (setq yas-visit-from-menu t) - :help "Visit snippets from the menu" - :active t :style radio :selected yas-visit-from-menu] - ["Expand snippets" (setq yas-visit-from-menu nil) - :help "Expand snippets from the menu" - :active t :style radio :selected (not yas-visit-from-menu)] - "----" - ["Show all known modes" (setq yas-use-menu 'full) - :help "Show one snippet submenu for each loaded table" - :active t :style radio :selected (eq yas-use-menu 'full)] - ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) - :help "Show only snippet submenus for the current active modes" - :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) - ("Indenting" - ["Auto" (setq yas-indent-line 'auto) - :help "Indent each line of the snippet with `indent-according-to-mode'" - :active t :style radio :selected (eq yas-indent-line 'auto)] - ["Fixed" (setq yas-indent-line 'fixed) - :help "Indent the snippet to the current column" - :active t :style radio :selected (eq yas-indent-line 'fixed)] - ["None" (setq yas-indent-line 'none) - :help "Don't apply any particular snippet indentation after expansion" - :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] - "----" - ["Also auto indent first line" (setq yas-also-auto-indent-first-line - (not yas-also-auto-indent-first-line)) - :help "When auto-indenting also, auto indent the first line menu" - :active (eq yas-indent-line 'auto) - :style toggle :selected yas-also-auto-indent-first-line] - ) - ("Prompting method" - ["System X-widget" (setq yas-prompt-functions - (cons 'yas-x-prompt - (remove 'yas-x-prompt - yas-prompt-functions))) - :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-x-prompt)] - ["Dropdown-list" (setq yas-prompt-functions - (cons 'yas-dropdown-prompt - (remove 'yas-dropdown-prompt - yas-prompt-functions))) - :help "Use a special dropdown list" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-dropdown-prompt)] - ["Ido" (setq yas-prompt-functions - (cons 'yas-ido-prompt - (remove 'yas-ido-prompt - yas-prompt-functions))) - :help "Use an ido-style minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-ido-prompt)] - ["Completing read" (setq yas-prompt-functions - (cons 'yas-completing-prompt - (remove 'yas-completing-prompt - yas-prompt-functions))) - :help "Use a normal minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-completing-prompt)] - ) - ("Misc" - ["Wrap region in exit marker" - (setq yas-wrap-around-region - (not yas-wrap-around-region)) - :help "If non-nil automatically wrap the selected text in the $0 snippet exit" - :style toggle :selected yas-wrap-around-region] - ["Allow stacked expansions " - (setq yas-triggers-in-field - (not yas-triggers-in-field)) - :help "If non-nil allow snippets to be triggered inside other snippet fields" - :style toggle :selected yas-triggers-in-field] - ["Revive snippets on undo " - (setq yas-snippet-revival - (not yas-snippet-revival)) - :help "If non-nil allow snippets to become active again after undo" - :style toggle :selected yas-snippet-revival] - ["Good grace " - (setq yas-good-grace - (not yas-good-grace)) - :help "If non-nil don't raise errors in bad embedded elisp in snippets" - :style toggle :selected yas-good-grace] - ) - "----" - ["Load snippets..." yas-load-directory - :help "Load snippets from a specific directory"] - ["Reload everything" yas-reload-all - :help "Cleanup stuff, reload snippets, rebuild menus"] - ["About" yas-about - :help "Display some information about YASnippet"])) +(defvar yas-minor-mode-map (yas--init-minor-keymap) + "The keymap used when `yas-minor-mode' is active.") (defvar yas--extra-modes nil "An internal list of modes for which to also lookup snippets. From b36a4f7449f61d22942fc188884f3314bb7fec35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Thu, 13 Mar 2014 20:24:11 +0000 Subject: [PATCH 28/83] Properly closes #469: Don't use `yas--init-minor-keymap' Previous reverted commit 498cbe4 forgot to take into account that one of the tests used the `yas--init-minor-keymap' function that was removed. * yasnippet.el (yas-use-menu): Don't allow `nil' value, it's useless. (yas--minor-mode-menu): Use top-level `easy-menu-define' form. (yas--init-minor-keymap): Remove definition. * yasnippet-tests.el (test-rebindings): Don't use `yas--init-minor-keymap'. Restore bindings explicitly. Not ideal, but should work. --- yasnippet-tests.el | 6 +- yasnippet.el | 223 ++++++++++++++++++++++----------------------- 2 files changed, 112 insertions(+), 117 deletions(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index d2f3c2c..02bf10c 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -600,7 +600,11 @@ TODO: be meaner" (yas-reload-all) (should (not (eq (key-binding (yas--read-keybinding "TAB")) 'yas-expand))) (should (eq (key-binding (yas--read-keybinding "SPC")) 'yas-expand)))) - (setcdr yas-minor-mode-map (cdr (yas--init-minor-keymap))))) + ;; FIXME: actually should restore to whatever saved values where there. + ;; + (define-key yas-minor-mode-map [tab] 'yas-expand) + (define-key yas-minor-mode-map (kbd "TAB") 'yas-expand) + (define-key yas-minor-mode-map (kbd "SPC") nil))) (ert-deftest test-yas-in-org () (with-temp-buffer diff --git a/yasnippet.el b/yasnippet.el index f4b4751..50a6e4b 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -313,9 +313,6 @@ menu and the modes set in `yas--extra-modes' are listed. - If set to `full', every submenu is listed -- It set to nil, don't display a menu at all (this requires a - `yas-reload-all' call if the menu is already visible). - Any other non-nil value, every submenu is listed." :type '(choice (const :tag "Full" full) (const :tag "Abbreviate" abbreviate) @@ -536,127 +533,121 @@ snippet itself contains a condition that returns the symbol (defvar yas--minor-mode-menu nil "Holds the YASnippet menu.") -(defun yas--init-minor-keymap () - "Set up the `yas-minor-mode' keymap." +(defvar yas-minor-mode-map (let ((map (make-sparse-keymap))) - (when yas-use-menu - (easy-menu-define yas--minor-mode-menu - map - "Menu used when `yas-minor-mode' is active." - '("YASnippet" - "----" - ["Expand trigger" yas-expand - :help "Possibly expand tab trigger before point"] - ["Insert at point..." yas-insert-snippet - :help "Prompt for an expandable snippet and expand it at point"] - ["New snippet..." yas-new-snippet - :help "Create a new snippet in an appropriate directory"] - ["Visit snippet file..." yas-visit-snippet-file - :help "Prompt for an expandable snippet and find its file"] - "----" - ("Snippet menu behaviour" - ["Visit snippets" (setq yas-visit-from-menu t) - :help "Visit snippets from the menu" - :active t :style radio :selected yas-visit-from-menu] - ["Expand snippets" (setq yas-visit-from-menu nil) - :help "Expand snippets from the menu" - :active t :style radio :selected (not yas-visit-from-menu)] - "----" - ["Show all known modes" (setq yas-use-menu 'full) - :help "Show one snippet submenu for each loaded table" - :active t :style radio :selected (eq yas-use-menu 'full)] - ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) - :help "Show only snippet submenus for the current active modes" - :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) - ("Indenting" - ["Auto" (setq yas-indent-line 'auto) - :help "Indent each line of the snippet with `indent-according-to-mode'" - :active t :style radio :selected (eq yas-indent-line 'auto)] - ["Fixed" (setq yas-indent-line 'fixed) - :help "Indent the snippet to the current column" - :active t :style radio :selected (eq yas-indent-line 'fixed)] - ["None" (setq yas-indent-line 'none) - :help "Don't apply any particular snippet indentation after expansion" - :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] - "----" - ["Also auto indent first line" (setq yas-also-auto-indent-first-line - (not yas-also-auto-indent-first-line)) - :help "When auto-indenting also, auto indent the first line menu" - :active (eq yas-indent-line 'auto) - :style toggle :selected yas-also-auto-indent-first-line] - ) - ("Prompting method" - ["System X-widget" (setq yas-prompt-functions - (cons 'yas-x-prompt - (remove 'yas-x-prompt - yas-prompt-functions))) - :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-x-prompt)] - ["Dropdown-list" (setq yas-prompt-functions - (cons 'yas-dropdown-prompt - (remove 'yas-dropdown-prompt - yas-prompt-functions))) - :help "Use a special dropdown list" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-dropdown-prompt)] - ["Ido" (setq yas-prompt-functions - (cons 'yas-ido-prompt - (remove 'yas-ido-prompt - yas-prompt-functions))) - :help "Use an ido-style minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-ido-prompt)] - ["Completing read" (setq yas-prompt-functions - (cons 'yas-completing-prompt - (remove 'yas-completing-prompt - yas-prompt-functions))) - :help "Use a normal minibuffer prompt" - :active t :style radio :selected (eq (car yas-prompt-functions) - 'yas-completing-prompt)] - ) - ("Misc" - ["Wrap region in exit marker" - (setq yas-wrap-around-region - (not yas-wrap-around-region)) - :help "If non-nil automatically wrap the selected text in the $0 snippet exit" - :style toggle :selected yas-wrap-around-region] - ["Allow stacked expansions " - (setq yas-triggers-in-field - (not yas-triggers-in-field)) - :help "If non-nil allow snippets to be triggered inside other snippet fields" - :style toggle :selected yas-triggers-in-field] - ["Revive snippets on undo " - (setq yas-snippet-revival - (not yas-snippet-revival)) - :help "If non-nil allow snippets to become active again after undo" - :style toggle :selected yas-snippet-revival] - ["Good grace " - (setq yas-good-grace - (not yas-good-grace)) - :help "If non-nil don't raise errors in bad embedded elisp in snippets" - :style toggle :selected yas-good-grace] - ) - "----" - ["Load snippets..." yas-load-directory - :help "Load snippets from a specific directory"] - ["Reload everything" yas-reload-all - :help "Cleanup stuff, reload snippets, rebuild menus"] - ["About" yas-about - :help "Display some information about YASnippet"]))) - - ;; Now for the stuff that has direct keybindings - ;; (define-key map [(tab)] 'yas-expand) (define-key map (kbd "TAB") 'yas-expand) (define-key map "\C-c&\C-s" 'yas-insert-snippet) (define-key map "\C-c&\C-n" 'yas-new-snippet) (define-key map "\C-c&\C-v" 'yas-visit-snippet-file) - map)) - -(defvar yas-minor-mode-map (yas--init-minor-keymap) + map) "The keymap used when `yas-minor-mode' is active.") +(easy-menu-define yas--minor-mode-menu + yas-minor-mode-map + "Menu used when `yas-minor-mode' is active." + '("YASnippet" + "----" + ["Expand trigger" yas-expand + :help "Possibly expand tab trigger before point"] + ["Insert at point..." yas-insert-snippet + :help "Prompt for an expandable snippet and expand it at point"] + ["New snippet..." yas-new-snippet + :help "Create a new snippet in an appropriate directory"] + ["Visit snippet file..." yas-visit-snippet-file + :help "Prompt for an expandable snippet and find its file"] + "----" + ("Snippet menu behaviour" + ["Visit snippets" (setq yas-visit-from-menu t) + :help "Visit snippets from the menu" + :active t :style radio :selected yas-visit-from-menu] + ["Expand snippets" (setq yas-visit-from-menu nil) + :help "Expand snippets from the menu" + :active t :style radio :selected (not yas-visit-from-menu)] + "----" + ["Show all known modes" (setq yas-use-menu 'full) + :help "Show one snippet submenu for each loaded table" + :active t :style radio :selected (eq yas-use-menu 'full)] + ["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate) + :help "Show only snippet submenus for the current active modes" + :active t :style radio :selected (eq yas-use-menu 'abbreviate)]) + ("Indenting" + ["Auto" (setq yas-indent-line 'auto) + :help "Indent each line of the snippet with `indent-according-to-mode'" + :active t :style radio :selected (eq yas-indent-line 'auto)] + ["Fixed" (setq yas-indent-line 'fixed) + :help "Indent the snippet to the current column" + :active t :style radio :selected (eq yas-indent-line 'fixed)] + ["None" (setq yas-indent-line 'none) + :help "Don't apply any particular snippet indentation after expansion" + :active t :style radio :selected (not (member yas-indent-line '(fixed auto)))] + "----" + ["Also auto indent first line" (setq yas-also-auto-indent-first-line + (not yas-also-auto-indent-first-line)) + :help "When auto-indenting also, auto indent the first line menu" + :active (eq yas-indent-line 'auto) + :style toggle :selected yas-also-auto-indent-first-line] + ) + ("Prompting method" + ["System X-widget" (setq yas-prompt-functions + (cons 'yas-x-prompt + (remove 'yas-x-prompt + yas-prompt-functions))) + :help "Use your windowing system's (gtk, mac, windows, etc...) default menu" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-x-prompt)] + ["Dropdown-list" (setq yas-prompt-functions + (cons 'yas-dropdown-prompt + (remove 'yas-dropdown-prompt + yas-prompt-functions))) + :help "Use a special dropdown list" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-dropdown-prompt)] + ["Ido" (setq yas-prompt-functions + (cons 'yas-ido-prompt + (remove 'yas-ido-prompt + yas-prompt-functions))) + :help "Use an ido-style minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-ido-prompt)] + ["Completing read" (setq yas-prompt-functions + (cons 'yas-completing-prompt + (remove 'yas-completing-prompt + yas-prompt-functions))) + :help "Use a normal minibuffer prompt" + :active t :style radio :selected (eq (car yas-prompt-functions) + 'yas-completing-prompt)] + ) + ("Misc" + ["Wrap region in exit marker" + (setq yas-wrap-around-region + (not yas-wrap-around-region)) + :help "If non-nil automatically wrap the selected text in the $0 snippet exit" + :style toggle :selected yas-wrap-around-region] + ["Allow stacked expansions " + (setq yas-triggers-in-field + (not yas-triggers-in-field)) + :help "If non-nil allow snippets to be triggered inside other snippet fields" + :style toggle :selected yas-triggers-in-field] + ["Revive snippets on undo " + (setq yas-snippet-revival + (not yas-snippet-revival)) + :help "If non-nil allow snippets to become active again after undo" + :style toggle :selected yas-snippet-revival] + ["Good grace " + (setq yas-good-grace + (not yas-good-grace)) + :help "If non-nil don't raise errors in bad embedded elisp in snippets" + :style toggle :selected yas-good-grace] + ) + "----" + ["Load snippets..." yas-load-directory + :help "Load snippets from a specific directory"] + ["Reload everything" yas-reload-all + :help "Cleanup stuff, reload snippets, rebuild menus"] + ["About" yas-about + :help "Display some information about YASnippet"])) + (defvar yas--extra-modes nil "An internal list of modes for which to also lookup snippets. From 8e7295b93460b7d389ecb65969fcedbee6495de8 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Fri, 14 Mar 2014 09:55:22 +0000 Subject: [PATCH 29/83] Closes #403: more uniform behaviour for `yas-use-menu' Suggested by Noam Postavsky, this uses the :visible arg to `easy-menu-define' to hide the whole "YASnippet" menu according to the run-time value of `yas-use-menu'. Previously, only the load-time value was considered and some functions we're noops when `yas-use-menu' was nil. The per-mode snippet submenus are now always updated even if `yas-use-menu' is nil, although they won't be shown until it becomes non-nil. * yasnippet.el (yas--minor-mode-menu): Use :visible arg and eval `yas-use-menu' (yas--update-template): Always update the menu. (yas--show-menu-p): Always return t if `yas-use-menu' is non-nil and not `abbreviate' (yas-define-menu): Always define a menu. (yas-use-menu): Update docstring. --- yasnippet.el | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 50a6e4b..252083a 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -313,6 +313,8 @@ menu and the modes set in `yas--extra-modes' are listed. - If set to `full', every submenu is listed +- If set to `nil', hide the menu. + Any other non-nil value, every submenu is listed." :type '(choice (const :tag "Full" full) (const :tag "Abbreviate" abbreviate) @@ -546,7 +548,7 @@ snippet itself contains a condition that returns the symbol (easy-menu-define yas--minor-mode-menu yas-minor-mode-map "Menu used when `yas-minor-mode' is active." - '("YASnippet" + '("YASnippet" :visible yas-use-menu "----" ["Expand trigger" yas-expand :help "Possibly expand tab trigger before point"] @@ -1063,8 +1065,7 @@ Also takes care of adding and updating to the associated menu." (yas--add-template table template) ;; Take care of the menu ;; - (when yas-use-menu - (yas--update-template-menu table template))) + (yas--update-template-menu table template)) (defun yas--update-template-menu (table template) "Update every menu-related for TEMPLATE." @@ -1976,10 +1977,7 @@ static in the menu." (mapcar #'(lambda (table) (yas--table-mode table)) (yas--get-snippet-tables)))) - ((eq yas-use-menu 'full) - t) - ((eq yas-use-menu t) - t))) + (yas-use-menu t))) (defun yas--delete-from-keymap (keymap uuid) "Recursively delete items with UUID from KEYMAP and its submenus." @@ -2022,24 +2020,21 @@ MENU is a list, its elements can be: list of groups of the snippets defined thereafter. OMIT-ITEMS is a list of snippet uuid's that will always be -omitted from MODE's menu, even if they're manually loaded. - -This function does nothing if `yas-use-menu' is nil." - (when yas-use-menu - (let* ((table (yas--table-get-create mode)) - (hash (yas--table-uuidhash table))) - (yas--define-menu-1 table - (yas--menu-keymap-get-create mode) - menu - hash) - (dolist (uuid omit-items) - (let ((template (or (gethash uuid hash) - (yas--populate-template (puthash uuid - (yas--make-blank-template) - hash) - :table table - :uuid uuid)))) - (setf (yas--template-menu-binding-pair template) (cons nil :none))))))) +omitted from MODE's menu, even if they're manually loaded." + (let* ((table (yas--table-get-create mode)) + (hash (yas--table-uuidhash table))) + (yas--define-menu-1 table + (yas--menu-keymap-get-create mode) + menu + hash) + (dolist (uuid omit-items) + (let ((template (or (gethash uuid hash) + (yas--populate-template (puthash uuid + (yas--make-blank-template) + hash) + :table table + :uuid uuid)))) + (setf (yas--template-menu-binding-pair template) (cons nil :none)))))) (defun yas--define-menu-1 (table menu-keymap menu uuidhash &optional group-list) "Helper for `yas-define-menu'." From a4e04f954b8c3f76002bbd4f36784b4e1d7d5fef Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 23 Mar 2014 19:44:35 -0400 Subject: [PATCH 30/83] update doc for org 8.x Keeping compabitily with 7.9 for now --- doc/org-setup.inc | 2 ++ doc/yas-doc-helper.el | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/org-setup.inc b/doc/org-setup.inc index 98f7c04..6ad09c9 100644 --- a/doc/org-setup.inc +++ b/doc/org-setup.inc @@ -6,4 +6,6 @@ #+OPTIONS: author:nil num:nil #+AUTHOR: +# org < 8.0 use +STYLE, after use +HTML_HEAD #+STYLE: +#+HTML_HEAD: diff --git a/doc/yas-doc-helper.el b/doc/yas-doc-helper.el index 925e41b..f6e101c 100755 --- a/doc/yas-doc-helper.el +++ b/doc/yas-doc-helper.el @@ -27,9 +27,18 @@ (eval-when-compile (require 'cl)) (require 'org) -(require 'org-publish) +(or (require 'org-publish nil t) + (require 'ox-publish)) (require 'yasnippet) ; docstrings must be loaded +(defun yas--org-raw-html (tag content) + ;; in version 8.0 org-mode changed the export syntax, see + ;; http://orgmode.org/worg/org-8.0.html#sec-8-1 + (format (if (version< org-version "8.0.0") + "@<%s>%s@" ; old: @ + "@@html:<%s>@@%s@@html:@@") ; new: @@html:@@ + tag content tag)) + (defun yas--document-symbol (symbol level) (flet ((concat-lines (&rest lines) (mapconcat #'identity lines "\n"))) @@ -71,7 +80,8 @@ (prefix (downcase match1)) (suffix (match-string 2 match)) (fmt (cond - ((member prefix args) "@%s@") + ((member prefix args) + (yas--org-raw-html "code" "%s")) ((null suffix) "/%s/")))) (if fmt (format fmt prefix) match1))) @@ -125,6 +135,7 @@ (princ yas--version (current-buffer))))) (proj-plist (list + :publishing-function 'org-html-publish-to-html :base-directory dir :publishing-directory dir :html-preamble (with-temp-buffer From 4d9eee93ba855d1ae5700620a93ea8a1998f0bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 27 Apr 2014 01:49:12 +0100 Subject: [PATCH 31/83] Simpler, more effective .travis file * .travis.yml (env): New section. (install): Simpler install recipes. (script): Just rake compile and rake tests. --- .travis.yml | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83990f6..4bd7940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,24 @@ language: emacs -before_install: - - echo -e "\ndeb http://us.archive.ubuntu.com/ubuntu raring universe multiverse main" | sudo tee -a /etc/apt/sources.list - - echo -e "\ndeb http://emacs.naquadah.org/ stable/" | sudo tee -a /etc/apt/sources.list - - echo -e "\ndeb-src http://emacs.naquadah.org/ stable/" | sudo tee -a /etc/apt/sources.list - - cat /etc/apt/sources.list - - wget -q -O - http://emacs.naquadah.org/key.gpg | sudo apt-key add - - - sudo apt-get update + +env: + - "EMACS=emacs23" + - "EMACS=emacs24" + install: - - sudo apt-get install emacs - - sudo apt-get -t raring install libgnutls26 - - sudo apt-get install emacs-snapshot-nox - - curl -O https://raw.github.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el - - curl -O https://raw.github.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert-x.el - - curl -o cl-lib.el http://elpa.gnu.org/packages/cl-lib-0.3.el -before_script: + - if [ "$EMACS" = "emacs23" ]; then + sudo apt-get -qq update && + sudo apt-get -qq -f install && + sudo apt-get -qq install emacs23-nox && + curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el && + curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert-x.el && + curl -Lo cl-lib.el http://elpa.gnu.org/packages/cl-lib-0.5.el; + fi + - if [ "$EMACS" = "emacs24" ]; then + sudo add-apt-repository -y ppa:cassou/emacs && + sudo apt-get -qq update && + sudo apt-get -qq -f install && + sudo apt-get -qq install emacs24-nox; + fi + script: - - export EMACS=emacs; rm *.elc; rake compile; rake tests - - rm ert*.el; rm cl-lib.el - - export EMACS=emacs-snapshot; rm *.elc; rake compile; rake tests -notifications: - email: - - joaotavora@gmail.com + - rake compile; rake tests From 4473b4ede5b9fb4736ef78482511349d2fe171eb Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 26 Apr 2014 19:09:57 -0400 Subject: [PATCH 32/83] New test for cc-mode's fontification functions This issue requires font locking to trigger. This can be be done by let-binding noninteractive to nil and using a buffer name that doesn't start with a space, instead of the external emacs hack which is now redundant. * yasnippet-tests.el (yas--with-font-locked-temp-buffer): new macro similar to with-temp-buffer but enables font-lock-mode even in -batch mode. (example-for-issue-474): new test (example-for-issue-404, example-for-issue-404-c-mode): use new macro (example-for-issue-404-external-emacs): removed --- yasnippet-tests.el | 82 ++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 02bf10c..f87b3d4 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -204,60 +204,56 @@ (ert-simulate-command `(yas-mock-insert "bbb")) (should (string= (yas--buffer-contents) "if condition\naaa\nelse\nbbb\nend"))))) -(ert-deftest example-for-issue-404 () - (with-temp-buffer - (c++-mode) - (yas-minor-mode 1) - (insert "#include \n") - (let ((snippet "main")) - (let ((yas-good-grace nil)) (yas-expand-snippet snippet)) - (should (string= (yas--buffer-contents) "#include \nmain"))))) +(defmacro yas--with-font-locked-temp-buffer (&rest body) + "Like `with-temp-buffer', but ensure `font-lock-mode'." + (declare (indent 0) (debug t)) + (let ((temp-buffer (make-symbol "temp-buffer"))) + ;; NOTE: buffer name must not start with a space, otherwise + ;; `font-lock-mode' doesn't turn on. + `(let ((,temp-buffer (generate-new-buffer "*yas-temp*"))) + (with-current-buffer ,temp-buffer + ;; pretend we're interactive so `font-lock-mode' turns on + (let ((noninteractive nil) + ;; turn on font locking after major mode change + (change-major-mode-after-body-hook #'font-lock-mode)) + (unwind-protect + (progn (require 'font-lock) + ;; turn on font locking before major mode change + (font-lock-mode +1) + ,@body) + (and (buffer-name ,temp-buffer) + (kill-buffer ,temp-buffer)))))))) -(ert-deftest example-for-issue-404-c-mode () - (with-temp-buffer +(ert-deftest example-for-issue-474 () + (yas--with-font-locked-temp-buffer (c-mode) (yas-minor-mode 1) (insert "#include \n") - (let ((snippet "main")) - (let ((yas-good-grace nil)) (yas-expand-snippet snippet)) - (should (string= (yas--buffer-contents) "#include \nmain"))))) + (let ((yas-good-grace nil)) (yas-expand-snippet "`(insert \"TODO: \")`")) + (should (string= (yas--buffer-contents) "#include \nTODO: ")))) -(ert-deftest example-for-issue-404-external-emacs () - :tags '(:external) - (let ((fixture-el-file (make-temp-file "yas-404-fixture" nil ".el"))) - (with-temp-buffer - (insert (pp-to-string - `(condition-case _ - (progn - (require 'yasnippet-tests) - (yas-with-snippet-dirs - '((".emacs.d/snippets" - ("c-mode" - ("main" . "int main ()")))) - (yas-global-mode) - (switch-to-buffer "foo.c") - (c-mode) - (insert "#include \nmain") - (setq yas-good-grace nil) - (yas-expand) - (should (string= (buffer-string) - "#include \nint main ()")) - (kill-emacs 0))) - (error (kill-emacs -1))))) - (write-file fixture-el-file)) - (should (= 0 - (call-process (concat invocation-directory invocation-name) - nil nil nil - "-Q" "--batch" - "-L" "." "-l" fixture-el-file))))) +(ert-deftest example-for-issue-404 () + (yas--with-font-locked-temp-buffer + (c++-mode) + (yas-minor-mode 1) + (insert "#include \n") + (let ((yas-good-grace nil)) (yas-expand-snippet "main")) + (should (string= (yas--buffer-contents) "#include \nmain")))) + +(ert-deftest example-for-issue-404-c-mode () + (yas--with-font-locked-temp-buffer + (c-mode) + (yas-minor-mode 1) + (insert "#include \n") + (let ((yas-good-grace nil)) (yas-expand-snippet "main")) + (should (string= (yas--buffer-contents) "#include \nmain")))) (ert-deftest middle-of-buffer-snippet-insertion () (with-temp-buffer (yas-minor-mode 1) (insert "beginning") (save-excursion (insert "end")) - (let ((snippet "-middle-")) - (yas-expand-snippet snippet)) + (yas-expand-snippet "-middle-") (should (string= (yas--buffer-contents) "beginning-middle-end")))) (ert-deftest another-example-for-issue-271 () From 599a2622c6a988829d181ec3aa951848b07d7819 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 26 Apr 2014 19:26:54 -0400 Subject: [PATCH 33/83] Closes #474: fix cc-mode fontification conflict * yasnippet.el (yas--save-backquotes): don't change buffer while narrowed. --- yasnippet.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yasnippet.el b/yasnippet.el index 252083a..e2dbca0 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -3907,7 +3907,8 @@ With optional string TEXT do it in string instead of the buffer." with their evaluated value into `yas--backquote-markers-and-strings'." (while (re-search-forward yas--backquote-lisp-expression-regexp nil t) (let ((current-string (match-string-no-properties 1)) transformed) - (delete-region (match-beginning 0) (match-end 0)) + (save-restriction (widen) + (delete-region (match-beginning 0) (match-end 0))) (setq transformed (yas--eval-lisp (yas--read-lisp (yas--restore-escapes current-string '(?`))))) (goto-char (match-beginning 0)) (when transformed From a80033d1426aee501d5b704318180cf96fbc115f Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 15:56:36 -0400 Subject: [PATCH 34/83] Refactor yas-good-grace error handling * yasnippet.el (yas--handle-error): New function. (yas--eval-lisp-no-saves, yas--eval-lisp): Use it. --- yasnippet.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index e2dbca0..c1527dd 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1246,6 +1246,12 @@ yasnippet keeps a list of modes like this to help the judgment." (or (fboundp mode) (find mode yas--known-modes))) +(defun yas--handle-error (err) + "Handle error depending on value of `yas-good-grace'." + (let ((msg (yas--format "elisp error: %s" (error-message-string err)))) + (if yas-good-grace msg + (error msg)))) + (defun yas--eval-lisp (form) "Evaluate FORM and convert the result to string." (let ((retval (catch 'yas--exception @@ -1257,10 +1263,7 @@ yasnippet keeps a list of modes like this to help the judgment." (let ((result (eval form))) (when result (format "%s" result)))))) - (error (if yas-good-grace - (yas--format "elisp error! %s" (error-message-string err)) - (error (yas--format "elisp error: %s" - (error-message-string err))))))))) + (error (yas--handle-error err)))))) (when (and (consp retval) (eq 'yas--exception (car retval))) (error (cdr retval))) @@ -1269,10 +1272,7 @@ yasnippet keeps a list of modes like this to help the judgment." (defun yas--eval-lisp-no-saves (form) (condition-case err (eval form) - (error (if yas-good-grace - (yas--format "elisp error! %s" (error-message-string err)) - (error (yas--format "elisp error: %s" - (error-message-string err))))))) + (error (yas--handle-error err)))) (defun yas--read-lisp (string &optional nil-on-error) "Read STRING as a elisp expression and return it. From 580e5c64f62153f0a3c6093770d4ffabcf695ce5 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 19:01:32 -0400 Subject: [PATCH 35/83] Don't lose error message when yas-good-grace is t * yasnippet.el (yas--eval-lisp-no-saves): Pass error message to message function. (yas--handle-error): Pass "%s" to error to avoid accidentally interpreting % in the error message as format codes. --- yasnippet.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index c1527dd..9d4764d 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1250,7 +1250,7 @@ yasnippet keeps a list of modes like this to help the judgment." "Handle error depending on value of `yas-good-grace'." (let ((msg (yas--format "elisp error: %s" (error-message-string err)))) (if yas-good-grace msg - (error msg)))) + (error "%s" msg)))) (defun yas--eval-lisp (form) "Evaluate FORM and convert the result to string." @@ -1272,7 +1272,7 @@ yasnippet keeps a list of modes like this to help the judgment." (defun yas--eval-lisp-no-saves (form) (condition-case err (eval form) - (error (yas--handle-error err)))) + (error (message "%s" (yas--handle-error err))))) (defun yas--read-lisp (string &optional nil-on-error) "Read STRING as a elisp expression and return it. From 8ced5c7f1d3d9128f4581accf3450710b6404b99 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 18:48:37 -0400 Subject: [PATCH 36/83] Remove type, expand-env from new snippet value They are seldom used, and can cause errors if left in. * yasnippet.el (yas-new-snippet-default): Remove type and expand-env directives. --- yasnippet.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 9d4764d..eeea636 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -188,9 +188,7 @@ as the default for storing the user's new snippets." # -*- mode: snippet; require-final-newline: nil -*- # name: $1 # key: ${2:${1:$(yas--key-from-desc yas-text)}}${3: -# binding: ${4:direct-keybinding}}${5: -# expand-env: ((${6:some-var} ${7:some-value}))}${8: -# type: command} +# binding: ${4:direct-keybinding}} # -- $0" "Default snippet to use when creating a new snippet. From f1760272e0f287d9b0a13ed2c7dbe1bfd5df01bc Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 14:07:58 -0400 Subject: [PATCH 37/83] Restore backquotes lost in rst -> org translation * doc/snippet-development.org: Re-add lost `s. --- doc/snippet-development.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/snippet-development.org b/doc/snippet-development.org index a7d653a..e48e397 100644 --- a/doc/snippet-development.org +++ b/doc/snippet-development.org @@ -182,14 +182,14 @@ to TextMate's. ** Plain Text Arbitrary text can be included as the content of a template. They are -usually interpreted as plain text, except =$= and ==. You need to -use \` to escape them: =\$= and =\=. The \` itself may also needed to be +usually interpreted as plain text, except =$= and =`=. You need to +use =\= to escape them: =\$= and =\`=. The =\= itself may also needed to be escaped as =\\= sometimes. ** Embedded Emacs-lisp code Emacs-Lisp code can be embedded inside the template, written inside -back-quotes (==). The lisp forms are evaluated when the snippet is +back-quotes (=`=). The lisp forms are evaluated when the snippet is being expanded. The evaluation is done in the same buffer as the snippet being expanded. From 4c16eaee0e5142da2a2780259254a017a0feb7bf Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 16:28:09 -0400 Subject: [PATCH 38/83] Document uuid directive * doc/snippet-development.org: Mention uuid in directive list. * yasnippet.el (yas-define-snippets): Fix docstring grammar. --- doc/snippet-development.org | 6 ++++++ yasnippet.el | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/snippet-development.org b/doc/snippet-development.org index e48e397..fb9b94a 100644 --- a/doc/snippet-development.org +++ b/doc/snippet-development.org @@ -169,6 +169,12 @@ This binding will be recorded in the keymap =html-mode-map=. To expand a paragraph tag newlines, just press =C-u C-c C-c C-m=. Omitting the =C-u= will expand the paragraph tag without newlines. +** =# uuid:= unique identifier + +This provides to a way to identify a snippet, independent of its name. +Loading a second snippet file with the same uuid would replace the +previous snippet. + ** =# contributor:= snippet author This is optional and has no effect whatsoever on snippet functionality, diff --git a/yasnippet.el b/yasnippet.el index eeea636..43564ff 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1631,8 +1631,8 @@ The remaining elements are strings. FILE is probably of very little use if you're programatically defining snippets. -UUID is the snippets \"unique-id\". Loading a second snippet file -with the same uuid replaced the previous snippet. +UUID is the snippet's \"unique-id\". Loading a second snippet +file with the same uuid would replace the previous snippet. You can use `yas--parse-template' to return such lists based on the current buffers contents." From 6b04dada67dcc9476a08d3ba59efcb831a66ac73 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 10 May 2014 18:51:45 -0400 Subject: [PATCH 39/83] Document type directive * doc/snippet-development.org: Add type to directive list. --- doc/snippet-development.org | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/snippet-development.org b/doc/snippet-development.org index fb9b94a..4e54bb1 100644 --- a/doc/snippet-development.org +++ b/doc/snippet-development.org @@ -169,6 +169,16 @@ This binding will be recorded in the keymap =html-mode-map=. To expand a paragraph tag newlines, just press =C-u C-c C-c C-m=. Omitting the =C-u= will expand the paragraph tag without newlines. +** =# type:= =snippet= or =command= + +If the =type= directive is set to =command=, the body of the snippet +is interpreted as lisp code to be evaluated when the snippet is +triggered. + +If it's =snippet= (the default when there is no =type= directive), the +snippet body will be parsed according to the [[Template Syntax]], +described below. + ** =# uuid:= unique identifier This provides to a way to identify a snippet, independent of its name. @@ -180,7 +190,7 @@ previous snippet. This is optional and has no effect whatsoever on snippet functionality, but it looks nice. -* Template syntax +* <