From cb6e2cd155601d8d5e6273fe70a4e861c1fcad06 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 23 Mar 2006 14:06:01 +0000 Subject: [PATCH] dot-emacs: New functions: library-exists-p and maybe-autoload library-exists-p decides whether an Emacs library is present. maybe-autoload sets up an autoload if a library exists. --- dot-emacs.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dot-emacs.el b/dot-emacs.el index 9899ef9..75e021b 100644 --- a/dot-emacs.el +++ b/dot-emacs.el @@ -57,6 +57,26 @@ (concat "(" (buffer-string) ")")))))) (cdr (assq sym mdw-config))) +;; --- Is an Emacs library available? --- + +(defun library-exists-p (name) + "Return non-nil if NAME.el (or NAME.elc) is somewhere on the Emacs load +path. The non-nil value is the filename we found for the library." + (let ((path load-path) elt (foundp nil)) + (while (and path (not foundp)) + (setq elt (car path)) + (setq path (cdr path)) + (setq foundp (or (let ((file (concat elt "/" name ".elc"))) + (and (file-exists-p file) file)) + (let ((file (concat elt "/" name ".el"))) + (and (file-exists-p file) file))))) + foundp)) + +(defun maybe-autoload (symbol file &optional docstring interactivep type) + "Set an autoload if the file actually exists." + (and (library-exists-p file) + (autoload symbol file docstring interactivep type))) + ;; --- Splitting windows --- (defconst mdw-scrollbar-width (if window-system 6 1) -- 2.11.0