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.el253
1 files changed, 130 insertions, 123 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index c4f8ae4..f5210d5 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-2023 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2024 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>
@@ -132,8 +132,7 @@
132;;; Code: 132;;; Code:
133 133
134(require 'cl-lib) 134(require 'cl-lib)
135(require 'eldoc) ; Needed for 24. 135(require 'eldoc) ; Needed for Emacs<25.
136(declare-function cl-progv-after "cl-extra") ; Needed for 23.4.
137(require 'easymenu) 136(require 'easymenu)
138(require 'help-mode) 137(require 'help-mode)
139 138
@@ -342,8 +341,8 @@ If non-nil insert region contents. This can be overridden on a
342per-snippet basis. A value of `cua' is considered equivalent to 341per-snippet basis. A value of `cua' is considered equivalent to
343`?0' for backwards compatibility." 342`?0' for backwards compatibility."
344 :type '(choice (character :tag "Insert from register") 343 :type '(choice (character :tag "Insert from register")
345 (const t :tag "Insert region contents") 344 (const :tag "Insert region contents" t)
346 (const nil :tag "Don't insert anything") 345 (const :tag "Don't insert anything" nil)
347 (const cua))) ; backwards compat 346 (const cua))) ; backwards compat
348 347
349(defcustom yas-good-grace t 348(defcustom yas-good-grace t
@@ -763,7 +762,7 @@ expanded.")
763 :help "Display some information about YASnippet"])) 762 :help "Display some information about YASnippet"]))
764 763
765(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1") 764(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1")
766(defvar yas--extra-modes nil 765(defvar yas--extra-modes nil ;FIXME: Use `defvar-local'?
767 "An internal list of modes for which to also lookup snippets. 766 "An internal list of modes for which to also lookup snippets.
768 767
769This variable probably makes more sense as buffer-local, so 768This variable probably makes more sense as buffer-local, so
@@ -773,7 +772,7 @@ ensure your use `make-local-variable' when you set it.")
773 "A hash table of mode symbols to `yas--table' objects.") 772 "A hash table of mode symbols to `yas--table' objects.")
774 773
775(defvar yas--parents (make-hash-table) 774(defvar yas--parents (make-hash-table)
776 "A hash table of mode symbols do lists of direct parent mode symbols. 775 "A hash table of mode symbols to lists of direct parent mode symbols.
777 776
778This list is populated when reading the \".yas-parents\" files 777This list is populated when reading the \".yas-parents\" files
779found when traversing snippet directories with 778found when traversing snippet directories with
@@ -805,29 +804,59 @@ which decides on the snippet to expand.")
805 yas--direct-keymaps)) 804 yas--direct-keymaps))
806 yas--tables)) 805 yas--tables))
807 806
807(defalias 'yas--merge-ordered-lists
808 (if (fboundp 'merge-ordered-lists) ;Emacs≥30.
809 #'merge-ordered-lists
810 (lambda (lists)
811 (setq lists (delq nil lists))
812 (if (null (cdr lists)) (car lists) ;Common case.
813 (delete-dups (apply #'append
814 ;; Prevent sharing the tail.
815 (append lists '(()) )))))))
816
817(defun yas--all-parents (mode)
818 "Like `derived-mode-all-parents' but obeying `yas--parents'."
819 (or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'?
820 (progn
821 (put mode 'yas--all-parents (list mode)) ;; Stop inf-loop with cycles.
822 (put mode 'yas--all-parents
823 (if (fboundp 'derived-mode-all-parents)
824 (let* ((ap (derived-mode-all-parents mode))
825 (extras
826 (mapcar (lambda (parent)
827 (yas--merge-ordered-lists
828 (mapcar #'yas--all-parents
829 (gethash parent yas--parents))))
830 ap)))
831 (yas--merge-ordered-lists
832 (cons (append ap '(fundamental-mode)) extras)))
833 (cons mode
834 (yas--merge-ordered-lists
835 (mapcar #'yas--all-parents
836 (remq nil
837 `(,(or (get mode 'derived-mode-parent)
838 ;; Consider `fundamental-mode'
839 ;; as ultimate ancestor.
840 'fundamental-mode)
841 ,(let ((alias (symbol-function mode)))
842 (when (symbolp alias) alias))
843 ,@(gethash mode yas--parents)))))))))))
844
808(defun yas--modes-to-activate (&optional mode) 845(defun yas--modes-to-activate (&optional mode)
809 "Compute list of mode symbols that are active for `yas-expand' and friends." 846 "Compute list of mode symbols that are active for `yas-expand' and friends."
810 (defvar yas--dfs) ;We rely on dynbind. We could use `letrec' instead! 847 (let* ((modes
811 (let* ((explored (if mode (list mode) ; Building up list in reverse. 848 (delete-dups
812 (cons major-mode (reverse yas--extra-modes)))) 849 (remq nil `(,(or mode major-mode)
813 (yas--dfs 850 ;; FIXME: Alternative major modes should use
814 (lambda (mode) 851 ;; `derived-mode-add-parents', but until that
815 (cl-loop for neighbour 852 ;; becomes common, use `major-mode-remap-alist'
816 in (cl-list* (or (get mode 'derived-mode-parent) 853 ;; as a crutch to supplement the mode hierarchy.
817 ;; Consider `fundamental-mode' 854 ,(and (boundp 'major-mode-remap-alist)
818 ;; as ultimate ancestor. 855 (car (rassq (or mode major-mode)
819 'fundamental-mode) 856 major-mode-remap-alist)))
820 ;; NOTE: `fboundp' check is redundant 857 ,@(unless mode (reverse yas--extra-modes)))))))
821 ;; since Emacs 24.4. 858 (yas--merge-ordered-lists
822 (and (fboundp mode) (symbol-function mode)) 859 (mapcar #'yas--all-parents modes))))
823 (gethash mode yas--parents))
824 when (and neighbour
825 (not (memq neighbour explored))
826 (symbolp neighbour))
827 do (push neighbour explored)
828 (funcall yas--dfs neighbour)))))
829 (mapc yas--dfs explored)
830 (nreverse explored)))
831 860
832(defvar yas-minor-mode-hook nil 861(defvar yas-minor-mode-hook nil
833 "Hook run when `yas-minor-mode' is turned on.") 862 "Hook run when `yas-minor-mode' is turned on.")
@@ -889,13 +918,8 @@ Key bindings:
889The function can be called in the hook of a minor mode to 918The function can be called in the hook of a minor mode to
890activate snippets associated with that mode." 919activate snippets associated with that mode."
891 (interactive 920 (interactive
892 (let (modes 921 (let ((symbol (completing-read
893 symbol) 922 "Activate mode: " yas--parents nil t)))
894 (maphash (lambda (k _)
895 (setq modes (cons (list k) modes)))
896 yas--parents)
897 (setq symbol (completing-read
898 "Activate mode: " modes nil t))
899 (list 923 (list
900 (when (not (string= "" symbol)) 924 (when (not (string= "" symbol))
901 (intern symbol))))) 925 (intern symbol)))))
@@ -909,9 +933,8 @@ activate snippets associated with that mode."
909 (list (intern 933 (list (intern
910 (completing-read 934 (completing-read
911 "Deactivate mode: " (mapcar #'list yas--extra-modes) nil t)))) 935 "Deactivate mode: " (mapcar #'list yas--extra-modes) nil t))))
912 (set (make-local-variable 'yas--extra-modes) 936 (setq-local yas--extra-modes
913 (remove mode 937 (remove mode yas--extra-modes)))
914 yas--extra-modes)))
915 938
916(defun yas-temp-buffer-p (&optional buffer) 939(defun yas-temp-buffer-p (&optional buffer)
917 (eq (aref (buffer-name buffer) 0) ?\s)) 940 (eq (aref (buffer-name buffer) 0) ?\s))
@@ -923,20 +946,10 @@ activate snippets associated with that mode."
923Functions are called with no argument, and should return non-nil to prevent 946Functions are called with no argument, and should return non-nil to prevent
924`yas-global-mode' from enabling yasnippet in this buffer. 947`yas-global-mode' from enabling yasnippet in this buffer.
925 948
926In Emacsen < 24, this variable is buffer-local. Because 949Only the global value is used. To define
927`yas-minor-mode-on' is called by `yas-global-mode' after
928executing the buffer's major mode hook, setting this variable
929there is an effective way to define exceptions to the \"global\"
930activation behaviour.
931
932In Emacsen >= 24, only the global value is used. To define
933per-mode exceptions to the \"global\" activation behaviour, call 950per-mode exceptions to the \"global\" activation behaviour, call
934`yas-minor-mode' with a negative argument directily in the major 951`yas-minor-mode' with a negative argument directily in the major
935mode's hook.") 952mode's hook.") ;; FIXME: Why do we say "Only the global value is used"?
936(unless (> emacs-major-version 23)
937 (with-no-warnings
938 (make-variable-buffer-local 'yas-dont-activate)))
939
940 953
941(defun yas-minor-mode-on () 954(defun yas-minor-mode-on ()
942 "Turn on YASnippet minor mode. 955 "Turn on YASnippet minor mode.
@@ -1003,23 +1016,13 @@ Honour `yas-dont-activate-functions', which see."
1003 1016
1004 1017
1005;;;###autoload(autoload 'snippet-mode "yasnippet" "A mode for editing yasnippets" t nil) 1018;;;###autoload(autoload 'snippet-mode "yasnippet" "A mode for editing yasnippets" t nil)
1006(eval-and-compile 1019(define-derived-mode snippet-mode prog-mode "Snippet"
1007 (if (fboundp 'prog-mode) 1020 "A mode for editing yasnippets"
1008 ;; `prog-mode' is new in 24.1. 1021 (setq font-lock-defaults '(yas--font-lock-keywords))
1009 (define-derived-mode snippet-mode prog-mode "Snippet" 1022 (setq-local require-final-newline nil)
1010 "A mode for editing yasnippets" 1023 (setq-local comment-start "#")
1011 (setq font-lock-defaults '(yas--font-lock-keywords)) 1024 (setq-local comment-start-skip "#+[\t ]*")
1012 (set (make-local-variable 'require-final-newline) nil) 1025 (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))
1013 (set (make-local-variable 'comment-start) "#")
1014 (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
1015 (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))
1016 (define-derived-mode snippet-mode fundamental-mode "Snippet"
1017 "A mode for editing yasnippets"
1018 (setq font-lock-defaults '(yas--font-lock-keywords))
1019 (set (make-local-variable 'require-final-newline) nil)
1020 (set (make-local-variable 'comment-start) "#")
1021 (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
1022 (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))))
1023 1026
1024(defun yas-snippet-mode-buffer-p () 1027(defun yas-snippet-mode-buffer-p ()
1025 "Return non-nil if current buffer should be in `snippet-mode'. 1028 "Return non-nil if current buffer should be in `snippet-mode'.
@@ -1721,12 +1724,10 @@ Optional PROMPT sets the prompt to use."
1721 (redisplay) 1724 (redisplay)
1722 (or 1725 (or
1723 (x-popup-menu 1726 (x-popup-menu
1724 (if (fboundp 'posn-at-point) 1727 (let ((x-y (posn-x-y (posn-at-point (point)))))
1725 (let ((x-y (posn-x-y (posn-at-point (point))))) 1728 (list (list (+ (car x-y) 10)
1726 (list (list (+ (car x-y) 10) 1729 (+ (cdr x-y) 20))
1727 (+ (cdr x-y) 20)) 1730 (selected-window)))
1728 (selected-window)))
1729 t)
1730 `(,prompt ("title" 1731 `(,prompt ("title"
1731 ,@(cl-mapcar (lambda (c d) `(,(concat " " d) . ,c)) 1732 ,@(cl-mapcar (lambda (c d) `(,(concat " " d) . ,c))
1732 choices 1733 choices
@@ -2100,6 +2101,9 @@ This works by stubbing a few functions, then calling
2100 (or (ignore-errors (car (let ((default-directory yas--loaddir)) 2101 (or (ignore-errors (car (let ((default-directory yas--loaddir))
2101 (process-lines "git" "describe" 2102 (process-lines "git" "describe"
2102 "--tags" "--dirty")))) 2103 "--tags" "--dirty"))))
2104 (eval-when-compile
2105 (and (fboundp 'package-get-version)
2106 (package-get-version)))
2103 (when (and (featurep 'package) 2107 (when (and (featurep 'package)
2104 (fboundp 'package-desc-version) 2108 (fboundp 'package-desc-version)
2105 (fboundp 'package-version-join)) 2109 (fboundp 'package-version-join))
@@ -2549,7 +2553,7 @@ visited file in `snippet-mode'."
2549 (cond ((and file (file-readable-p file)) 2553 (cond ((and file (file-readable-p file))
2550 (find-file-other-window file) 2554 (find-file-other-window file)
2551 (snippet-mode) 2555 (snippet-mode)
2552 (set (make-local-variable 'yas--editing-template) template)) 2556 (setq-local yas--editing-template template))
2553 (file 2557 (file
2554 (message "Original file %s no longer exists!" file)) 2558 (message "Original file %s no longer exists!" file))
2555 (t 2559 (t
@@ -2571,9 +2575,10 @@ visited file in `snippet-mode'."
2571 (pp-to-string (yas--template-content template)) 2575 (pp-to-string (yas--template-content template))
2572 (yas--template-content template)))) 2576 (yas--template-content template))))
2573 (snippet-mode) 2577 (snippet-mode)
2574 (set (make-local-variable 'yas--editing-template) template) 2578 (setq-local yas--editing-template template)
2575 (set (make-local-variable 'default-directory) 2579 (setq-local default-directory
2576 (car (cdr (car (yas--guess-snippet-directories (yas--template-table template)))))))))) 2580 (car (cdr (car (yas--guess-snippet-directories
2581 (yas--template-table template))))))))))
2577 2582
2578(defun yas--guess-snippet-directories-1 (table) 2583(defun yas--guess-snippet-directories-1 (table)
2579 "Guess possible snippet subdirectories for TABLE." 2584 "Guess possible snippet subdirectories for TABLE."
@@ -2649,11 +2654,11 @@ NO-TEMPLATE is non-nil."
2649 (kill-all-local-variables) 2654 (kill-all-local-variables)
2650 (snippet-mode) 2655 (snippet-mode)
2651 (yas-minor-mode 1) 2656 (yas-minor-mode 1)
2652 (set (make-local-variable 'yas--guessed-modes) 2657 (setq-local yas--guessed-modes
2653 (mapcar (lambda (d) (yas--table-mode (car d))) 2658 (mapcar (lambda (d) (yas--table-mode (car d)))
2654 guessed-directories)) 2659 guessed-directories))
2655 (set (make-local-variable 'default-directory) 2660 (setq-local default-directory
2656 (car (cdr (car guessed-directories)))) 2661 (car (cdr (car guessed-directories))))
2657 (if (and (not no-template) yas-new-snippet-default) 2662 (if (and (not no-template) yas-new-snippet-default)
2658 (yas-expand-snippet yas-new-snippet-default)))) 2663 (yas-expand-snippet yas-new-snippet-default))))
2659 2664
@@ -2703,8 +2708,8 @@ neither do the elements of PARENTS."
2703 ido-mode) 2708 ido-mode)
2704 'ido-completing-read 'completing-read))) 2709 'ido-completing-read 'completing-read)))
2705 (unless yas--guessed-modes 2710 (unless yas--guessed-modes
2706 (set (make-local-variable 'yas--guessed-modes) 2711 (setq-local yas--guessed-modes
2707 (or (yas--compute-major-mode-and-parents buffer-file-name)))) 2712 (yas--compute-major-mode-and-parents buffer-file-name)))
2708 (intern 2713 (intern
2709 (funcall prompt (format "Choose or enter a table (yas guesses %s): " 2714 (funcall prompt (format "Choose or enter a table (yas guesses %s): "
2710 (if yas--guessed-modes 2715 (if yas--guessed-modes
@@ -2736,11 +2741,12 @@ Return the `yas--template' object created"
2736 ;; 2741 ;;
2737 (t 2742 (t
2738 (unless yas--guessed-modes 2743 (unless yas--guessed-modes
2739 (set (make-local-variable 'yas--guessed-modes) (or (yas--compute-major-mode-and-parents buffer-file-name)))) 2744 (setq-local yas--guessed-modes
2745 (or (yas--compute-major-mode-and-parents buffer-file-name))))
2740 (let* ((table (yas--table-get-create table))) 2746 (let* ((table (yas--table-get-create table)))
2741 (set (make-local-variable 'yas--editing-template) 2747 (setq-local yas--editing-template
2742 (yas--define-snippets-1 (yas--parse-template buffer-file-name) 2748 (yas--define-snippets-1 (yas--parse-template buffer-file-name)
2743 table))))) 2749 table)))))
2744 (when interactive 2750 (when interactive
2745 (yas--message 3 "Snippet \"%s\" loaded for %s." 2751 (yas--message 3 "Snippet \"%s\" loaded for %s."
2746 (yas--template-name yas--editing-template) 2752 (yas--template-name yas--editing-template)
@@ -3097,14 +3103,13 @@ other fields."
3097 3103
3098;;; Snippet expansion and field management 3104;;; Snippet expansion and field management
3099 3105
3100(defvar yas--active-field-overlay nil 3106(defvar-local yas--active-field-overlay nil
3101 "Overlays the currently active field.") 3107 "Overlays the currently active field.")
3102 3108
3103(defvar yas--active-snippets nil 3109(defvar-local yas--active-snippets nil
3104 "List of currently active snippets") 3110 "List of currently active snippets")
3105(make-variable-buffer-local 'yas--active-snippets)
3106 3111
3107(defvar yas--field-protection-overlays nil 3112(defvar-local yas--field-protection-overlays nil
3108 "Two overlays protect the current active field.") 3113 "Two overlays protect the current active field.")
3109 3114
3110(defvar yas-selected-text nil 3115(defvar yas-selected-text nil
@@ -3113,8 +3118,6 @@ other fields."
3113(defvar yas--start-column nil 3118(defvar yas--start-column nil
3114 "The column where the snippet expansion started.") 3119 "The column where the snippet expansion started.")
3115 3120
3116(make-variable-buffer-local 'yas--active-field-overlay)
3117(make-variable-buffer-local 'yas--field-protection-overlays)
3118(put 'yas--active-field-overlay 'permanent-local t) 3121(put 'yas--active-field-overlay 'permanent-local t)
3119(put 'yas--field-protection-overlays 'permanent-local t) 3122(put 'yas--field-protection-overlays 'permanent-local t)
3120 3123
@@ -3494,8 +3497,7 @@ This renders the snippet as ordinary text."
3494 3497
3495 (yas--message 4 "Snippet %s exited." (yas--snippet-id snippet))) 3498 (yas--message 4 "Snippet %s exited." (yas--snippet-id snippet)))
3496 3499
3497(defvar yas--snippets-to-move nil) 3500(defvar-local yas--snippets-to-move nil)
3498(make-variable-buffer-local 'yas--snippets-to-move)
3499 3501
3500(defun yas--prepare-snippets-for-move (beg end buf pos) 3502(defun yas--prepare-snippets-for-move (beg end buf pos)
3501 "Gather snippets in BEG..END for moving to POS in BUF." 3503 "Gather snippets in BEG..END for moving to POS in BUF."
@@ -3762,13 +3764,10 @@ BEG, END and LENGTH like overlay modification hooks."
3762 3764
3763(defun yas--merge-and-drop-dups (list1 list2 cmp key) 3765(defun yas--merge-and-drop-dups (list1 list2 cmp key)
3764 ;; `delete-consecutive-dups' + `cl-merge'. 3766 ;; `delete-consecutive-dups' + `cl-merge'.
3765 (funcall (if (fboundp 'delete-consecutive-dups) 3767 (delete-consecutive-dups
3766 #'delete-consecutive-dups ; 24.4 3768 (cl-merge 'list list1 list2 cmp :key key)))
3767 #'delete-dups)
3768 (cl-merge 'list list1 list2 cmp :key key)))
3769 3769
3770(defvar yas--before-change-modified-snippets nil) 3770(defvar-local yas--before-change-modified-snippets nil)
3771(make-variable-buffer-local 'yas--before-change-modified-snippets)
3772 3771
3773(defun yas--gather-active-snippets (overlay beg end then-delete) 3772(defun yas--gather-active-snippets (overlay beg end then-delete)
3774 ;; Add active snippets in BEG..END into an OVERLAY keyed entry of 3773 ;; Add active snippets in BEG..END into an OVERLAY keyed entry of
@@ -3793,8 +3792,7 @@ BEG, END and LENGTH like overlay modification hooks."
3793 (when then-delete 3792 (when then-delete
3794 (cl-callf2 delq old yas--before-change-modified-snippets))))) 3793 (cl-callf2 delq old yas--before-change-modified-snippets)))))
3795 3794
3796(defvar yas--todo-snippet-indent nil nil) 3795(defvar-local yas--todo-snippet-indent nil nil)
3797(make-variable-buffer-local 'yas--todo-snippet-indent)
3798 3796
3799(defun yas--on-field-overlay-modification (overlay after? beg end &optional length) 3797(defun yas--on-field-overlay-modification (overlay after? beg end &optional length)
3800 "Clears the field and updates mirrors, conditionally. 3798 "Clears the field and updates mirrors, conditionally.
@@ -4104,25 +4102,34 @@ Returns the newly created snippet."
4104 ;; content. 4102 ;; content.
4105 (let ((buffer-undo-list t)) 4103 (let ((buffer-undo-list t))
4106 (goto-char begin) 4104 (goto-char begin)
4107 ;; Call before and after change functions manually, 4105 (if (> emacs-major-version 29)
4108 ;; otherwise cc-mode's cache can get messed up. Don't use 4106 ;; Don't use the workaround for CC-mode's cache,
4109 ;; `inhibit-modification-hooks' for that, that blocks 4107 ;; since it was presumably a bug in CC-mode, so either
4110 ;; overlay and text property hooks as well! FIXME: Maybe 4108 ;; it's fixed already, or it should get fixed.
4111 ;; use `combine-change-calls'? (Requires Emacs 27+ though.) 4109 (progn
4112 (run-hook-with-args 'before-change-functions begin end) 4110 (insert content)
4113 (let ((before-change-functions nil) 4111 (narrow-to-region begin (point))
4114 (after-change-functions nil)) 4112 (goto-char (point-min))
4115 ;; Some versions of cc-mode (might be the one with Emacs 4113 (yas--snippet-parse-create snippet))
4116 ;; 24.3 only) fail when inserting snippet content in a 4114 ;; Call before and after change functions manually,
4117 ;; narrowed buffer, so make sure to insert before 4115 ;; otherwise cc-mode's cache can get messed up. Don't use
4118 ;; narrowing. 4116 ;; `inhibit-modification-hooks' for that, that blocks
4119 (insert content) 4117 ;; overlay and text property hooks as well! FIXME: Maybe
4120 (narrow-to-region begin (point)) 4118 ;; use `combine-change-calls'? (Requires Emacs 27+ though.)
4121 (goto-char (point-min)) 4119 (run-hook-with-args 'before-change-functions begin end)
4122 (yas--snippet-parse-create snippet)) 4120 (let ((before-change-functions nil)
4123 (run-hook-with-args 'after-change-functions 4121 (after-change-functions nil))
4124 (point-min) (point-max) 4122 ;; Some versions of cc-mode (might be the one with Emacs
4125 (- end begin))) 4123 ;; 24.3 only) fail when inserting snippet content in a
4124 ;; narrowed buffer, so make sure to insert before
4125 ;; narrowing.
4126 (insert content)
4127 (narrow-to-region begin (point))
4128 (goto-char (point-min))
4129 (yas--snippet-parse-create snippet))
4130 (run-hook-with-args 'after-change-functions
4131 (point-min) (point-max)
4132 (- end begin))))
4126 (when (listp buffer-undo-list) 4133 (when (listp buffer-undo-list)
4127 (push (cons (point-min) (point-max)) 4134 (push (cons (point-min) (point-max))
4128 buffer-undo-list)) 4135 buffer-undo-list))