From 29f34b3ea80a1f37453bd92e1e1193d69a2c612e Mon Sep 17 00:00:00 2001 From: ueno Date: Thu, 25 Aug 2005 07:42:19 +0000 Subject: [PATCH] * riece.el (riece): Don't override riece-addons setting. * riece-globals.el (riece-addon-dependencies): New variable. * riece-addon.el (riece-sort-addon-dependencies): Rename from riece-resolve-addon-dependencies; return addon dependencies as an alist, instead of returning a list of addons. --- lisp/ChangeLog | 10 ++++++++++ lisp/riece-addon.el | 53 ++++++++++++++++++++++++++----------------------- lisp/riece-globals.el | 2 ++ lisp/riece.el | 8 ++++---- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f54cf56..28c6768 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2005-08-25 Daiki Ueno + + * riece.el (riece): Don't override riece-addons setting. + + * riece-globals.el (riece-addon-dependencies): New variable. + + * riece-addon.el (riece-sort-addon-dependencies): Rename from + riece-resolve-addon-dependencies; return addon dependencies as an + alist, instead of returning a list of addons. + 2005-08-20 Daiki Ueno * riece-addon.el (riece-command-enable-addon): Redraw entire diff --git a/lisp/riece-addon.el b/lisp/riece-addon.el index 6ab1c57..7181353 100644 --- a/lisp/riece-addon.el +++ b/lisp/riece-addon.el @@ -136,34 +136,24 @@ ;; Merge pred's succs. (while pointer (if (setq entry (assq (car pointer) dependencies)) - (setcdr (cdr entry) - (cons (car addons) (nthcdr 2 entry))) + (setcdr (cdr entry) (cons (car addons) (nthcdr 2 entry))) (setq dependencies (cons (list (car pointer) 0 (car addons)) dependencies))) (setq pointer (cdr pointer)))) (setq addons (cdr addons))) dependencies)) -(defun riece-resolve-addon-dependencies (addons) - (let ((pointer addons) - dependencies queue) - ;; Uniquify, first. - (while pointer - (if (memq (car pointer) (cdr pointer)) - (setcar pointer nil)) - (setq pointer (cdr pointer))) - (setq dependencies (riece-load-and-build-addon-dependencies - (delq nil addons)) - pointer dependencies) - ;; Sort them. +(defun riece-sort-addon-dependencies (dependencies) + (let ((pointer dependencies) + addons queue) (while pointer (if (zerop (nth 1 (car pointer))) (setq dependencies (delq (car pointer) dependencies) queue (cons (car pointer) queue))) (setq pointer (cdr pointer))) - (setq addons nil) (while queue - (setq addons (cons (car (car queue)) addons) + (setq addons (cons (cons (car (car queue)) (nthcdr 2 (car queue))) + addons) pointer (nthcdr 2 (car queue))) (while pointer (let* ((entry (assq (car pointer) dependencies)) @@ -179,16 +169,29 @@ (nreverse addons))) (defun riece-resolve-addons (addons) + ;; Add files in riece-addon-directory to addons. + (if (file-directory-p riece-addon-directory) + (setq addons (nconc + addons + (mapcar + (lambda (name) + (unless (file-directory-p + (expand-file-name name riece-addon-directory)) + (intern (file-name-sans-extension name)))) + (directory-files riece-addon-directory nil "\\`[^.]"))))) + ;; Sort & uniquify. + (setq addons (sort addons (lambda (symbol1 symbol2) + (string-lessp (symbol-name symbol1) + (symbol-name symbol2))))) + (let ((pointer addons)) + (while pointer + (if (memq (car pointer) (cdr pointer)) + (setcar pointer nil)) + (setq pointer (cdr pointer))) + (delq nil addons)) + ;; Build & resolve dependencies. (riece-resolve-addon-dependencies - (if (file-directory-p riece-addon-directory) - (append addons - (mapcar - (lambda (name) - (unless (file-directory-p - (expand-file-name name riece-addon-directory)) - (intern (file-name-sans-extension name)))) - (directory-files riece-addon-directory nil "\\`[^.]" t))) - addons))) + (riece-load-and-build-addon-dependencies addons))) (defun riece-insinuate-addon (addon &optional verbose) (if (get addon 'riece-addon-insinuated) diff --git a/lisp/riece-globals.el b/lisp/riece-globals.el index 814d41f..aa84072 100644 --- a/lisp/riece-globals.el +++ b/lisp/riece-globals.el @@ -71,6 +71,8 @@ (defvar riece-channel-obarray-size 103 "The size of obarray used by riece on channelname space.") +(defvar riece-addon-dependencies nil) + ;;; Variables local to the server buffers: (defvar riece-server-name nil "The name of the server. diff --git a/lisp/riece.el b/lisp/riece.el index 802ef5d..a9024dc 100644 --- a/lisp/riece.el +++ b/lisp/riece.el @@ -279,10 +279,10 @@ If optional argument CONFIRM is non-nil, ask which IRC server to connect." (modify-frame-parameters (selected-frame) (list (cons 'riece-window-configuration (current-window-configuration)))) - (setq riece-addons (riece-resolve-addons riece-addons)) - (let ((pointer riece-addons)) + (setq riece-addon-dependencies (riece-resolve-addons riece-addons)) + (let ((pointer riece-addon-dependencies)) (while pointer - (riece-insinuate-addon (car pointer) riece-debug) + (riece-insinuate-addon (car (car pointer)) riece-debug) (setq pointer (cdr pointer)))) (if (or confirm (null riece-server)) (setq riece-server (completing-read "Server: " riece-server-alist))) @@ -323,7 +323,7 @@ If optional argument CONFIRM is non-nil, ask which IRC server to connect." (unless (riece-server-opened server) (riece-command-open-server server)) (setq channel-list (cdr channel-list)))) - (let ((pointer riece-addons)) + (let ((pointer riece-addon-dependencies)) (while pointer (unless (get (car pointer) 'riece-addon-default-disabled) (riece-enable-addon (car pointer) riece-debug)) -- 1.7.10.4