Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'rolandwalker/byte-compiler-3'

Fix: reorder defuns to quieten byte-compiler

Conflicts:
	yasnippet.el
  • Loading branch information...
commit d5865b1092fd24099f4afedf0e5016fe9da86b5f 2 parents 5520088 + b7fe4c1
@capitaomorte authored
Showing with 87 additions and 81 deletions.
  1. +87 −81 yasnippet.el
View
168 yasnippet.el
@@ -1613,11 +1613,98 @@ Optional PROMPT sets the prompt to use."
(first choices))
+;;; Defining snippets
+;; This consists of creating and registering `yas--template' objects in the
+;; correct tables.
+;;
+
+(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-blank-template))))
+ ;; 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)
+ ;; 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))
+
+(defun yas-define-snippets (mode snippets)
+ "Define SNIPPETS for MODE.
+
+SNIPPETS is a list of snippet definitions, each taking the
+following form
+
+ (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING UUID)
+
+Within these, only KEY and TEMPLATE are actually mandatory.
+
+TEMPLATE might be a lisp form or a string, depending on whether
+this is a snippet or a snippet-command.
+
+CONDITION, EXPAND-ENV and KEYBINDING are lisp forms, they have
+been `yas--read-lisp'-ed and will eventually be
+`yas--eval-lisp'-ed.
+
+The remaining elements are strings.
+
+FILE is probably of very little use if you're programatically
+defining snippets.
+
+UUID is the snippets \"unique-id\". Loading a second snippet file
+with the same uuid replaced the previous snippet.
+
+You can use `yas--parse-template' to return such lists based on
+the current buffers contents."
+ (let ((snippet-table (yas--table-get-create mode))
+ (template nil))
+ (dolist (snippet snippets)
+ (setq template (yas-define-snippets-1 snippet
+ snippet-table)))
+ template))
+
+
;;; Loading snippets from files
(defun yas--load-yas-setup-file (file)
(load file 'noerror))
+(defun yas--define-parents (mode parents)
+ "Add PARENTS to the list of MODE's parents."
+ (puthash mode (remove-duplicates
+ (append parents
+ (gethash mode yas--parents)))
+ yas--parents))
+
(defun yas-load-directory (top-level-dir &optional use-jit)
"Load snippets in directory hierarchy TOP-LEVEL-DIR.
@@ -1867,87 +1954,6 @@ This works by stubbing a few functions, then calling
yas--version
") -- pluskid <pluskid@gmail.com>/joaotavora <joaotavora@gmail.com>")))
-(defun yas--define-parents (mode parents)
- "Add PARENTS to the list of MODE's parents."
- (puthash mode (remove-duplicates
- (append parents
- (gethash mode yas--parents)))
- yas--parents))
-
-(defun yas-define-snippets (mode snippets)
- "Define SNIPPETS for MODE.
-
-SNIPPETS is a list of snippet definitions, each taking the
-following form
-
- (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING UUID)
-
-Within these, only KEY and TEMPLATE are actually mandatory.
-
-TEMPLATE might be a lisp form or a string, depending on whether
-this is a snippet or a snippet-command.
-
-CONDITION, EXPAND-ENV and KEYBINDING are lisp forms, they have
-been `yas--read-lisp'-ed and will eventually be
-`yas--eval-lisp'-ed.
-
-The remaining elements are strings.
-
-FILE is probably of very little use if you're programatically
-defining snippets.
-
-UUID is the snippets \"unique-id\". Loading a second snippet file
-with the same uuid replaced the previous snippet.
-
-You can use `yas--parse-template' to return such lists based on
-the current buffers contents."
- (let ((snippet-table (yas--table-get-create mode))
- (template nil))
- (dolist (snippet snippets)
- (setq template (yas-define-snippets-1 snippet
- snippet-table)))
- template))
-
-(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-blank-template))))
- ;; 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)
- ;; 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))
-
;;; Apropos snippet menu:
;;
Please sign in to comment.
Something went wrong with that request. Please try again.