emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/erc/erc-menu.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/erc/erc-menu.el,v
Date: Wed, 17 Jan 2007 18:17:26 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     07/01/17 18:17:25

Index: lisp/erc/erc-menu.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/erc/erc-menu.el,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- lisp/erc/erc-menu.el        20 Nov 2006 06:50:29 -0000      1.4
+++ lisp/erc/erc-menu.el        17 Jan 2007 18:17:24 -0000      1.5
@@ -28,7 +28,7 @@
 
 ;;; Code:
 
-;(require 'erc)
+(require 'erc)
 (require 'easymenu)
 
 (defvar erc-menu-definition
@@ -40,10 +40,12 @@
         (and erc-server-connected (fboundp 'erc-list-channels))]
        ["Join channel..." erc-join-channel erc-server-connected]
        ["Start a query..." erc-cmd-QUERY erc-server-connected]
+       ["Input action..." erc-input-action (erc-default-target)]
        "-"
+       (list
+        "Current channel"
        ["List users in channel" erc-channel-names erc-channel-users]
        ["List channel operators" erc-cmd-OPS erc-channel-users]
-       ["Input action..." erc-input-action (erc-default-target)]
        ["Set topic..." erc-set-topic
         (and (and (erc-default-target) (not (erc-query-buffer-p)))
              (or (not (member "t" erc-channel-modes))
@@ -74,7 +76,7 @@
              ["Set a key..." erc-set-channel-key
               (erc-channel-user-op-p (erc-current-nick))])
        ["Leave this channel..." erc-part-from-channel erc-channel-users]
-       "-"
+        "-")
        (list "Pals, fools and other keywords"
              ["Add pal..." erc-add-pal]
              ["Delete pal..." erc-delete-pal]
@@ -98,16 +100,46 @@
        ["Show ERC version" erc-version t])
   "ERC menu definition.")
 
-;; `erc-mode-map' must be defined before doing this
-(eval-after-load "erc"
-  '(progn
+(defvar erc-menu-defined nil
+  "Internal variable used to keep track of whether we've defined the
+ERC menu yet.")
+
+;;;###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)
-     (easy-menu-add erc-menu erc-mode-map)
-
-     ;; 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))))))
+     (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)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]