Clean up prelude-mode

* Move the mode menu top-level, so it's easier to discover
* Make prelude-mode a global mode and remove prelude-global-mode
This commit is contained in:
Bozhidar Batsov 2018-09-28 09:13:55 +03:00
parent 598fdd8392
commit fef1988eac
2 changed files with 36 additions and 65 deletions

View file

@ -373,7 +373,7 @@ indent yanked text (with prefix arg don't indent)."
(add-hook 'compilation-filter-hook #'prelude-colorize-compilation-buffer) (add-hook 'compilation-filter-hook #'prelude-colorize-compilation-buffer)
;; enable Prelude's keybindings ;; enable Prelude's keybindings
(prelude-global-mode t) (prelude-mode t)
;; sensible undo ;; sensible undo
(global-undo-tree-mode) (global-undo-tree-mode)

View file

@ -79,13 +79,8 @@
(define-key map (kbd "s-m f") 'magit-log-buffer-file) (define-key map (kbd "s-m f") 'magit-log-buffer-file)
(define-key map (kbd "s-m b") 'magit-blame) (define-key map (kbd "s-m b") 'magit-blame)
(define-key map (kbd "s-o") 'crux-smart-open-line-above) (define-key map (kbd "s-o") 'crux-smart-open-line-above)
(easy-menu-define prelude-mode-menu map
map) "Prelude's menu."
"Keymap for Prelude mode.")
(defun prelude-mode-add-menu ()
"Add a menu entry for `prelude-mode' under Tools."
(easy-menu-add-item nil '("Tools")
'("Prelude" '("Prelude"
("Files" ("Files"
["Open with..." crux-open-with] ["Open with..." crux-open-with]
@ -95,11 +90,9 @@
["Find init file" crux-find-user-init-file] ["Find init file" crux-find-user-init-file]
["Find custom file" crux-find-user-custom-file] ["Find custom file" crux-find-user-custom-file]
["Find shell config file" crux-find-shell-init-file]) ["Find shell config file" crux-find-shell-init-file])
("Buffers" ("Buffers"
["Clean up buffer or region" crux-cleanup-buffer-or-region] ["Clean up buffer or region" crux-cleanup-buffer-or-region]
["Kill other buffers" crux-kill-other-buffers]) ["Kill other buffers" crux-kill-other-buffers])
("Editing" ("Editing"
["Go to beginning of line" crux-move-beginning-of-line] ["Go to beginning of line" crux-move-beginning-of-line]
["Kill line" crux-smart-kill-line] ["Kill line" crux-smart-kill-line]
@ -112,24 +105,16 @@
["Indent rigidly and copy to clipboard" crux-indent-rigidly-and-copy-to-clipboard] ["Indent rigidly and copy to clipboard" crux-indent-rigidly-and-copy-to-clipboard]
["Indent defun" crux-indent-defun] ["Indent defun" crux-indent-defun]
["Insert date" crux-insert-date] ["Insert date" crux-insert-date]
["Eval and replace" crux-eval-and-replace] ["Eval and replace" crux-eval-and-replace])
)
("Windows" ("Windows"
["Swap windows" crux-swap-windows]) ["Swap windows" crux-swap-windows])
("General" ("General"
["Visit term buffer" crux-visit-term-buffer] ["Visit term buffer" crux-visit-term-buffer]
["Search in Google" prelude-google] ["Search in Google" prelude-google]
["View URL" crux-view-url])) ["View URL" crux-view-url]))
"Search Files (Grep)...") "Search Files (Grep)...")
map)
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)...")) "Keymap for Prelude mode.")
(defun prelude-mode-remove-menu ()
"Remove `prelude-mode' menu entry."
(easy-menu-remove-item nil '("Tools") "Prelude")
(easy-menu-remove-item nil '("Tools") "--"))
;; define minor mode ;; define minor mode
(define-minor-mode prelude-mode (define-minor-mode prelude-mode
@ -138,21 +123,7 @@
\\{prelude-mode-map}" \\{prelude-mode-map}"
:lighter " Pre" :lighter " Pre"
:keymap prelude-mode-map :keymap prelude-mode-map
(if prelude-mode :global t)
;; on start
(prelude-mode-add-menu)
;; on stop
(prelude-mode-remove-menu)))
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
(defun prelude-on ()
"Turn on `prelude-mode'."
(prelude-mode +1))
(defun prelude-off ()
"Turn off `prelude-mode'."
(prelude-mode -1))
(provide 'prelude-mode) (provide 'prelude-mode)
;;; prelude-mode.el ends here ;;; prelude-mode.el ends here