Fixing some issues, might be broken

This commit is contained in:
capitaomorte 2009-09-04 12:07:06 +00:00
parent aec74e5564
commit 7022af00f4
2 changed files with 76 additions and 49 deletions

View File

@ -5,8 +5,10 @@
# -- # --
def ${1:name}($2): def ${1:name}($2):
"""$3 """$3
the comments dont enter into it stupid
${2:$ ${2:$
(let* ((indent (let*
((indent
(concat "\n" (make-string (current-column) 32))) (concat "\n" (make-string (current-column) 32)))
(args (args
(mapconcat (mapconcat

View File

@ -159,8 +159,8 @@ for multiple root directories. If you make this a list, the first
element is always the user-created snippets directory. Other element is always the user-created snippets directory. Other
directories are used for bulk reloading of all snippets using directories are used for bulk reloading of all snippets using
`yas/reload-all'" `yas/reload-all'"
:type '(choice (string :tag "Single directory (string)")
:type 'string (repeat :args (string) :tag "List of directories (strings)"))
:group 'yasnippet :group 'yasnippet
:require 'yasnippet :require 'yasnippet
:set #'(lambda (symbol new) :set #'(lambda (symbol new)
@ -199,7 +199,7 @@ nil.
signal `quit' with signal `quit' with
(signal 'quit \"user quit!\")." (signal 'quit \"user quit!\")."
:type 'list :type '(repeat function)
:group 'yasnippet) :group 'yasnippet)
(defcustom yas/indent-line 'auto (defcustom yas/indent-line 'auto
@ -249,27 +249,47 @@ representation using `read-kbd-macro'."
"The key to navigate to next field when a snippet is active. "The key to navigate to next field when a snippet is active.
Value is a string that is converted to the internal Emacs key Value is a string that is converted to the internal Emacs key
representation using `read-kbd-macro'." representation using `read-kbd-macro'.
:type 'string
:group 'yasnippet) Can also be a list of strings."
:type '(choice (string :tag "String")
(repeat :args (string) :tag "List of strings"))
:group 'yasnippet
:set #'(lambda (symbol val)
(set-default symbol val)
(if (fboundp 'yas/init-yas-in-snippet-keymap)
(yas/init-yas-in-snippet-keymap))))
(defcustom yas/prev-field-key '("<backtab>" "<S-tab>") (defcustom yas/prev-field-key '("<backtab>" "<S-tab>")
"The key to navigate to previous field when a snippet is active. "The key to navigate to previous field when a snippet is active.
Can also be a list of keys.
Value is a string that is converted to the internal Emacs key Value is a string that is converted to the internal Emacs key
representation using `read-kbd-macro'." representation using `read-kbd-macro'.
:type 'string
:group 'yasnippet) Can also be a list of strings."
:type '(choice (string :tag "String")
(repeat :args (string) :tag "List of strings"))
:group 'yasnippet
:set #'(lambda (symbol val)
(set-default symbol val)
(if (fboundp 'yas/init-yas-in-snippet-keymap)
(yas/init-yas-in-snippet-keymap))))
(defcustom yas/skip-and-clear-key "C-d" (defcustom yas/skip-and-clear-key "C-d"
"The key to clear the currently active field. "The key to clear the currently active field.
Value is a string that is converted to the internal Emacs key Value is a string that is converted to the internal Emacs key
representation using `read-kbd-macro'." representation using `read-kbd-macro'.
:type 'string
:group 'yasnippet) Can also be a list of strings."
:type '(choice (string :tag "String")
(repeat :args (string) :tag "List of strings"))
:group 'yasnippet
:set #'(lambda (symbol val)
(set-default symbol val)
(if (fboundp 'yas/init-yas-in-snippet-keymap)
(yas/init-yas-in-snippet-keymap))))
(defcustom yas/triggers-in-field nil (defcustom yas/triggers-in-field nil
"If non-nil, `yas/next-field-key' can trigger stacked expansions. "If non-nil, `yas/next-field-key' can trigger stacked expansions.
@ -288,11 +308,11 @@ field"
- nil or the symbol `return-nil' mean do nothing. (and - nil or the symbol `return-nil' mean do nothing. (and
`yas/expand-returns' nil) `yas/expand-returns' nil)
- An entry (apply COMMAND . ARGS) means interactively call - A lisp form (apply COMMAND . ARGS) means interactively call
COMMAND, if ARGS is non-nil, call COMMAND non-interactively COMMAND, if ARGS is non-nil, call COMMAND non-interactively
with ARGS as arguments." with ARGS as arguments."
:type '(choice (const :tag "Call previous command" 'call-other-command) :type '(choice (const :tag "Call previous command" call-other-command)
(const :tag "Do nothing" 'return-nil)) (const :tag "Do nothing" return-nil))
:group 'yasnippet) :group 'yasnippet)
(defcustom yas/choose-keys-first nil (defcustom yas/choose-keys-first nil
@ -391,6 +411,7 @@ This cafn only work when snippets are loaded from files."
(dolist (key keys) (dolist (key keys)
(define-key keymap (read-kbd-macro key) definition)))) (define-key keymap (read-kbd-macro key) definition))))
(defun yas/init-yas-in-snippet-keymap ()
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(mapc #'(lambda (binding) (mapc #'(lambda (binding)
(yas/define-some-keys (car binding) map (cdr binding))) (yas/define-some-keys (car binding) map (cdr binding)))
@ -398,7 +419,9 @@ This cafn only work when snippets are loaded from files."
(,yas/prev-field-key . yas/prev-field) (,yas/prev-field-key . yas/prev-field)
("C-g" . yas/abort-snippet) ("C-g" . yas/abort-snippet)
(,yas/skip-and-clear-key . yas/skip-and-clear-or-delete-char))) (,yas/skip-and-clear-key . yas/skip-and-clear-or-delete-char)))
(setq yas/keymap map)) (setq yas/keymap map)))
(yas/init-yas-in-snippet-keymap)
(defvar yas/key-syntaxes (list "w" "w_" "w_." "^ ") (defvar yas/key-syntaxes (list "w" "w_" "w_." "^ ")
"A list of syntax of a key. This list is tried in the order "A list of syntax of a key. This list is tried in the order
@ -776,16 +799,15 @@ Do this unless `yas/dont-activate' is t or the function
(list "Load this snippet" 'yas/load-snippet-buffer "\C-c\C-c") (list "Load this snippet" 'yas/load-snippet-buffer "\C-c\C-c")
(list "Try out this snippet" 'yas/tryout-snippet "\C-c\C-t")))))) (list "Try out this snippet" 'yas/tryout-snippet "\C-c\C-t"))))))
(progn
(yas/init-major-keymap))
(define-derived-mode snippet-mode text-mode "Snippet" (define-derived-mode snippet-mode text-mode "Snippet"
"A mode for editing yasnippets" "A mode for editing yasnippets"
(set-syntax-table (standard-syntax-table)) (set-syntax-table (standard-syntax-table))
(setq font-lock-defaults '(yas/font-lock-keywords)) (setq font-lock-defaults '(yas/font-lock-keywords))
(set (make-local-variable 'require-final-newline) nil) (set (make-local-variable 'require-final-newline) nil)
(use-local-map snippet-mode-map) (use-local-map snippet-mode-map))
(unless (cdr snippet-mode-map)
(yas/init-major-keymap)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal structs for template management ;; Internal structs for template management
@ -1682,7 +1704,9 @@ not need to be a real mode."
;; conflict! ;; conflict!
;; ;;
(when keybinding (when keybinding
(if (lookup-key (symbol-value (first keybinding)) (second keybinding)) (let ((lookup (lookup-key (symbol-value (first keybinding)) (second keybinding))))
(if (and lookup
(not (numberp lookup)))
(message "[yas] warning: won't overwrite keybinding \"%s\" for snippet \"%s\" in `%s'" (message "[yas] warning: won't overwrite keybinding \"%s\" for snippet \"%s\" in `%s'"
(key-description (second keybinding)) name (first keybinding)) (key-description (second keybinding)) name (first keybinding))
(define-key (define-key
@ -1695,7 +1719,7 @@ not need to be a real mode."
nil nil
nil nil
,(yas/template-expand-env template))))) ,(yas/template-expand-env template)))))
(add-to-list 'yas/active-keybindings keybinding))) (add-to-list 'yas/active-keybindings keybinding))))
;; Setup the menu groups, reorganizing from group to group if ;; Setup the menu groups, reorganizing from group to group if
;; necessary ;; necessary
@ -1822,12 +1846,13 @@ defined in `yas/fallback-behavior'"
nil) nil)
((eq yas/fallback-behavior 'call-other-command) ((eq yas/fallback-behavior 'call-other-command)
(let* ((yas/minor-mode nil) (let* ((yas/minor-mode nil)
(keys (or (this-command-keys-vector) (keys (or (and yas/trigger-key
(and yas/trigger-key
(stringp yas/trigger-key) (stringp yas/trigger-key)
(read-kbd-macro yas/trigger-key)))) (read-kbd-macro yas/trigger-key))
(this-command-keys-vector)))
(command (key-binding keys))) (command (key-binding keys)))
(when (commandp command) (when (and (commandp command)
(not (eq 'yas/expand command)))
(setq this-command command) (setq this-command command)
(call-interactively command)))) (call-interactively command))))
((and (listp yas/fallback-behavior) ((and (listp yas/fallback-behavior)