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.
--- /dev/null
+;;; 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
(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"))
;;; 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)