From: ueno Date: Thu, 29 May 2003 23:29:25 +0000 (+0000) Subject: * riece-ctcp.el (riece-ctcp-insinuate): New function. X-Git-Tag: riece-0_0_2~16 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d01e88cc6fd9112bc2a624da088626c10550d76;p=elisp%2Friece.git * riece-ctcp.el (riece-ctcp-insinuate): New function. * riece-options.el (riece-addons): New user option. (riece-addon-directory): New user option. * riece.el (riece-load-and-build-addon-dependencies): New function. (riece-insinuate-addons): New function. (riece): Call riece-insinuate-addons. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 869da0f..5b14373 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2003-05-29 Daiki Ueno + * riece-ctcp.el (riece-ctcp-insinuate): New function. + + * riece-options.el (riece-addons): New user option. + (riece-addon-directory): New user option. + + * riece.el (riece-load-and-build-addon-dependencies): New function. + (riece-insinuate-addons): New function. + (riece): Call riece-insinuate-addons. + * riece-misc.el (riece-get-users-on-server): Moved from riece-commands.el. diff --git a/lisp/riece-ctcp.el b/lisp/riece-ctcp.el index 87e6adb..51fc346 100644 --- a/lisp/riece-ctcp.el +++ b/lisp/riece-ctcp.el @@ -29,15 +29,13 @@ (defvar riece-ctcp-ping-time nil) -(add-hook 'riece-privmsg-hook 'riece-handle-ctcp-request) -(add-hook 'riece-notice-hook 'riece-handle-ctcp-response) - (defvar riece-dialogue-mode-map) -(eval-after-load "riece" - '(progn - (define-key riece-dialogue-mode-map "\C-cv" 'riece-command-ctcp-version) - (define-key riece-dialogue-mode-map "\C-cp" 'riece-command-ctcp-ping))) +(defun riece-ctcp-insinuate () + (add-hook 'riece-privmsg-hook 'riece-handle-ctcp-request) + (add-hook 'riece-notice-hook 'riece-handle-ctcp-response) + (define-key riece-dialogue-mode-map "\C-cv" 'riece-command-ctcp-version) + (define-key riece-dialogue-mode-map "\C-cp" 'riece-command-ctcp-ping)) (defun riece-handle-ctcp-request (prefix string) (when (and prefix string diff --git a/lisp/riece-options.el b/lisp/riece-options.el index 7c7515e..e4263fa 100644 --- a/lisp/riece-options.el +++ b/lisp/riece-options.el @@ -68,20 +68,6 @@ :type '(repeat integer) :group 'riece-looks) -(defcustom riece-icon-directory nil - "Location of the icon directory." - :type 'directory - :group 'riece-looks) - -(defcustom riece-user-image-alist - '((?@ . "ball.red.xpm") - (?+ . "ball.gray.xpm") - (? . "ball.blank.xpm")) - "An alist of icons to display user's mode." - :type '(repeat (list (character :tag "Mark") - (string :tag "XPM file"))) - :group 'riece-looks) - (defcustom riece-inhibit-startup-message nil "If non-nil, the startup message will not be displayed." :group 'riece-looks @@ -91,6 +77,12 @@ "Where to look for data files." :type 'directory :group 'riece-options) + +(defcustom riece-addon-directory + (expand-file-name "addons" riece-directory) + "Where to look for add-on files." + :type 'directory + :group 'riece-options) (defcustom riece-variables-file (expand-file-name "init" riece-directory) @@ -113,6 +105,11 @@ way is to put Riece variables on .emacs or file loaded from there." :type '(repeat (file :tag "Initialization File")) :group 'riece-options) +(defcustom riece-addons nil + "Add-ons insinuated into Riece." + :type '(repeat symbol) + :group 'riece-options) + (defgroup riece-server nil "Server settings" :prefix "riece-" diff --git a/lisp/riece.el b/lisp/riece.el index 75f38e7..676fc05 100644 --- a/lisp/riece.el +++ b/lisp/riece.el @@ -245,9 +245,9 @@ If optional argument SAFE is nil, overwrite previous definitions." If optional argument CONFIRM is non-nil, ask which IRC server to connect. If already connected, just pop up the windows." (interactive "P") - (riece-read-variables-files - (car command-line-args-left)) - (pop command-line-args-left) + (riece-read-variables-files (if noninteractive + (car command-line-args-left))) + (riece-insinuate-addons riece-addons) (run-hooks 'riece-after-load-startup-hook) (if (riece-server-opened) (riece-configure-windows) @@ -413,6 +413,57 @@ Instead, these commands are available: (funcall (cdr (car alist)))) (setq alist (cdr alist)))))) +(defun riece-load-and-build-addon-dependencies (addons) + (let ((load-path (cons riece-addon-directory load-path)) + dependencies) + (while addons + (require (car addons)) ;error will be reported here + (let* ((requires + (funcall (or (intern-soft (concat (symbol-name (car addons)) + "-requires")) + #'ignore))) + (pointer requires) + entry) + (while pointer + (if (setq entry (assq (car pointer) dependencies)) + (setcar (cdr entry) (1+ (nth 1 entry))) + (push (list (car pointer) 1 nil) dependencies)) + (setq pointer (cdr pointer))) + (if (setq entry (assq (car addons) dependencies)) + (setcar (nthcdr 2 entry) requires) + (push (list (car addons) 0 requires) dependencies))) + (setq addons (cdr addons))) + dependencies)) + +(defun riece-insinuate-addons (addons) + (let* ((dependencies (riece-load-and-build-addon-dependencies addons)) + (pointer dependencies) + queue) + (while pointer + (when (zerop (nth 1 (car pointer))) + (setq dependencies (delq (car pointer) dependencies)) + (push (car pointer) queue)) + (setq pointer (cdr pointer))) + (setq addons nil) + (while queue + (push (car (car queue)) addons) + (setq pointer (nth 2 (car queue))) + (while pointer + (let* ((entry (assq (car pointer) dependencies)) + (count (1- (nth 1 entry)))) + (if (zerop count) + (progn + (setq dependencies (delq entry dependencies) + queue (nconc queue (list entry)))) + (setcar (cdr entry) count))) + (setq pointer (cdr pointer)))) + (if dependencies + (error "Circular dependency found")) + (while addons + (require (car addons)) ;implicit dependency + (funcall (intern (concat (symbol-name (car addons)) "-insinuate"))) + (setq addons (cdr addons))))) + (provide 'riece) ;;; riece.el ends here