[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master cc1c758 18/60: Reorganize snippet construction from list c
From: |
João Távora |
Subject: |
[elpa] master cc1c758 18/60: Reorganize snippet construction from list code |
Date: |
Thu, 21 Jan 2016 22:35:54 +0000 |
branch: master
commit cc1c758ab7c8b7312fea26f9d8dbce2118ef916b
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Reorganize snippet construction from list code
* yasnippet.el (yas--template): New yas--define-snippets-2 constructor
with arguments matching yas-define-snippets format.
(yas--define-snippets-1): Use it.
(yas--update-template): Return TEMPLATE argument.
---
yasnippet.el | 68 ++++++++++++++++++++++++---------------------------------
1 files changed, 29 insertions(+), 39 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 1f6c7de..93990ac 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -914,7 +914,27 @@ Honour `yas-dont-activate', which see."
;;; Internal structs for template management
-(defstruct (yas--template (:constructor yas--make-template))
+(cl-defstruct (yas--template
+ (:constructor yas--make-template)
+ ;; Handles `yas-define-snippets' format, plus the
+ ;; initial TABLE argument.
+ (:constructor
+ yas--define-snippets-2
+ (table
+ key content
+ &optional xname condition group
+ expand-env file xkeybinding xuuid
+ &aux
+ (name (or xname
+ (and file (file-name-directory file))
+ key))
+ (keybinding (yas--read-keybinding xkeybinding))
+ (uuid (or xuuid name))
+ (old (gethash uuid (yas--table-uuidhash table)))
+ (menu-binding-pair
+ (and old (yas--template-menu-binding-pair old)))
+ (perm-group
+ (and old (yas--template-perm-group old))))))
"A template for a snippet."
key
content
@@ -1081,7 +1101,8 @@ keybinding)."
(defun yas--update-template (table template)
"Add or update TEMPLATE in TABLE.
-Also takes care of adding and updating to the associated menu."
+Also takes care of adding and updating to the associated menu.
+Return TEMPLATE."
;; Remove from table by uuid
;;
(yas--remove-template-by-uuid table (yas--template-uuid template))
@@ -1090,7 +1111,8 @@ Also takes care of adding and updating to the associated
menu."
(yas--add-template table template)
;; Take care of the menu
;;
- (yas--update-template-menu table template))
+ (yas--update-template-menu table template)
+ template)
(defun yas--update-template-menu (table template)
"Update every menu-related for TEMPLATE."
@@ -1600,42 +1622,10 @@ Optional PROMPT sets the prompt to use."
(defun yas--define-snippets-1 (snippet snippet-table)
"Helper for `yas-define-snippets'."
- ;; X) Calculate some more defaults on the values returned by
- ;; `yas--parse-template'.
- ;;
- (let* ((file (seventh snippet))
- (key (car snippet))
- (name (or (third snippet)
- (and file
- (file-name-directory file))))
- (condition (fourth snippet))
- (group (fifth snippet))
- (keybinding (yas--read-keybinding (eighth snippet)))
- (uuid (or (ninth snippet)
- name))
- (template (or (gethash uuid (yas--table-uuidhash snippet-table))
- (yas--make-template :uuid uuid
- :table snippet-table))))
- ;; X) populate the template object
- ;;
- (setf (yas--template-key template) key)
- (setf (yas--template-content template) (second snippet))
- (setf (yas--template-name template) (or name key))
- (setf (yas--template-group template) group)
- (setf (yas--template-condition template) condition)
- (setf (yas--template-expand-env template) (sixth snippet))
- (setf (yas--template-file template) (seventh snippet))
- (setf (yas--template-keybinding template) keybinding)
-
- ;; X) Update this template in the appropriate table. This step
- ;; also will take care of adding the key indicators in the
- ;; templates menu entry, if any
- ;;
- (yas--update-template snippet-table template)
- ;; X) Return the template
- ;;
- ;;
- template))
+ ;; Update the appropriate table. Also takes care of adding the
+ ;; key indicators in the templates menu entry, if any.
+ (yas--update-template
+ snippet-table (apply #'yas--define-snippets-2 snippet-table snippet)))
(defun yas-define-snippets (mode snippets)
"Define SNIPPETS for MODE.
- [elpa] master 5ebf347 11/60: Minor doc fixes, (continued)
- [elpa] master 5ebf347 11/60: Minor doc fixes, João Távora, 2016/01/21
- [elpa] master 197db9f 10/60: Merge pull request #578 from aluaces/patch-1, João Távora, 2016/01/21
- [elpa] master 7f4f6be 07/60: Merge pull request #571 from PhilHudson/master, João Távora, 2016/01/21
- [elpa] master c91a588 14/60: Simplify some code, João Távora, 2016/01/21
- [elpa] master 7bce1a6 12/60: Add new function yas-lookup-snippet, João Távora, 2016/01/21
- [elpa] master e8934ce 13/60: Merge pull request #596 from npostavs/lookup-snippet, João Távora, 2016/01/21
- [elpa] master 0ada0fc 15/60: Add documentation for snippet compilation, João Távora, 2016/01/21
- [elpa] master 4bd3d98 16/60: Merge pull request #599 from zmwangx/snippet-compilation-doc, João Távora, 2016/01/21
- [elpa] master 2f6cfef 17/60: Closes #601: updated snippets submodule, João Távora, 2016/01/21
- [elpa] master 68b0ab6 20/60: Accept documented snippet list formats, João Távora, 2016/01/21
- [elpa] master cc1c758 18/60: Reorganize snippet construction from list code,
João Távora <=
- [elpa] master 01139a2 23/60: * yasnippet.el (yas--define-snippets-2): Use file-name-NONdirectory., João Távora, 2016/01/21
- [elpa] master 8df6a6e 25/60: Fix invalid yas-key-syntaxes element warning, João Távora, 2016/01/21
- [elpa] master 7703a55 24/60: * doc/snippet-organization.org (.yas-skip): Add info., João Távora, 2016/01/21
- [elpa] master 041821a 22/60: * yasnippet-tests.el (string-suffix-p): Define for older Emacsen., João Távora, 2016/01/21
- [elpa] master fb6ec67 29/60: Fix #619; find parents for extra-modes too, João Távora, 2016/01/21
- [elpa] master 710ea4d 26/60: Update snippets module, João Távora, 2016/01/21
- [elpa] master 215ad9b 19/60: Fix #597; use SAVE-FILE to visit compiled snippets, João Távora, 2016/01/21
- [elpa] master e3f03ca 21/60: Test visiting compiled snippets, João Távora, 2016/01/21
- [elpa] master e56aa6f 28/60: Build a single `explored' list., João Távora, 2016/01/21
- [elpa] master b6d924c 31/60: * yasnippet.el (yas--scan-sexps): Use ignore-errors., João Távora, 2016/01/21