mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
* 'permanent-local' _experiment_ for issue 143.
* some cleanup
This commit is contained in:
parent
0d3248fc67
commit
ae06e0dac8
28
yasnippet.el
28
yasnippet.el
@ -810,11 +810,15 @@ Key bindings:
|
|||||||
;; but it works). Then define variables named after modes to
|
;; but it works). Then define variables named after modes to
|
||||||
;; index `yas/direct-keymaps'.
|
;; index `yas/direct-keymaps'.
|
||||||
;;
|
;;
|
||||||
|
;; Also install the post-command-hook.
|
||||||
|
;;
|
||||||
(add-hook 'emulation-mode-map-alists 'yas/direct-keymaps)
|
(add-hook 'emulation-mode-map-alists 'yas/direct-keymaps)
|
||||||
|
(add-hook 'post-command-hook 'yas/post-command-handler nil t)
|
||||||
(add-hook 'yas/minor-mode-hook 'yas/direct-keymaps-set-vars-runonce 'append))
|
(add-hook 'yas/minor-mode-hook 'yas/direct-keymaps-set-vars-runonce 'append))
|
||||||
(t
|
(t
|
||||||
;; Uninstall the direct keymaps.
|
;; Uninstall the direct keymaps and the post-command hook
|
||||||
;;
|
;;
|
||||||
|
(remove-hook 'post-command-hook 'yas/post-command-handler t)
|
||||||
(remove-hook 'emulation-mode-map-alists 'yas/direct-keymaps))))
|
(remove-hook 'emulation-mode-map-alists 'yas/direct-keymaps))))
|
||||||
|
|
||||||
(defun yas/direct-keymaps-set-vars-runonce ()
|
(defun yas/direct-keymaps-set-vars-runonce ()
|
||||||
@ -2805,9 +2809,6 @@ Use this in primary and mirror transformations to tget."
|
|||||||
(defconst yas/prefix nil
|
(defconst yas/prefix nil
|
||||||
"A prefix argument for expansion direct from keybindings")
|
"A prefix argument for expansion direct from keybindings")
|
||||||
|
|
||||||
(defvar yas/deleted-text nil
|
|
||||||
"The text deleted in the last snippet expansion.")
|
|
||||||
|
|
||||||
(defvar yas/selected-text nil
|
(defvar yas/selected-text nil
|
||||||
"The selected region deleted on the last snippet expansion.")
|
"The selected region deleted on the last snippet expansion.")
|
||||||
|
|
||||||
@ -2816,7 +2817,8 @@ Use this in primary and mirror transformations to tget."
|
|||||||
|
|
||||||
(make-variable-buffer-local 'yas/active-field-overlay)
|
(make-variable-buffer-local 'yas/active-field-overlay)
|
||||||
(make-variable-buffer-local 'yas/field-protection-overlays)
|
(make-variable-buffer-local 'yas/field-protection-overlays)
|
||||||
(make-variable-buffer-local 'yas/deleted-text)
|
(put 'yas/active-field-overlay 'permanent-local t)
|
||||||
|
(put 'yas/field-protection-overlays 'permanent-local t)
|
||||||
|
|
||||||
(defstruct (yas/snippet (:constructor yas/make-snippet ()))
|
(defstruct (yas/snippet (:constructor yas/make-snippet ()))
|
||||||
"A snippet.
|
"A snippet.
|
||||||
@ -3119,8 +3121,6 @@ snippet, if so cleans up the whole snippet up."
|
|||||||
(t
|
(t
|
||||||
nil))))
|
nil))))
|
||||||
(unless snippets-left
|
(unless snippets-left
|
||||||
(remove-hook 'post-command-hook 'yas/post-command-handler 'local)
|
|
||||||
(remove-hook 'pre-command-hook 'yas/pre-command-handler 'local)
|
|
||||||
(if snippet-exit-transform
|
(if snippet-exit-transform
|
||||||
(yas/eval-lisp-no-saves snippet-exit-transform)
|
(yas/eval-lisp-no-saves snippet-exit-transform)
|
||||||
(run-hooks 'yas/after-exit-snippet-hook)))))
|
(run-hooks 'yas/after-exit-snippet-hook)))))
|
||||||
@ -3413,8 +3413,7 @@ considered when expanding the snippet."
|
|||||||
;;
|
;;
|
||||||
(when (and to-delete
|
(when (and to-delete
|
||||||
(> end start))
|
(> end start))
|
||||||
(delete-region start end)
|
(delete-region start end))
|
||||||
(setq yas/deleted-text to-delete))
|
|
||||||
|
|
||||||
(cond ((listp content)
|
(cond ((listp content)
|
||||||
;; x) This is a snippet-command
|
;; x) This is a snippet-command
|
||||||
@ -3523,9 +3522,6 @@ After revival, push the `yas/take-care-of-redo' in the
|
|||||||
|
|
||||||
(yas/move-to-field snippet target-field)
|
(yas/move-to-field snippet target-field)
|
||||||
|
|
||||||
(add-hook 'post-command-hook 'yas/post-command-handler nil t)
|
|
||||||
(add-hook 'pre-command-hook 'yas/pre-command-handler t t)
|
|
||||||
|
|
||||||
(push `(apply yas/take-care-of-redo ,beg ,end ,snippet)
|
(push `(apply yas/take-care-of-redo ,beg ,end ,snippet)
|
||||||
buffer-undo-list))))
|
buffer-undo-list))))
|
||||||
|
|
||||||
@ -3547,10 +3543,6 @@ Returns the newly created snippet."
|
|||||||
;; Move to end
|
;; Move to end
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
|
|
||||||
;; Setup hooks
|
|
||||||
(add-hook 'post-command-hook 'yas/post-command-handler nil t)
|
|
||||||
(add-hook 'pre-command-hook 'yas/pre-command-handler t t)
|
|
||||||
|
|
||||||
snippet))
|
snippet))
|
||||||
|
|
||||||
|
|
||||||
@ -4103,7 +4095,7 @@ When multiple expressions are found, only the last one counts."
|
|||||||
t))))
|
t))))
|
||||||
|
|
||||||
|
|
||||||
;;; Pre- and post-command hooks:
|
;;; Post-command hooks:
|
||||||
|
|
||||||
(defvar yas/post-command-runonce-actions nil
|
(defvar yas/post-command-runonce-actions nil
|
||||||
"List of actions to run once `post-command-hook'.
|
"List of actions to run once `post-command-hook'.
|
||||||
@ -4115,8 +4107,6 @@ snippet command.
|
|||||||
After all actions have been run, this list is emptied, and after
|
After all actions have been run, this list is emptied, and after
|
||||||
that the rest of `yas/post-command-handler' runs.")
|
that the rest of `yas/post-command-handler' runs.")
|
||||||
|
|
||||||
(defun yas/pre-command-handler () )
|
|
||||||
|
|
||||||
(defun yas/post-command-handler ()
|
(defun yas/post-command-handler ()
|
||||||
"Handles various yasnippet conditions after each command."
|
"Handles various yasnippet conditions after each command."
|
||||||
(when yas/post-command-runonce-actions
|
(when yas/post-command-runonce-actions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user