2003-05-30 Daiki Ueno <ueno@unixuser.org>
+ * Riece: Version 0.0.2 released.
+ * riece-version.el (riece-version-number): Bump up to 0.0.2.
+
+ * riece.el (riece-load-and-build-addon-dependencies): Fixed.
+ * riece-url.el (riece-url-requires): Don't assert dependency on
+ riece-highlight unless it appears in riece-addons.
+
* riece-url.el: New add-on.
* COMPILE (riece-modules): Add riece-url.
;; 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-url)
+
;;; Code:
+(require 'riece-options)
+
(defvar browse-url-browser-function)
(defgroup riece-url nil
(autoload 'widget-convert-button "wid-edit")
-(defun riece-url-add-buttons (start end)
+(defun riece-url-scan-region (start end)
(save-excursion
(goto-char start)
(while (re-search-forward riece-url-regexp end t)
(let ((url (match-string 0)))
- (widget-convert-button
- 'url-link (match-beginning 0) (match-end 0) url)
+ (if (memq 'riece-highlight riece-addons)
+ (widget-convert-button
+ 'url-link (match-beginning 0) (match-end 0) url))
(unless (member url riece-urls)
(setq riece-urls (cons url riece-urls)))))))
(defvar riece-dialogue-mode-map)
(defun riece-url-requires ()
- '(riece-highlight))
+ (if (memq 'riece-highlight riece-addons)
+ '(riece-highlight)))
(defun riece-url-insinuate ()
- (add-hook 'riece-after-insert-functions 'riece-url-add-buttons)
+ (add-hook 'riece-after-insert-functions 'riece-url-scan-region)
(define-key riece-dialogue-mode-map "U" 'riece-command-browse-url))
(provide 'riece-url)
(defun riece-load-and-build-addon-dependencies (addons)
(let ((load-path (cons riece-addon-directory load-path))
- dependencies)
+ dependencies
+ pointer)
(while addons
(require (car addons)) ;error will be reported here
(let* ((requires
- (funcall (or (intern-soft (concat (symbol-name (car addons))
- "-requires"))
+ (funcall (or (intern-soft
+ (concat (symbol-name (car addons)) "-requires"))
#'ignore)))
(pointer requires)
entry)
+ ;; Increment succs' pred count.
+ (if (setq entry (assq (car addons) dependencies))
+ (setcar (cdr entry) (+ (length requires) (nth 1 entry)))
+ (setq dependencies (cons (list (car addons) (length requires))
+ dependencies)))
+ ;; Merge pred's succs.
(while pointer
(if (setq entry (assq (car pointer) dependencies))
- (setcar (cdr entry) (1+ (nth 1 entry)))
- (setq dependencies (cons (list (car pointer) 1 nil)
+ (setcdr (cdr entry)
+ (cons (car addons) (nthcdr 2 entry)))
+ (setq dependencies (cons (list (car pointer) 0 (car addons))
dependencies)))
- (setq pointer (cdr pointer)))
- (if (setq entry (assq (car addons) dependencies))
- (setcar (nthcdr 2 entry) requires)
- (setq dependencies (cons (list (car addons) 0 requires)
- dependencies))))
+ (setq pointer (cdr pointer))))
(setq addons (cdr addons)))
dependencies))
(defun riece-insinuate-addons (addons)
- (let* ((dependencies (riece-load-and-build-addon-dependencies addons))
- (pointer dependencies)
- queue)
+ (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.
(while pointer
(if (zerop (nth 1 (car pointer)))
(setq dependencies (delq (car pointer) dependencies)
(setq addons nil)
(while queue
(setq addons (cons (car (car queue)) addons)
- pointer (nth 2 (car queue)))
+ pointer (nthcdr 2 (car queue)))
(while pointer
(let* ((entry (assq (car pointer) dependencies))
(count (1- (nth 1 entry))))
(setq pointer (cdr pointer)))
(setq queue (cdr queue)))
(if dependencies
- (error "Circular dependency found"))
+ (error "Circular add-on dependency found"))
(while addons
(require (car addons)) ;implicit dependency
(funcall (intern (concat (symbol-name (car addons)) "-insinuate")))