Corrected a bad ChangeLog comment by adding full information from the package
[emacs.git] / lisp / erc / erc-menu.el
blobdd2d9c2a6665d6224013d9dab208173750a9ddf2
1 ;; erc-menu.el -- Menu-bar definitions for ERC
3 ;; Copyright (C) 2001, 2002, 2004, 2005, 2006,
4 ;; 2007 Free Software Foundation, Inc.
6 ;; Author: Mario Lang <mlang@delysid.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, or (at your option)
14 ;; 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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; Loading this file defines a menu for ERC.
30 ;;; Code:
32 (require 'erc)
33 (require 'easymenu)
35 (defvar erc-menu-definition
36 (list "ERC"
37 ["Connect to server..." erc t]
38 ["Disconnect from server..." erc-quit-server erc-server-connected]
39 "-"
40 ["List channels..." erc-list-channels
41 (and erc-server-connected (fboundp 'erc-list-channels))]
42 ["Join channel..." erc-join-channel erc-server-connected]
43 ["Start a query..." erc-cmd-QUERY erc-server-connected]
44 ["Input action..." erc-input-action (erc-default-target)]
45 "-"
46 (list
47 "Current channel"
48 ["List users in channel" erc-channel-names erc-channel-users]
49 ["List channel operators" erc-cmd-OPS erc-channel-users]
50 ["Set topic..." erc-set-topic
51 (and (and (erc-default-target) (not (erc-query-buffer-p)))
52 (or (not (member "t" erc-channel-modes))
53 (erc-channel-user-op-p (erc-current-nick))))]
54 (list "Channel modes"
55 ["Change mode..." erc-insert-mode-command
56 (erc-channel-user-op-p (erc-current-nick))]
57 ["No external send" (erc-toggle-channel-mode "n")
58 :active (erc-channel-user-op-p (erc-current-nick))
59 :style toggle :selected (member "n" erc-channel-modes)]
60 ["Topic set by channel operator" (erc-toggle-channel-mode "t")
61 :style toggle :selected (member "t" erc-channel-modes)
62 :active (erc-channel-user-op-p (erc-current-nick))]
63 ["Invite only" (erc-toggle-channel-mode "i")
64 :style toggle :selected (member "i" erc-channel-modes)
65 :active (erc-channel-user-op-p (erc-current-nick))]
66 ["Private" (erc-toggle-channel-mode "p")
67 :style toggle :selected (member "p" erc-channel-modes)
68 :active (erc-channel-user-op-p (erc-current-nick))]
69 ["Secret" (erc-toggle-channel-mode "s")
70 :style toggle :selected (member "s" erc-channel-modes)
71 :active (erc-channel-user-op-p (erc-current-nick))]
72 ["Moderated" (erc-toggle-channel-mode "m")
73 :style toggle :selected (member "m" erc-channel-modes)
74 :active (erc-channel-user-op-p (erc-current-nick))]
75 ["Set a limit..." erc-set-channel-limit
76 (erc-channel-user-op-p (erc-current-nick))]
77 ["Set a key..." erc-set-channel-key
78 (erc-channel-user-op-p (erc-current-nick))])
79 ["Leave this channel..." erc-part-from-channel erc-channel-users])
80 "-"
81 (list "Pals, fools and other keywords"
82 ["Add pal..." erc-add-pal]
83 ["Delete pal..." erc-delete-pal]
84 ["Add fool..." erc-add-fool]
85 ["Delete fool..." erc-delete-fool]
86 ["Add keyword..." erc-add-keyword]
87 ["Delete keyword..." erc-delete-keyword]
88 ["Add dangerous host..." erc-add-dangerous-host]
89 ["Delete dangerous host..." erc-delete-dangerous-host])
90 "-"
91 (list "IRC services"
92 ["Identify to NickServ..." erc-nickserv-identify
93 (and erc-server-connected (functionp 'erc-nickserv-identify))])
94 "-"
95 ["Save buffer in log" erc-save-buffer-in-logs
96 (fboundp 'erc-save-buffer-in-logs)]
97 ["Truncate buffer" erc-truncate-buffer (fboundp 'erc-truncate-buffer)]
98 "-"
99 ["Customize ERC" (customize-group 'erc) t]
100 ["Enable/Disable ERC Modules" (customize-variable 'erc-modules) t]
101 ["Show ERC version" erc-version t])
102 "ERC menu definition.")
104 (defvar erc-menu-defined nil
105 "Internal variable used to keep track of whether we've defined the
106 ERC menu yet.")
108 ;;;###autoload (autoload 'erc-menu-mode "erc-menu" nil t)
109 (define-erc-module menu nil
110 "Enable a menu in ERC buffers."
111 ((unless erc-menu-defined
112 ;; make sure the menu only gets defined once, since Emacs 22
113 ;; activates it immediately
114 (easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
115 (setq erc-menu-defined t))
116 (if (featurep 'xemacs)
117 (progn
118 ;; the menu isn't automatically added to the menu bar in
119 ;; XEmacs
120 (add-hook 'erc-mode-hook 'erc-menu-add)
121 (dolist (buffer (erc-buffer-list))
122 (with-current-buffer buffer (erc-menu-add))))
123 (erc-menu-add)))
124 ((if (featurep 'xemacs)
125 (progn
126 (remove-hook 'erc-mode-hook 'erc-menu-add)
127 (dolist (buffer (erc-buffer-list))
128 (with-current-buffer buffer (erc-menu-remove))))
129 (erc-menu-remove)
130 ;; `easy-menu-remove' is a no-op in Emacs 22
131 (message "You might have to restart Emacs to remove the ERC menu"))))
133 ;; silence byte-compiler warning
134 (eval-when-compile
135 (defvar erc-menu nil))
137 (defun erc-menu-add ()
138 "Add the ERC menu to the current buffer."
139 (easy-menu-add erc-menu erc-mode-map))
141 (defun erc-menu-remove ()
142 "Remove the ERC menu from the current buffer."
143 (easy-menu-remove erc-menu))
145 (provide 'erc-menu)
147 ;;; erc-menu.el ends here
149 ;; Local Variables:
150 ;; indent-tabs-mode: t
151 ;; tab-width: 8
152 ;; End:
154 ;; arch-tag: 671219f2-b082-4753-a185-1d0c7e0c05bd