mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Closes #277: add new yas-active-keys
(for auto-complete)
Also documented and reviewed related functionality slightly. commit 51b182104b
This commit is contained in:
parent
08c6dd44b3
commit
8a26ab0a31
24
yasnippet.el
24
yasnippet.el
@ -1257,13 +1257,13 @@ the template of a snippet in the current snippet-table."
|
|||||||
|
|
||||||
|
|
||||||
(defun yas--table-all-keys (table)
|
(defun yas--table-all-keys (table)
|
||||||
(when table
|
"Get trigger keys of all active snippets in TABLE"
|
||||||
(let ((acc))
|
(let ((acc))
|
||||||
(maphash #'(lambda (key namehash)
|
(maphash #'(lambda (key namehash)
|
||||||
(when (yas--filter-templates-by-condition (yas--namehash-templates-alist namehash))
|
(when (yas--filter-templates-by-condition (yas--namehash-templates-alist namehash))
|
||||||
(push key acc)))
|
(push key acc)))
|
||||||
(yas--table-hash table))
|
(yas--table-hash table))
|
||||||
acc)))
|
acc))
|
||||||
|
|
||||||
(defun yas--table-mode (table)
|
(defun yas--table-mode (table)
|
||||||
(intern (yas--table-name table)))
|
(intern (yas--table-name table)))
|
||||||
@ -2317,7 +2317,7 @@ Common gateway for `yas-expand-from-trigger-key' and
|
|||||||
;;; Utils for snippet development:
|
;;; Utils for snippet development:
|
||||||
|
|
||||||
(defun yas--all-templates (tables)
|
(defun yas--all-templates (tables)
|
||||||
"Return all snippet tables applicable for the current buffer.
|
"Get `yas--template' objects in TABLES, applicable for buffer and point.
|
||||||
|
|
||||||
Honours `yas-choose-tables-first', `yas-choose-keys-first' and
|
Honours `yas-choose-tables-first', `yas-choose-keys-first' and
|
||||||
`yas-buffer-local-condition'"
|
`yas-buffer-local-condition'"
|
||||||
@ -2641,6 +2641,11 @@ whether (and where) to save the snippet, then quit the window."
|
|||||||
(t
|
(t
|
||||||
(yas--message 3 "Cannot test snippet for unknown major mode")))))
|
(yas--message 3 "Cannot test snippet for unknown major mode")))))
|
||||||
|
|
||||||
|
(defun yas-active-keys ()
|
||||||
|
"Return all active trigger keys for current buffer and point"
|
||||||
|
(remove-duplicates (mapcan #'yas--table-all-keys (yas--get-snippet-tables))
|
||||||
|
:test #'string=))
|
||||||
|
|
||||||
(defun yas--template-fine-group (template)
|
(defun yas--template-fine-group (template)
|
||||||
(car (last (or (yas--template-group template)
|
(car (last (or (yas--template-group template)
|
||||||
(yas--template-perm-group template)))))
|
(yas--template-perm-group template)))))
|
||||||
@ -4507,6 +4512,7 @@ handle the end-of-buffer error fired in it by calling
|
|||||||
yas-unimplemented
|
yas-unimplemented
|
||||||
yas-define-condition-cache
|
yas-define-condition-cache
|
||||||
yas-hippie-try-expand
|
yas-hippie-try-expand
|
||||||
|
yas-active-keys
|
||||||
|
|
||||||
;; debug definitions
|
;; debug definitions
|
||||||
;; yas-debug-snippet-vars
|
;; yas-debug-snippet-vars
|
||||||
@ -4522,9 +4528,17 @@ handle the end-of-buffer error fired in it by calling
|
|||||||
;; yas-saving-variables
|
;; yas-saving-variables
|
||||||
;; yas-call-with-snippet-dirs
|
;; yas-call-with-snippet-dirs
|
||||||
;; yas-with-snippet-dirs
|
;; yas-with-snippet-dirs
|
||||||
))
|
)
|
||||||
|
"Exported yassnippet symbols.
|
||||||
|
|
||||||
(dolist (sym yas--exported-syms)
|
i.e. ones that I will try to keep in future yasnippet versions
|
||||||
|
and ones that other elisp libraries can more or less safely rely
|
||||||
|
upon.")
|
||||||
|
|
||||||
|
(defvar yas--dont-backport '(yas-active-keys)
|
||||||
|
"Exported symbols that don't map back to \"yas/*\" variants")
|
||||||
|
|
||||||
|
(dolist (sym (set-difference yas--exported-syms yas--dont-backport))
|
||||||
(let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym)))))
|
(let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym)))))
|
||||||
(when (boundp sym)
|
(when (boundp sym)
|
||||||
(make-obsolete-variable backported sym "yasnippet 0.8")
|
(make-obsolete-variable backported sym "yasnippet 0.8")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user