[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d19ef74 172/177: Getting rid of low-level assumptions in y
From: |
João Távora |
Subject: |
[elpa] master d19ef74 172/177: Getting rid of low-level assumptions in yasnippet |
Date: |
Sat, 28 Mar 2015 15:41:44 +0000 |
branch: master
commit d19ef74634ca7050c331971a7f9ee29211e08826
Author: Stefan Monnier <address@hidden>
Commit: João Távora <address@hidden>
Getting rid of low-level assumptions in yasnippet
The main thrust is to get rid of the use of the `cl-struct-slots'
property which doesn't exist in Emacs-25 any more.
* yasnippet.el: Update copyright
(yas--template): Change constructor name from
`yas--make-blank-template' to `yas--make-template'
(yas--populate-template): Remove.
(yas--define-snippets-1): Use `yas--make-template'
(yas--define-snippets-1): Use `setf's
(yas-define-menu, yas--define-menu-1, yas-tryout-snippet): Use
`yas--make-template'
---
yasnippet.el | 69 +++++++++++++++++++++++----------------------------------
1 files changed, 28 insertions(+), 41 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 0d9506b..8c9212c 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -1,6 +1,6 @@
;;; yasnippet.el --- Yet another snippet extension for Emacs.
-;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2013, 2015 Free Software Foundation, Inc.
;; Authors: pluskid <address@hidden>, João Távora <address@hidden>
;; Maintainer: João Távora <address@hidden>
;; Version: 0.8.1
@@ -912,7 +912,7 @@ Honour `yas-dont-activate', which see."
;;; Internal structs for template management
-(defstruct (yas--template (:constructor yas--make-blank-template))
+(defstruct (yas--template (:constructor yas--make-template))
"A template for a snippet."
key
content
@@ -928,16 +928,6 @@ Honour `yas-dont-activate', which see."
table
)
-(defun yas--populate-template (template &rest args)
- "Helper function to populate TEMPLATE with properties."
- (while args
- (aset template
- (position (intern (substring (symbol-name (car args)) 1))
- (mapcar #'car (get 'yas--template 'cl-struct-slots)))
- (second args))
- (setq args (cddr args)))
- template)
-
(defstruct (yas--table (:constructor yas--make-snippet-table (name)))
"A table to store snippets for a particular mode.
@@ -1620,20 +1610,19 @@ Optional PROMPT sets the prompt to use."
(uuid (or (ninth snippet)
name))
(template (or (gethash uuid (yas--table-uuidhash snippet-table))
- (yas--make-blank-template))))
+ (yas--make-template :uuid uuid
+ :table snippet-table))))
;; X) populate the template object
;;
- (yas--populate-template template
- :table snippet-table
- :key key
- :content (second snippet)
- :name (or name key)
- :group group
- :condition condition
- :expand-env (sixth snippet)
- :file (seventh snippet)
- :keybinding keybinding
- :uuid uuid)
+ (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
@@ -2071,11 +2060,10 @@ omitted from MODE's menu, even if they're manually
loaded."
hash)
(dolist (uuid omit-items)
(let ((template (or (gethash uuid hash)
- (yas--populate-template (puthash uuid
-
(yas--make-blank-template)
- hash)
- :table table
- :uuid uuid))))
+ (puthash uuid
+ (yas--make-template :table table
+ :uuid uuid)
+ hash))))
(setf (yas--template-menu-binding-pair template) (cons nil :none))))))
(defun yas--define-menu-1 (table menu-keymap menu uuidhash &optional
group-list)
@@ -2083,12 +2071,12 @@ omitted from MODE's menu, even if they're manually
loaded."
(dolist (e (reverse menu))
(cond ((eq (first e) 'yas-item)
(let ((template (or (gethash (second e) uuidhash)
- (yas--populate-template (puthash (second e)
-
(yas--make-blank-template)
- uuidhash)
- :table table
- :perm-group group-list
- :uuid (second e)))))
+ (puthash (second e)
+ (yas--make-template
+ :table table
+ :perm-group group-list
+ :uuid (second e))
+ uuidhash))))
(define-key menu-keymap (vector (gensym))
(car (yas--template-menu-binding-pair-get-create template
:stay)))))
((eq (first e) 'yas-submenu)
@@ -2607,12 +2595,11 @@ and `kill-buffer' instead."
(yas--current-template
(and parsed
(fboundp test-mode)
- (yas--populate-template (yas--make-blank-template)
- :table nil ;; no tables for
ephemeral snippets
- :key (first parsed)
- :content (second parsed)
- :name (third parsed)
- :expand-env (sixth parsed)))))
+ (yas--make-template :table nil ;; no tables for ephemeral
snippets
+ :key (first parsed)
+ :content (second parsed)
+ :name (third parsed)
+ :expand-env (sixth parsed)))))
(cond (yas--current-template
(let ((buffer-name (format "*testing snippet: %s*"
(yas--template-name yas--current-template))))
(kill-buffer (get-buffer-create buffer-name))
- [elpa] master 07734a1 165/177: Clarify what happens with yas-new-snippet., (continued)
- [elpa] master 07734a1 165/177: Clarify what happens with yas-new-snippet., João Távora, 2015/03/28
- [elpa] master 3c13348 167/177: yas-expand-snippet: Clarify EXPAND-ENV, João Távora, 2015/03/28
- [elpa] master 21ffe4b 168/177: Merge pull request #559 from mineo/patch-1, João Távora, 2015/03/28
- [elpa] master 197ef7f 166/177: Merge pull request #552 from treese/master, João Távora, 2015/03/28
- [elpa] master 3e7b56e 169/177: Implements #566: Remove dead major modes code, João Távora, 2015/03/28
- [elpa] master b9989f8 170/177: Add a CONTRIBUTING.md file, João Távora, 2015/03/28
- [elpa] master 316435e 173/177: Closes #562: Deleting inner numberless snippet causes error, João Távora, 2015/03/28
- [elpa] master fc5052b 171/177: Merge pull request #568 from npostavs/contrib, João Távora, 2015/03/28
- [elpa] master 885237a 174/177: Add useful development assertion, João Távora, 2015/03/28
- [elpa] master a467019 175/177: `yas-minor-mode' assertion broke a test. Good. Fix it., João Távora, 2015/03/28
- [elpa] master d19ef74 172/177: Getting rid of low-level assumptions in yasnippet,
João Távora <=
- [elpa] master 73701d9 176/177: Update packages/darkroom by merging its external subtree, João Távora, 2015/03/28
- [elpa] master 4f27187 062/177: refactor: removed extras and snippets tree, both point to submodules, João Távora, 2015/03/28
- [elpa] master 1cf9168 068/177: Merge branch 'unclutter': snippets and textmate importation snippets are now submodules, João Távora, 2015/03/28
- [elpa] master 39a27b6 177/177: Update packages/yasnippet by merging from its external upstream subtree, João Távora, 2015/03/28