mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Fix: new yas-trigger-key
default messed up the fallbacks.
Introduced an ugly `yas--trigger-key-for-fallback` hack, but should be good.
This commit is contained in:
parent
cdea084f7a
commit
5eede17563
15
yasnippet.el
15
yasnippet.el
@ -2256,6 +2256,18 @@ expand immediately. Common gateway for
|
|||||||
end
|
end
|
||||||
(yas--template-expand-env yas--current-template)))))
|
(yas--template-expand-env yas--current-template)))))
|
||||||
|
|
||||||
|
(defun yas--trigger-key-for-fallback ()
|
||||||
|
;; When `yas-trigger-key' is <tab> it correctly overrides
|
||||||
|
;; org-mode's <tab>, for example and searching for fallbacks
|
||||||
|
;; correctly returns `org-cycle'. However, most other modes bind
|
||||||
|
;; "TAB" (which is translated from <tab>), and calling
|
||||||
|
;; (key-binding "TAB") does not place return that command into
|
||||||
|
;; our command-2 local. So we cheat.
|
||||||
|
;;
|
||||||
|
(if (string= yas-trigger-key "<tab>")
|
||||||
|
"TAB"
|
||||||
|
yas-trigger-key))
|
||||||
|
|
||||||
(defun yas--fallback (&optional from-trigger-key-p)
|
(defun yas--fallback (&optional from-trigger-key-p)
|
||||||
"Fallback after expansion has failed.
|
"Fallback after expansion has failed.
|
||||||
|
|
||||||
@ -2267,6 +2279,7 @@ Common gateway for `yas-expand-from-trigger-key' and
|
|||||||
((eq yas-fallback-behavior 'call-other-command)
|
((eq yas-fallback-behavior 'call-other-command)
|
||||||
(let* ((yas-minor-mode nil)
|
(let* ((yas-minor-mode nil)
|
||||||
(yas--direct-keymaps nil)
|
(yas--direct-keymaps nil)
|
||||||
|
(yas-trigger-key (yas--trigger-key-for-fallback))
|
||||||
(keys-1 (this-command-keys-vector))
|
(keys-1 (this-command-keys-vector))
|
||||||
(keys-2 (and yas-trigger-key
|
(keys-2 (and yas-trigger-key
|
||||||
from-trigger-key-p
|
from-trigger-key-p
|
||||||
@ -4221,7 +4234,7 @@ When multiple expressions are found, only the last one counts."
|
|||||||
(let ((fallback-description
|
(let ((fallback-description
|
||||||
(cond ((eq yas-fallback-behavior 'call-other-command)
|
(cond ((eq yas-fallback-behavior 'call-other-command)
|
||||||
(let* ((yas-minor-mode nil)
|
(let* ((yas-minor-mode nil)
|
||||||
(fallback (key-binding (read-kbd-macro yas-trigger-key))))
|
(fallback (key-binding (read-kbd-macro (yas--trigger-key-for-fallback)))))
|
||||||
(or (and fallback
|
(or (and fallback
|
||||||
(format " call command `%s'." (pp-to-string fallback)))
|
(format " call command `%s'." (pp-to-string fallback)))
|
||||||
" do nothing.")))
|
" do nothing.")))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user