mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
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:
parent
d809e886e0
commit
b36a4f7449
@ -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
|
||||
|
223
yasnippet.el
223
yasnippet.el
@ -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,127 +533,121 @@ 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
|
||||
"Menu used when `yas-minor-mode' is active."
|
||||
'("YASnippet"
|
||||
"----"
|
||||
["Expand trigger" yas-expand
|
||||
:help "Possibly expand tab trigger before point"]
|
||||
["Insert at point..." yas-insert-snippet
|
||||
:help "Prompt for an expandable snippet and expand it at point"]
|
||||
["New snippet..." yas-new-snippet
|
||||
:help "Create a new snippet in an appropriate directory"]
|
||||
["Visit snippet file..." yas-visit-snippet-file
|
||||
:help "Prompt for an expandable snippet and find its file"]
|
||||
"----"
|
||||
("Snippet menu behaviour"
|
||||
["Visit snippets" (setq yas-visit-from-menu t)
|
||||
:help "Visit snippets from the menu"
|
||||
:active t :style radio :selected yas-visit-from-menu]
|
||||
["Expand snippets" (setq yas-visit-from-menu nil)
|
||||
:help "Expand snippets from the menu"
|
||||
:active t :style radio :selected (not yas-visit-from-menu)]
|
||||
"----"
|
||||
["Show all known modes" (setq yas-use-menu 'full)
|
||||
:help "Show one snippet submenu for each loaded table"
|
||||
:active t :style radio :selected (eq yas-use-menu 'full)]
|
||||
["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate)
|
||||
:help "Show only snippet submenus for the current active modes"
|
||||
:active t :style radio :selected (eq yas-use-menu 'abbreviate)])
|
||||
("Indenting"
|
||||
["Auto" (setq yas-indent-line 'auto)
|
||||
:help "Indent each line of the snippet with `indent-according-to-mode'"
|
||||
:active t :style radio :selected (eq yas-indent-line 'auto)]
|
||||
["Fixed" (setq yas-indent-line 'fixed)
|
||||
:help "Indent the snippet to the current column"
|
||||
:active t :style radio :selected (eq yas-indent-line 'fixed)]
|
||||
["None" (setq yas-indent-line 'none)
|
||||
:help "Don't apply any particular snippet indentation after expansion"
|
||||
:active t :style radio :selected (not (member yas-indent-line '(fixed auto)))]
|
||||
"----"
|
||||
["Also auto indent first line" (setq yas-also-auto-indent-first-line
|
||||
(not yas-also-auto-indent-first-line))
|
||||
:help "When auto-indenting also, auto indent the first line menu"
|
||||
:active (eq yas-indent-line 'auto)
|
||||
:style toggle :selected yas-also-auto-indent-first-line]
|
||||
)
|
||||
("Prompting method"
|
||||
["System X-widget" (setq yas-prompt-functions
|
||||
(cons 'yas-x-prompt
|
||||
(remove 'yas-x-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use your windowing system's (gtk, mac, windows, etc...) default menu"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-x-prompt)]
|
||||
["Dropdown-list" (setq yas-prompt-functions
|
||||
(cons 'yas-dropdown-prompt
|
||||
(remove 'yas-dropdown-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use a special dropdown list"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-dropdown-prompt)]
|
||||
["Ido" (setq yas-prompt-functions
|
||||
(cons 'yas-ido-prompt
|
||||
(remove 'yas-ido-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use an ido-style minibuffer prompt"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-ido-prompt)]
|
||||
["Completing read" (setq yas-prompt-functions
|
||||
(cons 'yas-completing-prompt
|
||||
(remove 'yas-completing-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use a normal minibuffer prompt"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-completing-prompt)]
|
||||
)
|
||||
("Misc"
|
||||
["Wrap region in exit marker"
|
||||
(setq yas-wrap-around-region
|
||||
(not yas-wrap-around-region))
|
||||
:help "If non-nil automatically wrap the selected text in the $0 snippet exit"
|
||||
:style toggle :selected yas-wrap-around-region]
|
||||
["Allow stacked expansions "
|
||||
(setq yas-triggers-in-field
|
||||
(not yas-triggers-in-field))
|
||||
:help "If non-nil allow snippets to be triggered inside other snippet fields"
|
||||
:style toggle :selected yas-triggers-in-field]
|
||||
["Revive snippets on undo "
|
||||
(setq yas-snippet-revival
|
||||
(not yas-snippet-revival))
|
||||
:help "If non-nil allow snippets to become active again after undo"
|
||||
:style toggle :selected yas-snippet-revival]
|
||||
["Good grace "
|
||||
(setq yas-good-grace
|
||||
(not yas-good-grace))
|
||||
:help "If non-nil don't raise errors in bad embedded elisp in snippets"
|
||||
:style toggle :selected yas-good-grace]
|
||||
)
|
||||
"----"
|
||||
["Load snippets..." yas-load-directory
|
||||
:help "Load snippets from a specific directory"]
|
||||
["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)
|
||||
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"
|
||||
"----"
|
||||
["Expand trigger" yas-expand
|
||||
:help "Possibly expand tab trigger before point"]
|
||||
["Insert at point..." yas-insert-snippet
|
||||
:help "Prompt for an expandable snippet and expand it at point"]
|
||||
["New snippet..." yas-new-snippet
|
||||
:help "Create a new snippet in an appropriate directory"]
|
||||
["Visit snippet file..." yas-visit-snippet-file
|
||||
:help "Prompt for an expandable snippet and find its file"]
|
||||
"----"
|
||||
("Snippet menu behaviour"
|
||||
["Visit snippets" (setq yas-visit-from-menu t)
|
||||
:help "Visit snippets from the menu"
|
||||
:active t :style radio :selected yas-visit-from-menu]
|
||||
["Expand snippets" (setq yas-visit-from-menu nil)
|
||||
:help "Expand snippets from the menu"
|
||||
:active t :style radio :selected (not yas-visit-from-menu)]
|
||||
"----"
|
||||
["Show all known modes" (setq yas-use-menu 'full)
|
||||
:help "Show one snippet submenu for each loaded table"
|
||||
:active t :style radio :selected (eq yas-use-menu 'full)]
|
||||
["Abbreviate according to current mode" (setq yas-use-menu 'abbreviate)
|
||||
:help "Show only snippet submenus for the current active modes"
|
||||
:active t :style radio :selected (eq yas-use-menu 'abbreviate)])
|
||||
("Indenting"
|
||||
["Auto" (setq yas-indent-line 'auto)
|
||||
:help "Indent each line of the snippet with `indent-according-to-mode'"
|
||||
:active t :style radio :selected (eq yas-indent-line 'auto)]
|
||||
["Fixed" (setq yas-indent-line 'fixed)
|
||||
:help "Indent the snippet to the current column"
|
||||
:active t :style radio :selected (eq yas-indent-line 'fixed)]
|
||||
["None" (setq yas-indent-line 'none)
|
||||
:help "Don't apply any particular snippet indentation after expansion"
|
||||
:active t :style radio :selected (not (member yas-indent-line '(fixed auto)))]
|
||||
"----"
|
||||
["Also auto indent first line" (setq yas-also-auto-indent-first-line
|
||||
(not yas-also-auto-indent-first-line))
|
||||
:help "When auto-indenting also, auto indent the first line menu"
|
||||
:active (eq yas-indent-line 'auto)
|
||||
:style toggle :selected yas-also-auto-indent-first-line]
|
||||
)
|
||||
("Prompting method"
|
||||
["System X-widget" (setq yas-prompt-functions
|
||||
(cons 'yas-x-prompt
|
||||
(remove 'yas-x-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use your windowing system's (gtk, mac, windows, etc...) default menu"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-x-prompt)]
|
||||
["Dropdown-list" (setq yas-prompt-functions
|
||||
(cons 'yas-dropdown-prompt
|
||||
(remove 'yas-dropdown-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use a special dropdown list"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-dropdown-prompt)]
|
||||
["Ido" (setq yas-prompt-functions
|
||||
(cons 'yas-ido-prompt
|
||||
(remove 'yas-ido-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use an ido-style minibuffer prompt"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-ido-prompt)]
|
||||
["Completing read" (setq yas-prompt-functions
|
||||
(cons 'yas-completing-prompt
|
||||
(remove 'yas-completing-prompt
|
||||
yas-prompt-functions)))
|
||||
:help "Use a normal minibuffer prompt"
|
||||
:active t :style radio :selected (eq (car yas-prompt-functions)
|
||||
'yas-completing-prompt)]
|
||||
)
|
||||
("Misc"
|
||||
["Wrap region in exit marker"
|
||||
(setq yas-wrap-around-region
|
||||
(not yas-wrap-around-region))
|
||||
:help "If non-nil automatically wrap the selected text in the $0 snippet exit"
|
||||
:style toggle :selected yas-wrap-around-region]
|
||||
["Allow stacked expansions "
|
||||
(setq yas-triggers-in-field
|
||||
(not yas-triggers-in-field))
|
||||
:help "If non-nil allow snippets to be triggered inside other snippet fields"
|
||||
:style toggle :selected yas-triggers-in-field]
|
||||
["Revive snippets on undo "
|
||||
(setq yas-snippet-revival
|
||||
(not yas-snippet-revival))
|
||||
:help "If non-nil allow snippets to become active again after undo"
|
||||
:style toggle :selected yas-snippet-revival]
|
||||
["Good grace "
|
||||
(setq yas-good-grace
|
||||
(not yas-good-grace))
|
||||
:help "If non-nil don't raise errors in bad embedded elisp in snippets"
|
||||
:style toggle :selected yas-good-grace]
|
||||
)
|
||||
"----"
|
||||
["Load snippets..." yas-load-directory
|
||||
:help "Load snippets from a specific directory"]
|
||||
["Reload everything" yas-reload-all
|
||||
:help "Cleanup stuff, reload snippets, rebuild menus"]
|
||||
["About" yas-about
|
||||
:help "Display some information about YASnippet"]))
|
||||
|
||||
(defvar yas--extra-modes nil
|
||||
"An internal list of modes for which to also lookup snippets.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user