mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Remove support for filenames-as-triggers
This commit is contained in:
parent
f48317e7c5
commit
238e46a020
104
yasnippet.el
104
yasnippet.el
@ -396,14 +396,6 @@ An error string \"[yas] error\" is returned instead."
|
|||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'yasnippet)
|
:group 'yasnippet)
|
||||||
|
|
||||||
(defcustom yas/ignore-filenames-as-triggers nil
|
|
||||||
"If non-nil, don't derive tab triggers from filenames.
|
|
||||||
|
|
||||||
This means a snippet without a \"# key:'\ directive won't have a
|
|
||||||
tab trigger."
|
|
||||||
:type 'boolean
|
|
||||||
:group 'yasnippet)
|
|
||||||
|
|
||||||
(defcustom yas/visit-from-menu nil
|
(defcustom yas/visit-from-menu nil
|
||||||
"If non-nil visit snippets's files from menu, instead of expanding them.
|
"If non-nil visit snippets's files from menu, instead of expanding them.
|
||||||
|
|
||||||
@ -703,11 +695,6 @@ snippet itself contains a condition that returns the symbol
|
|||||||
(not yas/good-grace))
|
(not yas/good-grace))
|
||||||
:help "If non-nil don't raise errors in bad embedded eslip in snippets"
|
:help "If non-nil don't raise errors in bad embedded eslip in snippets"
|
||||||
:style toggle :selected yas/good-grace]
|
:style toggle :selected yas/good-grace]
|
||||||
["Ignore filenames as triggers"
|
|
||||||
(setq yas/ignore-filenames-as-triggers
|
|
||||||
(not yas/ignore-filenames-as-triggers))
|
|
||||||
:help "If non-nil don't derive tab triggers from filenames"
|
|
||||||
:style toggle :selected yas/ignore-filenames-as-triggers]
|
|
||||||
)
|
)
|
||||||
"----"
|
"----"
|
||||||
["Load snippets..." yas/load-directory
|
["Load snippets..." yas/load-directory
|
||||||
@ -1380,9 +1367,7 @@ Here's a list of currently recognized directives:
|
|||||||
(let* ((type 'snippet)
|
(let* ((type 'snippet)
|
||||||
(name (and file
|
(name (and file
|
||||||
(file-name-nondirectory file)))
|
(file-name-nondirectory file)))
|
||||||
(key (unless yas/ignore-filenames-as-triggers
|
(key nil)
|
||||||
(and name
|
|
||||||
(file-name-sans-extension name))))
|
|
||||||
template
|
template
|
||||||
bound
|
bound
|
||||||
condition
|
condition
|
||||||
@ -1640,10 +1625,6 @@ TEMPLATES is a list of `yas/template'."
|
|||||||
(yas/compute-major-mode-and-parents (concat directory
|
(yas/compute-major-mode-and-parents (concat directory
|
||||||
"/dummy"))))
|
"/dummy"))))
|
||||||
(default-directory directory)
|
(default-directory directory)
|
||||||
(yas/ignore-filenames-as-triggers
|
|
||||||
(or yas/ignore-filenames-as-triggers
|
|
||||||
(file-exists-p (concat directory "/"
|
|
||||||
".yas-ignore-filenames-as-triggers"))))
|
|
||||||
(snippet-defs nil))
|
(snippet-defs nil))
|
||||||
;; load the snippet files
|
;; load the snippet files
|
||||||
;;
|
;;
|
||||||
@ -1934,10 +1915,7 @@ not need to be a real mode."
|
|||||||
;; `yas/parse-template'.
|
;; `yas/parse-template'.
|
||||||
;;
|
;;
|
||||||
(let* ((file (seventh snippet))
|
(let* ((file (seventh snippet))
|
||||||
(key (or (car snippet)
|
(key (car snippet))
|
||||||
(unless yas/ignore-filenames-as-triggers
|
|
||||||
(and file
|
|
||||||
(file-name-sans-extension (file-name-nondirectory file))))))
|
|
||||||
(name (or (third snippet)
|
(name (or (third snippet)
|
||||||
(and file
|
(and file
|
||||||
(file-name-directory file))))
|
(file-name-directory file))))
|
||||||
@ -2483,50 +2461,44 @@ 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")
|
||||||
(let ((yas/ignore-filenames-as-triggers
|
(cond
|
||||||
(or yas/ignore-filenames-as-triggers
|
;; We have `yas/editing-template', this buffer's
|
||||||
(and buffer-file-name
|
;; content comes from a template which is already loaded and
|
||||||
(locate-dominating-file
|
;; neatly positioned,...
|
||||||
buffer-file-name
|
;;
|
||||||
".yas-ignore-filenames-as-triggers")))))
|
(yas/editing-template
|
||||||
(cond
|
(yas/define-snippets-1 (yas/parse-template (yas/template-file yas/editing-template))
|
||||||
;; We have `yas/editing-template', this buffer's
|
(yas/template-table yas/editing-template)))
|
||||||
;; content comes from a template which is already loaded and
|
;; Try to use `yas/guessed-modes'. If we don't have that use the
|
||||||
;; neatly positioned,...
|
;; value from `yas/compute-major-mode-and-parents'
|
||||||
;;
|
;;
|
||||||
(yas/editing-template
|
(t
|
||||||
(yas/define-snippets-1 (yas/parse-template (yas/template-file yas/editing-template))
|
(unless yas/guessed-modes
|
||||||
(yas/template-table yas/editing-template)))
|
(set (make-local-variable 'yas/guessed-modes) (or (yas/compute-major-mode-and-parents buffer-file-name))))
|
||||||
;; Try to use `yas/guessed-modes'. If we don't have that use the
|
(let* ((prompt (if (and (featurep 'ido)
|
||||||
;; value from `yas/compute-major-mode-and-parents'
|
ido-mode)
|
||||||
;;
|
'ido-completing-read 'completing-read))
|
||||||
(t
|
(table (yas/table-get-create
|
||||||
(unless yas/guessed-modes
|
(intern
|
||||||
(set (make-local-variable 'yas/guessed-modes) (or (yas/compute-major-mode-and-parents buffer-file-name))))
|
(funcall prompt (format "Choose or enter a table (yas guesses %s): "
|
||||||
(let* ((prompt (if (and (featurep 'ido)
|
(if yas/guessed-modes
|
||||||
ido-mode)
|
(first yas/guessed-modes)
|
||||||
'ido-completing-read 'completing-read))
|
"nothing"))
|
||||||
(table (yas/table-get-create
|
(mapcar #'symbol-name yas/guessed-modes)
|
||||||
(intern
|
nil
|
||||||
(funcall prompt (format "Choose or enter a table (yas guesses %s): "
|
nil
|
||||||
(if yas/guessed-modes
|
nil
|
||||||
(first yas/guessed-modes)
|
nil
|
||||||
"nothing"))
|
(if (first yas/guessed-modes)
|
||||||
(mapcar #'symbol-name yas/guessed-modes)
|
(symbol-name (first yas/guessed-modes))))))))
|
||||||
nil
|
(set (make-local-variable 'yas/editing-template)
|
||||||
nil
|
(yas/define-snippets-1 (yas/parse-template buffer-file-name)
|
||||||
nil
|
table)))))
|
||||||
nil
|
;; Now, offer to save this shit iff:
|
||||||
(if (first yas/guessed-modes)
|
|
||||||
(symbol-name (first yas/guessed-modes))))))))
|
|
||||||
(set (make-local-variable 'yas/editing-template)
|
|
||||||
(yas/define-snippets-1 (yas/parse-template buffer-file-name)
|
|
||||||
table))))))
|
|
||||||
;; Now, offer to save this shit
|
|
||||||
;;
|
;;
|
||||||
;; 1) if `yas/snippet-dirs' is a list and its first element does not
|
;; 1) `yas/snippet-dirs' is a list and its first element does not
|
||||||
;; match this template's file (i.e. this is a library snippet, not
|
;; match this template's file (i.e. this is a library snippet, not
|
||||||
;; a user snippet).
|
;; a user snippet) OR
|
||||||
;;
|
;;
|
||||||
;; 2) yas/editing-template comes from a file that we cannot write to...
|
;; 2) yas/editing-template comes from a file that we cannot write to...
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user