2003-05-29 Daiki Ueno <ueno@unixuser.org>
+ * 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.
(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
: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
"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)
: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-"
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)
(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