From: ueno Date: Sun, 19 Oct 2003 06:24:25 +0000 (+0000) Subject: * riece-server.el (riece-server-process-opened): New function. X-Git-Tag: riece-0_1_4~6 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=546d4091c6fa9860bed252b6e4c588db653586e1;p=elisp%2Friece.git * 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 --- diff --git a/lisp/COMPILE b/lisp/COMPILE index 5e7f64e..0833c5a 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -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))) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index aae7b39..a109e84 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,20 @@ 2003-10-19 Daiki Ueno + * 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 + * riece-version.el (riece-extended-version): Remove interactive spec. (riece-version): New command. * riece.el (riece-command-map): Bind "V" to riece-version. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index 7497cca..d079d7c 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -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 index 0000000..7aede3a --- /dev/null +++ b/lisp/riece-menu.el @@ -0,0 +1,91 @@ +;;; riece-menu.el --- define command menu on menubar +;; Copyright (C) 1998-2003 Daiki Ueno + +;; Author: Daiki Ueno +;; 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 diff --git a/lisp/riece-options.el b/lisp/riece-options.el index 700bfc2..93be792 100644 --- a/lisp/riece-options.el +++ b/lisp/riece-options.el @@ -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) diff --git a/lisp/riece-server.el b/lisp/riece-server.el index 7a918ff..b290d57 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -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")) diff --git a/lisp/riece-url.el b/lisp/riece-url.el index 8a62c18..942963b 100644 --- a/lisp/riece-url.el +++ b/lisp/riece-url.el @@ -30,6 +30,7 @@ ;;; Code: (require 'riece-options) +(require 'riece-menu) ;riece-menu-items (defvar browse-url-browser-function) @@ -63,15 +64,29 @@ (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)