simplify `yas/reload-all\', don\'t save and restore global or minor modes there

This commit is contained in:
capitaomorte 2011-09-19 09:43:31 +00:00
parent 3e2ad14885
commit f669e9f6bf

View File

@ -833,7 +833,7 @@ behaviour. Can also be a function of zero arguments.")
(defun yas/minor-mode-on () (defun yas/minor-mode-on ()
"Turn on YASnippet minor mode. "Turn on YASnippet minor mode.
Do this unless `yas/dont-activate' is t " Do this unless `yas/dont-activate' is truish "
(interactive) (interactive)
(unless (or (minibufferp) (unless (or (minibufferp)
(if (functionp yas/dont-activate) (if (functionp yas/dont-activate)
@ -1688,16 +1688,12 @@ content of the file is the template."
(yas/load-directory directory)) (yas/load-directory directory))
(call-interactively 'yas/load-directory))) (call-interactively 'yas/load-directory)))
(defun yas/reload-all (&optional reset-root-directory) (defun yas/reload-all (&optional interactive)
"Reload all snippets and rebuild the YASnippet menu. " "Reload all snippets and rebuild the YASnippet menu. "
(interactive "P") (interactive "p")
;; Turn off global modes and minor modes, save their state though ;; Turn off global modes and minor modes, save their state though
;; ;;
(let ((restore-global-mode (prog1 yas/global-mode (let ((errors))
(yas/global-mode -1)))
(restore-minor-mode (prog1 yas/minor-mode
(yas/minor-mode -1)))
(errors))
;; Empty all snippet tables and all menu tables ;; Empty all snippet tables and all menu tables
;; ;;
(setq yas/tables (make-hash-table)) (setq yas/tables (make-hash-table))
@ -1709,9 +1705,6 @@ content of the file is the template."
(setf (cdr yas/minor-mode-map) (setf (cdr yas/minor-mode-map)
(cdr (yas/init-minor-keymap))) (cdr (yas/init-minor-keymap)))
(when reset-root-directory
(setq yas/snippet-dirs nil))
;; Reload the directories listed in `yas/snippet-dirs' or prompt ;; Reload the directories listed in `yas/snippet-dirs' or prompt
;; the user to select one. ;; the user to select one.
;; ;;
@ -1722,12 +1715,6 @@ content of the file is the template."
;; Reload the direct keybindings ;; Reload the direct keybindings
;; ;;
(yas/direct-keymaps-reload) (yas/direct-keymaps-reload)
;; Restore the mode configuration
;;
(when restore-minor-mode
(yas/minor-mode 1))
(when restore-global-mode
(yas/global-mode 1))
(message "[yas] Reloaded everything...%s." (if errors " (some errors, check *Messages*)" "")))) (message "[yas] Reloaded everything...%s." (if errors " (some errors, check *Messages*)" ""))))
(defun yas/quote-string (string) (defun yas/quote-string (string)