mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
* Adjustments to `yas/load-snippet-buffer'
This commit is contained in:
parent
affd244f04
commit
5b0786fa4d
24
yasnippet.el
24
yasnippet.el
@ -429,7 +429,7 @@ This cafn only work when snippets are loaded from files."
|
|||||||
map)
|
map)
|
||||||
"The keymap active while a snippet expansion is in progress.")
|
"The keymap active while a snippet expansion is in progress.")
|
||||||
|
|
||||||
(defvar yas/key-syntaxes (list "w" "w_" "w_." "w_.()" "^ ")
|
(defvar yas/key-syntaxes (list "w" "w_" "w_.()" "^ ")
|
||||||
"A list of syntax of a key. This list is tried in the order
|
"A list of syntax of a key. This list is tried in the order
|
||||||
to try to find a key. For example, if the list is '(\"w\" \"w_\").
|
to try to find a key. For example, if the list is '(\"w\" \"w_\").
|
||||||
And in emacs-lisp-mode, where \"-\" has the syntax of \"_\":
|
And in emacs-lisp-mode, where \"-\" has the syntax of \"_\":
|
||||||
@ -2162,10 +2162,12 @@ tables (or optional TABLE).
|
|||||||
Returns a a list of options alist TABLE -> DIRS where DIRS are
|
Returns a a list of options alist TABLE -> DIRS where DIRS are
|
||||||
all the possibly directories where snippets of table might be
|
all the possibly directories where snippets of table might be
|
||||||
lurking."
|
lurking."
|
||||||
(let ((main-dir (or (and (listp yas/snippet-dirs)
|
(let ((main-dir (replace-regexp-in-string
|
||||||
|
"/+$" ""
|
||||||
|
(or (and (listp yas/snippet-dirs)
|
||||||
(first yas/snippet-dirs))
|
(first yas/snippet-dirs))
|
||||||
yas/snippet-dirs
|
yas/snippet-dirs
|
||||||
(setq yas/snippet-dirs "~/.emacs.d/snippets")))
|
(setq yas/snippet-dirs "~/.emacs.d/snippets"))))
|
||||||
(tables (or (and table
|
(tables (or (and table
|
||||||
(list table))
|
(list table))
|
||||||
(yas/get-snippet-tables))))
|
(yas/get-snippet-tables))))
|
||||||
@ -2190,6 +2192,8 @@ lurking."
|
|||||||
"Returns a dir inside TABLE-AND-DIRS, prompts for creation if none exists."
|
"Returns a dir inside TABLE-AND-DIRS, prompts for creation if none exists."
|
||||||
(or (some #'(lambda (dir) (when (file-directory-p dir) dir)) (cdr table-and-dirs))
|
(or (some #'(lambda (dir) (when (file-directory-p dir) dir)) (cdr table-and-dirs))
|
||||||
(let ((candidate (first (cdr table-and-dirs))))
|
(let ((candidate (first (cdr table-and-dirs))))
|
||||||
|
(unless (file-writable-p (file-name-directory candidate))
|
||||||
|
(error "[yas] %s is not writable."))
|
||||||
(if (y-or-n-p (format "Guessed directory (%s) for%s%s table \"%s\" does not exist! Create? "
|
(if (y-or-n-p (format "Guessed directory (%s) for%s%s table \"%s\" does not exist! Create? "
|
||||||
candidate
|
candidate
|
||||||
(if (gethash (intern (yas/snippet-table-name (car table-and-dirs)))
|
(if (gethash (intern (yas/snippet-table-name (car table-and-dirs)))
|
||||||
@ -2348,12 +2352,13 @@ With optional prefix argument KILL quit the window and buffer."
|
|||||||
(chosen (and option
|
(chosen (and option
|
||||||
(yas/make-directory-maybe option))))
|
(yas/make-directory-maybe option))))
|
||||||
(when chosen
|
(when chosen
|
||||||
(condition-case quit
|
(let ((default-file-name (or (and (yas/template-file yas/current-template)
|
||||||
(let ((default-directory (concat chosen "/" (yas/template-name yas/current-template)))
|
(file-name-nondirectory (yas/template-file yas/current-template)))
|
||||||
(ido-mode nil))
|
(yas/template-name yas/current-template))))
|
||||||
(call-interactively 'write-file)
|
(write-file (concat chosen "/"
|
||||||
(setf (yas/template-file yas/current-template) buffer-file-name))
|
(read-from-minibuffer (format "File name to create in %s? " chosen)
|
||||||
(quit nil))))))
|
default-file-name)))
|
||||||
|
(setf (yas/template-file yas/current-template) buffer-file-name))))))
|
||||||
(when kill
|
(when kill
|
||||||
(quit-window kill))
|
(quit-window kill))
|
||||||
(message "[yas] Snippet \"%s\" loaded for %s."
|
(message "[yas] Snippet \"%s\" loaded for %s."
|
||||||
@ -2502,6 +2507,7 @@ With optional prefix argument KILL quit the window and buffer."
|
|||||||
(insert (format "bound to %s " (key-description (yas/template-keybinding p)))))
|
(insert (format "bound to %s " (key-description (yas/template-keybinding p)))))
|
||||||
(insert "\n")))))
|
(insert "\n")))))
|
||||||
(yas/create-snippet-xrefs)
|
(yas/create-snippet-xrefs)
|
||||||
|
(beginning-of-buffer)
|
||||||
(help-mode))
|
(help-mode))
|
||||||
(t
|
(t
|
||||||
(insert "\n\nYASnippet tables by NAMEHASH: \n")
|
(insert "\n\nYASnippet tables by NAMEHASH: \n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user