summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/yasnippet.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp/yasnippet.el')
-rw-r--r--.emacs.d/lisp/yasnippet.el42
1 files changed, 22 insertions, 20 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 782c440..602e74e 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -1,6 +1,6 @@
1;;; yasnippet.el --- Yet another snippet extension for Emacs -*- lexical-binding: t; -*- 1;;; yasnippet.el --- Yet another snippet extension for Emacs -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2008-2024 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2025 Free Software Foundation, Inc.
4;; Authors: pluskid <pluskid@gmail.com>, 4;; Authors: pluskid <pluskid@gmail.com>,
5;; João Távora <joaotavora@gmail.com>, 5;; João Távora <joaotavora@gmail.com>,
6;; Noam Postavsky <npostavs@gmail.com> 6;; Noam Postavsky <npostavs@gmail.com>
@@ -1000,7 +1000,7 @@ Honour `yas-dont-activate-functions', which see."
1000;;; Major mode stuff 1000;;; Major mode stuff
1001 1001
1002(defvar yas--font-lock-keywords 1002(defvar yas--font-lock-keywords
1003 (append '(("^#.*$" . font-lock-comment-face)) 1003 (append '(("^#.*$" (0 'font-lock-comment-face)))
1004 (with-temp-buffer 1004 (with-temp-buffer
1005 (let ((prog-mode-hook nil) 1005 (let ((prog-mode-hook nil)
1006 (emacs-lisp-mode-hook nil)) 1006 (emacs-lisp-mode-hook nil))
@@ -1011,14 +1011,14 @@ Honour `yas-dont-activate-functions', which see."
1011 (cadr font-lock-keywords) 1011 (cadr font-lock-keywords)
1012 font-lock-keywords)) 1012 font-lock-keywords))
1013 '(("\\$\\([0-9]+\\)" 1013 '(("\\$\\([0-9]+\\)"
1014 (0 font-lock-keyword-face) 1014 (0 'font-lock-keyword-face)
1015 (1 font-lock-string-face t)) 1015 (1 'font-lock-string-face t))
1016 ("\\${\\([0-9]+\\):?" 1016 ("\\${\\([0-9]+\\):?"
1017 (0 font-lock-keyword-face) 1017 (0 'font-lock-keyword-face)
1018 (1 font-lock-warning-face t)) 1018 (1 'font-lock-warning-face t))
1019 ("\\(\\$(\\)" 1 font-lock-preprocessor-face) 1019 ("\\(\\$(\\)" 1 'font-lock-preprocessor-face)
1020 ("}" 1020 ("}"
1021 (0 font-lock-keyword-face))))) 1021 (0 'font-lock-keyword-face)))))
1022 1022
1023(defvar snippet-mode-map 1023(defvar snippet-mode-map
1024 (let ((map (make-sparse-keymap))) 1024 (let ((map (make-sparse-keymap)))
@@ -2784,18 +2784,20 @@ Return the `yas--template' object created"
2784 2784
2785(defun yas-maybe-load-snippet-buffer () 2785(defun yas-maybe-load-snippet-buffer ()
2786 "Added to `after-save-hook' in `snippet-mode'." 2786 "Added to `after-save-hook' in `snippet-mode'."
2787 (let* ((mode (intern (file-name-sans-extension 2787 (save-excursion ;; Issue #1146. Here or in `yas--parse-template`?
2788 (file-name-nondirectory 2788 (let* ((mode (intern (file-name-sans-extension
2789 (directory-file-name default-directory))))) 2789 (file-name-nondirectory
2790 (current-snippet 2790 (directory-file-name default-directory)))))
2791 (apply #'yas--define-snippets-2 (yas--table-get-create mode) 2791 (current-snippet
2792 (yas--parse-template buffer-file-name))) 2792 (apply #'yas--define-snippets-2 (yas--table-get-create mode)
2793 (uuid (yas--template-uuid current-snippet))) 2793 ;; FIXME: `yas-load-snippet-buffer' will *re*parse!
2794 (unless (equal current-snippet 2794 (yas--parse-template buffer-file-name)))
2795 (if uuid (yas--get-template-by-uuid mode uuid) 2795 (uuid (yas--template-uuid current-snippet)))
2796 (yas--lookup-snippet-1 2796 (unless (equal current-snippet
2797 (yas--template-name current-snippet) mode))) 2797 (if uuid (yas--get-template-by-uuid mode uuid)
2798 (yas-load-snippet-buffer mode t)))) 2798 (yas--lookup-snippet-1
2799 (yas--template-name current-snippet) mode)))
2800 (yas-load-snippet-buffer mode t)))))
2799 2801
2800(defun yas-load-snippet-buffer-and-close (table &optional kill) 2802(defun yas-load-snippet-buffer-and-close (table &optional kill)
2801 "Load and save the snippet, then `quit-window' if saved. 2803 "Load and save the snippet, then `quit-window' if saved.