[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [commit][emacs22] erc-menu: Turn this into a module
From: |
mwolson |
Subject: |
[Erc-commit] [commit][emacs22] erc-menu: Turn this into a module |
Date: |
Sun, 14 Oct 2007 00:48:38 -0400 |
commit 075c79c4fb39e1091776ca504c1112ed8df5ce99
Author: Michael Olson <address@hidden>
Date: Sun Jan 7 03:49:14 2007 +0000
erc-menu: Turn this into a module
2007-01-07 Michael Olson <address@hidden>
* erc.el (erc-modules): Add the menu module. This should fix a
bug with incorrect ERC submenus being displayed.
* erc-menu.el: Turn this into a module.
(erc-menu-add, erc-menu-remove): New functions that add and remove
the ERC menu.
git-archimport-id: address@hidden/erc--main--0--patch-78
diff --git a/ChangeLog b/ChangeLog
index 61b05c0..51ba380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-01-07 Michael Olson <address@hidden>
+
+ * erc.el (erc-modules): Add the menu module. This should fix a
+ bug with incorrect ERC submenus being displayed.
+
+ * erc-menu.el: Turn this into a module.
+ (erc-menu-add, erc-menu-remove): New functions that add and remove
+ the ERC menu.
+
2006-12-28 Michael Olson <address@hidden>
* erc-list.el: Change header to mention that this is part of ERC,
diff --git a/erc-menu.el b/erc-menu.el
index a2dc7a1..466ed23 100644
--- a/erc-menu.el
+++ b/erc-menu.el
@@ -28,7 +28,7 @@
;;; Code:
-;(require 'erc)
+(require 'erc)
(require 'easymenu)
(defvar erc-menu-definition
@@ -98,16 +98,46 @@
["Show ERC version" erc-version t])
"ERC menu definition.")
-;; `erc-mode-map' must be defined before doing this
-(eval-after-load "erc"
- '(progn
- (easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
- (easy-menu-add erc-menu erc-mode-map)
+(defvar erc-menu-defined nil
+ "Internal variable used to keep track of whether we've defined the
+ERC menu yet.")
- ;; for some reason the menu isn't automatically added to the menu bar
- (when (featurep 'xemacs)
- (add-hook 'erc-mode-hook
- (lambda () (easy-menu-add erc-menu erc-mode-map))))))
+;;;###autoload (autoload 'erc-menu-mode "erc-menu" nil t)
+(define-erc-module menu nil
+ "Enable a menu in ERC buffers."
+ ((unless erc-menu-defined
+ ;; make sure the menu only gets defined once, since Emacs 22
+ ;; activates it immediately
+ (easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
+ (setq erc-menu-defined t))
+ (if (featurep 'xemacs)
+ (progn
+ ;; the menu isn't automatically added to the menu bar in
+ ;; XEmacs
+ (add-hook 'erc-mode-hook 'erc-menu-add)
+ (dolist (buffer (erc-buffer-list))
+ (with-current-buffer buffer (erc-menu-add))))
+ (erc-menu-add)))
+ ((if (featurep 'xemacs)
+ (progn
+ (remove-hook 'erc-mode-hook 'erc-menu-add)
+ (dolist (buffer (erc-buffer-list))
+ (with-current-buffer buffer (erc-menu-remove))))
+ (erc-menu-remove)
+ ;; `easy-menu-remove' is a no-op in Emacs 22
+ (message "You might have to restart Emacs to remove the ERC menu"))))
+
+;; silence byte-compiler warning
+(eval-when-compile
+ (defvar erc-menu nil))
+
+(defun erc-menu-add ()
+ "Add the ERC menu to the current buffer."
+ (easy-menu-add erc-menu erc-mode-map))
+
+(defun erc-menu-remove ()
+ "Remove the ERC menu from the current buffer."
+ (easy-menu-remove erc-menu))
(provide 'erc-menu)
diff --git a/erc.el b/erc.el
index cd665e8..dd784c6 100644
--- a/erc.el
+++ b/erc.el
@@ -74,7 +74,6 @@
(require 'pp)
(require 'thingatpt)
(require 'erc-compat)
-(require 'erc-menu)
(defvar erc-official-location
"http://emacswiki.org/cgi-bin/wiki/ERC (mailing list: address@hidden)"
@@ -1784,7 +1783,7 @@ buffer rather than a server buffer.")
(defcustom erc-modules '(netsplit fill button match track completion readonly
ring autojoin noncommands irccontrols
- stamp list)
+ stamp menu list)
"A list of modules which ERC should enable.
If you set the value of this without using `customize' remember to call
\(erc-update-modules) after you change it. When using `customize', modules
@@ -1826,6 +1825,7 @@ removed from the list will be disabled."
(const :tag "List channels in a separate buffer" list)
(const :tag "Save buffers in logs" log)
(const :tag "Highlight pals, fools, and other keywords" match)
+ (const :tag "Display a menu in ERC buffers" menu)
(const :tag "Detect netsplits" netsplit)
(const :tag "Don't display non-IRC commands after evaluation"
noncommands)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [commit][emacs22] erc-menu: Turn this into a module,
mwolson <=