forked from emacs-w3m/emacs-w3m
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
w3m.el
12119 lines (11359 loc) · 445 KB
/
w3m.el
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
;;; w3m.el --- an Emacs interface to w3m -*- lexical-binding: t -*-
;; Copyright (C) 2000-2024 TSUCHIYA Masatoshi <[email protected]>
;; Authors: TSUCHIYA Masatoshi <[email protected]>,
;; Shun-ichi GOTO <[email protected]>,
;; Satoru Takabayashi <[email protected]>,
;; Hideyuki SHIRAI <[email protected]>,
;; Keisuke Nishida <[email protected]>,
;; Yuuichi Teranishi <[email protected]>,
;; Akihiro Arisawa <[email protected]>,
;; Katsumi Yamaoka <[email protected]>,
;; Tsuyoshi CHO <[email protected]>
;; Keywords: w3m, WWW, hypermedia
;; This file is the main 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., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Emacs-w3m is an Emacs interface to the w3m program. For more
;; detail about w3m, see:
;;
;; http://w3m.sourceforge.net/
;;; How to install:
;; See the README file in any case. We also recommend you check
;; whether a newer version of w3m is released.
;;
;; The outline of installation is: run the `configure' script and type
;; `make install' in the top directory of the emacs-w3m distribution.
;;; Code:
(require 'cl-lib) ;; cl-decf, cl-incf, cl-labels, cl-remove-if
(require 'w3m-util)
(require 'w3m-proc)
(require 'tab-line) ;; tab-line-exclude-modes
;; `w3m-use-tab-line' refers this variable.
(eval-and-compile
(defcustom w3m-use-tab t
"Use emacs-w3m in \"Tabbed\" display mode.
This variable is now DEPRECATED! Please use `w3m-display-mode'
instead. When non-nil, emacs-w3m will make a reasonable effort to
display all its buffers in a single window, which has a clickable
tab bar along the top.
See also `w3m-use-tab-line' and `w3m-use-tab-menubar'."
:group 'w3m
:type 'boolean
:set (lambda (symbol value)
(prog1
(custom-set-default symbol value)
(when (boundp 'w3m-use-tab-line)
;; w3m.elc has already been loaded
;; or `w3m-use-tab-line' has already been set.
(if (and value w3m-use-tab-line)
(add-to-list 'tab-line-exclude-modes 'w3m-mode)
(setq tab-line-exclude-modes
(delq 'w3m-mode tab-line-exclude-modes))))))))
;; Why the two variable `w3m-select-buffer-hook' and `w3m-use-tab-line'
;; are here is because w3m-ems.el uses.
(defcustom w3m-select-buffer-hook nil
"Hook run when a different emacs-w3m buffer is selected."
:group 'w3m
:type 'hook)
(require 'w3m-fb) ;; The following section references `w3m-fb-mode'.
(eval-and-compile
(defcustom w3m-use-tab-line t
"Use `tab-line-format' instead of `header-line-format' to display tabs.
See also `w3m-use-tab'."
:group 'w3m
:type 'boolean
:set (lambda (symbol value)
(prog1
value
(if (boundp symbol)
(unless (equal (symbol-value symbol) value)
(custom-set-default symbol value)
(when (featurep 'w3m-ems)
(defvar w3m-tab-separator-map)
(setcar (cadr w3m-tab-separator-map)
(if value 'tab-line 'header-line))
(let ((cur (cons (selected-frame) (selected-window)))
window)
(dolist (buffer (let (w3m-fb-mode) (ignore w3m-fb-mode)
(w3m-list-buffers t)))
(with-current-buffer buffer
(w3m-setup-tab-line)
(w3m-tab-make-keymap t)
;; Redisplay window in order to redraw tabs
;; (`force-mode-line-update', `redraw-display', etc.
;; didn't work but is this really necessary?).
(when (setq window
(get-buffer-window buffer 'visible))
(unwind-protect
(progn
(select-frame (window-frame window))
(select-window window t)
(with-temp-buffer
(switch-to-buffer (current-buffer))
(sit-for 0)))
(select-frame (car cur))
(select-window (cdr cur)))))))))
(custom-set-default symbol value))
(if (and value w3m-use-tab)
(add-to-list 'tab-line-exclude-modes 'w3m-mode)
(setq tab-line-exclude-modes
(delq 'w3m-mode tab-line-exclude-modes)))))))
(eval-and-compile (require 'w3m-ems))
(add-hook 'w3m-select-buffer-hook #'w3m-set-buffer-seen)
(require 'bookmark-w3m)
(require 'w3m-hist)
(require 'timezone)
(require 'image-mode)
;; Add-on programs:
(eval-and-compile
(autoload 'w3m-bookmark-view "w3m-bookmark"
"Display the bookmark" t)
(autoload 'w3m-bookmark-view-new-session "w3m-bookmark"
"Display the bookmark on a new session" t)
(autoload 'w3m-bookmark-add-this-url "w3m-bookmark"
"Add a link under point to the bookmark." t)
(autoload 'w3m-bookmark-add-current-url "w3m-bookmark"
"Add a url of the current page to the bookmark." t)
(autoload 'w3m-bookmark-add-all-urls "w3m-bookmark"
"Add urls of all pages being visited to the bookmark." t)
(autoload 'w3m-bookmark-add "w3m-bookmark" "Add URL to bookmark.")
(autoload 'w3m-bookmark-iterator "w3m-bookmark"
"Iteration bookmark groups/entries.")
(autoload 'w3m-search "w3m-search"
"Search a word using search engines." t)
(autoload 'w3m-search-new-session "w3m-search"
"Search a word using search engines in a new session." t)
(autoload 'w3m-search-uri-replace "w3m-search")
(autoload 'w3m-weather "w3m-weather"
"Display a weather report." t)
(autoload 'w3m-about-weather "w3m-weather")
(autoload 'w3m-antenna "w3m-antenna"
"Report changes of web sites." t)
(autoload 'w3m-antenna-add-current-url "w3m-antenna"
"Add a link address of the current page to the antenna database." t)
(autoload 'w3m-about-antenna "w3m-antenna")
(autoload 'w3m-dtree "w3m-dtree"
"Display a directory tree." t)
(autoload 'w3m-about-dtree "w3m-dtree")
(autoload 'w3m-namazu "w3m-namazu"
"Search files with Namazu." t)
(autoload 'w3m-about-namazu "w3m-namazu")
(autoload 'w3m-perldoc "w3m-perldoc"
"View Perl documents" t)
(autoload 'w3m-about-perldoc "w3m-perldoc")
(autoload 'w3m-fontify-forms "w3m-form")
(autoload 'w3m-fontify-textareas "w3m-form")
(autoload 'w3m-form-textarea-file-cleanup "w3m-form")
(autoload 'w3m-form-textarea-files-remove "w3m-form")
(autoload 'w3m-form-kill-buffer "w3m-form")
(autoload 'w3m-form-set-number "w3m-form")
(autoload 'w3m-form-expand-form "w3m-form")
(autoload 'w3m-form-unexpand-form "w3m-form")
(autoload 'w3m-form-make-form-data "w3m-form")
(autoload 'w3m-filter "w3m-filter")
(autoload 'w3m-toggle-filtering "w3m-filter"
"Toggle whether to modify html source by the filters before rendering." t)
(autoload 'w3m-setup-tab-menu "w3m-tabmenu")
(autoload 'w3m-setup-bookmark-menu "w3m-bookmark")
(autoload 'w3m-switch-buffer "w3m-tabmenu")
(autoload 'w3m-cookie-set "w3m-cookie")
(autoload 'w3m-cookie-get "w3m-cookie")
(autoload 'w3m-cookie "w3m-cookie")
(autoload 'w3m-about-cookie "w3m-cookie")
(autoload 'w3m-cookie-shutdown "w3m-cookie" nil t)
(autoload 'report-emacs-w3m-bug "w3m-bug" nil t)
(autoload 'w3m-replace-symbol "w3m-symbol" nil t)
(autoload 'w3m-mail "w3m-mail" nil t)
(autoload 'w3m-lnum-mode "w3m-lnum" nil t)
(autoload 'w3m-lnum-follow "w3m-lnum" nil t)
(autoload 'w3m-lnum-goto "w3m-lnum" nil t)
(autoload 'w3m-lnum-universal "w3m-lnum" nil t)
(autoload 'w3m-lnum-toggle-inline-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-view-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-external-view-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-edit-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-print-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-download-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-bookmark-add-this-url "w3m-lnum" nil t)
(autoload 'w3m-lnum-zoom-in-image "w3m-lnum" nil t)
(autoload 'w3m-lnum-zoom-out-image "w3m-lnum" nil t)
(autoload 'w3m-session-select "w3m-session"
"Select session from session list." t)
(autoload 'w3m-session-save "w3m-session"
"Save list of displayed session." t)
(autoload 'w3m-setup-session-menu "w3m-session")
(autoload 'w3m-session-automatic-save "w3m-session")
(autoload 'w3m-session-deleted-save "w3m-session")
(autoload 'w3m-session-last-autosave-session "w3m-session")
(autoload 'w3m-session-goto-session "w3m-session")
(autoload 'w3m-session-crash-recovery-save "w3m-session")
(autoload 'w3m-session-last-crashed-session "w3m-session")
(autoload 'w3m-save-buffer "w3m-save"
"Save the current page and its image data locally."))
;; Avoid byte-compile warnings.
(declare-function doc-view-mode "doc-view")
(declare-function doc-view-mode-p "doc-view" (type))
(declare-function image-backward-hscroll "image-mode" (&optional n))
(declare-function image-bol "image-mode" (arg))
(declare-function image-eol "image-mode" (arg))
(declare-function image-forward-hscroll "image-mode" (&optional n))
(declare-function image-mode-setup-winprops "image-mode")
(declare-function image-scroll-down "image-mode" (&optional n))
(declare-function image-scroll-up "image-mode" (&optional n))
(declare-function quit-window "window" (&optional kill window))
(declare-function w3m-search-escape-query-string "w3m-search"
(str &optional coding))
(declare-function widget-convert-button "wid-edit" (type from to &rest args))
(declare-function widget-forward "wid-edit" (arg))
(declare-function widget-get "wid-edit" (widget property))
(declare-function zone-call "zone" (program &optional timeout))
(defvar bidi-paragraph-direction)
(defvar doc-view-mode-map)
(defvar w3m-bookmark-mode)
(defvar w3m-bookmark-menu-items)
(defvar w3m-bookmark-menu-items-pre)
(defvar w3m-tab-menubar-make-items-preitems)
(defvar w3m-search-engine-alist)
(defvar w3m-session-menu-items-pre)
(defvar w3m-session-menu-items)
;; The version is decided by the final revision 1.1717 which was
;; hosted by the CVS repository.
(defconst emacs-w3m-version
"1.4.632"
"Version number of this package.
Not to be confused with `w3m-version'.")
(defgroup w3m nil
"Emacs-w3m - the web browser of choice."
:group 'hypermedia)
(defgroup w3m-face nil
"Faces used for emacs-w3m."
:group 'w3m
:prefix "w3m-")
(defcustom w3m-command nil
"Name of the executable file of the w3m command.
You normally don't have to specify the value, since emacs-w3m looks
for the existing commands in order of w3m, w3mmee and w3m-m17n in the
`exec-path' directories in order if it is nil in the beginning.
If you want to use the other w3m command, specify the value of this
variable explicitly in the .emacs file or customize the value and save
it. In this case, you need to restart Emacs and emacs-w3m. That is,
there is currently no way to apply the changing of the w3m command to
all the emacs-w3m programs safely after loading the w3m.elc module."
:group 'w3m
:type '(radio (const :format "Not specified " nil)
(string :format "Command: %v")))
(defcustom w3m-display-ins-del 'auto
"Value of `display_ins_del' option."
:group 'w3m
:type '(radio (const :format "Delect automatically " auto)
(const :format "Use fontify\n" fontify)
(const :format "Use tag " tag)
(const :format "No have option" nil)))
(defvar w3m-type nil
"Type of the w3m command.
The valid values include `w3m', `w3mmee', and `w3m-m17n'.")
(defvar w3m-compile-options nil
"Compile options that the w3m command was built with.")
(defvar w3m-version nil
"Version string of the external w3m command.
Not to be confused with `emacs-w3m-version'.")
;; Set w3m-command, w3m-type, w3m-version and w3m-compile-options
(if noninteractive ;; Don't call the external command when compiling.
(unless w3m-command
(setq w3m-command "w3m"))
(when (or (null w3m-command)
(null w3m-type)
(null w3m-version)
(null w3m-compile-options))
(let ((command (or w3m-command
(w3m-which-command "w3m")
(w3m-which-command "w3mmee")
(w3m-which-command "w3m-m17n"))))
(when command
(setq w3m-command command)
(with-temp-buffer
(call-process command nil t nil "-version")
(goto-char (point-min))
(when (re-search-forward "version \\(w3m/0\\.[3-9]\
\\(?:\\.[0-9\\]\\)*\\(?:rc[0-9]+\\)?\
\\(?:-stable\\|\\(?:\\+cvs\\(?:-[0-9]+\\.[0-9]+\\)?\\)\\)?\
\\(?:-inu\\|\\(-m17n\\|\\(\\+mee\\)\\)\\)?[^,]*\\)" nil t)
(setq w3m-version (match-string 1))
(setq w3m-type
(cond
((match-beginning 3) 'w3mmee)
((match-beginning 2) 'w3m-m17n)
((match-beginning 1) 'w3m)
(t 'other))))
(when (re-search-forward "options +" nil t)
(setq w3m-compile-options
(or (split-string (buffer-substring (match-end 0)
(line-end-position))
",")
(list nil)))
(when (member "m17n" w3m-compile-options)
(setq w3m-type 'w3m-m17n))))))))
(when (not (stringp w3m-command))
(error "\
Install w3m command in `exec-path' or set `w3m-command' variable correctly"))
(defcustom w3m-user-agent (concat "Emacs-w3m/" emacs-w3m-version
" " w3m-version)
"String used for the User-Agent field. See also `w3m-add-user-agent'."
:group 'w3m
:type 'string)
(defcustom w3m-add-user-agent t
"Non-nil means add the User-Agent field to the request header.
The value of `w3m-user-agent' is used for the field body."
:group 'w3m
:type 'boolean)
(defvar w3m-user-agent-default-alist
`(("Emacs-w3m (user default)" . ,w3m-user-agent)
("Emacs-w3m (package default)"
. ,(concat "Emacs-w3m/" emacs-w3m-version " " w3m-version)))
"An default alist of user agent strings.
This is used when offering the user the opportunity to change user
agent strings. This should normally not be modified; instead modify
`w3m-user-agent-alist'.")
(defcustom w3m-user-agent-alist
'(("Android" . "Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36\
(KHTML, like Gecko) Chrome/91.0.4472.120 Mobile Safari/537.36")
("Apple iOS" . "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X)\
AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148\
Safari/604.1")
("Linux Chrome" . "Mozilla/5.0 (X11; CrOS armv7l 9592.96.0)\
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.114 Safari/537.36")
("Linux Firefox" . "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\
Firefox/78.0")
("Mac OS Chrome" . "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)\
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36")
("Mac OS Firefox" . "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0)\
Gecko/20100101 Firefox/56.0")
("Mac OS Opera" . "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)\
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36\
OPR/47.0.2631.55")
("Mac OS Safari" . "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)\
AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5")
("Windows Chrome" . "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36\
(KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36")
("Windows Edge" . "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36\
Edge/15.15063")
("Windows Explorer" . "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0;\
rv:11.0) like Gecko")
("Windows Firefox" . "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0)\
Gecko/20100101 Firefox/56.0")
("Windows Opera" . "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\
OPR/48.0.2685.52")
("Windows Safari" . "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)\
AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27"))
"An alist of user agent strings.
Each entry should be a cons of a short descriptive string and the user
agent string."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 2
(string :tag "Short Description")
(string :tag "User Agent string"))))
(defcustom w3m-user-agent-site-specific-alist nil
"An alist of user-agent strings to be used for specific URLs.
Each entry should be a CONS, whose CAR is a regexp of the URLs to be
covered by the rule, and whose CDR is either a user-agent string to be
used or a string matching a CAR of variable `w3m-user-agent-alist'."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 2
(string :tag "URL regexp")
(string :tag "User Agent string"))))
(defcustom w3m-language (if (equal #1="Japanese" current-language-environment)
#1#)
"Your preferred language used in emacs-w3m sessions."
:group 'w3m
:type '(radio
:value-to-internal (lambda (_widget value)
(if (and (stringp value)
(let ((case-fold-search t))
(string-match "\\`japan" value)))
"Japanese"))
:value-to-external (lambda (_widget value)
(if (equal value "Japanese") "Japanese"))
(const :format "%v " "Japanese")
(const :tag "Other" nil)))
(defcustom w3m-command-arguments
(if (eq w3m-type 'w3mmee) '("-o" "concurrent=0" "-F") nil)
"List of the default arguments passed to the w3m command.
See also `w3m-command-arguments-alist'."
:group 'w3m
:type '(repeat (string :format "Argument: %v")))
(defcustom w3m-command-arguments-alist nil
"Alist of regexps matching urls and additional arguments passed to w3m.
A typical usage of this variable is to specify whether to use the proxy
server for the particular hosts. The first match made will be used.
Here is an example of how to set this variable:
(setq w3m-command-arguments-alist
\\='(;; Don't use the proxy server to visit local web pages.
(\"\\\\`http://\\\\(?:[^/]*\\\\.\\\\)*your-company\\\\.com\\\\(?:/\\\\|\\\\'\\\\)\"
\"-no-proxy\")
;; Use the proxy server to visit any foreign urls.
(\"\"
\"-o\" \"http_proxy=http://proxy.your-company.com:8080/\")))
Where the first element matches the url that the scheme is \"http\" and
the hostname is either \"your-company.com\" or a name ended with
\".your-company.com\", and the proxy server is not used for those hosts.
If you are a novice on the regexps, you can use the
`w3m-no-proxy-domains' variable instead."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 4
(regexp :format "%t: %v")
(repeat :tag "Arguments passed to w3m command"
(string :format "Arg: %v")))))
(defcustom w3m-no-proxy-domains nil
"List of domain names with which emacs-w3m will not use a proxy server.
Each element should be exactly a domain name which means the latter
common part of the host names, not a regexp."
:group 'w3m
:type '(repeat (string :format "Domain name: %v")))
(defcustom w3m-command-environment
(delq nil
(list
(if (eq w3m-type 'w3mmee)
(cons "W3MLANG" "ja_JP.kterm"))
(if (eq system-type 'cygwin)
(cons "CYGWIN" "binmode"))
(cons "LC_ALL" "C")))
"Alist of environment variables for subprocesses to inherit."
:group 'w3m
:type '(repeat
(cons :format "%v" :indent 4
(string :format "Name: %v")
(string :format " Value: %v"))))
(defcustom w3m-fill-column -1
"Integer used as the value for `fill-column' in emacs-w3m buffers.
If it is positive, pages will be displayed within the columns of that
number. If it is zero or negative, the number of columns which
subtracted that number from the window width is applied to the maximum
width of pages."
:group 'w3m
:type 'integer)
(defcustom w3m-mailto-url-function nil
"Function used to handle the `mailto' urls.
Function is called with one argument, just a url. If it is nil, a
function specified by the `mail-user-agent' variable will be used for
composing mail messages."
:group 'w3m
:type '(radio (const :tag "Not specified" nil)
(function :format "%t: %v")))
(defcustom w3m-mailto-url-popup-function-alist
'((cmail-mail-mode . pop-to-buffer)
(mail-mode . pop-to-buffer)
(message-mode . pop-to-buffer)
(mew-draft-mode . pop-to-buffer)
(mh-letter-mode . pop-to-buffer)
(wl-draft-mode . pop-to-buffer))
"Alist of (MAJOR-MODE . FUNCTION) pairs used to pop to a mail buffer up.
If a user clicks on a `mailto' url and a mail buffer is composed by
`mail-user-agent' with the MAJOR-MODE, FUNCTION will be called with
a mail buffer as an argument.
Note that the variables `display-buffer-alist',
`same-window-buffer-names' and `same-window-regexps' will be bound to
nil while popping to a buffer up."
:group 'w3m
:type '(repeat (cons :format "%v" :indent 11
(symbol :format "Major-mode: %v")
(function :format "%t: %v"))))
(defcustom w3m-use-ange-ftp nil
"Non-nil means that `ange-ftp' or `efs' is used to access FTP servers."
:group 'w3m
:type 'boolean)
(defcustom w3m-doc-view-content-types
(condition-case nil
(delq nil (mapcar (lambda (type)
(if (doc-view-mode-p type)
(format "application/%s" type)))
'(dvi postscript pdf)))
(error nil))
"List of content types for which to use `doc-view-mode' to view contents.
This overrides `w3m-content-type-alist'."
:group 'w3m
:type '(repeat (string :tag "Type" :value "application/")))
(define-obsolete-variable-alias
'w3m-imitate-widget-button 'w3m-handle-non-anchor-buttons "sometime")
(define-obsolete-function-alias
'w3m-imitate-widget-button 'w3m-handle-non-anchor-buttons "sometime")
(defcustom w3m-handle-non-anchor-buttons '(derived-mode-p 'gnus-article-mode)
"If non-nil, regard non anchor buttons as anchor buttons.
It is useful for moving about in a Gnus article buffer using TAB key.
The value may be a boolean, or a list that will be `eval'd."
:group 'w3m
:type '(radio (const :format "%v " nil) (const :format "%v \n" t)
(sexp :format "Sexp to be eval'd: %v")))
(defcustom w3m-treat-image-size t
"Non-nil means let w3m mind the ratio of the size of images and text.
If it is non-nil, the w3m command will make a halfdump which reserves
rectangle spaces in which images will be put, and also `alt' texts
will be truncated or padded with spaces so that their display width
will be the same as the width of images.
See also `w3m-pixels-per-character' and `w3m-pixels-per-line'. Those
values will be passed to the w3m command in order to compute columns
and lines which images occupy."
:group 'w3m
:type 'boolean)
(defcustom w3m-pixels-per-line 64
"Integer used for the `-ppl' argument of the w3m command.
If nil, the height of the default face is used. It is valid only when
`w3m-treat-image-size' is non-nil. Note that a small value may not
induce a good result. If you want to use emacs-w3m in a character
terminal and make `w3m-treat-image-size' effective, you need to set
this variable properly."
:group 'w3m
:type '(choice (const :tag "Auto Detect" nil)
(integer :tag "Specify Pixels")))
(defcustom w3m-pixels-per-character nil
"Integer used for the `-ppc' argument of the w3m command.
If nil, the width of the default face is used. It is valid only when
`w3m-treat-image-size' is non-nil. If you want to use emacs-w3m in a
character terminal and make `w3m-treat-image-size' effective, you need
to set this variable properly."
:group 'w3m
:type '(radio (const :tag "Auto Detect" nil)
(integer :format "Specify Pixels: %v")))
(defcustom w3m-image-default-background nil
"Color name used as transparent color of image.
Nil means to use the background color of the Emacs frame. Note that
this value is effective only to xbm and monochrome pbm images in Emacs
22 and greater."
:group 'w3m
:type '(radio (string :format "Color: %v"
:match (lambda (widget value)
(and (stringp value) (> (length value) 0))))
(const :tag "Use the background color of the Emacs frame" nil)
(const :tag "Null string" "")))
(defvar w3m-accept-japanese-characters
(and (not noninteractive)
(or (memq w3m-type '(w3mmee w3m-m17n))
;; Examine whether the w3m command specified by `w3m-command'
;; uses `euc-japan' for the internal character set.
(let ((str
(eval-when-compile
(format
(concat
"<!doctype html public \"-//W3C//DTD HTML 3.2//EN\">"
"<html><head><meta http-equiv=\"Content-Type\" "
"content=\"text/html; charset=ISO-2022-JP\">"
"</head><body>%s</body>\n")
(string 27 36 66 52 65 59 122 27 40 66)))))
(with-temp-buffer
(set-buffer-multibyte nil)
(insert str)
(let ((coding-system-for-write 'binary)
(coding-system-for-read 'binary)
(default-process-coding-system (cons 'binary 'binary)))
(call-process-region (point-min) (point-max) w3m-command
t t nil "-T" "text/html" "-halfdump")
(goto-char (point-min))
(and (re-search-forward (string ?\264 ?\301 ?\273 ?\372)
nil t)
t))))))
"Non-nil means that the w3m command accepts Japanese characters.")
(defcustom w3m-coding-system (if (eq w3m-type 'w3mmee)
'iso-2022-7bit-ss2
'iso-2022-7bit)
"Default coding system used to communicate with the w3m command."
:group 'w3m
:type 'coding-system)
(defcustom w3m-terminal-coding-system (if w3m-accept-japanese-characters
'euc-japan 'iso-8859-1)
"Default coding system used when writing to w3m processes.
It is just a default value to set process' coding system initially.
(This variable name is analogically derived from the behavior of the
w3m command which accepts data from Emacs just like reads from the
terminal.)"
:group 'w3m
:type 'coding-system)
(defcustom w3m-output-coding-system (if (eq w3m-type 'w3mmee) 'ctext 'utf-8)
"Coding system used when reading from w3m processes."
:group 'w3m
:type 'coding-system)
(defcustom w3m-input-coding-system w3m-output-coding-system
"Coding system used when writing to w3m processes.
It overrides `coding-system-for-write' if it is not `binary'.
Otherwise, the value of the `w3m-current-coding-system' variable is
used instead."
:group 'w3m
:type 'coding-system)
(defcustom w3m-file-coding-system 'iso-2022-7bit
"Coding system used when writing configuration files.
This value will be referred to by the `w3m-save-list' function."
:group 'w3m
:type 'coding-system)
(defvar w3m-file-coding-system-for-read nil
"*Coding system used when reading configuration files.
It is strongly recommended that you do not set this variable if there
is no particular reason. The value will be referred to by the
`w3m-load-list' function.")
(defcustom w3m-file-name-coding-system
(if (memq system-type '(windows-nt OS/2 emx))
'shift_jis 'euc-japan)
"Coding system used to convert pathnames when emacs-w3m accesses files."
:group 'w3m
:type 'coding-system)
(defcustom w3m-default-coding-system
(if (equal "Japanese" w3m-language) 'shift_jis 'iso-8859-1)
"Default coding system used to encode url strings and post-data."
:group 'w3m
:type 'coding-system)
(defcustom w3m-coding-system-priority-list
(if (equal "Japanese" w3m-language) '(shift_jis))
"Coding systems in order of priority used for emacs-w3m sessions."
:group 'w3m
:type '(repeat (coding-system :format "%t: %v")))
(defcustom w3m-url-coding-system-alist
'(("\\`https?://\\(?:[^./?#]+\\.\\)+google\\(?:\\.[^./?#]+\\)+/"
. (lambda (url)
(if (string-match "&ie=\\([^&]+\\)" url)
(w3m-charset-to-coding-system (match-string 1 url)))))
(nil . utf-8))
"Alist of url regexps and coding systems used to encode url to retrieve.
The form looks like:
((\"REGEXP\" . CODING) (\"REGEXP\" . CODING)...(nil . CODING))
Where REGEXP is a regular expression that matches a url. REGEXP nil
means any url; element of which the car is nil, that is the default,
has to be the last item of this alist.
CODING is a coding system used to encode a url that REGEXP matches.
CODING nil means using the coding system corresponding to a charset
used to encode the current page. CODING may also be a function that
takes one argument URL and returns a coding system.
If the example.com site requires a browser to use `shift_jis' to encode
url for example, you can add it to this variable as follows:
(add-to-list
\\='w3m-url-coding-system-alist
\\='(\"\\\\\\=`https?://\\\\(?:[^./?#]+\\\\.\\\\)*example\\\\.com/\" . shift_jis))"
:group 'w3m
:type '(repeat (cons :format "\n%v" :indent 2
(radio :format "nil or regexp:\n %v"
(const :format "Any " nil)
regexp)
(radio :format "coding-system or function:\n %v"
(const :format "Page's coding system " nil)
coding-system
function))))
(defcustom w3m-key-binding nil
"Type of key binding set used in emacs-w3m sessions.
The valid values include `info' which provides Info-like keys, and
nil which provides Lynx-like keys."
:group 'w3m
:type '(choice
(const :tag "Use Info-like key mapping." info)
(const :tag "Use Lynx-like key mapping." nil))
:set (lambda (symbol value)
(prog1
(custom-set-default symbol value)
(if (or noninteractive
;; Loading w3m.elc is just in progress...
(not (featurep 'w3m)))
nil
(if (and;; Some program might bind `w3m-mode-map' for compiling.
(boundp 'w3m-mode-map)
(boundp 'w3m-info-like-map)
(boundp 'w3m-lynx-like-map))
;; It won't be bound at the first time.
(eval
`(setq w3m-mode-map (if (eq ',value 'info)
w3m-info-like-map
w3m-lynx-like-map)
w3m-minor-mode-map (w3m-make-minor-mode-keymap))))
(let ((buffers (buffer-list)))
(save-current-buffer
(while buffers
(set-buffer (car buffers))
(if (eq major-mode 'w3m-mode)
(condition-case nil
(progn
(use-local-map (symbol-value 'w3m-mode-map))
(w3m-setup-toolbar)
(w3m-setup-menu))
(error)))
(setq buffers (cdr buffers)))))))))
(defcustom w3m-use-cygdrive (eq system-type 'cygwin)
"If non-nil, use /cygdrive/ prefix when performing `expand-file-name'."
:group 'w3m
:type 'boolean)
(eval-and-compile
(defconst w3m-treat-drive-letter (memq system-type '(windows-nt OS/2 emx))
"Say whether the system uses drive letters."))
(defcustom w3m-profile-directory
(concat "~/." (file-name-sans-extension
(file-name-nondirectory w3m-command)))
"Directory where emacs-w3m config files are loaded from or saved to."
:group 'w3m
:type 'directory)
(defcustom w3m-init-file "~/.emacs-w3m"
"Your emacs-w3m startup file name.
If a file with the `.el' or `.elc' suffixes exists, it will be read
instead. Nil means no init file will be loaded.
Note: This file is used as the startup configuration *NOT* for the w3m
command but for emacs-w3m. In order to modify configurations for the
w3m command, edit the file named \"~/.w3m/config\" normally."
:group 'w3m
:type '(radio file (const :format "None " nil)))
(defcustom w3m-default-save-directory
(concat "~/." (file-name-sans-extension
(file-name-nondirectory w3m-command)))
"Default directory where downloaded files will be saved to."
:group 'w3m
:type 'directory)
(defcustom w3m-external-view-temp-directory w3m-profile-directory
"Directory where files are saved for the external file viewer."
:group 'w3m
:type 'directory)
(defcustom w3m-default-directory nil
"Directory used as the current directory in emacs-w3m buffers.
The valid values include a string specifying an existing directory,
a symbol of which the value specifies an existing directory,
a function which takes a url as an argument and returns a directory,
and nil. If the specified directory does not exist or it is nil,
the value of `w3m-profile-directory' is used.
Note that there is an exception: if a page visits a local file or
visits a remote file using ftp, the directory in which the file exists
is used as the current directory instead."
:group 'w3m
:type '(radio (directory :format "%{%t%}: %v" :value "~/")
(symbol :format "%{%t%}: %v"
:match (lambda (widget value) value)
:value default-directory)
(function :format "%{%t%}: %v")
(const nil)))
(defcustom w3m-queries-log-file (expand-file-name
"emacs-w3m-queries_log.txt"
w3m-profile-directory)
"File in which to log URL queries."
:group 'w3m
:type 'file)
(defcustom w3m-accept-languages
(let ((file (expand-file-name "config" w3m-profile-directory)))
(or (when (file-readable-p file)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(when (re-search-forward "^accept_language[\t ]+\\(.+\\)$" nil t)
(delete "" (split-string (match-string 1)
"[ \t\r\f\n]*,[ \t\r\f\n]*")))))
(when (string= w3m-language "Japanese")
'("ja" "en"))))
"List of acceptable languages in descending order of priority.
The default value is set according to the accept_language entry of the
w3m configuration file (normally \"~/.w3m/config\")."
:group 'w3m
:type '(repeat (string :format "Lang: %v")))
(defcustom w3m-delete-duplicated-empty-lines t
"Non-nil means display two or more continuous empty lines into single."
:group 'w3m
:type 'boolean)
(defvar-local w3m-display-inline-images nil
"Internal variable controls whether to show images in emacs-w3m buffers.
This variable is buffer-local which defaults to the value of
`w3m-default-display-inline-images'. Don't set it directly; modify
the `w3m-default-display-inline-images' variable or use the\
`\\<w3m-mode-map>\\[w3m-toggle-inline-images]' command
to change the appearance of images.
See also `w3m-toggle-inline-images-permanently'.")
(defcustom w3m-default-display-inline-images nil
"Non-nil means display images inline in emacs-w3m buffers.
You can toggle the visibility of images by the\
`\\<w3m-mode-map>\\[w3m-toggle-inline-images]' command.
See also `w3m-toggle-inline-images-permanently'."
:group 'w3m
:type 'boolean)
(defcustom w3m-toggle-inline-images-permanently t
"Non-nil means let the visibility of images continue permanently.
The visibility of images is initialized according to
`w3m-default-display-inline-images' at the first time, and except that
it may be toggled by the `\\<w3m-mode-map>\\[w3m-toggle-inline-images]'\
command, it does not change hereafter, if
it is non-nil. Otherwise, whether images are visible is initialized
according to `w3m-default-display-inline-images' whenever you visit a
new page or reload the current page in an emacs-w3m buffer."
:group 'w3m
:type 'boolean)
(defcustom w3m-icon-directory
(let (dir)
(or
(catch 'found-dir
(let* ((path (locate-library "w3m"))
(paths (if path
(cons (file-name-directory path) load-path)
load-path)))
(while paths
(setq path (car paths)
paths (cdr paths))
(if path
(progn
(if (file-directory-p
(setq dir
(expand-file-name "../../etc/images/w3m/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../etc/images/w3m/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../../etc/w3m/icons/" path)))
(throw 'found-dir dir))
(if (file-directory-p
(setq dir
(expand-file-name "../etc/w3m/icons/" path)))
(throw 'found-dir dir)))))))
(and (file-directory-p
(setq dir (expand-file-name "images/w3m/" data-directory)))
dir)
(and (file-directory-p
(setq dir (expand-file-name "w3m/icons/" data-directory)))
dir)))
"Directory where emacs-w3m should find icon files."
:group 'w3m
:type '(radio (const :tag "Not specified")
(directory :format "%t: %v")))
(defcustom w3m-broken-proxy-cache nil
"Set it to t if the proxy server seems not to work properly in caching.
Note that this may be the double-edged sword; setting it to t will
likely be harmful if the proxy server sends bad requests (e.g., not
including the Host header, see RFC2616 section 14.23) to foreign
servers when the w3m command specifies the \"no-cache\" directive. Also
note that it may not be effective if you are using old w3m command."
:group 'w3m
:type 'boolean)
(defcustom w3m-quick-start t
"Non-nil means let emacs-w3m start quickly w/o requiring confirmation.
When you invoke the `w3m' command, it attempts to visit the page of a
string like url around the cursor or the value of `w3m-home-page'.
You won't be asked for the confirmation then if this value is non-nil.
Otherwise, you will be prompted for that url with the editing form."
:group 'w3m
:type 'boolean)
(defcustom w3m-home-page
(or (getenv "HTTP_HOME")
(getenv "WWW_HOME")
"about:")
"This variable specifies the url string to open when emacs-w3m starts.
Don't say HP, which is the abbreviated name of a certain company. ;-)"
:group 'w3m
:type '(radio
:convert-widget w3m-widget-type-convert-widget
`(,@(if (getenv "HTTP_HOME")
`((const :format "HTTP_HOME: \"%v\"\n"
,(getenv "HTTP_HOME"))))
,@(if (getenv "WWW_HOME")
`((const :format "WWW_HOME: \"%v\"\n"
(getenv "WWW_HOME"))))
(const :tag "About emacs-w3m" "about:")
(const :tag "Blank page" "about:blank")
(string :format "URL: %v"))))
(defcustom w3m-arrived-file
(expand-file-name ".arrived" w3m-profile-directory)
"Name of the file to keep the arrived URLs database."
:group 'w3m
:type 'file)
(defcustom w3m-keep-arrived-urls 500
"Maximum number of URLs which the arrived URLs database keeps."
:group 'w3m
:type 'integer)
(defcustom w3m-prefer-cache nil
"Non-nil means that cached contents are used without checking headers."
:group 'w3m
:type 'boolean)
(defcustom w3m-keep-cache-size 300
"Maximum number of pages to be cached in emacs-w3m."
:group 'w3m
:type 'integer)
(defcustom w3m-follow-redirection 9
"Maximum number of redirections which emacs-w3m honors and follows.
If nil, redirections are followed by the w3m command. Don't set it to
nil if you allow to use cookies (i.e., you have set `w3m-use-cookies'
to non-nil) since cookies may be shared among many redirected pages."
:group 'w3m
:type '(radio (const :format "Ignore redirections " nil)
integer))
(defcustom w3m-redirect-with-get t
"If non-nil, use the GET method after redirection.
It controls how emacs-w3m works when a server responds the code 301 or
302. Here is an extract from RFC2616:
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method."
:group 'w3m
:type 'boolean)
(defcustom w3m-resize-image-scale 50
"Number of steps in percent used when resizing images."
:group 'w3m
:type 'integer)