* riece-server.el (riece-server-process-opened): New function.
authorueno <ueno>
Sun, 19 Oct 2003 06:24:25 +0000 (06:24 +0000)
committerueno <ueno>
Sun, 19 Oct 2003 06:24:25 +0000 (06:24 +0000)
(riece-server-opened): Use it.

* riece-url.el: Require 'riece-menu.
(riece-url-insinuate): Add "Open URL..." menu in
riece-command-mode-hook.

* riece-options.el (riece-addons): Add riece-menu.

* riece-menu.el: New add-on.
* COMPILE (riece-modules): Add riece-menu.
* Makefile.am (EXTRA_DIST): Add riece-menu.el

lisp/COMPILE
lisp/ChangeLog
lisp/Makefile.am
lisp/riece-menu.el [new file with mode: 0644]
lisp/riece-options.el
lisp/riece-server.el
lisp/riece-url.el

index 5e7f64e..0833c5a 100644 (file)
@@ -54,7 +54,8 @@
                riece-guess
                riece-history
                riece-button
-               riece-keyword))))
+               riece-keyword
+               riece-menu))))
 
 (defun riece-compile-modules (modules)
   (let ((load-path (cons nil load-path)))
index aae7b39..a109e84 100644 (file)
@@ -1,5 +1,20 @@
 2003-10-19  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-server.el (riece-server-process-opened): New function.
+       (riece-server-opened): Use it.
+
+       * riece-url.el: Require 'riece-menu.
+       (riece-url-insinuate): Add "Open URL..." menu in
+       riece-command-mode-hook.
+
+       * riece-options.el (riece-addons): Add riece-menu.
+
+       * riece-menu.el: New add-on.
+       * COMPILE (riece-modules): Add riece-menu.
+       * Makefile.am (EXTRA_DIST): Add riece-menu.el
+
+2003-10-19  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-version.el (riece-extended-version): Remove interactive spec.
        (riece-version): New command.
        * riece.el (riece-command-map): Bind "V" to riece-version.
index 7497cca..d079d7c 100644 (file)
@@ -9,7 +9,8 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \
        riece-ctcp.el riece-url.el riece-unread.el \
        riece-ndcc.el riece-rdcc.el riece-log.el riece-mini.el \
        riece-doctor.el riece-alias.el riece-layout.el riece-skk-kakutei.el \
-       riece-guess.el riece-history.el riece-button.el riece-keyword.el
+       riece-guess.el riece-history.el riece-button.el riece-keyword.el \
+       riece-menu.el
 
 CLEANFILES = auto-autoloads.el custom-load.el *.elc
 FLAGS ?= -batch -q -no-site-file
diff --git a/lisp/riece-menu.el b/lisp/riece-menu.el
new file mode 100644 (file)
index 0000000..7aede3a
--- /dev/null
@@ -0,0 +1,91 @@
+;;; riece-menu.el --- define command menu on menubar
+;; Copyright (C) 1998-2003 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Created: 1998-09-28
+;; Keywords: IRC, riece
+
+;; This file is part of Riece.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; To use, add the following line to your ~/.riece/init.el:
+;; (add-to-list 'riece-addons 'riece-menu)
+
+;;; Code:
+
+(defvar riece-menu-items
+  `("Riece"
+    ["Version" riece-version t]
+    "----"
+    ["Change Window Layout"
+     riece-command-change-layout t]
+    ["Toggle Freeze Channel Buffer"
+     riece-command-toggle-freeze t]
+    ["Toggle Freeze Channel Buffer Until Next Message"
+     riece-command-toggle-own-freeze t]
+    ["Toggle Display Channel Buffer"
+     riece-command-toggle-channel-buffer-mode t]
+    ["Toggle Display Channel List Buffer"
+     riece-command-toggle-channel-list-buffer-mode t]
+    ["Toggle Display User List Buffer"
+     riece-command-toggle-user-list-buffer-mode t]
+    "----"
+    ["Join Channel" riece-command-join t]
+    ["Change Nickname" riece-command-change-nickname t]
+    ["Quit IRC" riece-command-quit t]
+    "----"
+    ("Channels" :filter riece-menu-create-channels-menu)
+    ("Servers" :filter riece-menu-create-servers-menu))
+  "Menu used in command mode.")
+
+(defun riece-menu-create-channels-menu (menu)
+  (mapcar (lambda (channel)
+           (list (riece-format-identity channel)
+                 (vector "Switch To Channel"
+                         (list 'riece-command-switch-to-channel channel) t)
+                 (vector "Part Channel"
+                         (list 'riece-command-part channel) t)
+                 (vector "List Channel"
+                         (list 'riece-command-list
+                               (riece-identity-prefix channel)) t)))
+         riece-current-channels))
+
+(defun riece-menu-create-servers-menu (menu)
+  (mapcar (lambda (entry)
+           (list (car entry)
+                 (vector "Open Server"
+                         (list 'riece-command-open-server (car entry))
+                         (not (riece-server-opened (car entry))))
+                 (vector "Close Server"
+                         (list 'riece-command-close-server (car entry))
+                         (riece-server-opened (car entry)))))
+         riece-server-alist))
+
+(defun riece-menu-insinuate ()
+  (add-hook 'riece-command-mode-hook
+           (lambda ()
+             (easy-menu-define riece-menu
+                               riece-command-mode-map
+                               "Riece Menu"
+                               riece-menu-items)
+             (easy-menu-add riece-menu))))
+
+(provide 'riece-menu)
+
+;;; riece-menu.el ends here
index 700bfc2..93be792 100644 (file)
@@ -106,7 +106,8 @@ way is to put Riece variables on .emacs or file loaded from there."
                          riece-unread
                          riece-history
                          riece-url
-                         riece-button)
+                         riece-button
+                         riece-menu)
   "Add-ons insinuated into Riece."
   :type '(repeat symbol)
   :group 'riece-options)
index 7a918ff..b290d57 100644 (file)
@@ -202,13 +202,20 @@ the `riece-server-keyword-map' variable."
        (delq (rassq process riece-server-process-alist)
              riece-server-process-alist)))
 
+(defun riece-server-process-opened (process)
+  (memq (process-status process) '(open run)))
+
 (defun riece-server-opened (&optional server-name)
-  (let ((alist riece-server-process-alist))
-    (catch 'found
-      (while alist
-       (if (memq (process-status (cdr (car alist))) '(open run))
-           (throw 'found t))
-       (setq alist (cdr alist))))))
+  (if server-name
+      (let ((process (riece-server-process server-name)))
+       (and process
+            (riece-server-process-opened process)))
+    (let ((alist riece-server-process-alist))
+      (catch 'found
+       (while alist
+         (if (riece-server-process-opened (cdr (car alist)))
+             (throw 'found t))
+         (setq alist (cdr alist)))))))
 
 (eval-when-compile
   (autoload 'riece-exit "riece"))
index 8a62c18..942963b 100644 (file)
@@ -30,6 +30,7 @@
 ;;; Code:
 
 (require 'riece-options)
+(require 'riece-menu)                  ;riece-menu-items
 
 (defvar browse-url-browser-function)
 
    (list (completing-read "Open URL: " (mapcar #'list riece-urls))))
   (browse-url url))
 
+(defun riece-url-create-menu (menu)
+  (mapcar (lambda (url)
+           (vector url (list 'browse-url url)))
+         riece-urls))
+           
 (defvar riece-dialogue-mode-map)
 
 (defun riece-url-requires ()
-  (if (memq 'riece-highlight riece-addons)
-      '(riece-highlight)))
+  (append (if (memq 'riece-highlight riece-addons)
+             '(riece-highlight))
+         (if (memq 'riece-menu riece-addons)
+             '(riece-menu))))
 
 (defun riece-url-insinuate ()
   (add-hook 'riece-after-insert-functions 'riece-url-scan-region)
-  (define-key riece-dialogue-mode-map "U" 'riece-command-browse-url))
+  (define-key riece-dialogue-mode-map "U" 'riece-command-browse-url)
+  (if (memq 'riece-menu riece-addons)
+      (add-hook 'riece-command-mode-hook
+               (lambda ()
+                 (easy-menu-add-item
+                  nil (list (car riece-menu-items))
+                  '("Open URL..." :filter riece-url-create-menu)))
+               t)))
 
 (provide 'riece-url)