mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
* Fix Issue 132.
* Add `yas/expand-uuid' * Remove some `make-variable-buffer-local'
This commit is contained in:
parent
71d1b9b7c5
commit
df408a1c00
19
yasnippet.el
19
yasnippet.el
@ -325,7 +325,6 @@ field"
|
|||||||
: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)
|
||||||
(make-variable-buffer-local 'yas/fallback-behavior)
|
|
||||||
|
|
||||||
(defcustom yas/choose-keys-first nil
|
(defcustom yas/choose-keys-first nil
|
||||||
"If non-nil, prompt for snippet key first, then for template.
|
"If non-nil, prompt for snippet key first, then for template.
|
||||||
@ -2134,9 +2133,11 @@ Common gateway for `yas/expand-from-trigger-key' and
|
|||||||
(command-2 (and keys-2 (key-binding keys-2)))
|
(command-2 (and keys-2 (key-binding keys-2)))
|
||||||
;; An (ugly) safety: prevents infinite recursion of
|
;; An (ugly) safety: prevents infinite recursion of
|
||||||
;; yas/expand* calls.
|
;; yas/expand* calls.
|
||||||
(command (or (and (not (string-match "yas/expand" (symbol-name command-1)))
|
(command (or (and (symbolp command-1)
|
||||||
|
(not (string-match "yas/expand" (symbol-name command-1)))
|
||||||
command-1)
|
command-1)
|
||||||
command-2)))
|
(and (symbolp command-2)
|
||||||
|
command-2))))
|
||||||
(when (and (commandp command)
|
(when (and (commandp command)
|
||||||
(not (string-match "yas/expand" (symbol-name command))))
|
(not (string-match "yas/expand" (symbol-name command))))
|
||||||
(setq this-command command)
|
(setq this-command command)
|
||||||
@ -2401,14 +2402,12 @@ there, otherwise, proposes to create the first option returned by
|
|||||||
|
|
||||||
(defvar yas/editing-template nil
|
(defvar yas/editing-template nil
|
||||||
"Supporting variable for `yas/load-snippet-buffer' and `yas/visit-snippet'")
|
"Supporting variable for `yas/load-snippet-buffer' and `yas/visit-snippet'")
|
||||||
(make-variable-buffer-local 'yas/editing-template)
|
|
||||||
|
|
||||||
(defvar yas/current-template nil
|
(defvar yas/current-template nil
|
||||||
"Holds the current template being expanded into a snippet.")
|
"Holds the current template being expanded into a snippet.")
|
||||||
|
|
||||||
(defvar yas/guessed-directories nil
|
(defvar yas/guessed-directories nil
|
||||||
"Supporting variable for `yas/load-snippet-buffer' and `yas/new-snippet'")
|
"Supporting variable for `yas/load-snippet-buffer' and `yas/new-snippet'")
|
||||||
(make-variable-buffer-local 'yas/guessed-directories)
|
|
||||||
|
|
||||||
(defun yas/load-snippet-buffer (&optional kill)
|
(defun yas/load-snippet-buffer (&optional kill)
|
||||||
"Parse and load current buffer's snippet definition.
|
"Parse and load current buffer's snippet definition.
|
||||||
@ -4157,6 +4156,16 @@ object satisfying `yas/field-p' to restrict the expansion to.")))
|
|||||||
(help-xref-button 1 'help-snippet-def template)
|
(help-xref-button 1 'help-snippet-def template)
|
||||||
(kill-region (match-beginning 0) (match-beginning 1)))))))
|
(kill-region (match-beginning 0) (match-beginning 1)))))))
|
||||||
|
|
||||||
|
(defun yas/expand-uuid (mode-symbol uuid &optional start end expand-env)
|
||||||
|
"Expand a snippet registered in MODE-SYMBOL's table with UUID.
|
||||||
|
|
||||||
|
Remaining args as in `yas/expand-snippet'."
|
||||||
|
(let* ((table (gethash mode-symbol yas/tables))
|
||||||
|
(yas/current-template (and table
|
||||||
|
(gethash uuid (yas/table-uuidhash table)))))
|
||||||
|
(when yas/current-template
|
||||||
|
(yas/expand-snippet (yas/template-content yas/current-template)))))
|
||||||
|
|
||||||
|
|
||||||
;;; Some hacks:
|
;;; Some hacks:
|
||||||
;; `locate-dominating-file' is added for compatibility in emacs < 23
|
;; `locate-dominating-file' is added for compatibility in emacs < 23
|
||||||
|
Loading…
x
Reference in New Issue
Block a user