summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-salt.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-05-02 20:41:45 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2010-05-02 20:41:45 -0400
commitbbf52f1e6fdaca0197ce67b897eb69a006fff8ad (patch)
tree3c41f146a8835ff85ae32fe666e4348653a292ce /lisp/gnus/gnus-salt.el
parenta101e0fbac19df1d78912ee67d690d65d8f96ab0 (diff)
downloademacs-bbf52f1e6fdaca0197ce67b897eb69a006fff8ad.tar.gz
Use define-minor-mode in Gnus where applicable.
* mml.el (mml-mode): Use define-minor-mode. * gnus-undo.el (gnus-undo-mode-map): Initialize in declaration. (gnus-undo-mode): Use define-minor-mode. * gnus-sum.el (gnus-dead-summary-mode-map): Initialize in declaration. (gnus-dead-summary-mode): Use define-minor-mode. * gnus-salt.el (gnus-pick-mode-map, gnus-binary-mode-map): Initialize in declaration. (gnus-pick-mode, gnus-binary-mode): Use define-minor-mode. * gnus-ml.el (gnus-mailing-list-mode-map): Initialize in declaration. (gnus-mailing-list-mode): Use define-minor-mode. * gnus-draft.el (gnus-draft-mode-map): Initialize in declaration. (gnus-draft-mode): Use define-minor-mode. * gnus-dired.el (gnus-dired-mode-map): Initialize in declaration. (gnus-dired-mode): Use define-minor-mode.
Diffstat (limited to 'lisp/gnus/gnus-salt.el')
-rw-r--r--lisp/gnus/gnus-salt.el113
1 files changed, 48 insertions, 65 deletions
diff --git a/lisp/gnus/gnus-salt.el b/lisp/gnus/gnus-salt.el
index d729fada009..22e446629f2 100644
--- a/lisp/gnus/gnus-salt.el
+++ b/lisp/gnus/gnus-salt.el
@@ -35,10 +35,6 @@
;;; gnus-pick-mode
;;;
-(defvar gnus-pick-mode nil
- "Minor mode for providing a pick-and-read interface in Gnus
-summary buffers.")
-
(defcustom gnus-pick-display-summary nil
"*Display summary while reading."
:type 'boolean
@@ -72,17 +68,15 @@ It accepts the same format specs that `gnus-summary-line-format' does."
;;; Internal variables.
-(defvar gnus-pick-mode-map nil)
-
-(unless gnus-pick-mode-map
- (setq gnus-pick-mode-map (make-sparse-keymap))
-
- (gnus-define-keys gnus-pick-mode-map
- " " gnus-pick-next-page
- "u" gnus-pick-unmark-article-or-thread
- "." gnus-pick-article-or-thread
- gnus-down-mouse-2 gnus-pick-mouse-pick-region
- "\r" gnus-pick-start-reading))
+(defvar gnus-pick-mode-map
+ (let ((map (make-sparse-keymap)))
+ (gnus-define-keys map
+ " " gnus-pick-next-page
+ "u" gnus-pick-unmark-article-or-thread
+ "." gnus-pick-article-or-thread
+ gnus-down-mouse-2 gnus-pick-mouse-pick-region
+ "\r" gnus-pick-start-reading)
+ map))
(defun gnus-pick-make-menu-bar ()
(unless (boundp 'gnus-pick-menu)
@@ -104,30 +98,30 @@ It accepts the same format specs that `gnus-summary-line-format' does."
["Start reading" gnus-pick-start-reading t]
["Switch pick mode off" gnus-pick-mode gnus-pick-mode]))))
-(defun gnus-pick-mode (&optional arg)
+(define-minor-mode gnus-pick-mode
"Minor mode for providing a pick-and-read interface in Gnus summary buffers.
\\{gnus-pick-mode-map}"
- (interactive "P")
- (when (eq major-mode 'gnus-summary-mode)
- (if (not (set (make-local-variable 'gnus-pick-mode)
- (if (null arg) (not gnus-pick-mode)
- (> (prefix-numeric-value arg) 0))))
- (remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
- ;; Make sure that we don't select any articles upon group entry.
- (set (make-local-variable 'gnus-auto-select-first) nil)
- ;; Change line format.
- (setq gnus-summary-line-format gnus-summary-pick-line-format)
- (setq gnus-summary-line-format-spec nil)
- (gnus-update-format-specifications nil 'summary)
- (gnus-update-summary-mark-positions)
- (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
- (set (make-local-variable 'gnus-summary-goto-unread) 'never)
- ;; Set up the menu.
- (when (gnus-visual-p 'pick-menu 'menu)
- (gnus-pick-make-menu-bar))
- (add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map)
- (gnus-run-hooks 'gnus-pick-mode-hook))))
+ :lighter " Pick" :keymap gnus-pick-mode-map
+ (cond
+ ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-pick-mode nil))
+ ((not gnus-pick-mode)
+ ;; FIXME: a buffer-local minor mode removing globally from a hook??
+ (remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message))
+ (t
+ ;; Make sure that we don't select any articles upon group entry.
+ (set (make-local-variable 'gnus-auto-select-first) nil)
+ ;; Change line format.
+ (setq gnus-summary-line-format gnus-summary-pick-line-format)
+ (setq gnus-summary-line-format-spec nil)
+ (gnus-update-format-specifications nil 'summary)
+ (gnus-update-summary-mark-positions)
+ ;; FIXME: a buffer-local minor mode adding globally to a hook??
+ (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
+ (set (make-local-variable 'gnus-summary-goto-unread) 'never)
+ ;; Set up the menu.
+ (when (gnus-visual-p 'pick-menu 'menu)
+ (gnus-pick-make-menu-bar)))))
(defun gnus-pick-setup-message ()
"Make Message do the right thing on exit."
@@ -319,20 +313,14 @@ This must be bound to a button-down mouse event."
;;; gnus-binary-mode
;;;
-(defvar gnus-binary-mode nil
- "Minor mode for providing a binary group interface in Gnus summary buffers.")
-
(defvar gnus-binary-mode-hook nil
"Hook run in summary binary mode buffers.")
-(defvar gnus-binary-mode-map nil)
-
-(unless gnus-binary-mode-map
- (setq gnus-binary-mode-map (make-sparse-keymap))
-
- (gnus-define-keys
- gnus-binary-mode-map
- "g" gnus-binary-show-article))
+(defvar gnus-binary-mode-map
+ (let ((map (make-sparse-keymap)))
+ (gnus-define-keys map
+ "g" gnus-binary-show-article)
+ map))
(defun gnus-binary-make-menu-bar ()
(unless (boundp 'gnus-binary-menu)
@@ -341,25 +329,20 @@ This must be bound to a button-down mouse event."
'("Pick"
["Switch binary mode off" gnus-binary-mode t]))))
-(defun gnus-binary-mode (&optional arg)
+(define-minor-mode gnus-binary-mode
"Minor mode for providing a binary group interface in Gnus summary buffers."
- (interactive "P")
- (when (eq major-mode 'gnus-summary-mode)
- (make-local-variable 'gnus-binary-mode)
- (setq gnus-binary-mode
- (if (null arg) (not gnus-binary-mode)
- (> (prefix-numeric-value arg) 0)))
- (when gnus-binary-mode
- ;; Make sure that we don't select any articles upon group entry.
- (make-local-variable 'gnus-auto-select-first)
- (setq gnus-auto-select-first nil)
- (make-local-variable 'gnus-summary-display-article-function)
- (setq gnus-summary-display-article-function 'gnus-binary-display-article)
- ;; Set up the menu.
- (when (gnus-visual-p 'binary-menu 'menu)
- (gnus-binary-make-menu-bar))
- (add-minor-mode 'gnus-binary-mode " Binary" gnus-binary-mode-map)
- (gnus-run-hooks 'gnus-binary-mode-hook))))
+ :lighter " Binary" :keymap gnus-binary-mode-map
+ (cond
+ ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-binary-mode nil))
+ (gnus-binary-mode
+ ;; Make sure that we don't select any articles upon group entry.
+ (make-local-variable 'gnus-auto-select-first)
+ (setq gnus-auto-select-first nil)
+ (make-local-variable 'gnus-summary-display-article-function)
+ (setq gnus-summary-display-article-function 'gnus-binary-display-article)
+ ;; Set up the menu.
+ (when (gnus-visual-p 'binary-menu 'menu)
+ (gnus-binary-make-menu-bar)))))
(defun gnus-binary-display-article (article &optional all-header)
"Run ARTICLE through the binary decode functions."