X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fdgnushack.el;h=476b612e28f288335aff48847dd8f6dcc4c8101f;hb=4cacb5f23eb830e6950dba987063f413977708d7;hp=95c85b062498db57d2a558234e3536f9a5b1c625;hpb=2a85048c0497a917e093c281fbd2aad3d92075f4;p=elisp%2Fgnus.git- diff --git a/lisp/dgnushack.el b/lisp/dgnushack.el index 95c85b0..476b612 100644 --- a/lisp/dgnushack.el +++ b/lisp/dgnushack.el @@ -22,8 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -45,6 +45,8 @@ (copy-sequence coding-category-list)) '(coding-category-sjis)))))) +(defvar dgnushack-default-load-path (copy-sequence load-path)) + (defalias 'facep 'ignore) (require 'cl) @@ -318,6 +320,8 @@ adding the --with-addpath=FLIM_PATH option.\n" (autoload 'setenv "process" nil t) (autoload 'setenv "env" nil t)) (autoload 'sgml-mode "psgml" nil t) + (autoload 'sha1 "sha1") + (autoload 'sha1-binary "sha1") (autoload 'smtpmail-send-it "smtpmail") (autoload 'sort-numeric-fields "sort" nil t) (autoload 'sort-subr "sort") @@ -693,4 +697,81 @@ dgnushack-compile." (while (setq file (pop files)) (insert "etc/images/smilies/" file "\n")))))) +(defun dgnushack-find-lisp-shadows (&optional lispdir) + "Return a list of directories in which other Gnus installations exist. +This function looks for the other Gnus installations which will shadow +the new Gnus Lisp modules which have been installed in LISPDIR, using +the default `load-path'. The return value will make sense only when +LISPDIR is existent and is listed in the default `load-path'. Assume +LISPDIR will be prepended to `load-path' by a user if the default +`load-path' does not contain it." + (unless lispdir + (setq lispdir (getenv "lispdir"))) + (when (and lispdir (file-directory-p lispdir)) + (setq lispdir (file-truename (directory-file-name lispdir))) + (let ((indices '("gnus.elc" "gnus.el" "gnus.el.bz2" "gnus.el.gz" + "message.elc" "message.el" "message.el.bz2" + "message.el.gz")) + (path (delq nil (mapcar + (lambda (p) + (condition-case nil + (when (and p (file-directory-p p)) + (file-truename (directory-file-name p))) + (error nil))) + dgnushack-default-load-path))) + rest elcs) + (while path + (setq rest (cons (car path) rest) + path (delete (car rest) (cdr path)))) + (setq path (nreverse (cdr (member lispdir rest))) + rest nil) + (while path + (setq elcs indices) + (while elcs + (when (file-exists-p (expand-file-name (pop elcs) (car path))) + (setq rest (cons (car path) rest) + elcs nil))) + (setq path (cdr path))) + (prog1 + (setq path (nreverse rest)) + (when path + (let (print-level print-length) + (princ (concat "\n\ +WARNING: The other gnus installation" (if (cdr path) "s have" " has") "\ + been detected in:\n\n " (mapconcat 'identity path "\n ") "\n\n\ +You will need to modify the run-time `load-path', remove them manually, +or remove them using `make remove-installed-shadows'.\n\n")))))))) + +(defun dgnushack-remove-lisp-shadows (&optional lispdir) + "Remove the other Gnus installations which shadow the recent one." + (let ((path (with-temp-buffer + (let ((standard-output (current-buffer))) + (dgnushack-find-lisp-shadows lispdir)))) + elcs files shadows file) + (when path + (unless (setq elcs (directory-files srcdir nil "\\.elc\\'")) + (error "You should build .elc files first.")) + (setq files + (apply + 'append + (mapcar + (lambda (el) + (list (concat el "c") el (concat el ".bz2") (concat el ".gz"))) + (append + (list (file-name-nondirectory dgnushack-gnus-load-file) + (file-name-nondirectory dgnushack-cus-load-file)) + (mapcar (lambda (elc) (substring elc 0 -1)) elcs))))) + (while path + (setq shadows files) + (while shadows + (setq file (expand-file-name (pop shadows) (car path))) + (when (file-exists-p file) + (princ (concat " Removing " file "...")) + (condition-case nil + (progn + (delete-file file) + (princ "done\n")) + (error (princ "failed\n"))))) + (setq path (cdr path)))))) + ;;; dgnushack.el ends here