Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple means by which users can customize how filenames are suggested #1162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion yasnippet.el
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ the trigger key itself."
It must be set to nil before loading yasnippet to take effect."
:type 'boolean)

(defcustom yas-default-filename-transform-function #'default
"Transform the snippet name to a filename."
:type 'function)

;; Only two faces, and one of them shouldn't even be used...
;;
(defface yas-field-highlight-face
Expand Down Expand Up @@ -2807,7 +2811,7 @@ and `kill-buffer' instead."
(yas--table-name (yas--template-table template)))))
(let ((default-directory (car (cdr (car (yas--guess-snippet-directories
(yas--template-table template))))))
(default-file-name (yas--template-name template)))
(default-file-name (funcall yas-default-filename-transform-function (yas--template-name template))))
(unless (or buffer-file-name (not default-file-name))
(setq buffer-file-name
(read-file-name "File to save snippet in: "
Expand Down