* Fixed some little bugs. Bundle compilation works with `yas/define-menu'

This commit is contained in:
capitaomorte 2010-03-21 00:44:19 +00:00
parent b66c38ce52
commit f55c2dfc46

View File

@ -1283,7 +1283,7 @@ otherwise we attempt to calculate it from FILE.
Return a snippet-definition, i.e. a list Return a snippet-definition, i.e. a list
(KEY TEMPLATE NAME CONDITION GROUP VARS FILE KEYBINDING) (KEY TEMPLATE NAME CONDITION GROUP VARS FILE KEYBINDING UID)
If the buffer contains a line of \"# --\" then the contents If the buffer contains a line of \"# --\" then the contents
above this line are ignored. Variables can be set above this above this line are ignored. Variables can be set above this
@ -1293,7 +1293,6 @@ line through the syntax:
Here's a list of currently recognized variables: Here's a list of currently recognized variables:
* uid
* type * type
* name * name
* contributor * contributor
@ -1301,6 +1300,7 @@ Here's a list of currently recognized variables:
* key * key
* expand-env * expand-env
* binding * binding
* uid
#name: #include \"...\" #name: #include \"...\"
# -- # --
@ -1353,7 +1353,7 @@ Here's a list of currently recognized variables:
(buffer-substring-no-properties (point-min) (point-max)))) (buffer-substring-no-properties (point-min) (point-max))))
(when (eq type 'command) (when (eq type 'command)
(setq template (yas/read-lisp (concat "(progn" template ")")))) (setq template (yas/read-lisp (concat "(progn" template ")"))))
(list key template name condition group expand-env file binding))) (list key template name condition group expand-env file binding uid)))
(defun yas/calculate-group (file) (defun yas/calculate-group (file)
"Calculate the group for snippet file path FILE." "Calculate the group for snippet file path FILE."
@ -1715,12 +1715,12 @@ Here's the default value for all the parameters:
(insert "\n\n")))) (insert "\n\n"))))
(dolist (dir dirs) (dolist (dir dirs)
(dolist (subdir (yas/subdirs dir)) (dolist (subdir (yas/subdirs dir))
(yas/load-directory-1 subdir nil)
(let ((file (concat subdir "/.yas-setup.el"))) (let ((file (concat subdir "/.yas-setup.el")))
(when (file-readable-p file) (when (file-readable-p file)
(insert ";; Supporting elisp for subdir " (file-name-nondirectory subdir) "\n\n") (insert ";; Supporting elisp for subdir " (file-name-nondirectory subdir) "\n\n")
(goto-char (+ (point) (goto-char (+ (point)
(second (insert-file-contents file))))))))) (second (insert-file-contents file))))))
(yas/load-directory-1 subdir nil))))
(insert (pp-to-string `(yas/global-mode 1))) (insert (pp-to-string `(yas/global-mode 1)))
(insert ")\n\n" code "\n") (insert ")\n\n" code "\n")
@ -1899,7 +1899,7 @@ not need to be a real mode."
(cons `(menu-item ,(or (yas/template-name template) (cons `(menu-item ,(or (yas/template-name template)
(yas/template-uid template)) (yas/template-uid template))
,(yas/make-menu-binding template) ,(yas/make-menu-binding template)
:keys nil) :keys ,nil)
type))))) type)))))
(defun yas/show-menu-p (mode) (defun yas/show-menu-p (mode)
@ -1956,7 +1956,7 @@ Skip any submenus named \"parent mode\""
(yas/table-uidhash table)))) (yas/table-uidhash table))))
(defun yas/define-menu-1 (table keymap menu uidhash) (defun yas/define-menu-1 (table keymap menu uidhash)
(dolist (e menu) (dolist (e (reverse menu))
(cond ((eq (first e) 'yas/item) (cond ((eq (first e) 'yas/item)
(let ((template (or (gethash (second e) uidhash) (let ((template (or (gethash (second e) uidhash)
(yas/populate-template (puthash (second e) (yas/populate-template (puthash (second e)
@ -2381,7 +2381,7 @@ there, otherwise, proposes to create the first option returned by
With optional prefix argument KILL quit the window and buffer." With optional prefix argument KILL quit the window and buffer."
(interactive "P") (interactive "P")
(cond (cond
;; X) Option 2: We have `yas/current-template', this buffer's ;; X) Option 1: We have `yas/current-template', this buffer's
;; content comes from a template which is already loaded and ;; content comes from a template which is already loaded and
;; neatly positioned,... ;; neatly positioned,...
;; ;;
@ -2434,9 +2434,9 @@ With optional prefix argument KILL quit the window and buffer."
(message "[yas] Snippet \"%s\" loaded for %s." (message "[yas] Snippet \"%s\" loaded for %s."
(yas/template-name yas/current-template) (yas/template-name yas/current-template)
(yas/table-name (yas/template-table yas/current-template)))) (yas/table-name (yas/template-table yas/current-template))))
( ;; X) Option 1: We have a file name, consider this as being (;; X) Option 2: We have a file name, consider this a brand new
;; a brand new snippet and calculate name, groups, etc from ;; snippet and calculate name, groups, etc from the current
;; the current file-name and buffer content ;; file-name and buffer content
;; ;;
buffer-file-name buffer-file-name
(let ((major-mode-and-parent (yas/compute-major-mode-and-parents buffer-file-name))) (let ((major-mode-and-parent (yas/compute-major-mode-and-parents buffer-file-name)))
@ -2447,10 +2447,9 @@ With optional prefix argument KILL quit the window and buffer."
(name (and parsed (name (and parsed
(third parsed)))) (third parsed))))
(when name (when name
(let ((yas/better-guess-for-replacements t)) (yas/define-snippets (car major-mode-and-parent)
(yas/define-snippets (car major-mode-and-parent) (list parsed)
(list parsed) (cdr major-mode-and-parent)))
(cdr major-mode-and-parent))))
(when (and (buffer-modified-p) (when (and (buffer-modified-p)
(y-or-n-p "Also save snippet buffer? ")) (y-or-n-p "Also save snippet buffer? "))
(save-buffer)) (save-buffer))