Don’t double-encode non-ASCII for mail client
[emacs.git] / lisp / erc / erc-menu.el
blob0832fb891d50a8d25310bdb0a2bacaaa0f66657b
1 ;; erc-menu.el -- Menu-bar definitions for ERC
3 ;; Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc.
5 ;; Author: Mario Lang <mlang@delysid.org>
6 ;; Maintainer: emacs-devel@gnu.org
7 ;; Keywords: comm, processes, menu
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; Loading this file defines a menu for ERC.
28 ;;; Code:
30 (require 'erc)
31 (require 'easymenu)
33 (defgroup erc-menu nil
34 "ERC menu support."
35 :group 'erc)
37 (defvar erc-menu-definition
38 (list "ERC"
39 ["Connect to server..." erc t]
40 ["Disconnect from server..." erc-quit-server erc-server-connected]
41 "-"
42 ["List channels..." erc-list-channels
43 (and erc-server-connected (fboundp 'erc-list-channels))]
44 ["Join channel..." erc-join-channel erc-server-connected]
45 ["Start a query..." erc-cmd-QUERY erc-server-connected]
46 ["Input action..." erc-input-action (erc-default-target)]
47 "-"
48 (list
49 "Current channel"
50 ["List users in channel" erc-channel-names erc-channel-users]
51 ["List channel operators" erc-cmd-OPS erc-channel-users]
52 ["Set topic..." erc-set-topic
53 (and (and (erc-default-target) (not (erc-query-buffer-p)))
54 (or (not (member "t" erc-channel-modes))
55 (erc-channel-user-op-p (erc-current-nick))))]
56 (list "Channel modes"
57 ["Change mode..." erc-insert-mode-command
58 (erc-channel-user-op-p (erc-current-nick))]
59 ["No external send" (erc-toggle-channel-mode "n")
60 :active (erc-channel-user-op-p (erc-current-nick))
61 :style toggle :selected (member "n" erc-channel-modes)]
62 ["Topic set by channel operator" (erc-toggle-channel-mode "t")
63 :style toggle :selected (member "t" erc-channel-modes)
64 :active (erc-channel-user-op-p (erc-current-nick))]
65 ["Invite only" (erc-toggle-channel-mode "i")
66 :style toggle :selected (member "i" erc-channel-modes)
67 :active (erc-channel-user-op-p (erc-current-nick))]
68 ["Private" (erc-toggle-channel-mode "p")
69 :style toggle :selected (member "p" erc-channel-modes)
70 :active (erc-channel-user-op-p (erc-current-nick))]
71 ["Secret" (erc-toggle-channel-mode "s")
72 :style toggle :selected (member "s" erc-channel-modes)
73 :active (erc-channel-user-op-p (erc-current-nick))]
74 ["Moderated" (erc-toggle-channel-mode "m")
75 :style toggle :selected (member "m" erc-channel-modes)
76 :active (erc-channel-user-op-p (erc-current-nick))]
77 ["Set a limit..." erc-set-channel-limit
78 (erc-channel-user-op-p (erc-current-nick))]
79 ["Set a key..." erc-set-channel-key
80 (erc-channel-user-op-p (erc-current-nick))])
81 ["Leave this channel..." erc-part-from-channel erc-channel-users])
82 "-"
83 (list "Pals, fools and other keywords"
84 ["Add pal..." erc-add-pal]
85 ["Delete pal..." erc-delete-pal]
86 ["Add fool..." erc-add-fool]
87 ["Delete fool..." erc-delete-fool]
88 ["Add keyword..." erc-add-keyword]
89 ["Delete keyword..." erc-delete-keyword]
90 ["Add dangerous host..." erc-add-dangerous-host]
91 ["Delete dangerous host..." erc-delete-dangerous-host])
92 "-"
93 (list "IRC services"
94 ["Identify to NickServ..." erc-nickserv-identify
95 (and erc-server-connected (functionp 'erc-nickserv-identify))])
96 "-"
97 ["Save buffer in log" erc-save-buffer-in-logs
98 (fboundp 'erc-save-buffer-in-logs)]
99 ["Truncate buffer" erc-truncate-buffer (fboundp 'erc-truncate-buffer)]
101 ["Customize ERC" (customize-group 'erc) t]
102 ["Enable/Disable ERC Modules" (customize-variable 'erc-modules) t]
103 ["Show ERC version" erc-version t])
104 "ERC menu definition.")
106 (defvar erc-menu-defined nil
107 "Internal variable used to keep track of whether we've defined the
108 ERC menu yet.")
110 ;;;###autoload (autoload 'erc-menu-mode "erc-menu" nil t)
111 (define-erc-module menu nil
112 "Enable a menu in ERC buffers."
113 ((unless erc-menu-defined
114 ;; make sure the menu only gets defined once, since Emacs 22
115 ;; activates it immediately
116 (easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
117 (setq erc-menu-defined t))
118 (if (featurep 'xemacs)
119 (progn
120 ;; the menu isn't automatically added to the menu bar in
121 ;; XEmacs
122 (add-hook 'erc-mode-hook 'erc-menu-add)
123 (dolist (buffer (erc-buffer-list))
124 (with-current-buffer buffer (erc-menu-add))))
125 (erc-menu-add)))
126 ((if (featurep 'xemacs)
127 (progn
128 (remove-hook 'erc-mode-hook 'erc-menu-add)
129 (dolist (buffer (erc-buffer-list))
130 (with-current-buffer buffer (erc-menu-remove))))
131 (erc-menu-remove)
132 ;; `easy-menu-remove' is a no-op in Emacs 22
133 (message "You might have to restart Emacs to remove the ERC menu"))))
135 ;; silence byte-compiler warning
136 (defvar erc-menu)
138 (defun erc-menu-add ()
139 "Add the ERC menu to the current buffer."
140 (easy-menu-add erc-menu erc-mode-map))
142 (defun erc-menu-remove ()
143 "Remove the ERC menu from the current buffer."
144 (easy-menu-remove erc-menu))
146 (provide 'erc-menu)
148 ;;; erc-menu.el ends here
150 ;; Local Variables:
151 ;; indent-tabs-mode: t
152 ;; tab-width: 8
153 ;; End: