mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
* Fixed the "direct-keymaps" bug with `emulation-mode-map-alists'
* Fixed a bug when evaluating primary field expressions * Completed importation of TextMate HTML snippets, some TextMate HTML commands missing.
This commit is contained in:
parent
73bad7366f
commit
477f7c99e4
@ -17,7 +17,7 @@
|
||||
(setq word-begin (point))
|
||||
(forward-word 1)
|
||||
(setq word-end (point)))
|
||||
(when (and (> word-end word-begin)
|
||||
(when (and (< word-begin orig-point)
|
||||
(>= word-end (point)))
|
||||
(setq retval
|
||||
(cons
|
||||
@ -57,12 +57,19 @@
|
||||
|
||||
(defun yas/html-wrap-each-line-in-openclose-tag ()
|
||||
(let* ((mirror "${1:$(yas/html-first-word yas/text)}")
|
||||
(yas/html-wrap-newline (when (string-match "\n" yas/selected-text) "\n"))
|
||||
(template (concat (format "<${1:%s}>" (or yas/html-default-tag "p"))
|
||||
yas/selected-text
|
||||
"</" mirror ">")))
|
||||
(setq template (replace-regexp-in-string "\n" (concat "</" mirror ">\n<" mirror ">") template))
|
||||
(setq template (replace-regexp-in-string "\n" (concat "</" mirror ">\n<$1>") template))
|
||||
(yas/expand-snippet template)))
|
||||
|
||||
(defun yas/html-wrap-selection-if-not-wrapped-already (wrapping)
|
||||
(if (string-match (format "<%s>.*</%s>" wrapping wrapping) yas/selected-text)
|
||||
(insert yas/selected-text)
|
||||
(insert (format "<%s>%s</%s>" wrapping yas/selected-text wrapping))))
|
||||
|
||||
|
||||
(defun yas/html-between-tag-pair-p ()
|
||||
(save-excursion
|
||||
(backward-word)
|
||||
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 5.0 only
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if IE 5.0]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.0 only }}<![endif]-->$0
|
||||
<!--[if IE 5.0]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.0 only ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 5.5 only
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if IE 5.5000]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.5 only }}<![endif]-->$0
|
||||
<!--[if IE 5.5000]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.5 only ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 5.x
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if lt IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.x }}<![endif]-->$0
|
||||
<!--[if lt IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 5.x ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 6 and below
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if lte IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 6 and below }}<![endif]-->$0
|
||||
<!--[if lte IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 6 and below ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 6 only
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 6 only }}<![endif]-->$0
|
||||
<!--[if IE 6]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 6 only ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer 7 and above
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if gte IE 7]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 7 and above }}<![endif]-->$0
|
||||
<!--[if gte IE 7]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer 7 and above ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: Internet Explorer
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if IE]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer }}<![endif]-->$0
|
||||
<!--[if IE]>${1:`(or yas/selected-text " IE Conditional Comment: Internet Explorer ")`}<![endif]-->$0
|
@ -4,4 +4,4 @@
|
||||
# name: IE Conditional Comment: NOT Internet Explorer
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<!--[if !IE]><!-->${1:${TM_SELECTED_TEXT: IE Conditional Comment: NOT Internet Explorer }}<!-- <![endif]-->$0
|
||||
<!--[if !IE]><!-->${1:`(or yas/selected-text " IE Conditional Comment: NOT Internet Explorer ")`}<!-- <![endif]-->$0
|
@ -1,7 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Non-Breaking Space
|
||||
## binding: "~ "
|
||||
# key: nbsp
|
||||
## binding: " "
|
||||
## condition: "text.html"
|
||||
# --
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# type: command
|
||||
# name: Emphasize
|
||||
# binding: "A-i"
|
||||
# binding: A-i
|
||||
## condition: "text.html"
|
||||
# --
|
||||
(yas/html-wrap-selection-if-not-wrapped-already "em")
|
||||
|
@ -1,8 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Strong
|
||||
# binding: "A-b"
|
||||
# binding: A-b
|
||||
## condition: "text.html"
|
||||
# --
|
||||
(yas/html-wrap-selection-if-not-wrapped-already "strong")
|
||||
|
@ -5,13 +5,13 @@
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
<param name="src" value="$1"${TM_XHTML}>
|
||||
<param name="controller" value="$4"${TM_XHTML}>
|
||||
<param name="autoplay" value="$5"${TM_XHTML}>
|
||||
<param name="src" value="$1"`yas/html-xhtml-attr`>
|
||||
<param name="controller" value="$4"`yas/html-xhtml-attr`>
|
||||
<param name="autoplay" value="$5"`yas/html-xhtml-attr`>
|
||||
<embed src="${1:movie.mov}"
|
||||
width="${2:320}" height="${3:240}"
|
||||
controller="${4:true}" autoplay="${5:true}"
|
||||
scale="tofit" cache="true"
|
||||
pluginspage="http://www.apple.com/quicktime/download/"
|
||||
${TM_XHTML}>
|
||||
pluginspage="http://www.apple.com/quicktime/download/"`(when (and yas/html-xhtml-attr (not (string= "" yas/html-xhtml-attr)))
|
||||
(concat "\n" yas/html-xhtml-attr))`>
|
||||
</object>
|
@ -4,7 +4,7 @@
|
||||
# name: Fieldset
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<fieldset id="${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}" ${2:class="${3:}"}>
|
||||
<fieldset id="${1:$(yas/html-id-from-string yas/text)}" ${2:class="$3"}>
|
||||
<legend>${1:`yas/selected-text`}</legend>
|
||||
|
||||
$0
|
||||
|
@ -4,4 +4,6 @@
|
||||
# name: Input with Label
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}${TM_XHTML}>
|
||||
<label for="${2:id$(yas/get-field-once 1 #'yas/html-id-from-string)}">$1</label><input type="${3:$$(yas/choose-value '("text" "submit" "hidden" "button"))}" name="${4:name$(
|
||||
yas/get-field-once 2)}" value="$5"${6: id="${7:id$(
|
||||
yas/get-field-once 2)}"}`yas/html-xhtml-attr`>
|
@ -4,4 +4,4 @@
|
||||
# name: Option
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<option${1: value="${2:option}"}>${3:$2}</option>
|
||||
<option${1: value="${2:option}"}>${3:option$(unless yas/modified-p (yas/field-value 2))}</option>
|
@ -4,8 +4,8 @@
|
||||
# name: Select Box
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
|
||||
<option${9: value="${10:option1}"}>${11:$10}</option>
|
||||
<option${12: value="${13:option2}"}>${14:$13}</option>${15:}
|
||||
<select name="${1:some_name}" id="${2:id$(yas/get-field-once 1)}"${3:${4: multiple}${5: onchange="$6"}${7: size="${8:1}"}}>
|
||||
<option${9: value="${10:option1}"}>${11:$$(yas/get-field-once 10)}</option>
|
||||
<option${12: value="${13:option2}"}>${14:$$(yas/get-field-once 13)}</option>$15
|
||||
$0
|
||||
</select>
|
@ -4,4 +4,4 @@
|
||||
# name: Base
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<base href="$1"${2: target="$3"}${TM_XHTML}>
|
||||
<base href="$1"${2: target="$3"}`yas/html-xhtml-attr`>
|
@ -4,6 +4,8 @@
|
||||
# name: Body
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<body id="${1:${TM_FILENAME/(.*)\..*/\L$1/}}"${2: onload="$3"}>
|
||||
<body id="${1:`(or (and buffer-file-name
|
||||
(downcase (file-name-sans-extension (file-name-nondirectory buffer-file-name))))
|
||||
"some_id")`}"${2: onload="$3"}>
|
||||
$0
|
||||
</body>
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Br
|
||||
## binding: "^
"
|
||||
# binding: M-RET
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<br${TM_XHTML}>
|
||||
<br`yas/html-xhtml-attr`>
|
@ -4,8 +4,11 @@
|
||||
# name: Form
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<form action="${1:${TM_FILENAME/(.*?)\..*/$1_submit/}}" method="${2:get}" accept-charset="utf-8">
|
||||
<form action="${1:`(or (and buffer-file-name
|
||||
(concat (file-name-sans-extension (file-name-nondirectory buffer-file-name))
|
||||
"_submit"))
|
||||
"some_action")`}" method="${2:get}" accept-charset="utf-8">
|
||||
$0
|
||||
|
||||
<p><input type="submit" value="Continue →"${TM_XHTML}></p>
|
||||
<p><input type="submit" value="Continue →"`yas/html-xhtml-attr`></p>
|
||||
</form>
|
@ -4,4 +4,4 @@
|
||||
# name: Heading
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<h1 id="${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}">${1:`yas/selected-text`}</h1>
|
||||
<h1 id="${1:$(yas/html-id-from-string yas/text)}">${1:`yas/selected-text`}</h1>
|
@ -5,7 +5,9 @@
|
||||
## condition: "text.html - text.html source"
|
||||
# --
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"${TM_XHTML}>
|
||||
<title>${1:${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/}}</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"`yas/html-xhtml-attr`>
|
||||
<title>${1:`(or (and buffer-file-name
|
||||
(file-name-sans-extension (file-name-nondirectory buffer-file-name)))
|
||||
"Page Title")`}</title>
|
||||
$0
|
||||
</head>
|
@ -1,7 +1,6 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: input
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Input
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}${TM_XHTML}>
|
||||
<input type="${1:$$(yas/choose-value '("text" "submit" "hidden" "button"))}" name="${2:some_name}" value="$3"${4: id="${5:$$(yas/get-field-once 2)}"}`yas/html-xhtml-attr`>
|
@ -4,4 +4,4 @@
|
||||
# name: Link
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"${TM_XHTML}>
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`yas/html-xhtml-attr`>
|
@ -4,4 +4,4 @@
|
||||
# name: Meta
|
||||
## condition: "text.html"
|
||||
# --
|
||||
<meta name="${1:name}" content="${2:content}"${TM_XHTML}>
|
||||
<meta name="${1:name}" content="${2:content}"`yas/html-xhtml-attr`>
|
@ -4,4 +4,6 @@
|
||||
# name: Title
|
||||
## condition: "text.html - text.blog"
|
||||
# --
|
||||
<title>${1:${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/}}</title>
|
||||
<title>${1:`(or (and buffer-file-name
|
||||
(file-name-sans-extension (file-name-nondirectory buffer-file-name)))
|
||||
"Page Title")`}</title>
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Special: Return Inside Empty Open/Close Tags
|
||||
# binding: "C-M"
|
||||
# binding: RET
|
||||
# condition: (yas/html-between-tag-pair-p)
|
||||
# --
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# contributor: joaotavora, adapted from TextMate HTML bundle
|
||||
# name: Wrap Selection in Open/Close Tag
|
||||
# binding: "C-S-w"
|
||||
# binding: C-S-w
|
||||
# condition: mark-active
|
||||
# expand-env: ((yas/html-wrap-newline (when (string-match "\n" yas/selected-text) "\n")))
|
||||
# --
|
||||
<${1:p}>`yas/selected-text`</${1:$(yas/html-first-word yas/text)}>
|
||||
<${1:p}>`(concat yas/html-wrap-newline yas/selected-text yas/html-wrap-newline)`</${1:$(yas/html-first-word yas/text)}>
|
89
yasnippet.el
89
yasnippet.el
@ -710,7 +710,7 @@ With optional UNBIND-KEY, try to unbind that key from
|
||||
(defvar yas/snippet-tables (make-hash-table)
|
||||
"A hash table of MAJOR-MODE symbols to `yas/snippet-table' objects.")
|
||||
|
||||
(defvar yas/snippet-keymaps nil
|
||||
(defvar yas/direct-keymaps (list)
|
||||
"Keymap alist supporting direct snippet keybindings.
|
||||
|
||||
This variable is is placed `emulation-mode-map-alists'.
|
||||
@ -721,17 +721,28 @@ set buffer-locally when entering `yas/minor-mode'. KEYMAP binds
|
||||
all defined direct keybindings to the command
|
||||
`yas/expand-from-keymap', which acts similarly to `yas/expand'")
|
||||
|
||||
(defun yas/snippet-keymaps-reload ()
|
||||
(defun yas/direct-keymaps-reload ()
|
||||
"Force reload the direct keybinding for active snippet tables."
|
||||
(interactive)
|
||||
(setq yas/snippet-keymaps nil)
|
||||
(setq yas/direct-keymaps nil)
|
||||
(maphash #'(lambda (name table)
|
||||
(mapc #'(lambda (table)
|
||||
(push (cons name
|
||||
(yas/snippet-table-keymap table))
|
||||
yas/snippet-keymaps))
|
||||
(push (cons (intern (format "yas//direct-%s" name))
|
||||
(yas/snippet-table-direct-keymap table))
|
||||
yas/direct-keymaps))
|
||||
(cons table (yas/snippet-table-get-all-parents table))))
|
||||
yas/snippet-tables))
|
||||
|
||||
(defun yas/direct-keymaps-set-vars ()
|
||||
(let ((modes-to-activate (list major-mode))
|
||||
(mode major-mode))
|
||||
(while (setq mode (get mode 'derived-mode-parent))
|
||||
(push mode modes-to-activate))
|
||||
(dolist (mode modes-to-activate)
|
||||
(let ((name (intern (format "yas//direct-%s" mode))))
|
||||
(set-default name nil)
|
||||
(set (make-local-variable name) t)))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode yas/minor-mode
|
||||
"Toggle YASnippet mode.
|
||||
@ -764,26 +775,19 @@ Key bindings:
|
||||
;; Install the direct keymaps in `emulation-mode-map-alists'
|
||||
;; (we use `add-hook' even though it's not technically a hook,
|
||||
;; but it works). Then define variables named after modes to
|
||||
;; index `yas/snippet-keymaps'.
|
||||
;; index `yas/direct-keymaps'.
|
||||
;;
|
||||
;; FIXME: this is quite wrong and breaks cua-mode for
|
||||
;; example. It is either `yas/snippet-keymaps' that needs to
|
||||
;; example. It is either `yas/direct-keymaps' that needs to
|
||||
;; have a buffer-local value, or those little indicator vars
|
||||
;; need to be set and unset buffer-locally (preferred).
|
||||
;;
|
||||
(add-hook 'emulation-mode-map-alists 'yas/snippet-keymaps nil 'local)
|
||||
(let ((modes-to-activate (list major-mode))
|
||||
(mode major-mode))
|
||||
(while (setq mode (get mode 'derived-mode-parent))
|
||||
(push mode modes-to-activate))
|
||||
(dolist (mode modes-to-activate)
|
||||
(unless (and (boundp mode)
|
||||
(symbol-value mode))
|
||||
(set (make-local-variable mode) t)))))
|
||||
(add-hook 'emulation-mode-map-alists 'yas/direct-keymaps)
|
||||
(yas/direct-keymaps-set-vars))
|
||||
(t
|
||||
;; Uninstall the direct keymaps.
|
||||
;;
|
||||
(remove-hook 'emulation-mode-map-alists 'yas/snippet-keymaps 'local))))
|
||||
(remove-hook 'emulation-mode-map-alists 'yas/direct-keymaps))))
|
||||
|
||||
(defvar yas/dont-activate #'(lambda ()
|
||||
(and yas/root-directory
|
||||
@ -892,7 +896,7 @@ Has the following fields:
|
||||
|
||||
A hash table, known as the \"keyhash\" where key is a string or
|
||||
a vector. In case of a string its the snippet trigger key,
|
||||
whereas a vector means its a direct keybinding. The value is
|
||||
whereas a vector means it's a direct keybinding. The value is
|
||||
yet another hash of (NAME . TEMPLATE), known as the
|
||||
\"namehash\", where NAME is the snippet name and TEMPLATE is a
|
||||
`yas/template' object.
|
||||
@ -902,7 +906,7 @@ Has the following fields:
|
||||
A list of tables considered parents of this table: i.e. when
|
||||
searching for expansions they are searched as well.
|
||||
|
||||
`yas/snippet-keymap'
|
||||
`yas/snippet-table-direct-keymap'
|
||||
|
||||
A keymap for the snippets in this table that have direct
|
||||
keybindings. This is kept in sync with the keyhash, i.e., all
|
||||
@ -912,7 +916,7 @@ Has the following fields:
|
||||
name
|
||||
(hash (make-hash-table :test 'equal))
|
||||
(parents nil)
|
||||
(keymap (make-sparse-keymap)))
|
||||
(direct-keymap (make-sparse-keymap)))
|
||||
|
||||
;; Apropos storing/updating, this is works with two steps:
|
||||
;;
|
||||
@ -968,7 +972,7 @@ Has the following fields:
|
||||
(when (= 0 (hash-table-count (cdr elem)))
|
||||
(remhash (car elem) (yas/snippet-table-hash table))
|
||||
(when (vectorp (car elem))
|
||||
(define-key (yas/snippet-table-keymap table) (car elem) nil))))))
|
||||
(define-key (yas/snippet-table-direct-keymap table) (car elem) nil))))))
|
||||
|
||||
(defun yas/add-snippet (table name key template)
|
||||
"Store in TABLE the snippet NAME indexed by KEY and expanding TEMPLATE.
|
||||
@ -987,7 +991,7 @@ keybinding)."
|
||||
(make-hash-table :test 'equal)
|
||||
(yas/snippet-table-hash table))))
|
||||
(when (vectorp key)
|
||||
(define-key (yas/snippet-table-keymap table) key 'yas/expand-from-keymap))))
|
||||
(define-key (yas/snippet-table-direct-keymap table) key 'yas/expand-from-keymap))))
|
||||
|
||||
(defun yas/fetch (table key)
|
||||
"Fetch snippets in TABLE by KEY. "
|
||||
@ -1053,13 +1057,7 @@ conditions to filter out potential expansions."
|
||||
(let* ((requirement (or requirement
|
||||
(yas/require-template-specific-condition-p)))
|
||||
(result (or (null condition)
|
||||
(yas/eval-condition
|
||||
(condition-case err
|
||||
(read condition)
|
||||
(error (progn
|
||||
(message (format "[yas] error reading condition: %s"
|
||||
(error-message-string err))))
|
||||
nil))))))
|
||||
(yas/eval-condition condition))))
|
||||
(cond ((eq requirement t)
|
||||
result)
|
||||
(t
|
||||
@ -1182,7 +1180,9 @@ already have such a property."
|
||||
yas/snippet-tables)))
|
||||
(unless table
|
||||
(setq table (yas/make-snippet-table (symbol-name mode)))
|
||||
(puthash mode table yas/snippet-tables))
|
||||
(puthash mode table yas/snippet-tables)
|
||||
(aput 'yas/direct-keymaps (intern (format "yas//direct-%s" mode))
|
||||
(yas/snippet-table-direct-keymap table)))
|
||||
table))
|
||||
|
||||
(defun yas/get-snippet-tables (&optional mode-symbol dont-search-parents)
|
||||
@ -1284,7 +1284,7 @@ Here's a list of currently recognized variables:
|
||||
(when (string= "name" (match-string-no-properties 1))
|
||||
(setq name (match-string-no-properties 2)))
|
||||
(when (string= "condition" (match-string-no-properties 1))
|
||||
(setq condition (match-string-no-properties 2)))
|
||||
(setq condition (yas/read-lisp (match-string-no-properties 2))))
|
||||
(when (string= "group" (match-string-no-properties 1))
|
||||
(setq group (match-string-no-properties 2)))
|
||||
(when (string= "expand-env" (match-string-no-properties 1))
|
||||
@ -1556,7 +1556,7 @@ content of the file is the template."
|
||||
(call-interactively 'yas/load-directory))
|
||||
;; Reload the direct keybindings
|
||||
;;
|
||||
(yas/snippet-keymaps-reload)
|
||||
(yas/direct-keymaps-reload)
|
||||
;; Restore the mode configuration
|
||||
;;
|
||||
(when restore-minor-mode
|
||||
@ -1669,7 +1669,12 @@ Here's the default value for all the parameters:
|
||||
(insert "\n\n"))))
|
||||
(dolist (dir dirs)
|
||||
(dolist (subdir (yas/subdirs dir))
|
||||
(yas/load-directory-1 subdir nil 'no-hierarchy-parents))))
|
||||
(yas/load-directory-1 subdir nil 'no-hierarchy-parents)
|
||||
(let ((file (concat subdir "/.yas-setup.el")))
|
||||
(when (file-readable-p file)
|
||||
(insert ";; Supporting elisp for subdir " (file-name-nondirectory subdir) "\n\n")
|
||||
(goto-char (+ (point)
|
||||
(second (insert-file-contents file)))))))))
|
||||
|
||||
(insert (pp-to-string `(yas/global-mode 1)))
|
||||
(insert ")\n\n" code "\n")
|
||||
@ -1930,7 +1935,7 @@ object satisfying `yas/field-p' to restrict the expansion to."
|
||||
(yas/fallback 'trigger-key))))
|
||||
|
||||
(defun yas/expand-from-keymap ()
|
||||
"Directly expand some snippets, searching `yas/snippet-keymaps'.
|
||||
"Directly expand some snippets, searching `yas/direct-keymaps'.
|
||||
|
||||
If expansion fails, execute the previous binding for this key"
|
||||
(interactive)
|
||||
@ -1968,7 +1973,7 @@ Common gateway for `yas/expand-from-trigger-key' and
|
||||
nil)
|
||||
((eq yas/fallback-behavior 'call-other-command)
|
||||
(let* ((yas/minor-mode nil)
|
||||
(yas/snippet-keymaps nil)
|
||||
(yas/direct-keymaps nil)
|
||||
(keys-1 (this-command-keys-vector))
|
||||
(keys-2 (and yas/trigger-key
|
||||
from-trigger-key-p
|
||||
@ -2172,7 +2177,7 @@ lurking."
|
||||
# -*- mode: snippet -*-
|
||||
# name: %s
|
||||
# key: $1${2:
|
||||
# binding: \"${3:keybinding}\"}${4:
|
||||
# binding: \"${3:direct-keybinding}\"}${4:
|
||||
# expand-env: ((${5:some-var} ${6:some-value}))}
|
||||
# --
|
||||
$0" name))))
|
||||
@ -2373,6 +2378,12 @@ Otherwise throw exception."
|
||||
(when field
|
||||
(yas/field-text-for-display field))))
|
||||
|
||||
(defun yas/get-field-once (number &optional transform-fn)
|
||||
(unless yas/modified-p
|
||||
(if transform-fn
|
||||
(funcall transform-fn yas/field-value number)
|
||||
(yas/field-value number))))
|
||||
|
||||
(defun yas/default-from-field (number)
|
||||
(unless yas/modified-p
|
||||
(yas/field-value number)))
|
||||
@ -3451,7 +3462,7 @@ When multiple expressions are found, only the last one counts."
|
||||
(let ((lisp-expression-string (buffer-substring-no-properties (match-beginning 1)
|
||||
real-match-end-1)))
|
||||
(setf (yas/field-transform parent-field)
|
||||
(yas/restore-escapes (yas/read-lisp lisp-expression-string))))
|
||||
(yas/read-lisp (yas/restore-escapes lisp-expression-string))))
|
||||
(push (cons (match-beginning 0) real-match-end-1)
|
||||
yas/dollar-regions)))))))
|
||||
|
||||
@ -3623,7 +3634,7 @@ object satisfying `yas/field-p' to restrict the expansion to.")))
|
||||
(templates (mapcan #'(lambda (table)
|
||||
(yas/fetch table vec))
|
||||
(yas/get-snippet-tables)))
|
||||
(yas/snippet-keymaps nil)
|
||||
(yas/direct-keymaps nil)
|
||||
(fallback (key-binding vec)))
|
||||
(concat "In this particular case\nmy guess is it would "
|
||||
(when templates
|
||||
|
Loading…
x
Reference in New Issue
Block a user