Fix the toggle behavior of prelude-mode.

This commit is contained in:
Bozhidar Batsov 2013-01-13 16:16:17 +02:00
parent 91a4c94730
commit 5a8a724abb

View file

@ -54,52 +54,57 @@
map) map)
"Keymap for Prelude mode.") "Keymap for Prelude mode.")
(easy-menu-add-item nil '("Tools") (defun prelude-mode-add-menu ()
'("Prelude" (easy-menu-add-item nil '("Tools")
("Files" '("Prelude"
["Open with..." prelude-open-with] ("Files"
["Delete file and buffer" prelude-delete-file-and-buffer] ["Open with..." prelude-open-with]
["Rename file and buffer" prelude-rename-file-and-buffer] ["Delete file and buffer" prelude-delete-file-and-buffer]
["Copy file name to clipboard" prelude-copy-file-name-to-clipboard]) ["Rename file and buffer" prelude-rename-file-and-buffer]
["Copy file name to clipboard" prelude-copy-file-name-to-clipboard])
("Buffers" ("Buffers"
["Clean up buffer" prelude-cleanup-buffer] ["Clean up buffer" prelude-cleanup-buffer]
["Kill other buffers" prelude-kill-other-buffers]) ["Kill other buffers" prelude-kill-other-buffers])
("Editing" ("Editing"
["Insert empty line" prelude-insert-empty-line] ["Insert empty line" prelude-insert-empty-line]
["Move line up" prelude-move-line-up] ["Move line up" prelude-move-line-up]
["Move line down" prelude-move-line-down] ["Move line down" prelude-move-line-down]
["Indent buffer" prelude-indent-buffer] ["Indent buffer" prelude-indent-buffer]
["Indent buffer or region" prelude-indent-buffer-or-region] ["Indent buffer or region" prelude-indent-buffer-or-region]
["Duplicate line or region" prelude-duplicate-current-line-or-region] ["Duplicate line or region" prelude-duplicate-current-line-or-region]
["Copy to clipboard as blockquote" prelude-indent-blockquote-and-copy-to-clipboard] ["Copy to clipboard as blockquote" prelude-indent-blockquote-and-copy-to-clipboard]
["Copy to clipboard as nested blockqoute" prelude-indent-nested-blockquote-and-copy-to-clipboard] ["Copy to clipboard as nested blockqoute" prelude-indent-nested-blockquote-and-copy-to-clipboard]
["Insert date" prelude-insert-date] ["Insert date" prelude-insert-date]
["Eval and replace" prelude-eval-and-replace]) ["Eval and replace" prelude-eval-and-replace])
("Navigation" ("Navigation"
["Helm" helm-prelude]) ["Helm" helm-prelude])
("Windows" ("Windows"
["Swap windows" prelude-swap-windows]) ["Swap windows" prelude-swap-windows])
("General" ("General"
["Visit term buffer" prelude-visit-term-buffer] ["Visit term buffer" prelude-visit-term-buffer]
["Search in Google" prelude-google] ["Search in Google" prelude-google]
["View URL" prelude-view-url])) ["View URL" prelude-view-url]))
"Search Files (Grep)...") "Search Files (Grep)...")
(easy-menu-add-item nil '("Tools") '("----") "Search Files (Grep)...") (easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
(defun prelude-mode-remove-menu ()
(easy-menu-remove-item nil '("Tools") "Prelude")
(easy-menu-remove-item nil '("Tools") "--"))
;; define minor mode ;; define minor mode
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on) (define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
(defun prelude-on () (defun prelude-on ()
(prelude-mode t)) (prelude-mode +1))
(defun prelude-off () (defun prelude-off ()
(easy-menu-remove)) (prelude-mode -1))
(define-minor-mode prelude-mode (define-minor-mode prelude-mode
"Minor mode to consolidate Emacs Prelude extensions. "Minor mode to consolidate Emacs Prelude extensions.
@ -109,8 +114,9 @@
:keymap prelude-mode-map :keymap prelude-mode-map
(if prelude-mode (if prelude-mode
;; on start ;; on start
(prelude-mode-add-menu)
;; on stop ;; on stop
(prelude-off))) (prelude-mode-remove-menu)))
(provide 'prelude-mode) (provide 'prelude-mode)
;;; prelude-mode.el ends here ;;; prelude-mode.el ends here