diff lisp/w3/w3-sysdp.el @ 122:d2f30a177268 r20-1b14

Import from CVS: tag r20-1b14
author cvs
date Mon, 13 Aug 2007 09:26:03 +0200
parents 8619ce7e4c50
children b980b6286996
line wrap: on
line diff
--- a/lisp/w3/w3-sysdp.el	Mon Aug 13 09:25:31 2007 +0200
+++ b/lisp/w3/w3-sysdp.el	Mon Aug 13 09:26:03 2007 +0200
@@ -994,6 +994,24 @@
 ;; NT doesn't have make-symbolic-link
 (sysdep-defalias 'make-symbolic-link 'copy-file)
 
+(sysdep-defun run-hook-with-args-until-success (hook &rest args)
+  "Run HOOK with the specified arguments ARGS.
+HOOK should be a symbol, a hook variable.  Its value should
+be a list of functions.  We call those functions, one by one,
+passing arguments ARGS to each of them, until one of them
+returns a non-nil value.  Then we return that value.
+If all the functions return nil, we return nil."
+  (let ((rval nil)
+	(todo (and (boundp hook) (symbol-value hook)))
+	(global (and (boundp hook) (default-value hook)))
+	(cur nil))
+    (while (and (setq cur (car todo)) (not rval))
+      (setq todo (cdr todo))
+      (if (eq cur t)
+	  (if global
+	      (setq todo (append global todo)))
+	(setq rval (apply cur args))))))
+
 (sysdep-defun split-string (string pattern)
   "Return a list of substrings of STRING which are separated by PATTERN."
   (let (parts (start 0))