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

Re: --with-icondir



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

山岡> この byte-optimizer は defcustom の第一引数が w3m-icon-directory
山岡> だったら byte-compile する直前に第二引数を configure で指定され
山岡> た icondir で置き換えるという意味です。動作未確認。

阿呆でした。defcustom とその実体である custom-declare-variable
は byte-compile されないので (^^;;)、代わりのものを作りました。
w3mhack-nonunix-icondir の扱いに自信が無いので、ちょっと見ていた
だけるとうれしいです。幹の emacs-w3m へのパッチです。
--- emacs-w3m/Makefile.in~	2002-09-03 21:52:57 +0000
+++ emacs-w3m/Makefile.in	2002-09-17 09:12:32 +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);\
--- emacs-w3m/w3mhack.el~	2002-08-29 08:22:55 +0000
+++ emacs-w3m/w3mhack.el	2002-09-17 09:12:32 +0000
@@ -136,6 +136,30 @@
 	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))))
+
+(when w3mhack-icon-directory
+  (defadvice defcustom (before replace-default (symbol value doc &rest args)
+			       activate)
+    "Replace the default value for `w3m-icon-directory' in w3m.elc."
+    (if (eq symbol 'w3m-icon-directory)
+	(setq value w3mhack-icon-directory)))
+  (message "\
+The default value for `w3m-icon-directory' will be set in w3m.elc to\n\
+    \"%s\".\n" w3mhack-icon-directory))
+
 ;; Add supplementary directories to `load-path'.
 (let ((addpath (or (pop command-line-args-left) "NONE"))
       path paths)
@@ -328,10 +352,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 +377,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.
@@ -778,23 +802,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 "