[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6ee3d2e 029/177: Closes #404: merge remote-tracking branch
From: |
João Távora |
Subject: |
[elpa] master 6ee3d2e 029/177: Closes #404: merge remote-tracking branch 'npostavs/widen' |
Date: |
Sat, 28 Mar 2015 15:40:36 +0000 |
branch: master
commit 6ee3d2e0b6c0e16e432c78d6dacb1da8e65f16c0
Merge: 43a484e d7b2b89
Author: Joao Tavora <address@hidden>
Commit: Joao Tavora <address@hidden>
Closes #404: merge remote-tracking branch 'npostavs/widen'
---
yasnippet.el | 63 +++++++++++++++++++++++-----------------------------------
1 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 91aabd9..c7aecfa 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -837,7 +837,8 @@ Honour `yas-dont-activate', which see."
(when (third ent)
(define-key map (third ent) (second ent)))
(vector (first ent) (second ent) t))
- '(("Load this snippet" yas-load-snippet-buffer "\C-c\C-c")
+ '(("Load this snippet" yas-load-snippet-buffer "\C-c\C-l")
+ ("Load and quit window"
yas-load-snippet-buffer-and-close "\C-c\C-c")
("Try out this snippet" yas-tryout-snippet
"\C-c\C-t")))))
map)
"The keymap used when `snippet-mode' is active.")
@@ -2526,8 +2527,7 @@ neither do the elements of PARENTS."
TABLE is a symbol naming a passed to `yas--table-get-create'.
-When called interactively, prompt for the table name and
-whether (and where) to save the snippet, then quit the window."
+When called interactively, prompt for the table name."
(interactive (list (yas--read-table) t))
(cond
;; We have `yas--editing-template', this buffer's content comes from a
@@ -2546,9 +2546,25 @@ whether (and where) to save the snippet, then quit the
window."
(set (make-local-variable 'yas--editing-template)
(yas--define-snippets-1 (yas--parse-template buffer-file-name)
table)))))
+ (when interactive
+ (yas--message 3 "Snippet \"%s\" loaded for %s."
+ (yas--template-name yas--editing-template)
+ (yas--table-name (yas--template-table
yas--editing-template)))))
+
+(defun yas-load-snippet-buffer-and-close (table &optional kill)
+ "Load the snippet with `yas-load-snippet-buffer', possibly
+ save, then `quit-window' if saved.
+
+If the snippet is new, ask the user whether (and where) to save
+it. If the snippet already has a file, just save it.
- (when (and interactive
- (or
+The prefix argument KILL is passed to `quit-window'.
+
+Don't use this from a Lisp program, call `yas-load-snippet-buffer'
+and `kill-buffer' instead."
+ (interactive (list (yas--read-table) current-prefix-arg))
+ (yas-load-snippet-buffer table t)
+ (when (and (or
;; Only offer to save this if it looks like a library or new
;; snippet (loaded from elisp, from a dir in `yas-snippet-dirs'
;; which is not the first, or from an unwritable file)
@@ -2571,11 +2587,9 @@ whether (and where) to save the snippet, then quit the
window."
(read-from-minibuffer (format "File name to
create in %s? " chosen)
default-file-name)))
(setf (yas--template-file yas--editing-template)
buffer-file-name)))))
- (when interactive
- (yas--message 3 "Snippet \"%s\" loaded for %s."
- (yas--template-name yas--editing-template)
- (yas--table-name (yas--template-table
yas--editing-template)))
- (quit-window interactive)))
+ (when buffer-file-name
+ (save-buffer)
+ (quit-window kill)))
(defun yas-tryout-snippet (&optional debug)
"Test current buffer's snippet template in other buffer."
@@ -3805,7 +3819,7 @@ Meant to be called in a narrowed buffer, does various
passes"
(yas--calculate-adjacencies snippet)
;; Delete $-constructs
;;
- (yas--delete-regions yas--dollar-regions)
+ (save-restriction (widen) (yas--delete-regions yas--dollar-regions))
;; restore backquoted expression values
;;
(yas--restore-backquotes)
@@ -4394,33 +4408,6 @@ and return the directory. Return nil if not found."
(setq file nil))))
root))))
-;; `c-neutralize-syntax-in-CPP` sometimes fires "End of Buffer" error
-;; (when it execute forward-char) and interrupt the after change
-;; hook. Thus prevent the insert-behind hook of yasnippet to be
-;; invoked. Here's a way to reproduce it:
-
-;; # open a *new* Emacs.
-;; # load yasnippet.
-;; # open a *new* .cpp file.
-;; # input "inc" and press TAB to expand the snippet.
-;; # select the `#include <...>` snippet.
-;; # type inside `<>`
-
-(defadvice c-neutralize-syntax-in-CPP
- (around yas--mp/c-neutralize-syntax-in-CPP activate)
- "Adviced `c-neutralize-syntax-in-CPP' to properly
-handle the `end-of-buffer' error fired in it by calling
-`forward-char' at the end of buffer."
- (condition-case err
- ad-do-it
- (error (message (error-message-string err)))))
-
-;; disable c-electric-* serial command in YAS fields
-(add-hook 'c-mode-common-hook
- '(lambda ()
- (dolist (k '(":" ">" ";" "<" "{" "}"))
- (define-key (symbol-value (make-local-variable 'yas-keymap))
- k 'self-insert-command))))
;;; Backward compatibility to yasnippet <= 0.7
- [elpa] master 3bb1515 018/177: Merge pull request #409 from npostavs/font-lock, (continued)
- [elpa] master 3bb1515 018/177: Merge pull request #409 from npostavs/font-lock, João Távora, 2015/03/28
- [elpa] master 6c3e029 020/177: Merge pull request #412 from npostavs/less-narrow, João Távora, 2015/03/28
- [elpa] master 32ee5cb 021/177: Closes #415: remove c-specific hacks, harmful on emacs 24.3, João Távora, 2015/03/28
- [elpa] master ffd497d 022/177: don't kill snippet buffer unless saved, João Távora, 2015/03/28
- [elpa] master 205b0e6 023/177: move snippet saving from loading to closing, João Távora, 2015/03/28
- [elpa] master 33dff9a 024/177: let C-c C-c save existing snippets too, João Távora, 2015/03/28
- [elpa] master d7b2b89 027/177: widen before deleting regions, João Távora, 2015/03/28
- [elpa] master 84b7e69 025/177: Merge pull request #423 from npostavs/load-snippet-ui, João Távora, 2015/03/28
- [elpa] master 43a484e 028/177: add: external test for issue #404, João Távora, 2015/03/28
- [elpa] master d5d6e45 026/177: Feature: de/activate-extra-mode, João Távora, 2015/03/28
- [elpa] master 6ee3d2e 029/177: Closes #404: merge remote-tracking branch 'npostavs/widen',
João Távora <=
- [elpa] master a4a7e5e 032/177: fix typo: .yas.parents -> .yas-parents, João Távora, 2015/03/28
- [elpa] master fdd550a 035/177: Fix screencast link., João Távora, 2015/03/28
- [elpa] master bc4cfbb 033/177: yas/ -> yas-, João Távora, 2015/03/28
- [elpa] master b20f0a4 034/177: fix exporting of doc strings for org manual, João Távora, 2015/03/28
- [elpa] master f5457df 031/177: Go back to org manual, João Távora, 2015/03/28
- [elpa] master 0f67c07 030/177: Merge pull request #424 from ljos/de/activate-extra-mode, João Távora, 2015/03/28
- [elpa] master 8e8320f 036/177: remove reference to yas-trigger-key, João Távora, 2015/03/28
- [elpa] master 042837d 038/177: Migrate to snippets maintained by the TextMate community, João Távora, 2015/03/28
- [elpa] master 81e26b4 039/177: Merge pull request #431 from ignisf/update-snippet-submodules, João Távora, 2015/03/28
- [elpa] master c7c6516 040/177: don't use link abbreviations, João Távora, 2015/03/28