[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: --with-icondir



>>>>> In [emacs-w3m : No.03918]
>>>>>	Katsumi Yamaoka <yamaoka@jpl.org> wrote:

山岡> ...そのたった一つのために専用のファイルを設けることにはぼくも抵
山岡> 抗がありますね。

白井さん> だけど、こうすると w3m.el と w3m.elc が食い違っちゃうのです
白井さん> よね。ちょっと悩ましいような気もします。

山岡> そうなんですよ。

専用ファイルを作る以外にマトモな手段は無いという結論に達しました。
とは言え、転んでもタダで起きるのでは情けないので、いろんな情報を
詰め込んで以下のようなものを作るようにしてみたのですが、いかがで
しょう?

--8<---------------cut here---------------start------------->8---
;;; w3m-build.el --- records which built emacs-w3m

;; This file was generated automatically to record some data which have
;; been used when building emacs-w3m.

(defconst emacs-w3m-build-records
  '((builder . "yamaoka")
    (date . "Thu Sep 19 12:25:29 2002")
    (emacs-version . "XEmacs 21.4 (patch 9) \"Informed Management\" [Lucid] (sparc-sun-solaris2.6, Mule) of Sun Sep  1 2002 on kchisa")
    (file-coding . t)
    (icon-directory . "/usr/local/lib/xemacs/packages/etc/w3m")
    (meadow-version . nil)
    (mule-p . t)
    (mule-version . nil)
    (system-name . "kchisa")
    (system-type . usg-unix-v)))

;;; w3m-build.el ends here
--8<---------------cut here---------------end--------------->8---

XEmacs package でも正しい icon-directory が得られるようにしたつ
もりです。以下に幹への差分:
--- Makefile.in~	2002-09-03 21:52:57 +0000
+++ Makefile.in	2002-09-19 12:24:19 +0000
@@ -11,7 +11,8 @@
 
 @SET_MAKE@
 EMACS   = @EMACS@
-FLAGS   = -q -no-site-file -batch -l w3mhack.el $(ADDITIONAL_LOAD_PATH)
+FLAGS   = -q -no-site-file -batch -l w3mhack.el\
+	  $(ICONDIR) $(ADDITIONAL_LOAD_PATH)
 
 PACKAGE = emacs-w3m
 TARBALL = $(PACKAGE)-$(VERSION).tar.gz
@@ -27,8 +28,7 @@
 	$(EMACS) $(FLAGS) -f w3mhack-compile
 
 what-where:
-	@$(EMACS) $(FLAGS) -f w3mhack-what-where\
-	"$(lispdir)" "$(ICONDIR)" "$(PACKAGEDIR)"
+	@$(EMACS) $(FLAGS) -f w3mhack-what-where "$(lispdir)" "$(PACKAGEDIR)"
 
 install: default
 	@$(SHELL) ./mkinstalldirs $(lispdir);\
@@ -69,6 +69,7 @@
 	  echo "What a pity!  Your \"$(EMACS)\" does not support"\
 		"a package system.";\
 	else\
+	  $(MAKE) ICONDIR="$(PACKAGEDIR)/etc/w3m" build-records;\
 	  $(MAKE) lispdir="$(PACKAGEDIR)/lisp/w3m" install;\
 	  $(MAKE) ICONDIR="$(PACKAGEDIR)/etc/w3m" install-icons;\
 	  echo "$(EMACS) $(FLAGS) -f w3mhack-make-package $(PACKAGEDIR)";\
@@ -107,7 +108,7 @@
 	rm -rf $(DISTDIR)
 
 clean:
-	-rm -rf *~ *.elc shimbun/*.elc $(PACKAGE)* w3m-kwds.el
+	-rm -rf *~ *.elc shimbun/*.elc $(PACKAGE)* w3m-kwds.el w3m-build.el
 
 distclean: clean
 	-rm -f config.log config.status config.cache Makefile;\
@@ -153,9 +154,14 @@
 
 ## Create the file w3m-kwds.el if it is needed for $(EMACS).
 keywords:
-	@ echo "$(EMACS) $(FLAGS)";\
+	@echo "$(EMACS) $(FLAGS)";\
 	$(EMACS) $(FLAGS);\
 	if test ! -f w3m-kwds.el; then\
 	  echo "There is no need to bind colon keywords for \"$(EMACS)\".";\
 	  echo "The file w3m-kwds.el is not created.";\
 	fi
+
+## Create the file w3m-build.el.
+build-records:
+	rm -f w3m-build.el;\
+	$(EMACS) $(FLAGS)
--- w3m.el~	2002-09-18 21:52:22 +0000
+++ w3m.el	2002-09-19 12:24:19 +0000
@@ -574,12 +574,23 @@
   :type 'boolean)
 
 (defcustom w3m-icon-directory
-  (if (fboundp 'locate-data-directory)
-      (locate-data-directory "w3m")
-    (let ((icons (expand-file-name "w3m/icons/"
-				   data-directory)))
-      (if (file-directory-p icons)
-	  icons)))
+  (let (icons)
+    (cond (noninteractive
+	   nil)
+	  ((condition-case nil
+	       (let (emacs-w3m-build-records)
+		 (load "w3m-build.el" nil t t)
+		 (and (setq icons (cdr (assq 'icon-directory
+					     emacs-w3m-build-records)))
+		      (file-exists-p (expand-file-name "antenna-up.xpm"
+						       icons))))
+	     (error nil))
+	   icons)
+	  ((fboundp 'locate-data-directory)
+	   (locate-data-directory "w3m"))
+	  ((file-directory-p
+	    (setq icons (expand-file-name "w3m/icons/" data-directory)))
+	   icons)))
   "*Icon directory for w3m (XEmacs or Emacs 21)."
   :group 'w3m
   :type 'directory)
--- w3mhack.el~	2002-08-29 08:22:55 +0000
+++ w3mhack.el	2002-09-19 12:24:19 +0000
@@ -136,6 +136,20 @@
 	nil))
     (byte-compile 'locate-library)))
 
+(defvar w3mhack-icon-directory
+  (let ((icon-dir (pop command-line-args-left)))
+    (when (if w3mhack-nonunix-icondir
+	      (setq icon-dir w3mhack-nonunix-icondir)
+	    (if (and icon-dir
+		     (string-equal icon-dir "NONE"))
+		nil
+	      icon-dir))
+      (while (string-match "//+" icon-dir)
+	(replace-match "/" nil nil icon-dir))
+      (if (string-match "/\\'" icon-dir)
+	  (substring icon-dir 0 -1)
+	icon-dir))))
+
 ;; Add supplementary directories to `load-path'.
 (let ((addpath (or (pop command-line-args-left) "NONE"))
       path paths)
@@ -202,6 +216,8 @@
 
 (defconst w3mhack-colon-keywords-file "w3m-kwds.el")
 
+(defconst w3mhack-build-records-file "w3m-build.el")
+
 ;; Needed for interdependencies among w3m and shimbun modules.
 (push default-directory load-path)
 (push (expand-file-name shimbun-module-directory default-directory) load-path)
@@ -225,7 +241,8 @@
 				     "w3m-fsf.el" "w3m-om.el" "w3m-xmas.el"))
 	 (ignores;; modules not to be byte-compiled.
 	  (append
-	   (list "w3mhack.el" w3mhack-colon-keywords-file)
+	   (list "w3mhack.el"
+		 w3mhack-colon-keywords-file w3mhack-build-records-file)
 	   (w3mhack-mdelete (cond ((featurep 'xemacs)
 				   "w3m-xmas.el")
 				  ((boundp 'MULE)
@@ -328,10 +345,10 @@
   (unless w3mhack-nonunix-lispdir
     (setq w3mhack-nonunix-lispdir
 	  (expand-file-name "../../site-lisp/w3m" data-directory)))
-  (and (not w3mhack-nonunix-icondir)
+  (and (not w3mhack-icon-directory)
        (or (featurep 'xemacs)
 	   (> w3mhack-emacs-major-version 20))
-       (setq w3mhack-nonunix-icondir
+       (setq w3mhack-icon-directory
 	     (expand-file-name "w3m/icons" data-directory)))
   (labels
       ((mkdir (dir)
@@ -353,9 +370,9 @@
 	   (expand-file-name shimbun-module-directory default-directory)))
       (when (file-exists-p (expand-file-name "shimbun.elc" shimbun-directory))
 	(install shimbun-directory w3mhack-nonunix-lispdir "\\.elc?\\'")))
-    (when w3mhack-nonunix-icondir
-      (mkdir w3mhack-nonunix-icondir)
-      (install (expand-file-name "icons") w3mhack-nonunix-icondir
+    (when w3mhack-icon-directory
+      (mkdir w3mhack-icon-directory)
+      (install (expand-file-name "icons") w3mhack-icon-directory
 	       "\\.xpm\\'"))))
 
 ;; Byte optimizers and version specific functions.
@@ -730,11 +747,57 @@
     (let ((kwds-file (expand-file-name w3mhack-colon-keywords-file)))
       :symbol-for-testing-whether-colon-keyword-is-available-or-not
       (when (file-exists-p kwds-file)
-	(delete-file (expand-file-name w3mhack-colon-keywords-file))))
+	(delete-file kwds-file)))
   (void-variable
    (byte-compile 'w3mhack-generate-colon-keywords-file)
    (w3mhack-generate-colon-keywords-file)))
 
+(defun w3mhack-generate-build-records-file ()
+  "Generate a file to record informations on how emacs-w3m has built."
+  (let ((record (expand-file-name w3mhack-build-records-file))
+	(makefile (expand-file-name "Makefile")))
+    (if (and (file-exists-p record)
+	     (file-exists-p makefile)
+	     (file-newer-than-file-p record makefile))
+	nil
+      (let* ((default-enable-multibyte-characters t)
+	     (default-mc-flag t)
+	     (buffer (get-buffer-create " *build records*"))
+	     make-backup-files)
+	(save-excursion
+	  (set-buffer buffer)
+	  (erase-buffer)
+	  (insert ";;; " w3mhack-build-records-file "\
+ --- records which built emacs-w3m
+
+;; This file was generated automatically to record some data which have
+;; been used when building emacs-w3m.
+
+\(defconst emacs-w3m-build-records
+  '((builder . " (prin1-to-string (user-login-name)) ")
+    (date . " (prin1-to-string (current-time-string)) ")
+    (emacs-version . " (prin1-to-string (emacs-version)) ")
+    (file-coding . " (prin1-to-string (featurep 'file-coding)) ")
+    (icon-directory . " (prin1-to-string w3mhack-icon-directory) ")
+    (meadow-version . " (prin1-to-string (if (fboundp 'Meadow-version)
+					     (Meadow-version))) ")
+    (mule-p . " (prin1-to-string (featurep 'mule)) ")
+    (mule-version . " (prin1-to-string (if (boundp 'mule-version)
+					   mule-version)) ")
+    (system-name . " (prin1-to-string (system-name)) ")
+    (system-type . " (prin1-to-string system-type) ")))
+
+;;; " w3mhack-build-records-file " ends here
+")
+	  (if (featurep 'mule)
+	      (let ((coding-system-for-write 'iso-2022-7bit)
+		    (file-coding-system '*iso-2022-jp*))
+		(write-region (point-min) (point) record))
+	    (write-region (point-min) (point) record)))
+	(kill-buffer buffer)))))
+
+(w3mhack-generate-build-records-file)
+
 (defun w3mhack-load-path ()
   "Print default value of additional load paths for w3m.el."
   (let (paths x)
@@ -778,23 +841,21 @@
 (defun w3mhack-what-where ()
   "Show what files should be installed and where should they go."
   (let ((lisp-dir (pop command-line-args-left))
-	(icon-dir (pop command-line-args-left))
 	(package-dir (pop command-line-args-left)))
     (message "
 lispdir=%s
 ICONDIR=%s
 PACKAGEDIR=%s"
-	     lisp-dir icon-dir package-dir)
+	     lisp-dir (or w3mhack-icon-directory "NONE") package-dir)
     (message "
 install:
   *.el, *.elc, ChangeLog* -> %s"
 	     (file-name-as-directory lisp-dir))
-    (setq icon-dir (file-name-as-directory icon-dir))
-    (unless (string-equal "NONE/" icon-dir)
+    (when w3mhack-icon-directory
       (message "
 install-icons:
   *.xpm                   -> %s"
-	       icon-dir))
+	       w3mhack-icon-directory))
     (setq package-dir (file-name-as-directory package-dir))
     (unless (string-equal "NONE/" package-dir)
       (message "