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