summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2018-03-19 10:08:28 +0100
committerSimeon Simeonov2018-03-19 10:08:28 +0100
commit56e823ecbecf1b3bc7b485dc7acb268735d21d8e (patch)
tree90ffabbf1fc1a4b02b2c246de164cb31a27dbcb6
parenteeee6220a7d0fcd8cfa9be2381ed95dca96350b6 (diff)
Update yasnippet. Update snippets in prog-mode
-rw-r--r--.emacs.d/lisp/yasnippet.el50
-rw-r--r--.emacs.d/snippets/prog-mode/fixme2
-rw-r--r--.emacs.d/snippets/prog-mode/todo2
-rw-r--r--.emacs.d/snippets/prog-mode/xxx2
4 files changed, 52 insertions, 4 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index b36c422..562a1db 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -582,6 +582,23 @@ override bindings from other packages (e.g., `company-mode')."
582 "The original value of `auto-fill-function'.") 582 "The original value of `auto-fill-function'.")
583(make-variable-buffer-local 'yas--original-auto-fill-function) 583(make-variable-buffer-local 'yas--original-auto-fill-function)
584 584
585(defun yas--watch-auto-fill (_sym newval op _where)
586 (when (and (null newval) (eq auto-fill-function 'yas--auto-fill)
587 (fboundp 'backtrace-frames) ; Suppress compiler warning.
588 ;; If we're about to change `auto-fill-function' too,
589 ;; it's okay (probably).
590 (not (and (eq op 'makunbound)
591 (not (eq (default-value 'auto-fill-function) 'yas--auto-fill))
592 (cl-member 'kill-all-local-variables
593 (backtrace-frames 'yas--watch-auto-fill)
594 :key (lambda (frame) (nth 1 frame))))))
595 (debug nil "`yas--original-auto-fill-function' unexpectedly nil! Please report this backtrace (hit `c' to continue)")) )
596
597;; Try to get more info on #873/919 (this only works for Emacs 26+).
598(when (fboundp 'add-variable-watcher)
599 (add-variable-watcher 'yas--original-auto-fill-function
600 #'yas--watch-auto-fill))
601
585(defun yas--snippet-next-id () 602(defun yas--snippet-next-id ()
586 (let ((id yas--snippet-id-seed)) 603 (let ((id yas--snippet-id-seed))
587 (cl-incf yas--snippet-id-seed) 604 (cl-incf yas--snippet-id-seed)
@@ -3683,7 +3700,38 @@ field start. This hook does nothing if an undo is in progress."
3683 reoverlays)) 3700 reoverlays))
3684 (goto-char orig-point) 3701 (goto-char orig-point)
3685 (let ((yas--inhibit-overlay-hooks t)) 3702 (let ((yas--inhibit-overlay-hooks t))
3686 (funcall yas--original-auto-fill-function)) 3703 (if (null yas--original-auto-fill-function)
3704 ;; Try to get more info on #873/919.
3705 (let ((yas--fill-fun-values `((t ,(default-value 'yas--original-auto-fill-function))))
3706 (fill-fun-values `((t ,(default-value 'auto-fill-function))))
3707 ;; Listing 2 buffers with the same value is enough
3708 (print-length 3))
3709 (save-current-buffer
3710 (dolist (buf (let ((bufs (buffer-list)))
3711 ;; List the current buffer first.
3712 (setq bufs (cons (current-buffer)
3713 (remq (current-buffer) bufs)))))
3714 (set-buffer buf)
3715 (let* ((yf-cell (assq yas--original-auto-fill-function
3716 yas--fill-fun-values))
3717 (af-cell (assq auto-fill-function fill-fun-values)))
3718 (when (local-variable-p 'yas--original-auto-fill-function)
3719 (if yf-cell (setcdr yf-cell (cons buf (cdr yf-cell)))
3720 (push (list yas--original-auto-fill-function buf) yas--fill-fun-values)))
3721 (when (local-variable-p 'auto-fill-function)
3722 (if af-cell (setcdr af-cell (cons buf (cdr af-cell)))
3723 (push (list auto-fill-function buf) fill-fun-values))))))
3724 (lwarn '(yasnippet auto-fill bug) :error
3725 "`yas--original-auto-fill-function' unexpectedly nil in %S! Disabling auto-fill.
3726 %S
3727 `auto-fill-function': %S"
3728 (current-buffer) yas--fill-fun-values fill-fun-values)
3729 ;; Try to avoid repeated triggering of this bug.
3730 (auto-fill-mode -1)
3731 ;; Don't pop up more than once in a session (still log though).
3732 (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'.
3733 (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug)))
3734 (funcall yas--original-auto-fill-function)))
3687 (save-excursion 3735 (save-excursion
3688 (setq end (progn (forward-paragraph) (point))) 3736 (setq end (progn (forward-paragraph) (point)))
3689 (setq beg (progn (backward-paragraph) (point)))) 3737 (setq beg (progn (backward-paragraph) (point))))
diff --git a/.emacs.d/snippets/prog-mode/fixme b/.emacs.d/snippets/prog-mode/fixme
index 146db8b..df81c1d 100644
--- a/.emacs.d/snippets/prog-mode/fixme
+++ b/.emacs.d/snippets/prog-mode/fixme
@@ -3,4 +3,4 @@
3# key: fi 3# key: fi
4# condition: (not (eq major-mode 'sh-mode)) 4# condition: (not (eq major-mode 'sh-mode))
5# -- 5# --
6`(yas-with-comment "FIXME: ")` \ No newline at end of file 6`comment-start`FIXME: $0`comment-end` \ No newline at end of file
diff --git a/.emacs.d/snippets/prog-mode/todo b/.emacs.d/snippets/prog-mode/todo
index 973151f..79484e7 100644
--- a/.emacs.d/snippets/prog-mode/todo
+++ b/.emacs.d/snippets/prog-mode/todo
@@ -2,4 +2,4 @@
2# name: todo 2# name: todo
3# key: t 3# key: t
4# -- 4# --
5`(yas-with-comment "TODO: ")` \ No newline at end of file 5`comment-start`TODO: $0`comment-end` \ No newline at end of file
diff --git a/.emacs.d/snippets/prog-mode/xxx b/.emacs.d/snippets/prog-mode/xxx
index 09df18b..85f0e6b 100644
--- a/.emacs.d/snippets/prog-mode/xxx
+++ b/.emacs.d/snippets/prog-mode/xxx
@@ -2,4 +2,4 @@
2# name: xxx 2# name: xxx
3# key: x 3# key: x
4# -- 4# --
5`(yas-with-comment "XXX: ")` \ No newline at end of file 5`comment-start`XXX: $0`comment-end` \ No newline at end of file