/usr/share/emacs/site-lisp/w3m/w3mhack.el is in w3m-el 1.4.4-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | ;;; w3mhack.el --- a hack to setup the environment for building w3m
;; Copyright (C) 2001, 2002, 2003, 2004, 2005
;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>
;; Author: Katsumi Yamaoka <yamaoka@jpl.org>
;; Keywords: w3m, WWW, hypermedia
;; This file is a part of emacs-w3m.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This file provides the stuffs to setup the environment for building
;; emacs-w3m and the installer for non-UNIX systems.
;;; How to install:
;; ( These document is a simple summary of README. For more detail,
;; see the original. )
;; In order to install emacs-w3m to non-UNIX systems which lack an
;; ability to execute `configure' script or have no `make' utility,
;; execute this command.
;;
;; emacs -batch -q -no-site-file -l w3mhack.el NONE -f w3mhack-nonunix-install
;;
;; When required packages, such as APEL, are installed into unusual
;; places, the installer may miss them. In this case, it is necessary
;; to tell their places to the installer, as follows:
;;
;; emacs -batch -q -no-site-file -l w3mhack.el //c/share/apel://c/share/flim -f w3mhack-nonunix-install
;;
;; If you want to install programs and icons to unusual directories,
;; edit this file and set your request to `w3mhack-nonunix-lispdir'
;; and `w3mhack-nonunix-icondir'.
;;; Code:
(defvar w3mhack-nonunix-lispdir nil
"*Directory to where emacs-w3m lisp programs are installed.
nil means that all programs are installed to the default directory.")
(defvar w3mhack-nonunix-icondir nil
"*Directory to where emacs-w3m icons are installed.
nil means that all icons are installed to the default directory.")
(defvar w3mhack-nonunix-dryrun nil
"*Non-nil means that print the commands to install programs and datas,
but do not execute them.")
(require 'cl)
;; Check whether the shell command can be used.
(let ((test (lambda (shell)
(let ((buffer (generate-new-buffer " *temp*"))
(msg "Hello World"))
(save-excursion
(set-buffer buffer)
(condition-case nil
(call-process shell nil t nil "-c"
(concat "MESSAGE=\"" msg "\"&&"
"echo \"${MESSAGE}\""))
(error))
(prog2
(goto-char (point-min))
(search-forward msg nil t)
(kill-buffer buffer)))))))
(or (funcall test shell-file-name)
(progn
(require 'executable)
(let ((executable-binary-suffixes
(if (memq system-type '(OS/2 emx))
'(".exe" ".com" ".bat" ".cmd" ".btm" "")
executable-binary-suffixes))
shell)
(or (and (setq shell (executable-find "cmdproxy"))
(funcall test shell)
(setq shell-file-name shell))
(and (setq shell (executable-find "sh"))
(funcall test shell)
(setq shell-file-name shell))
(and (setq shell (executable-find "bash"))
(funcall test shell)
(setq shell-file-name shell))
(not (member (nth 1 (or (member "-f" command-line-args)
(member "-funcall" command-line-args)
(member "--funcall" command-line-args)
(member "-e" command-line-args)))
'("w3mhack-batch-compile" "w3mhack-compile"
"w3mhack-makeinfo" "w3mhack-make-package")))
(error "%s" "\n\
There seems to be no shell command which is equivalent to /bin/sh.
Try ``make SHELL=foo [option...]'', where `foo' is the absolute
path name for the proper shell command in your system.\n"))))))
(unless (dolist (var nil t))
;; Override the macro `dolist' which may have been defined in egg.el.
(load "cl-macs" nil t))
(require 'bytecomp)
;; Since Emacs won't optimize the butlast elements of the arguments
;; for the functions and/or, we do it by ourselves.
(when (equal
(cadr
(byte-optimize-form
'(and
(< 0 1)
(message "The subform `(< 0 1)' should be optimized to `t'"))
'for-effect))
'(< 0 1))
(setq max-specpdl-size (* 5 max-specpdl-size));; Needed for Mule 2.
(defadvice byte-optimize-form-code-walker
(around fix-bug-in-and/or-forms (form for-effect) activate)
"Fix a bug in the optimizing and/or forms.
It has already been fixed in XEmacs since 1999-12-06."
(if (and for-effect (memq (car-safe form) '(and or)))
(let ((fn (car form))
(backwards (reverse (cdr form))))
(while (and backwards
(null (setcar backwards
(byte-optimize-form (car backwards) t))))
(setq backwards (cdr backwards)))
(if (and (cdr form) (null backwards))
(byte-compile-log
" all subforms of %s called for effect; deleted" form))
(when backwards
(setcdr backwards
(mapcar 'byte-optimize-form (cdr backwards))))
(setq ad-return-value (cons fn (nreverse backwards))))
ad-do-it)))
(when (and (not (featurep 'xemacs))
(= emacs-major-version 21)
(= emacs-minor-version 3)
(condition-case code
(let ((byte-compile-error-on-warn t))
(byte-optimize-form (quote (pop x)) t)
nil)
(error (string-match "called for effect"
(error-message-string code)))))
(defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
(form for-effect)
activate)
"Silence the warning \"...called for effect\" for the `pop' form.
It is effective only when the `pop' macro is defined by cl.el rather
than subr.el."
(let (tmp)
(if (and (eq (car-safe form) 'car)
for-effect
(setq tmp (get 'car 'side-effect-free))
(not byte-compile-delete-errors)
(not (eq tmp 'error-free))
(eq (car-safe (cadr form)) 'prog1)
(let ((var (cadr (cadr form)))
(last (nth 2 (cadr form))))
(and (symbolp var)
(null (nthcdr 3 (cadr form)))
(eq (car-safe last) 'setq)
(eq (cadr last) var)
(eq (car-safe (nth 2 last)) 'cdr)
(eq (cadr (nth 2 last)) var))))
(progn
(put 'car 'side-effect-free 'error-free)
(unwind-protect
ad-do-it
(put 'car 'side-effect-free tmp)))
ad-do-it))))
(when (<= emacs-major-version 19)
;; Make `locate-library' run quietly.
(let (current-load-list)
;; Mainly for the compile-time.
(defun locate-library (library &optional nosuffix)
"Show the full path name of Emacs library LIBRARY.
This command searches the directories in `load-path' like `M-x load-library'
to find the file that `M-x load-library RET LIBRARY RET' would load.
Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
to the specified name LIBRARY (a la calling `load' instead of `load-library')."
(interactive "sLocate library: ")
(catch 'answer
(mapcar
'(lambda (dir)
(mapcar
'(lambda (suf)
(let ((try (expand-file-name (concat library suf) dir)))
(and (file-readable-p try)
(null (file-directory-p try))
(progn
(or noninteractive
(message "Library is file %s" try))
(throw 'answer try)))))
(if nosuffix '("") '(".elc" ".el" ""))))
load-path)
(or noninteractive
(message "No library %s in search path" library))
nil))
(byte-compile 'locate-library)))
;; Fix an XEmacs 21.5 bug in `call-process-region'. It has been reported
;; as <URL:http://news.gmane.org/group/gmane.emacs.xemacs.beta/thread=16564>.
(when (and (featurep 'xemacs)
(executable-find "cat")
(with-temp-buffer
(insert "bar")
(backward-char)
(call-process-region (1- (point)) (point) "cat" t t)
(goto-char (point-min))
(not (looking-at "bar"))))
(defadvice call-process-region (around fix-xemacs-bug activate)
"Narrow to the specified region while running the original function.
It fixes an XEmacs 21.5 bug."
(save-restriction
(narrow-to-region (ad-get-arg 0) (ad-get-arg 1))
(goto-char (point-max))
ad-do-it)))
;; Add `configure-package-path' to `load-path' for XEmacs. Those paths
;; won't appear in `load-path' when XEmacs starts with the `-vanilla'
;; option or the `-no-autoloads' option because of a bug. :<
(when (and (featurep 'xemacs)
(boundp 'configure-package-path)
(listp configure-package-path))
(let ((paths
(apply 'nconc
(mapcar
(lambda (path)
(when (and (stringp path)
(not (string-equal path ""))
(file-directory-p
(setq path (expand-file-name "lisp" path))))
(directory-files path t)))
configure-package-path)))
path adds)
(while paths
(setq path (car paths)
paths (cdr paths))
(when (and path
(not (or (string-match "/\\.\\.?\\'" path)
(member (file-name-as-directory path) load-path)
(member path load-path)))
(file-directory-p path))
(push (file-name-as-directory path) adds)))
(setq load-path (nconc (nreverse adds) load-path))))
;; Add supplementary directories to `load-path'.
(let ((addpath (or (pop command-line-args-left) "NONE"))
path paths)
(while (string-match "\\([^\0-\37:]+\\)[\0-\37:]*" addpath)
(setq path (file-name-as-directory
(expand-file-name (substring addpath
(match-beginning 1)
(match-end 1))))
addpath (substring addpath (match-end 0)))
(when (file-directory-p path)
(push path paths)))
(unless (null paths)
(setq load-path (nconc (nreverse paths) load-path))))
;; Check for the required modules.
(when (or (featurep 'xemacs)
(<= emacs-major-version 19))
(let ((apel (locate-library "path-util"))
(emu (locate-library "pccl")))
(if (and apel emu)
(when (featurep 'xemacs)
(setq apel (file-name-directory apel)
emu (file-name-directory emu))
(if (not (string-equal apel emu))
(setq apel (concat apel "\n " emu)))
(unless (if (featurep 'mule)
(condition-case nil
(progn
;; Checking whether APEL has been compiled for
;; XEmacs with MULE.
(require 'pccl)
(featurep 'pccl-20))
(error nil))
(condition-case nil
;; Checking whether APEL has been compiled for
;; XEmacs without MULE (whether `pccl' does not
;; require `ccl').
(require 'pccl)
(error nil)))
(error "\nError: %s%s%s%s\n"
(if (featurep 'mule)
"\
APEL package seems to have been compiled for non-MULE XEmacs,
even though you are using XEmacs with MULE to build emacs-w3m."
"\
APEL package seems to have been compiled for XEmacs with MULE,
even though you are using non-MULE XEmacs to build emacs-w3m.")
" APEL
modules are installed in:\n\n "
apel
"\n
If you are using the official APEL XEmacs package (or possibly SUMO),
look for the new one (version 1.23 and later) and install it in your
system, or send a bug report to the maintainers using
`M-x report-xemacs-bug'. Otherwise, you may rebuild APEL from the
source distribution, see manuals where you could get it from.")))
(error "
Error: You have to install APEL before building emacs-w3m, see manuals.
If you have already installed APEL in the non-standard Lisp directory,
use the `--with-addpath=' configure option with that path name (or
colon separated those path names) and run configure again."))))
(let ((old-mew-path "/usr/share/xemacs21/packages/lisp/mew/"))
(if (member old-mew-path load-path)
(setq load-path (delete old-mew-path load-path))))
(defconst shimbun-module-directory "shimbun")
(defconst w3mhack-colon-keywords-file "w3m-kwds.el")
(defvar w3mhack-load-file "w3m-load.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)
(defun w3mhack-mdelete (elts list)
"Like `delete', except that it also works for a list of subtractions."
(if elts
(if (consp elts)
(let ((rest (delete (car elts) list)))
(while (setq elts (cdr elts))
(setq rest (delete (car elts) rest))
(delete (car elts) list))
rest)
(delete elts list))
list))
(defun w3mhack-module-list ()
"Returna a list of w3m modules should be byte-compile'd."
(let* ((modules (directory-files default-directory nil "^[^#]+\\.el$"))
(version-specific-modules '("w3m-e19.el" "w3m-e20.el" "w3m-e21.el"
"w3m-e23.el"
"w3m-fsf.el" "w3m-om.el" "w3m-xmas.el"))
(ignores;; modules not to be byte-compiled.
(append
(list "w3mhack.el" "w3m-setup.el"
w3mhack-load-file w3mhack-colon-keywords-file)
(w3mhack-mdelete (cond ((featurep 'xemacs)
"w3m-xmas.el")
((boundp 'MULE)
"w3m-om.el")
((>= emacs-major-version 23)
'("w3m-e23.el" "w3m-fsf.el"))
((>= emacs-major-version 21)
'("w3m-e21.el" "w3m-fsf.el"))
((= emacs-major-version 20)
'("w3m-e20.el" "w3m-fsf.el"))
(t
"w3m-e19.el"))
(copy-sequence version-specific-modules))))
(shimbun-dir (file-name-as-directory shimbun-module-directory))
print-level print-length)
(unless (locate-library "mew")
(push "mew-w3m.el" ignores))
(unless (if (featurep 'xemacs)
(and (featurep 'mule) (locate-library "pccl"))
(locate-library "ccl"))
(push "w3m-ccl.el" ignores))
(unless (and (featurep 'mule)
(if (featurep 'xemacs)
;; Mule-UCS does not support XEmacs versions prior
;; to 21.2.37.
(and (>= emacs-major-version 21)
(or (> emacs-minor-version 2)
(and (= emacs-major-version 2)
(>= emacs-beta-version 37))))
(>= emacs-major-version 20))
(locate-library "un-define"))
(push "w3m-ucs.el" ignores))
(if (and (featurep 'mule)
(locate-library "mime-def"))
(progn
;; Add shimbun modules.
(dolist (file (directory-files (expand-file-name shimbun-dir)
nil "^[^#]+\\.el$"))
(setq modules (nconc modules (list (concat shimbun-dir file)))))
;; mew-shimbun check
(unless
;; Mew 2.x and later do not support Mule2.3/Emacs19.
(and (>= emacs-major-version 20)
(locate-library "mew-nntp"))
(push (concat shimbun-dir "mew-shimbun.el") ignores))
;; nnshimbun check
(unless (let ((gnus (locate-library "gnus")))
(when gnus
(let ((load-path (list (file-name-directory gnus))))
(locate-library "nnimap"))))
(push (concat shimbun-dir "nnshimbun.el") ignores)))
(push "mime-w3m.el" ignores)
(push "octet.el" ignores))
(unless (featurep 'mule)
(push "w3m-weather.el" ignores)
(push "w3m-symbol.el" ignores))
(if (and (not (featurep 'xemacs))
(<= emacs-major-version 20)
(locate-library "bitmap"))
;; Against the error "Already defined charset: 242".
(when (locate-library "un-define")
(require 'un-define)
(setq bitmap-alterable-charset 'tibetan-1-column)
(require 'bitmap))
(push "w3m-bitmap.el" ignores))
(unless (>= emacs-major-version 21)
(push "w3m-favicon.el" ignores))
;; List shimbun modules which cannot be byte-compiled with this system.
(unless (locate-library "xml")
(setq ignores (nconc ignores (w3mhack-shimbun-modules-using-rss))))
(let (list)
;; To byte-compile w3m-util.el and a version specific module first.
(push "w3m-util.el" list)
(setq modules (delete "w3m-util.el" modules))
(push "w3m-proc.el" list)
(setq modules (delete "w3m-proc.el" modules))
(dolist (module version-specific-modules)
(when (and (not (member module ignores))
(member module modules))
(setq modules (delete module modules))
(push module list)))
(dolist (module modules)
(unless (member module ignores)
(push module list)))
(nreverse list))))
(defun w3mhack-examine-modules ()
"Examine w3m modules should be byte-compile'd."
(dolist (module (w3mhack-module-list))
(princ (format "%sc " module))))
(defun w3mhack-shimbun-modules-using-rss ()
"Return a list of shimbun modules using RSS."
(let* ((dir (file-name-as-directory shimbun-module-directory))
;; sb-rss.el exactly needs xml.el.
(files (delete "sb-rss.el" (directory-files dir nil "\\.el\\'")))
(rest (list (concat dir "sb-rss.el")))
(buffer (generate-new-buffer " *temp*"))
file form)
(save-excursion
(set-buffer buffer)
(while files
(setq file (concat dir (car files))
files (cdr files))
(insert-file-contents file)
(goto-char (point-min))
(while (and file
(setq form (condition-case nil
(read (current-buffer))
(error nil))))
(when (equal form '(require (quote sb-rss)))
(push file rest)
(setq file nil)))
(erase-buffer)))
(kill-buffer buffer)
rest))
(when (or (<= emacs-major-version 19)
(and (= emacs-major-version 20)
(<= emacs-minor-version 2)))
;; Not to get the byte-code for `current-column' inlined.
(put 'current-column 'byte-compile nil))
(defun w3mhack-compile ()
"Byte-compile the w3m modules."
(w3mhack-check-colon-keywords-file)
(w3mhack-generate-load-file)
(let (modules)
(dolist (el (w3mhack-module-list))
(let ((elc (concat el "c")))
(if (file-exists-p elc)
(if (file-newer-than-file-p elc el)
(message " `%s' is up to date" elc)
(delete-file elc)
(push el modules))
(push el modules))))
(setq modules (nreverse modules))
(while modules
(condition-case nil
(byte-compile-file (car modules))
(error))
(setq modules (cdr modules)))))
(defun w3mhack-batch-compile ()
"Wrapper function of `batch-byte-compile'."
(w3mhack-check-colon-keywords-file)
(batch-byte-compile))
(defun w3mhack-nonunix-install ()
"Byte-compile the w3m modules and install them."
(w3mhack-compile)
(unless w3mhack-nonunix-lispdir
(setq w3mhack-nonunix-lispdir
(expand-file-name "../../site-lisp/w3m" data-directory)))
(and (not w3mhack-nonunix-icondir)
(or (featurep 'xemacs)
(> emacs-major-version 20))
(setq w3mhack-nonunix-icondir
(expand-file-name "images/w3m" data-directory)))
(labels
((mkdir (dir)
(unless (file-directory-p dir)
(message "mkdir %s" dir)
(unless w3mhack-nonunix-dryrun
(make-directory dir 'parents))))
(install (srcdir dstdir pattern)
(dolist (src (directory-files srcdir t pattern))
(let ((dst (expand-file-name
(file-name-nondirectory src) dstdir)))
(message "cp %s %s"
(file-relative-name src default-directory) dst)
(unless w3mhack-nonunix-dryrun
(copy-file src dst t t))))))
(mkdir w3mhack-nonunix-lispdir)
(install default-directory w3mhack-nonunix-lispdir "\\.elc?\\'")
(let ((shimbun-directory
(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 (if (featurep 'xemacs)
"icons30"
"icons"))
w3mhack-nonunix-icondir "\\.xpm\\'"))))
;; Byte optimizers and version specific functions.
(condition-case nil
(char-after)
(wrong-number-of-arguments
(put 'char-after 'byte-optimizer
(lambda (form)
(if (cdr form)
form
'(char-after (point)))))))
(condition-case nil
(char-before)
(wrong-number-of-arguments
(put 'char-before 'byte-optimizer
(lambda (form)
(if (cdr form)
form
'(char-before (point))))))
(void-function
(put 'char-before 'byte-optimizer
(lambda (form)
(if (cdr form)
(let ((pos (car (cdr form))))
(` (let ((cur (point)))
(prog2
(goto-char (, pos))
(if (bobp)
nil
(preceding-char))
(goto-char cur)))))
'(if (bobp)
nil
(preceding-char)))))))
(put 'match-string-no-properties 'byte-optimizer
(lambda (form)
(let ((num (nth 1 form))
(string (nth 2 form)))
(cond ((and string (featurep 'xemacs))
(` (let ((num (, num)))
(if (match-beginning num)
(let ((string (substring (, string)
(match-beginning num)
(match-end num))))
(map-extents (lambda (extent maparg)
(delete-extent extent))
string 0 (length string))
string)))))
(string
(` (let ((num (, num)))
(if (match-beginning num)
(let ((string (substring (, string)
(match-beginning num)
(match-end num))))
(set-text-properties 0 (length string) nil string)
string)))))
(t
(` (let ((num (, num)))
(if (match-beginning num)
(buffer-substring-no-properties
(match-beginning num) (match-end num))))))))))
(cond
((featurep 'xemacs)
;; Don't warn for the unused non-global variables.
(setq byte-compile-warnings
(delq 'unused-vars (copy-sequence byte-compile-default-warnings)))
(defun w3mhack-byte-optimize-letX (form)
"Byte optimize `let' or `let*' FORM in the source level
to remove some obsolete variables in the first argument VARLIST.
Examples of the optimization:
;;From
(let ((coding-system-for-read 'binary)
(file-coding-system-for-read *noconv*))
(insert-file-contents FILE))
;;To
(let ((coding-system-for-read 'binary))
(insert-file-contents FILE))
;;From
(let* ((codesys 'utf-8)
(file-coding-system codesys)
(coding-system-for-write file-coding-system))
(save-buffer))
;;To
(let* ((codesys 'utf-8)
(coding-system-for-write codesys))
(save-buffer))
"
(let ((obsoletes '(file-coding-system
file-coding-system-for-read
pathname-coding-system
pop-up-frame-alist))
(varlist (copy-sequence (cadr form)))
obsolete elements element value)
(while (setq obsolete (pop obsoletes))
(setq elements varlist
varlist nil)
(while (setq element (pop elements))
(if (or (prog1
(eq obsolete element)
(setq value nil))
(when (eq obsolete (car-safe element))
(setq value (unless (eq obsolete (cadr element))
(cadr element)))
t))
(when (eq 'let* (car form))
(while (setq element (rassoc (list obsolete) elements))
(setcdr element (list value))))
(push element varlist)))
(setq varlist (nreverse varlist)))
(setcar (cdr form) varlist))
form)
(require 'byte-optimize)
(defadvice byte-optimize-form-code-walker
(before w3mhack-byte-optimize-letX activate compile)
"Byte optimize `let' or `let*' FORM in the source level
to remove some obsolete variables in the first argument VARLIST."
(when (memq (car-safe (ad-get-arg 0)) '(let let*))
(ad-set-arg 0 (w3mhack-byte-optimize-letX (ad-get-arg 0)))))
;; We dare to do it even though it might be a futile work, since the
;; doc-string says "You should NEVER use this function". If the
;; function `set-text-properties' is used for a whole string, it
;; will make the program run a little bit faster.
(put 'set-text-properties 'byte-optimizer
(lambda (form)
(let ((start (nth 1 form))
(end (nth 2 form))
(props (nth 3 form))
(string (nth 4 form)))
(if (and string
(zerop start)
(eq 'length (car-safe end))
(eq string (car-safe (cdr-safe end))))
(if props
(` (let ((end (, end)))
(map-extents (lambda (extent maparg)
(delete-extent extent))
(, string) 0 end)
(add-text-properties 0 end (, props) (, string))))
(` (map-extents (lambda (extent maparg)
(delete-extent extent))
(, string) 0 (, end))))
form))))
(defun w3mhack-make-package ()
"Make some files in the XEmacs package directory."
(let* ((temp-dir (expand-file-name
;; A dir name must be ended with "/w3m".
"w3m"
(make-temp-name (expand-file-name "pkgtmp"))))
(make-hardlink 'add-name-to-file)
(package-dir (pop command-line-args-left))
(lisp-dir (expand-file-name "lisp/w3m/" package-dir))
(custom-load (expand-file-name "custom-load.el" lisp-dir))
(generated-autoload-file (expand-file-name "auto-autoloads.el"
temp-dir))
(els (nconc (directory-files default-directory nil "^[^#]+\\.el\\'")
(directory-files (expand-file-name
shimbun-module-directory)
nil "^[^#]+\\.el\\'")))
(elcs (with-temp-buffer
(let ((standard-output (current-buffer)))
(w3mhack-examine-modules)
(split-string (buffer-string) " \\(shimbun/\\)?"))))
(icons (directory-files (expand-file-name "icons30/") nil
"^[^#]+\\.xpm\\'"))
(infos (directory-files (expand-file-name "doc/") nil
"^[^#]+\\.info\\(-[0-9]+\\)?\\'"))
(si:message (symbol-function 'message))
hardlink manifest make-backup-files noninteractive)
;; Non-Mule XEmacs cannot handle .el files containing non-ascii chars.
;; So, we should make custom-load.el and auto-autoloads.el for only
;; .el files which have been byte-compiled. The following processings
;; are performed in the `temp-dir' only to those files.
(make-directory temp-dir t)
(unless (condition-case nil
(progn
(setq hardlink (expand-file-name "w3m.el" temp-dir))
(funcall make-hardlink "w3m.el" hardlink)
(prog1
(file-exists-p hardlink)
(delete-file hardlink)))
(error nil))
;; This system doesn't allow hard links.
(setq make-hardlink 'copy-file))
(dolist (el (cons w3mhack-load-file (w3mhack-module-list)))
(funcall make-hardlink
el (expand-file-name (file-name-nondirectory el) temp-dir)))
(with-temp-buffer
(let ((standard-output (current-buffer)))
(Custom-make-dependencies temp-dir))
;; Print messages into stderr.
(message "%s" (buffer-string)))
(if (file-exists-p (expand-file-name "custom-load.el" temp-dir))
(progn
(copy-file (expand-file-name "custom-load.el" temp-dir)
custom-load t)
(require 'cus-load)
(byte-compile-file custom-load)
(push "custom-load.el" els)
(push "custom-load.elc" elcs))
(when (file-exists-p custom-load)
(delete-file custom-load))
(when (file-exists-p (concat custom-load "c"))
(delete-file (concat custom-load "c"))))
(message "Updating autoloads for the directory %s..." lisp-dir)
(w3mhack-generate-xemacs-load-file generated-autoload-file)
(if (file-exists-p generated-autoload-file)
(progn
(copy-file generated-autoload-file
(expand-file-name "auto-autoloads.el" lisp-dir) t)
(byte-compile-file (expand-file-name "auto-autoloads.el" lisp-dir))
(push "auto-autoloads.el" els)
(push "auto-autoloads.elc" elcs))
(setq generated-autoload-file (expand-file-name "auto-autoloads.el"
lisp-dir))
(when (file-exists-p generated-autoload-file)
(delete-file generated-autoload-file))
(when (file-exists-p (concat generated-autoload-file "c"))
(delete-file (concat generated-autoload-file "c"))))
;; Clear the `temp-dir'.
(dolist (el (directory-files temp-dir t "\\.el\\'"))
(delete-file el))
(delete-directory temp-dir)
(delete-directory (expand-file-name ".." temp-dir))
(when (file-directory-p (expand-file-name "pkginfo/" package-dir))
(setq manifest (expand-file-name "pkginfo/MANIFEST.w3m" package-dir))
(message "Generating %s..." manifest)
(with-temp-file manifest
(insert "pkginfo/MANIFEST.w3m\n")
(dolist (log (directory-files lisp-dir nil
"^ChangeLog\\(\\.[0-9]+\\)?\\'"))
(insert "lisp/w3m/" log "\n"))
(dolist (el els)
(insert "lisp/w3m/" el "\n")
(when (member (concat el "c") elcs)
(insert "lisp/w3m/" el "c\n")))
(dolist (icon icons)
(insert "etc/images/w3m/" icon "\n"))
(dolist (info infos)
(insert "info/" info "\n")))
(message "Generating %s...done" manifest)))))
((>= emacs-major-version 21)
;; Don't warn for the dummy autoloads and mis-judging of the cl
;; run-time functions.
(setq byte-compile-warnings
(delq 'noruntime
(delq 'cl-functions
(copy-sequence byte-compile-warning-types)))))
((= emacs-major-version 19)
;; Bind defcustom'ed variables.
(put 'custom-declare-variable 'byte-hunk-handler
(lambda (form)
(if (memq 'free-vars byte-compile-warnings)
(setq byte-compile-bound-variables
(cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
form))
;; Make `locate-library' run quietly at run-time.
(put 'locate-library 'byte-optimizer
(lambda (form)
(` (let ((fn (function locate-library))
(msg (symbol-function 'message)))
(fset 'message (function ignore))
(unwind-protect
(, (append '(funcall fn) (cdr form)))
(fset 'message msg))))))))
(defun w3mhack-generate-colon-keywords-file ()
"Generate a file which contains a list of colon keywords to be bound at
run-time. The file name is specified by `w3mhack-colon-keywords-file'."
(let* ((srcdir default-directory)
(kwds-file (expand-file-name w3mhack-colon-keywords-file srcdir))
(makefile (expand-file-name "Makefile" srcdir))
(buffer (get-buffer-create " *colon keywords*"))
(dirs '("./" "./shimbun/"))
;; This program ignores the `defface' form since the custom package
;; supports all the colon keywords used for the face attributes.
;; However, there is one exception `:strike-through' which is not
;; available in the old custom package (`:strikethru' is for only
;; avoiding byte-compile warning).
(keywords '(:strike-through :strikethru))
ignores files file directories dir form elem make-backup-files)
(save-excursion
(set-buffer buffer)
(let (buffer-file-format
format-alist
insert-file-contents-post-hook insert-file-contents-pre-hook
jam-zcat-filename-list jka-compr-compression-info-list)
(unless (and (file-exists-p kwds-file)
(file-exists-p makefile)
(file-newer-than-file-p kwds-file makefile))
(setq
ignores
'(:symbol-for-testing-whether-colon-keyword-is-available-or-not
;; The following keywords will be bound by CUSTOM.
:get :group :initialize :link :load :options :prefix
:require :set :tag :type))
;; Add el(c) files in the following list if necessary.
;; Each file should be representative file of a package
;; which will be used together with emacs-w3m.
(setq files (list (locate-library "mailcap")
(locate-library "mime-def")
(locate-library "path-util")
(locate-library "poem")))
(while files
(when (setq file (pop files))
(setq dir (file-name-directory file))
(unless (member dir dirs)
(push dir dirs))))
(setq directories dirs)
(message "Searching for all the colon keywords in:")
(while dirs
(setq dir (pop dirs))
(message " %s" dir)
(setq files (directory-files dir t "\\.el\\(\\.gz\\|\\.bz2\\)?$"))
(while files
(setq file (pop files))
(if (string-match "\\(\\.gz$\\)\\|\\.bz2$" file)
(let ((temp (expand-file-name "w3mtemp.el" srcdir)))
(when
(let* ((binary (if (boundp 'MULE)
'*noconv*
'binary))
(coding-system-for-read binary)
(coding-system-for-write binary)
(input-coding-system binary)
(output-coding-system binary)
(default-process-coding-system
(cons binary binary))
call-process-hook)
(insert-file-contents file nil nil nil t)
(when
(condition-case code
(progn
(if (match-beginning 1)
(call-process-region (point-min)
(point-max)
"gzip" t buffer
nil "-cd")
(call-process-region (point-min)
(point-max)
"bzip2" t buffer
nil "-d"))
t)
(error
(erase-buffer)
(message "In file %s: %s" file code)
nil))
(write-region (point-min) (point-max) temp nil
'silent)
t))
(unwind-protect
(insert-file-contents temp nil nil nil t)
(delete-file temp))))
(insert-file-contents file nil nil nil t))
(goto-char (point-min))
(while (setq form (condition-case nil
(read buffer)
(error nil)))
(while form
(setq elem (car-safe form)
form (cdr-safe form))
(unless (memq (car-safe elem)
'(\` backquote defcustom defface defgroup
define-widget quote))
(while (consp elem)
(push (car elem) form)
(setq elem (cdr elem)))
(when (and elem
(symbolp elem)
(not (eq ': elem))
(eq ?: (aref (symbol-name elem) 0))
(not (memq elem ignores))
(not (memq elem keywords)))
(push elem keywords)))))))
;; `string-lessp' allows symbols as well.
(setq keywords (sort keywords 'string-lessp))
(erase-buffer)
(insert ";;; " w3mhack-colon-keywords-file "\
--- List of colon keywords which will be bound at run-time
;; This file should be generated by make in emacs-w3m source directory.
;; There are some colon keywords which were found in the directories
;; listed below:
;;
;; "
(mapconcat 'identity directories "\n;; ")
"\n
\(defvar w3m-colon-keywords)
\(setq w3m-colon-keywords
'(" (symbol-name (pop keywords)) "\n\t")
(let (keyword)
(while keywords
(setq keyword (symbol-name (pop keywords)))
(when (> (+ (current-column) (length keyword)) (if keywords
79
77))
(delete-char -1)
(insert "\n\t"))
(insert keyword " ")))
(delete-char -1)
(insert "))\n")
(write-region (point-min) (point) kwds-file))))
(kill-buffer buffer)))
(defun w3mhack-check-colon-keywords-file ()
(let* ((kwds-file (expand-file-name w3mhack-colon-keywords-file))
(dir (file-name-directory kwds-file)))
(when (file-writable-p dir)
(condition-case nil
: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)))
(void-variable
(byte-compile 'w3mhack-generate-colon-keywords-file)
(w3mhack-generate-colon-keywords-file))))))
(defun w3mhack-load-path ()
"Print default value of additional load paths for w3m.el."
(let (paths x)
(and (or (featurep 'xemacs)
(boundp 'MULE)
(locate-library "mime-def"))
(setq x (locate-library "poe"))
(progn
(setq x (file-name-directory x))
(if (string-match "/emu/\\'" x)
(push (substring x 0 (1+ (match-beginning 0))) paths))
(push x paths)))
(if (setq x (locate-library "mime-def"))
(push (file-name-directory x) paths))
(and (boundp 'MULE)
(setq x (locate-library "custom"))
(push (file-name-directory x) paths))
(and (boundp 'MULE)
(setq x (locate-library "regexp-opt"))
(push (file-name-directory x) paths))
(if (setq x (locate-library "mew"))
(push (file-name-directory x) paths))
(if (setq x (locate-library "gnus"))
(push (file-name-directory x) paths))
(and (if (featurep 'xemacs)
;; Mule-UCS does not support XEmacs versions prior to 21.2.37.
(and (>= emacs-major-version 21)
(or (> emacs-minor-version 2)
(and (= emacs-major-version 2)
(>= emacs-beta-version 37))))
(>= emacs-major-version 20))
(setq x (locate-library "un-define"))
(push (file-name-directory x) paths))
(and (not (featurep 'xemacs))
(<= emacs-major-version 20)
(setq x (locate-library "bitmap"))
(push (file-name-directory x) paths))
(let (print-level print-length)
(princ (mapconcat
(function directory-file-name)
(nreverse paths) ":")))))
(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))
(info-dir (pop command-line-args-left)))
(message "
lispdir=%s
ICONDIR=%s
PACKAGEDIR=%s
infodir=%s"
lisp-dir icon-dir package-dir info-dir)
(setq info-dir (file-name-as-directory info-dir))
(message "
install:
*.el, *.elc, ChangeLog* -> %s
*.info, *.info-* -> %s"
(file-name-as-directory lisp-dir) info-dir)
(setq icon-dir (file-name-as-directory icon-dir))
(unless (string-equal "NONE/" icon-dir)
(message "
install-icons:
*.gif, *.xpm -> %s"
icon-dir))
(setq package-dir (file-name-as-directory package-dir))
(message "
install-info:
*.info, *.info-* -> %s"
info-dir)
(unless (string-equal "NONE/" package-dir)
(message "
install-package:
*.el, *.elc, ChangeLog* -> %slisp/w3m/
*.gif, *.xpm -> %setc/images/w3m/
*.info, *.info-* -> %sinfo/
MANIFEST.w3m -> %spkginfo/"
package-dir package-dir package-dir package-dir)))
(message (if (featurep 'xemacs) "\n" "")))
(defun w3mhack-makeinfo ()
"Emacs makeinfo in batch mode.
NOTE: This function must be called from the top directory."
(let ((file (pop command-line-args-left))
auto-save-default
find-file-run-dired
coding-system-for-write
output-coding-system
(error 0)
(load-path load-path)
(texinfmt (locate-library "texinfmt")))
;; ptexinfmt.elc requires texinfmt.elc and texinfmt.elc requires
;; texinfo.elc in the same directory where texinfmt.elc is installed.
;; However, another version of texinfo.elc (e.g. auctex provides such
;; one) may be loaded depending on the value of the `load-path'. So,
;; we need to force it to load the correct one.
(when texinfmt
(push (file-name-directory texinfmt) load-path))
;; ptexinfmt.el uses `with-temp-buffer' which is not available in
;; Emacs 19.
(unless (fboundp 'with-temp-buffer)
(require 'poe))
(load "doc/ptexinfmt.el" nil t t)
(cd "doc")
(if (and (string-match "-ja\\.texi\\'" file)
(not (featurep 'mule)))
(message "Cannot format %s with this version of %sEmacs (ignored)"
file
(if (featurep 'xemacs) "X" ""))
(condition-case err
(progn
(find-file file)
(setq buffer-read-only nil)
(buffer-disable-undo (current-buffer))
(cond ((boundp 'MULE)
(setq output-coding-system file-coding-system))
((boundp 'buffer-file-coding-system)
(setq coding-system-for-write
(symbol-value 'buffer-file-coding-system))))
;; process @include before updating node
;; This might produce some problem if we use @lowersection or
;; such.
(let ((input-directory default-directory)
(texinfo-command-end))
(while (re-search-forward "^@include" nil t)
(setq texinfo-command-end (point))
(let ((filename (concat input-directory
(texinfo-parse-line-arg))))
(re-search-backward "^@include")
(delete-region (point) (save-excursion
(forward-line 1)
(point)))
(message "Reading included file: %s" filename)
(save-excursion
(save-restriction
(narrow-to-region
(point) (+ (point)
(car (cdr (insert-file-contents filename)))))
(goto-char (point-min))
;; Remove `@setfilename' line from included file,
;; if any, so @setfilename command not duplicated.
(if (re-search-forward "^@setfilename"
(save-excursion
(forward-line 100)
(point))
t)
(progn
(beginning-of-line)
(delete-region (point) (save-excursion
(forward-line 1)
(point))))))))))
;; Remove ignored areas.
(goto-char (point-min))
(while (re-search-forward "^@ignore[\t\r ]*$" nil t)
(delete-region (match-beginning 0)
(if (re-search-forward
"^@end[\t ]+ignore[\t\r ]*$" nil t)
(1+ (match-end 0))
(point-max))))
;; Remove unsupported commands.
(goto-char (point-min))
(while (re-search-forward "@\\(end \\)?ifnottex" nil t)
(replace-match ""))
(goto-char (point-min))
(while (search-forward "\n@iflatex\n" nil t)
(delete-region (1+ (match-beginning 0))
(search-forward "\n@end iflatex\n")))
(texinfo-mode)
(texinfo-every-node-update)
(set-buffer-modified-p nil)
(message "texinfo formatting %s..." file)
(let ((si:message (symbol-function 'message))
(si:push-mark (symbol-function 'push-mark)))
(fset
'message
(cond ((featurep 'mule)
;; Encode messages to terminal.
(byte-compile
(cond ((boundp 'MULE)
`(lambda (fmt &rest args)
(funcall ,si:message "%s"
(code-convert-string
(apply 'format fmt args)
'*internal* '*junet*))))
((featurep 'xemacs)
`(lambda (fmt &rest args)
(unless (and (string-equal fmt "%s clean")
(equal (car args)
buffer-file-name))
(funcall ,si:message "%s"
(encode-coding-string
(apply 'format fmt args)
'iso-2022-7bit)))))
(t
`(lambda (fmt &rest args)
(funcall ,si:message "%s"
(encode-coding-string
(apply 'format fmt args)
'iso-2022-7bit)))))))
((featurep 'xemacs)
(byte-compile
`(lambda (fmt &rest args)
(unless (and (string-equal fmt "%s clean")
(equal (car args) buffer-file-name))
(apply ,si:message fmt args)))))
(t
si:message)))
;; Silence it when formatting @multitable section.
(fset 'push-mark
(byte-compile
`(lambda (&rest args)
(apply ,si:push-mark (car args) t (cddr args)))))
(unwind-protect
(texinfo-format-buffer nil)
(fset 'message si:message)
(fset 'push-mark si:push-mark)))
(if (buffer-modified-p)
(progn (message "Saving modified %s" (buffer-file-name))
(save-buffer))))
(error
(message ">> Error: %s" (prin1-to-string err))
(message ">> point at")
(let ((s (buffer-substring (point) (min (+ (point) 100) (point-max))))
(tem 0))
(while (setq tem (string-match "\n+" s tem))
(setq s (concat (substring s 0 (match-beginning 0))
"\n>> "
(substring s (match-end 0)))
tem (1+ tem)))
(message ">> %s" s))
(setq error 1))))
(kill-emacs error)))
(defun w3mhack-update-files-autoloads (files)
"Run `update-file-autoloads' with FILES, silently in XEmacs."
(if (featurep 'xemacs)
(let ((si:message (symbol-function 'message)))
(defun message (fmt &rest args)
"Ignore useless messages while generating autoloads."
(cond ((and (string-equal "Generating autoloads for %s..." fmt)
(file-exists-p (file-name-nondirectory (car args))))
(funcall si:message
fmt (file-name-nondirectory (car args))))
((string-equal "No autoloads found in %s" fmt))
((string-equal "Generating autoloads for %s...done" fmt))
(t (apply si:message fmt args))))
(unwind-protect
(dolist (file files)
(update-file-autoloads file))
(fset 'message si:message)))
(dolist (file files)
(update-file-autoloads file))))
(defun w3mhack-generate-load-file ()
"Generate a file including all autoload stubs."
(require 'autoload)
(let ((files (w3mhack-module-list))
(generated-autoload-file (expand-file-name w3mhack-load-file))
(make-backup-files nil)
(autoload-package-name "emacs-w3m"))
(if (and (file-exists-p w3mhack-load-file)
(not (catch 'modified
(dolist (file files)
(when (file-newer-than-file-p file w3mhack-load-file)
(throw 'modified t))))))
(message " `%s' is up to date" w3mhack-load-file)
(when (fboundp 'autoload-ensure-default-file)
(autoload-ensure-default-file generated-autoload-file))
(save-excursion
(set-buffer (find-file-noselect generated-autoload-file))
(if (fboundp 'autoload-ensure-default-file)
(let ((case-fold-search t))
(goto-char (point-min))
(when (re-search-forward
"^[\t ]*\\(;+[\t ]*Local[\t ]+Variables:\\)"
nil t)
(delete-region (point-min) (match-beginning 1))
(goto-char (point-min))))
(erase-buffer))
(insert ";;; " w3mhack-load-file "\
--- automatically extracted autoload
;;
;; This file should be generated by make in emacs-w3m source directory.
;;
;;; Code:
\(provide '" (file-name-sans-extension w3mhack-load-file) ")
")
;; When missing ^L, `update-file-autoloads' of old emacsen
;; such as Mule2.3 signals an error.
(unless (featurep 'xemacs)
(insert "\C-l\n"))
(w3mhack-update-files-autoloads files)
(unless (fboundp 'autoload-ensure-default-file)
(goto-char (point-max))
(insert (if (featurep 'xemacs) "\C-l\n" "")
";;; " w3mhack-load-file " ends here\n"))
(save-buffer)))))
(defun w3mhack-generate-xemacs-load-file (file)
(with-temp-buffer
(insert "\
;;; DO NOT MODIFY THIS FILE
\(if (featurep 'w3m-autoloads) (error \"Already loaded\"))
\(or (featurep '" (file-name-sans-extension w3mhack-load-file) ")
(load (expand-file-name \"" w3mhack-load-file "\"
(if load-file-name
(file-name-directory load-file-name)))
nil t t))
\(provide 'w3m-autoloads)
")
(write-region (point-min) (point-max) file)))
(defun w3mhack-locate-library ()
"Print the precise file name of Emacs library remaining on the commane line."
(princ (or (locate-library (pop command-line-args-left)) "")))
(defun w3mhack-print-status ()
(princ "OK"))
(defun w3mhack-version ()
"Print the value of `emacs-w3m-version'."
(require 'w3m)
(let (print-level print-length)
(princ emacs-w3m-version)))
;;; w3mhack.el ends here
|