summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2024-02-10 20:40:19 +0100
committerSimeon Simeonov2024-02-10 20:40:19 +0100
commit9fffbc025f80ef22a77ccc62f53baa990568b214 (patch)
tree7ad612f426050d6eee5ef1f513a859688f4e37f1
parentff160687915804b109fe626a5c7fbe949f227106 (diff)
Upgrade yasnippet
-rw-r--r--.emacs.d/lisp/yasnippet.el216
1 files changed, 115 insertions, 101 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index f5210d5..d130cb9 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.0 8;; Version: 0.14.1
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
@@ -421,7 +421,12 @@ The condition will respect the value of `yas-keymap-disable-hook'."
421 421
422(defvar yas-keymap 422(defvar yas-keymap
423 (let ((map (make-sparse-keymap))) 423 (let ((map (make-sparse-keymap)))
424 (define-key map [(tab)] (yas-filtered-definition 'yas-next-field-or-maybe-expand)) 424 ;; Modes should always bind to TAB instead of `tab', so as not to override
425 ;; bindings that should take higher precedence but which bind to `TAB`
426 ;; instead (relying on `function-key-map` to remap `tab` to TAB).
427 ;; If this causes problem because of another package that binds to `tab`,
428 ;; complain to that other package!
429 ;; (define-key map [tab] (yas-filtered-definition 'yas-next-field-or-maybe-expand))
425 (define-key map (kbd "TAB") (yas-filtered-definition 'yas-next-field-or-maybe-expand)) 430 (define-key map (kbd "TAB") (yas-filtered-definition 'yas-next-field-or-maybe-expand))
426 (define-key map [(shift tab)] (yas-filtered-definition 'yas-prev-field)) 431 (define-key map [(shift tab)] (yas-filtered-definition 'yas-prev-field))
427 (define-key map [backtab] (yas-filtered-definition 'yas-prev-field)) 432 (define-key map [backtab] (yas-filtered-definition 'yas-prev-field))
@@ -489,18 +494,19 @@ Attention: This hook is not run when exiting nested/stacked snippet expansion!")
489 "Hook run just before expanding a snippet.") 494 "Hook run just before expanding a snippet.")
490 495
491(defconst yas-not-string-or-comment-condition 496(defconst yas-not-string-or-comment-condition
492 '(if (let ((ppss (syntax-ppss))) 497 (lambda ()
493 (or (nth 3 ppss) (nth 4 ppss))) 498 (if (let ((ppss (syntax-ppss)))
494 '(require-snippet-condition . force-in-comment) 499 (or (nth 3 ppss) (nth 4 ppss)))
495 t) 500 '(require-snippet-condition . force-in-comment)
501 t))
496 "Disables snippet expansion in strings and comments. 502 "Disables snippet expansion in strings and comments.
497To use, set `yas-buffer-local-condition' to this value.") 503To use, set `yas-buffer-local-condition' to this value.")
498 504
499(defcustom yas-buffer-local-condition t 505(defcustom yas-buffer-local-condition t
500 "Snippet expanding condition. 506 "Snippet expanding condition.
501 507
502This variable is a Lisp form which is evaluated every time a 508This variable is either a Lisp function (called with no arguments)
503snippet expansion is attempted: 509or a Lisp form. It is evaluated every time a snippet expansion is attempted:
504 510
505 * If it evaluates to nil, no snippets can be expanded. 511 * If it evaluates to nil, no snippets can be expanded.
506 512
@@ -538,12 +544,13 @@ inside comments, in `python-mode' only, with the exception of
538snippets returning the symbol `force-in-comment' in their 544snippets returning the symbol `force-in-comment' in their
539conditions. 545conditions.
540 546
541 (add-hook \\='python-mode-hook 547 (add-hook \\='python-mode-hook
542 (lambda () 548 (lambda ()
543 (setq yas-buffer-local-condition 549 (setq yas-buffer-local-condition
544 \\='(if (python-syntax-comment-or-string-p) 550 (lambda ()
545 \\='(require-snippet-condition . force-in-comment) 551 (if (python-syntax-comment-or-string-p)
546 t))))" 552 \\='(require-snippet-condition . force-in-comment)
553 t)))))"
547 :type 554 :type
548 `(choice 555 `(choice
549 (const :tag "Disable snippet expansion inside strings and comments" 556 (const :tag "Disable snippet expansion inside strings and comments"
@@ -554,9 +561,12 @@ conditions.
554 sexp)) 561 sexp))
555 562
556(defcustom yas-keymap-disable-hook nil 563(defcustom yas-keymap-disable-hook nil
557 "The `yas-keymap' bindings are disabled if any function in this list returns non-nil. 564 "Abnormal hook run to decide when `yas-keymap' bindings are enabled.
565The bindings are disabled whenever any function in this list returns non-nil.
558This is useful to control whether snippet navigation bindings 566This is useful to control whether snippet navigation bindings
559override bindings from other packages (e.g., `company-mode')." 567override bindings from other packages (e.g., `company-mode').
568This is run (several times) every time we perform a key lookup, so
569it has to be fast."
560 :type 'hook) 570 :type 'hook)
561 571
562(defcustom yas-overlay-priority 100 572(defcustom yas-overlay-priority 100
@@ -648,7 +658,7 @@ expanded.")
648 ;; instead (relying on `function-key-map` to remap `tab` to TAB). 658 ;; instead (relying on `function-key-map` to remap `tab` to TAB).
649 ;; If this causes problem because of another package that binds to `tab`, 659 ;; If this causes problem because of another package that binds to `tab`,
650 ;; complain to that other package! 660 ;; complain to that other package!
651 ;;(define-key map [(tab)] yas-maybe-expand) 661 ;;(define-key map [tab] yas-maybe-expand)
652 (define-key map (kbd "TAB") yas-maybe-expand) 662 (define-key map (kbd "TAB") yas-maybe-expand)
653 (define-key map "\C-c&\C-s" #'yas-insert-snippet) 663 (define-key map "\C-c&\C-s" #'yas-insert-snippet)
654 (define-key map "\C-c&\C-n" #'yas-new-snippet) 664 (define-key map "\C-c&\C-n" #'yas-new-snippet)
@@ -819,42 +829,49 @@ which decides on the snippet to expand.")
819 (or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'? 829 (or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'?
820 (progn 830 (progn
821 (put mode 'yas--all-parents (list mode)) ;; Stop inf-loop with cycles. 831 (put mode 'yas--all-parents (list mode)) ;; Stop inf-loop with cycles.
822 (put mode 'yas--all-parents 832 (let ((all-parents
823 (if (fboundp 'derived-mode-all-parents) 833 (if (fboundp 'derived-mode-all-parents)
824 (let* ((ap (derived-mode-all-parents mode)) 834 (let* ((ap (derived-mode-all-parents mode))
825 (extras 835 (extras
826 (mapcar (lambda (parent) 836 (mapcar (lambda (parent)
827 (yas--merge-ordered-lists 837 (yas--merge-ordered-lists
828 (mapcar #'yas--all-parents 838 (mapcar #'yas--all-parents
829 (gethash parent yas--parents)))) 839 (gethash parent yas--parents))))
830 ap))) 840 ap)))
831 (yas--merge-ordered-lists 841 (cl-assert (eq mode (car ap)))
832 (cons (append ap '(fundamental-mode)) extras))) 842 (cons mode
833 (cons mode 843 (yas--merge-ordered-lists
834 (yas--merge-ordered-lists 844 (cons (if (eq mode 'fundamental-mode) ()
835 (mapcar #'yas--all-parents 845 (append (cdr ap) '(fundamental-mode)))
836 (remq nil 846 extras))))
837 `(,(or (get mode 'derived-mode-parent) 847 (cons mode
838 ;; Consider `fundamental-mode' 848 (yas--merge-ordered-lists
839 ;; as ultimate ancestor. 849 (mapcar #'yas--all-parents
840 'fundamental-mode) 850 (remq nil
841 ,(let ((alias (symbol-function mode))) 851 `(,(or (get mode 'derived-mode-parent)
842 (when (symbolp alias) alias)) 852 ;; Consider `fundamental-mode'
843 ,@(gethash mode yas--parents))))))))))) 853 ;; as ultimate ancestor.
854 'fundamental-mode)
855 ,(let ((alias (symbol-function mode)))
856 (when (symbolp alias) alias))
857 ,@(gethash mode yas--parents)))))))))
858 (dolist (parent all-parents)
859 (cl-pushnew mode (get parent 'yas--cached-children)))
860 (put mode 'yas--all-parents all-parents)))))
844 861
845(defun yas--modes-to-activate (&optional mode) 862(defun yas--modes-to-activate (&optional mode)
846 "Compute list of mode symbols that are active for `yas-expand' and friends." 863 "Compute list of mode symbols that are active for `yas-expand' and friends."
847 (let* ((modes 864 (let* ((modes
848 (delete-dups 865 (delete-dups
849 (remq nil `(,(or mode major-mode) 866 (remq nil `(,@(unless mode yas--extra-modes)
867 ,(or mode major-mode)
850 ;; FIXME: Alternative major modes should use 868 ;; FIXME: Alternative major modes should use
851 ;; `derived-mode-add-parents', but until that 869 ;; `derived-mode-add-parents', but until that
852 ;; becomes common, use `major-mode-remap-alist' 870 ;; becomes common, use `major-mode-remap-alist'
853 ;; as a crutch to supplement the mode hierarchy. 871 ;; as a crutch to supplement the mode hierarchy.
854 ,(and (boundp 'major-mode-remap-alist) 872 ,(and (boundp 'major-mode-remap-alist)
855 (car (rassq (or mode major-mode) 873 (car (rassq (or mode major-mode)
856 major-mode-remap-alist))) 874 major-mode-remap-alist))))))))
857 ,@(unless mode (reverse yas--extra-modes)))))))
858 (yas--merge-ordered-lists 875 (yas--merge-ordered-lists
859 (mapcar #'yas--all-parents modes)))) 876 (mapcar #'yas--all-parents modes))))
860 877
@@ -1276,7 +1293,7 @@ Return TEMPLATE."
1276 (cl-assert menu-keymap) 1293 (cl-assert menu-keymap)
1277 (yas--delete-from-keymap menu-keymap (yas--template-uuid template)) 1294 (yas--delete-from-keymap menu-keymap (yas--template-uuid template))
1278 1295
1279 ;; Add necessary subgroups as necessary. 1296 ;; Add subgroups as necessary.
1280 ;; 1297 ;;
1281 (dolist (subgroup group) 1298 (dolist (subgroup group)
1282 (let ((subgroup-keymap (lookup-key menu-keymap (vector (make-symbol subgroup))))) 1299 (let ((subgroup-keymap (lookup-key menu-keymap (vector (make-symbol subgroup)))))
@@ -1314,14 +1331,15 @@ string and TEMPLATE is a `yas--template' structure."
1314 1331
1315;;; Filtering/condition logic 1332;;; Filtering/condition logic
1316 1333
1317(defun yas--eval-condition (condition) 1334(defun yas--funcall-condition (fun &rest args)
1318 (condition-case err 1335 (condition-case err
1319 (save-excursion 1336 (save-excursion
1320 (save-restriction 1337 (save-restriction
1321 (save-match-data 1338 (save-match-data
1322 (eval condition t)))) 1339 (apply fun args))))
1323 (error (progn 1340 (error (progn
1324 (yas--message 1 "Error in condition evaluation: %s" (error-message-string err)) 1341 (yas--message 1 "Error in condition evaluation: %s"
1342 (error-message-string err))
1325 nil)))) 1343 nil))))
1326 1344
1327 1345
@@ -1346,9 +1364,13 @@ This function implements the rules described in
1346conditions to filter out potential expansions." 1364conditions to filter out potential expansions."
1347 (if (eq 'always yas-buffer-local-condition) 1365 (if (eq 'always yas-buffer-local-condition)
1348 'always 1366 'always
1349 (let ((local-condition (or (and (consp yas-buffer-local-condition) 1367 (let ((local-condition
1350 (yas--eval-condition yas-buffer-local-condition)) 1368 (or (cond
1351 yas-buffer-local-condition))) 1369 ((functionp yas-buffer-local-condition)
1370 (yas--funcall-condition yas-buffer-local-condition))
1371 ((consp yas-buffer-local-condition)
1372 (yas--funcall-condition #'eval yas-buffer-local-condition t)))
1373 yas-buffer-local-condition)))
1352 (when local-condition 1374 (when local-condition
1353 (if (eq local-condition t) 1375 (if (eq local-condition t)
1354 t 1376 t
@@ -1360,7 +1382,7 @@ conditions to filter out potential expansions."
1360(defun yas--template-can-expand-p (condition requirement) 1382(defun yas--template-can-expand-p (condition requirement)
1361 "Evaluate CONDITION and REQUIREMENT and return a boolean." 1383 "Evaluate CONDITION and REQUIREMENT and return a boolean."
1362 (let* ((result (or (null condition) 1384 (let* ((result (or (null condition)
1363 (yas--eval-condition condition)))) 1385 (yas--funcall-condition #'eval condition t))))
1364 (cond ((eq requirement t) 1386 (cond ((eq requirement t)
1365 result) 1387 result)
1366 (t 1388 (t
@@ -1486,7 +1508,7 @@ Also tries to work around Emacs Bug#30931."
1486 (yas--safely-call-fun (apply-partially #'eval form))) 1508 (yas--safely-call-fun (apply-partially #'eval form)))
1487 1509
1488(defun yas--read-lisp (string &optional nil-on-error) 1510(defun yas--read-lisp (string &optional nil-on-error)
1489 "Read STRING as a elisp expression and return it. 1511 "Read STRING as an Elisp expression and return it.
1490 1512
1491In case STRING in an invalid expression and NIL-ON-ERROR is nil, 1513In case STRING in an invalid expression and NIL-ON-ERROR is nil,
1492return an expression that when evaluated will issue an error." 1514return an expression that when evaluated will issue an error."
@@ -1500,7 +1522,7 @@ return an expression that when evaluated will issue an error."
1500 (when (and keybinding 1522 (when (and keybinding
1501 (not (string-match "keybinding" keybinding))) 1523 (not (string-match "keybinding" keybinding)))
1502 (condition-case err 1524 (condition-case err
1503 (let ((res (or (and (string-match "^\\[.*\\]$" keybinding) 1525 (let ((res (or (and (string-match "\\`\\[.*\\]\\'" keybinding)
1504 (read keybinding)) 1526 (read keybinding))
1505 (read-kbd-macro keybinding 'need-vector)))) 1527 (read-kbd-macro keybinding 'need-vector))))
1506 res) 1528 res)
@@ -1584,7 +1606,6 @@ Here's a list of currently recognized directives:
1584 (file-name-nondirectory file))) 1606 (file-name-nondirectory file)))
1585 (key nil) 1607 (key nil)
1586 template 1608 template
1587 bound
1588 condition 1609 condition
1589 (group (and file 1610 (group (and file
1590 (yas--calculate-group file))) 1611 (yas--calculate-group file)))
@@ -1592,31 +1613,27 @@ Here's a list of currently recognized directives:
1592 binding 1613 binding
1593 uuid) 1614 uuid)
1594 (if (re-search-forward "^# --\\s-*\n" nil t) 1615 (if (re-search-forward "^# --\\s-*\n" nil t)
1595 (progn (setq template 1616 (let ((bound (point)))
1596 (buffer-substring-no-properties (point) 1617 (setq template
1597 (point-max))) 1618 (buffer-substring-no-properties (point)
1598 (setq bound (point)) 1619 (point-max)))
1599 (goto-char (point-min)) 1620 (goto-char (point-min))
1600 (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*?\\)[[:space:]]*$" bound t) 1621 (while (re-search-forward
1601 (when (string= "uuid" (match-string-no-properties 1)) 1622 "^# *\\([^ ]+?\\) *: *\\(.*?\\)[[:space:]]*$" bound t)
1602 (setq uuid (match-string-no-properties 2))) 1623 (let ((val (match-string-no-properties 2)))
1603 (when (string= "type" (match-string-no-properties 1)) 1624 (pcase (match-string-no-properties 1)
1604 (setq type (if (string= "command" (match-string-no-properties 2)) 1625 ("uuid" (setq uuid val))
1605 'command 1626 ("type" (setq type (intern val)))
1606 'snippet))) 1627 ("key" (setq key val))
1607 (when (string= "key" (match-string-no-properties 1)) 1628 ("name" (setq name val))
1608 (setq key (match-string-no-properties 2))) 1629 ("condition" (setq condition (yas--read-lisp val)))
1609 (when (string= "name" (match-string-no-properties 1)) 1630 ("group" (setq group val))
1610 (setq name (match-string-no-properties 2))) 1631 ("expand-env"
1611 (when (string= "condition" (match-string-no-properties 1)) 1632 (setq expand-env (yas--read-lisp val 'nil-on-error)))
1612 (setq condition (yas--read-lisp (match-string-no-properties 2)))) 1633 ("binding" (setq binding val))
1613 (when (string= "group" (match-string-no-properties 1)) 1634 ("contributor" nil) ;Documented in `snippet-development.org'.
1614 (setq group (match-string-no-properties 2))) 1635 (dir (message "Ignoring unknown directive %S in file: %s"
1615 (when (string= "expand-env" (match-string-no-properties 1)) 1636 dir file))))))
1616 (setq expand-env (yas--read-lisp (match-string-no-properties 2)
1617 'nil-on-error)))
1618 (when (string= "binding" (match-string-no-properties 1))
1619 (setq binding (match-string-no-properties 2)))))
1620 (setq template 1637 (setq template
1621 (buffer-substring-no-properties (point-min) (point-max)))) 1638 (buffer-substring-no-properties (point-min) (point-max))))
1622 (unless (or key binding) 1639 (unless (or key binding)
@@ -1811,14 +1828,6 @@ the current buffers contents."
1811 (if yas--creating-compiled-snippets 1828 (if yas--creating-compiled-snippets
1812 (let ((print-length nil)) 1829 (let ((print-length nil))
1813 (insert ";;; Snippet definitions:\n;;;\n") 1830 (insert ";;; Snippet definitions:\n;;;\n")
1814 (dolist (snippet snippets)
1815 ;; Fill in missing elements with nil.
1816 (setq snippet (append snippet (make-list (- 10 (length snippet)) nil)))
1817 ;; Move LOAD-FILE to SAVE-FILE because we will load from the
1818 ;; compiled file, not LOAD-FILE.
1819 (let ((load-file (nth 6 snippet)))
1820 (setcar (nthcdr 6 snippet) nil)
1821 (setcar (nthcdr 9 snippet) load-file)))
1822 (insert (pp-to-string 1831 (insert (pp-to-string
1823 `(yas-define-snippets ',mode ',snippets))) 1832 `(yas-define-snippets ',mode ',snippets)))
1824 (insert "\n\n")) 1833 (insert "\n\n"))
@@ -1854,6 +1863,9 @@ the current buffers contents."
1854 1863
1855(defun yas--define-parents (mode parents) 1864(defun yas--define-parents (mode parents)
1856 "Add PARENTS to the list of MODE's parents." 1865 "Add PARENTS to the list of MODE's parents."
1866 (dolist (child (get mode 'yas--cached-children))
1867 (put child 'yas--all-parents nil)) ;Flush the cache for children.
1868 (put 'mode 'yas--cached-children nil)
1857 (puthash mode (cl-remove-duplicates 1869 (puthash mode (cl-remove-duplicates
1858 (append parents 1870 (append parents
1859 (gethash mode yas--parents))) 1871 (gethash mode yas--parents)))
@@ -1923,7 +1935,8 @@ With prefix argument USE-JIT do jit-loading of snippets."
1923 (current-time-string))))) 1935 (current-time-string)))))
1924 ;; Normal case. 1936 ;; Normal case.
1925 (unless (file-exists-p (expand-file-name ".yas-skip" directory)) 1937 (unless (file-exists-p (expand-file-name ".yas-skip" directory))
1926 (unless (and (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3)) 1938 (unless (and (load (expand-file-name ".yas-compiled-snippets" directory)
1939 'noerror (<= yas-verbosity 3))
1927 (progn (yas--message 4 "Loaded compiled snippets from %s" directory) t)) 1940 (progn (yas--message 4 "Loaded compiled snippets from %s" directory) t))
1928 (yas--message 4 "Loading snippet files from %s" directory) 1941 (yas--message 4 "Loading snippet files from %s" directory)
1929 (yas--load-directory-2 directory mode-sym))))) 1942 (yas--load-directory-2 directory mode-sym)))))
@@ -2072,7 +2085,7 @@ prefix argument."
2072 2085
2073This works by stubbing a few functions, then calling 2086This works by stubbing a few functions, then calling
2074`yas-load-directory'." 2087`yas-load-directory'."
2075 (interactive "DTop level snippet directory?") 2088 (interactive "DTop level snippet directory? ")
2076 (let ((yas--creating-compiled-snippets t)) 2089 (let ((yas--creating-compiled-snippets t))
2077 (yas-load-directory top-level-dir nil))) 2090 (yas-load-directory top-level-dir nil)))
2078 2091
@@ -2923,7 +2936,8 @@ DEBUG is for debugging the YASnippet engine itself."
2923 (if (and condition 2936 (if (and condition
2924 original-buffer) 2937 original-buffer)
2925 (with-current-buffer original-buffer 2938 (with-current-buffer original-buffer
2926 (if (yas--eval-condition condition) 2939 (if (yas--funcall-condition
2940 #'eval condition t)
2927 "(y)" 2941 "(y)"
2928 "(s)")) 2942 "(s)"))
2929 "(a)"))) 2943 "(a)")))
@@ -3596,8 +3610,8 @@ If so cleans up the whole snippet up."
3596 (yas--commit-snippet snippet) 3610 (yas--commit-snippet snippet)
3597 (setq exited-snippets-p t)) 3611 (setq exited-snippets-p t))
3598 ((and active-field 3612 ((and active-field
3599 (or (not yas--active-field-overlay) 3613 (not (and yas--active-field-overlay
3600 (not (overlay-buffer yas--active-field-overlay)))) 3614 (overlay-buffer yas--active-field-overlay))))
3601 ;; 3615 ;;
3602 ;; stacked expansion: this case is mainly for recent 3616 ;; stacked expansion: this case is mainly for recent
3603 ;; snippet exits that place us back int the field of 3617 ;; snippet exits that place us back int the field of
@@ -3711,7 +3725,7 @@ Otherwise deletes a character normally by calling `delete-char'."
3711 (t (call-interactively 'delete-char)))) 3725 (t (call-interactively 'delete-char))))
3712 3726
3713(defun yas--skip-and-clear (field &optional from) 3727(defun yas--skip-and-clear (field &optional from)
3714 "Deletes the region of FIELD and sets it's modified state to t. 3728 "Delete the region of FIELD and set its modified state to t.
3715If given, FROM indicates position to start at instead of FIELD's beginning." 3729If given, FROM indicates position to start at instead of FIELD's beginning."
3716 ;; Just before skipping-and-clearing the field, mark its children 3730 ;; Just before skipping-and-clearing the field, mark its children
3717 ;; fields as modified, too. If the children have mirrors-in-fields 3731 ;; fields as modified, too. If the children have mirrors-in-fields
@@ -3926,14 +3940,16 @@ Move the overlays, or create them if they do not exit."
3926 (overlay-put ov 'face 'yas--field-debug-face) 3940 (overlay-put ov 'face 'yas--field-debug-face)
3927 (overlay-put ov 'yas--snippet snippet) 3941 (overlay-put ov 'yas--snippet snippet)
3928 ;; (overlay-put ov 'evaporate t) 3942 ;; (overlay-put ov 'evaporate t)
3929 (overlay-put ov 'modification-hooks '(yas--on-protection-overlay-modification))))))) 3943 (overlay-put ov 'modification-hooks
3944 '(yas--on-protection-overlay-modification)))))))
3930 3945
3931(defun yas--on-protection-overlay-modification (_overlay after? beg end &optional length) 3946(defun yas--on-protection-overlay-modification (overlay after? beg end &optional length)
3932 "Commit the snippet if the protection overlay is being killed." 3947 "Commit the snippet if the protection overlay is being killed."
3933 (unless (or yas--inhibit-overlay-hooks 3948 (unless (or yas--inhibit-overlay-hooks
3934 yas-inhibit-overlay-modification-protection 3949 yas-inhibit-overlay-modification-protection
3935 (not after?) 3950 (not after?)
3936 (= length (- end beg)) ; deletion or insertion 3951 (= length (- end beg)) ; deletion or insertion
3952 (>= beg (overlay-end overlay)) ;Emacs=29.1 bug#65929
3937 (yas--undo-in-progress)) 3953 (yas--undo-in-progress))
3938 (let ((snippets (yas-active-snippets))) 3954 (let ((snippets (yas-active-snippets)))
3939 (yas--message 2 "Committing snippets. Action would destroy a protection overlay.") 3955 (yas--message 2 "Committing snippets. Action would destroy a protection overlay.")
@@ -3984,9 +4000,7 @@ for normal snippets, and a list for command snippets)."
3984 (run-hooks 'yas-before-expand-snippet-hook) 4000 (run-hooks 'yas-before-expand-snippet-hook)
3985 4001
3986 (let* ((clear-field 4002 (let* ((clear-field
3987 (let ((field (and yas--active-field-overlay 4003 (let ((field (yas-current-field)))
3988 (overlay-buffer yas--active-field-overlay)
3989 (overlay-get yas--active-field-overlay 'yas--field))))
3990 (and field (yas--skip-and-clear-field-p 4004 (and field (yas--skip-and-clear-field-p
3991 field (point) (point) 0) 4005 field (point) (point) 0)
3992 field))) 4006 field)))
@@ -4033,9 +4047,7 @@ for normal snippets, and a list for command snippets)."
4033 4047
4034 ;; Stacked-expansion: This checks for stacked expansion, save the 4048 ;; Stacked-expansion: This checks for stacked expansion, save the
4035 ;; `yas--previous-active-field' and advance its boundary. 4049 ;; `yas--previous-active-field' and advance its boundary.
4036 (let ((existing-field (and yas--active-field-overlay 4050 (let ((existing-field (yas-current-field)))
4037 (overlay-buffer yas--active-field-overlay)
4038 (overlay-get yas--active-field-overlay 'yas--field))))
4039 (when existing-field 4051 (when existing-field
4040 (setf (yas--snippet-previous-active-field snippet) existing-field) 4052 (setf (yas--snippet-previous-active-field snippet) existing-field)
4041 (yas--advance-end-maybe-previous-fields 4053 (yas--advance-end-maybe-previous-fields
@@ -4510,7 +4522,8 @@ The SNIPPET's markers are preserved."
4510 remarkers))) 4522 remarkers)))
4511 (unwind-protect 4523 (unwind-protect
4512 (progn (back-to-indentation) 4524 (progn (back-to-indentation)
4513 (indent-according-to-mode)) 4525 (with-demoted-errors "%S"
4526 (indent-according-to-mode)))
4514 (save-restriction 4527 (save-restriction
4515 (narrow-to-region bol (line-end-position)) 4528 (narrow-to-region bol (line-end-position))
4516 (dolist (remarker remarkers) 4529 (dolist (remarker remarkers)
@@ -4953,6 +4966,7 @@ When multiple expressions are found, only the last one counts."
4953 ;; When not in an undo, check if we must commit the snippet 4966 ;; When not in an undo, check if we must commit the snippet
4954 ;; (user exited it). 4967 ;; (user exited it).
4955 (yas--check-commit-snippet)))) 4968 (yas--check-commit-snippet))))
4969 ;; FIXME: Why?
4956 ((debug error) (signal (car err) (cdr err))))) 4970 ((debug error) (signal (car err) (cdr err)))))
4957 4971
4958;;; Fancy docs: 4972;;; Fancy docs: