Properly closes #469: Don't use `yas--init-minor-keymap'

Previous reverted commit 498cbe4 forgot to take into account that one
of the tests used the `yas--init-minor-keymap' function that was
removed.

* yasnippet.el (yas-use-menu): Don't allow `nil' value, it's
useless.
(yas--minor-mode-menu): Use top-level `easy-menu-define' form.
(yas--init-minor-keymap): Remove definition.

* yasnippet-tests.el (test-rebindings): Don't use
`yas--init-minor-keymap'. Restore bindings explicitly. Not ideal,
but should work.
This commit is contained in:
João Távora 2014-03-13 20:24:11 +00:00
parent d809e886e0
commit b36a4f7449
2 changed files with 112 additions and 117 deletions

View File

@ -600,7 +600,11 @@ TODO: be meaner"
(yas-reload-all)
(should (not (eq (key-binding (yas--read-keybinding "TAB")) 'yas-expand)))
(should (eq (key-binding (yas--read-keybinding "SPC")) 'yas-expand))))
(setcdr yas-minor-mode-map (cdr (yas--init-minor-keymap)))))
;; FIXME: actually should restore to whatever saved values where there.
;;
(define-key yas-minor-mode-map [tab] 'yas-expand)
(define-key yas-minor-mode-map (kbd "TAB") 'yas-expand)
(define-key yas-minor-mode-map (kbd "SPC") nil)))
(ert-deftest test-yas-in-org ()
(with-temp-buffer

View File

@ -313,9 +313,6 @@ menu and the modes set in `yas--extra-modes' are listed.
- If set to `full', every submenu is listed
- It set to nil, don't display a menu at all (this requires a
`yas-reload-all' call if the menu is already visible).
Any other non-nil value, every submenu is listed."
:type '(choice (const :tag "Full" full)
(const :tag "Abbreviate" abbreviate)
@ -536,12 +533,18 @@ snippet itself contains a condition that returns the symbol
(defvar yas--minor-mode-menu nil
"Holds the YASnippet menu.")
(defun yas--init-minor-keymap ()
"Set up the `yas-minor-mode' keymap."
(defvar yas-minor-mode-map
(let ((map (make-sparse-keymap)))
(when yas-use-menu
(easy-menu-define yas--minor-mode-menu
map
(define-key map [(tab)] 'yas-expand)
(define-key map (kbd "TAB") 'yas-expand)
(define-key map "\C-c&\C-s" 'yas-insert-snippet)
(define-key map "\C-c&\C-n" 'yas-new-snippet)
(define-key map "\C-c&\C-v" 'yas-visit-snippet-file)
map)
"The keymap used when `yas-minor-mode' is active.")
(easy-menu-define yas--minor-mode-menu
yas-minor-mode-map
"Menu used when `yas-minor-mode' is active."
'("YASnippet"
"----"
@ -643,19 +646,7 @@ snippet itself contains a condition that returns the symbol
["Reload everything" yas-reload-all
:help "Cleanup stuff, reload snippets, rebuild menus"]
["About" yas-about
:help "Display some information about YASnippet"])))
;; Now for the stuff that has direct keybindings
;;
(define-key map [(tab)] 'yas-expand)
(define-key map (kbd "TAB") 'yas-expand)
(define-key map "\C-c&\C-s" 'yas-insert-snippet)
(define-key map "\C-c&\C-n" 'yas-new-snippet)
(define-key map "\C-c&\C-v" 'yas-visit-snippet-file)
map))
(defvar yas-minor-mode-map (yas--init-minor-keymap)
"The keymap used when `yas-minor-mode' is active.")
:help "Display some information about YASnippet"]))
(defvar yas--extra-modes nil
"An internal list of modes for which to also lookup snippets.