summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/yasnippet.el
diff options
context:
space:
mode:
authorSimeon Simeonov2025-05-11 22:43:09 +0200
committerSimeon Simeonov2025-05-11 22:43:09 +0200
commite5b13f21317f6209b515caa8b9c9f22a98000333 (patch)
treecc200f574f9a068136b188559a6a93625515691f /.emacs.d/lisp/yasnippet.el
parenta429db57b6fc60d6bd026bd530cdb80554101622 (diff)
Upgrade markdown-mode and yasnippet
Diffstat (limited to '.emacs.d/lisp/yasnippet.el')
-rw-r--r--.emacs.d/lisp/yasnippet.el73
1 files changed, 31 insertions, 42 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 602e74e..806f2bc 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -5,7 +5,7 @@
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>
7;; Maintainer: Noam Postavsky <npostavs@gmail.com> 7;; Maintainer: Noam Postavsky <npostavs@gmail.com>
8;; Version: 0.14.1 8;; Version: 0.14.2
9;; X-URL: http://github.com/joaotavora/yasnippet 9;; X-URL: http://github.com/joaotavora/yasnippet
10;; Keywords: convenience, emulation 10;; Keywords: convenience, emulation
11;; URL: http://github.com/joaotavora/yasnippet 11;; URL: http://github.com/joaotavora/yasnippet
@@ -588,8 +588,6 @@ can be useful."
588 588
589;;; Internal variables 589;;; Internal variables
590 590
591(defconst yas--version "0.14.0")
592
593(defvar yas--menu-table (make-hash-table) 591(defvar yas--menu-table (make-hash-table)
594 "A hash table of MAJOR-MODE symbols to menu keymaps.") 592 "A hash table of MAJOR-MODE symbols to menu keymaps.")
595 593
@@ -891,18 +889,10 @@ which decides on the snippet to expand.")
891 889
892;;;###autoload 890;;;###autoload
893(define-minor-mode yas-minor-mode 891(define-minor-mode yas-minor-mode
894 "Toggle YASnippet mode. 892 "YASnippet minor mode.
895 893
896When YASnippet mode is enabled, `yas-expand', normally bound to 894When YASnippet mode is enabled, `yas-expand', normally bound to
897the TAB key, expands snippets of code depending on the major 895the TAB key, expands snippets of code depending on the major mode."
898mode.
899
900With no argument, this command toggles the mode.
901positive prefix argument turns on the mode.
902Negative prefix argument turns off the mode.
903
904Key bindings:
905\\{yas-minor-mode-map}"
906 :lighter " yas" ;; The indicator for the mode line. 896 :lighter " yas" ;; The indicator for the mode line.
907 (cond ((and yas-minor-mode (featurep 'yasnippet)) 897 (cond ((and yas-minor-mode (featurep 'yasnippet))
908 ;; Install the direct keymaps in `emulation-mode-map-alists' 898 ;; Install the direct keymaps in `emulation-mode-map-alists'
@@ -1463,7 +1453,7 @@ Returns (TEMPLATES START END). This function respects
1463(defun yas--remove-misc-free-from-undo (old-undo-list) 1453(defun yas--remove-misc-free-from-undo (old-undo-list)
1464 "Tries to work around Emacs Bug#30931. 1454 "Tries to work around Emacs Bug#30931.
1465Helper function for `yas--save-restriction-and-widen'." 1455Helper function for `yas--save-restriction-and-widen'."
1466 ;; If Bug#30931 is unfixed, we get (#<Lisp_Misc_Free> . INTEGER) 1456 ;; If Bug#30931 is unfixed (Emacs<26.2), we get (#<Lisp_Misc_Free> . INTEGER)
1467 ;; entries in the undo list. If we call `type-of' on the 1457 ;; entries in the undo list. If we call `type-of' on the
1468 ;; Lisp_Misc_Free object then Emacs aborts, so try to find it by 1458 ;; Lisp_Misc_Free object then Emacs aborts, so try to find it by
1469 ;; checking that its type is none of the expected ones. 1459 ;; checking that its type is none of the expected ones.
@@ -1487,15 +1477,16 @@ Helper function for `yas--save-restriction-and-widen'."
1487 1477
1488(defmacro yas--save-restriction-and-widen (&rest body) 1478(defmacro yas--save-restriction-and-widen (&rest body)
1489 "Equivalent to (save-restriction (widen) BODY). 1479 "Equivalent to (save-restriction (widen) BODY).
1490Also tries to work around Emacs Bug#30931." 1480Also tries to work around Emacs Bug#30931, fixed in Emacs-26.2."
1491 (declare (debug (body)) (indent 0)) 1481 (declare (debug (body)) (indent 0))
1492 ;; Disable garbage collection, since it could cause an abort. 1482 (let ((main `(save-restriction (widen) ,@body)))
1493 `(let ((gc-cons-threshold most-positive-fixnum) 1483 (if (< emacs-major-version 27)
1494 (old-undo-list buffer-undo-list)) 1484 ;; Disable garbage collection, since it could cause an abort.
1495 (prog1 (save-restriction 1485 `(let ((gc-cons-threshold most-positive-fixnum)
1496 (widen) 1486 (old-undo-list buffer-undo-list))
1497 ,@body) 1487 (prog1 ,main
1498 (yas--remove-misc-free-from-undo old-undo-list)))) 1488 (yas--remove-misc-free-from-undo old-undo-list)))
1489 main)))
1499 1490
1500(defun yas--eval-for-string (form) 1491(defun yas--eval-for-string (form)
1501 "Evaluate FORM and convert the result to string." 1492 "Evaluate FORM and convert the result to string."
@@ -1679,8 +1670,9 @@ Here's a list of currently recognized directives:
1679 (directory-files directory t))) 1670 (directory-files directory t)))
1680 1671
1681(defun yas--make-menu-binding (template) 1672(defun yas--make-menu-binding (template)
1682 (let ((mode (yas--table-mode (yas--template-table template)))) 1673 (let ((mode (yas--table-mode (yas--template-table template)))
1683 `(lambda () (interactive) (yas--expand-or-visit-from-menu ',mode ,(yas--template-uuid template))))) 1674 (uuid (yas--template-uuid template)))
1675 (lambda () (interactive) (yas--expand-or-visit-from-menu mode uuid))))
1684 1676
1685(defun yas--expand-or-visit-from-menu (mode uuid) 1677(defun yas--expand-or-visit-from-menu (mode uuid)
1686 (let* ((table (yas--table-get-create mode)) 1678 (let* ((table (yas--table-get-create mode))
@@ -2127,27 +2119,23 @@ This works by stubbing a few functions, then calling
2127(defun yas-about () 2119(defun yas-about ()
2128 (interactive) 2120 (interactive)
2129 (message "yasnippet (version %s) -- pluskid/joaotavora/npostavs" 2121 (message "yasnippet (version %s) -- pluskid/joaotavora/npostavs"
2130 (or (ignore-errors (car (let ((default-directory yas--loaddir)) 2122 (or (eval-when-compile
2131 (process-lines "git" "describe"
2132 "--tags" "--dirty"))))
2133 (eval-when-compile
2134 (and (fboundp 'package-get-version) 2123 (and (fboundp 'package-get-version)
2135 (package-get-version))) 2124 (package-get-version)))
2136 (when (and (featurep 'package) 2125 (when (and (boundp 'package-alist)
2137 (fboundp 'package-desc-version) 2126 (fboundp 'package-desc-version)
2138 (fboundp 'package-version-join)) 2127 (fboundp 'package-version-join))
2139 (defvar package-alist)
2140 (ignore-errors 2128 (ignore-errors
2141 (let* ((yas-pkg (cdr (assq 'yasnippet package-alist))) 2129 (let* ((yas-pkg (cdr (assq 'yasnippet package-alist))))
2142 (version (package-version-join 2130 (when yas-pkg
2143 (package-desc-version (car yas-pkg))))) 2131 (package-version-join
2144 ;; Special case for MELPA's bogus version numbers. 2132 (package-desc-version (car yas-pkg)))))))
2145 (if (string-match "\\`20..[01][0-9][0-3][0-9][.][0-9]\\{3,4\\}\\'" 2133 ;; The Git description can be misleading, for lack of
2146 version) 2134 ;; recent tags, so we prefer package version info.
2147 (concat yas--version "-snapshot" version) 2135 (ignore-errors (car (let ((default-directory yas--loaddir))
2148 version)))) 2136 (process-lines "git" "describe"
2149 yas--version))) 2137 "--tags" "--dirty"))))
2150 2138 "unknown")))
2151 2139
2152;;; Apropos snippet menu: 2140;;; Apropos snippet menu:
2153;; 2141;;
@@ -4133,7 +4121,7 @@ Returns the newly created snippet."
4133 (unwind-protect 4121 (unwind-protect
4134 (let ((buffer-undo-list t)) 4122 (let ((buffer-undo-list t))
4135 (goto-char begin) 4123 (goto-char begin)
4136 (if (> emacs-major-version 29) 4124 (if (< emacs-major-version 27)
4137 ;; Don't use the workaround for CC-mode's cache, 4125 ;; Don't use the workaround for CC-mode's cache,
4138 ;; since it was presumably a bug in CC-mode, so either 4126 ;; since it was presumably a bug in CC-mode, so either
4139 ;; it's fixed already, or it should get fixed. 4127 ;; it's fixed already, or it should get fixed.
@@ -4161,6 +4149,7 @@ Returns the newly created snippet."
4161 (run-hook-with-args 'after-change-functions 4149 (run-hook-with-args 'after-change-functions
4162 (point-min) (point-max) 4150 (point-min) (point-max)
4163 (- end begin)))) 4151 (- end begin))))
4152 ;; FIXME: Use `undo-amalgamate-change-group'?
4164 (when (listp buffer-undo-list) 4153 (when (listp buffer-undo-list)
4165 (push (cons (point-min) (point-max)) 4154 (push (cons (point-min) (point-max))
4166 buffer-undo-list))) 4155 buffer-undo-list)))
@@ -5056,7 +5045,7 @@ object satisfying `yas--field-p' to restrict the expansion to.")))
5056(define-button-type 'help-snippet-def 5045(define-button-type 'help-snippet-def
5057 :supertype 'help-xref 5046 :supertype 'help-xref
5058 'help-function (lambda (template) (yas--visit-snippet-file-1 template)) 5047 'help-function (lambda (template) (yas--visit-snippet-file-1 template))
5059 'help-echo (purecopy "mouse-2, RET: find snippets's definition")) 5048 'help-echo "mouse-2, RET: find snippets's definition")
5060 5049
5061(defun yas--snippet-description-finish-runonce () 5050(defun yas--snippet-description-finish-runonce ()
5062 "Final adjustments for the help buffer when snippets are concerned." 5051 "Final adjustments for the help buffer when snippets are concerned."