mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Fixing some issues, might be broken
This commit is contained in:
parent
aec74e5564
commit
7022af00f4
@ -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
|
||||||
|
121
yasnippet.el
121
yasnippet.el
@ -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,14 +411,17 @@ 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))))
|
||||||
|
|
||||||
(let ((map (make-sparse-keymap)))
|
(defun yas/init-yas-in-snippet-keymap ()
|
||||||
(mapc #'(lambda (binding)
|
(let ((map (make-sparse-keymap)))
|
||||||
(yas/define-some-keys (car binding) map (cdr binding)))
|
(mapc #'(lambda (binding)
|
||||||
`((,yas/next-field-key . yas/next-field-or-maybe-expand)
|
(yas/define-some-keys (car binding) map (cdr binding)))
|
||||||
(,yas/prev-field-key . yas/prev-field)
|
`((,yas/next-field-key . yas/next-field-or-maybe-expand)
|
||||||
("C-g" . yas/abort-snippet)
|
(,yas/prev-field-key . yas/prev-field)
|
||||||
(,yas/skip-and-clear-key . yas/skip-and-clear-or-delete-char)))
|
("C-g" . yas/abort-snippet)
|
||||||
(setq yas/keymap map))
|
(,yas/skip-and-clear-key . yas/skip-and-clear-or-delete-char)))
|
||||||
|
(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,20 +1704,22 @@ 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))))
|
||||||
(message "[yas] warning: won't overwrite keybinding \"%s\" for snippet \"%s\" in `%s'"
|
(if (and lookup
|
||||||
(key-description (second keybinding)) name (first keybinding))
|
(not (numberp lookup)))
|
||||||
(define-key
|
(message "[yas] warning: won't overwrite keybinding \"%s\" for snippet \"%s\" in `%s'"
|
||||||
(symbol-value (first keybinding))
|
(key-description (second keybinding)) name (first keybinding))
|
||||||
(second keybinding)
|
(define-key
|
||||||
`(lambda (&optional yas/prefix)
|
(symbol-value (first keybinding))
|
||||||
(interactive "P")
|
(second keybinding)
|
||||||
(when (yas/template-can-expand-p ,(yas/template-condition template))
|
`(lambda (&optional yas/prefix)
|
||||||
(yas/expand-snippet ,(yas/template-content template)
|
(interactive "P")
|
||||||
nil
|
(when (yas/template-can-expand-p ,(yas/template-condition template))
|
||||||
nil
|
(yas/expand-snippet ,(yas/template-content template)
|
||||||
,(yas/template-expand-env template)))))
|
nil
|
||||||
(add-to-list 'yas/active-keybindings keybinding)))
|
nil
|
||||||
|
,(yas/template-expand-env template)))))
|
||||||
|
(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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user