Mercurial > emacs
comparison lisp/man.el @ 14672:9556c7cfabe4
(man): Don't call Man-init-defvars here.
Do it at top level instead.
(Man-init-defvars): Now a defun, not a defsubst.
Don't set Man-uses-untabify-flag.
(Man-uses-untabify-flag): Add doc string. Make default value t.
(Man-filter-list): Add doc string.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 26 Feb 1996 00:15:09 +0000 |
parents | 83f275dcd93a |
children | eae53a7dcf03 |
comparison
equal
deleted
inserted
replaced
14671:0493e857a13b | 14672:9556c7cfabe4 |
---|---|
99 ;; empty defvars (keep the compiler quiet) | 99 ;; empty defvars (keep the compiler quiet) |
100 | 100 |
101 (defvar Man-notify) | 101 (defvar Man-notify) |
102 (defvar Man-current-page) | 102 (defvar Man-current-page) |
103 (defvar Man-page-list) | 103 (defvar Man-page-list) |
104 (defvar Man-filter-list) | 104 (defvar Man-filter-list nil |
105 "*Manpage cleaning filter command phrases. | |
106 This variable contains a list of the following form: | |
107 | |
108 '((command-string phrase-string*)*) | |
109 | |
110 Each phrase-string is concatenated onto the command-string to form a | |
111 command filter. The (standard) output (and standard error) of the Un*x | |
112 man command is piped through each command filter in the order the | |
113 commands appear in the association list. The final output is placed in | |
114 the manpage buffer.") | |
115 | |
105 (defvar Man-original-frame) | 116 (defvar Man-original-frame) |
106 (defvar Man-arguments) | 117 (defvar Man-arguments) |
107 (defvar Man-sections-alist) | 118 (defvar Man-sections-alist) |
108 (defvar Man-refpages-alist) | 119 (defvar Man-refpages-alist) |
109 (defvar Man-uses-untabify-flag) | 120 (defvar Man-uses-untabify-flag t |
121 "When non-nil use `untabify' instead of Man-untabify-command.") | |
110 (defvar Man-page-mode-string) | 122 (defvar Man-page-mode-string) |
111 (defvar Man-sed-script) | 123 (defvar Man-sed-script nil |
124 "Script for sed to nuke backspaces and ANSI codes from manpages.") | |
112 | 125 |
113 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | 126 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
114 ;; user variables | 127 ;; user variables |
115 | 128 |
116 (defvar Man-fontify-manpage-flag t | 129 (defvar Man-fontify-manpage-flag t |
301 | 314 |
302 | 315 |
303 ;; ====================================================================== | 316 ;; ====================================================================== |
304 ;; utilities | 317 ;; utilities |
305 | 318 |
306 (defsubst Man-init-defvars () | 319 (defun Man-init-defvars () |
307 "Used for initialising variables based on the value of window-system. | 320 "Used for initialising variables based on the value of window-system. |
308 This is necessary if one wants to dump man.el with emacs." | 321 This is necessary if one wants to dump man.el with emacs." |
309 | 322 |
310 ;; The following is necessary until fonts are implemented on | 323 ;; The following is necessary until fonts are implemented on |
311 ;; terminals. | 324 ;; terminals. |
312 (setq Man-fontify-manpage-flag (and Man-fontify-manpage-flag | 325 (setq Man-fontify-manpage-flag (and Man-fontify-manpage-flag |
313 window-system)) | 326 window-system)) |
314 | 327 |
315 (defconst Man-uses-untabify-flag t | 328 (setq Man-sed-script |
316 ;; don't use pr: it is buggy | 329 (cond |
317 ;; (or (not (file-readable-p "/etc/passwd")) | 330 (Man-fontify-manpage-flag |
318 ;; (/= 0 (apply 'call-process | 331 nil) |
319 ;; Man-untabify-command nil nil nil | 332 ((= 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script)) |
320 ;; (append Man-untabify-command-args | 333 Man-sysv-sed-script) |
321 ;; (list "/etc/passwd"))))) | 334 ((= 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script)) |
322 "When non-nil use `untabify' instead of Man-untabify-command.") | 335 Man-berkeley-sed-script) |
323 | 336 (t |
324 (defconst Man-sed-script | 337 nil))) |
325 (cond | 338 |
326 (Man-fontify-manpage-flag | 339 (setq Man-filter-list |
327 nil) | 340 (list |
328 ((= 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script)) | |
329 Man-sysv-sed-script) | |
330 ((= 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script)) | |
331 Man-berkeley-sed-script) | |
332 (t | |
333 nil)) | |
334 "Script for sed to nuke backspaces and ANSI codes from manpages.") | |
335 | |
336 (defvar Man-filter-list | |
337 (list | |
338 (cons | |
339 Man-sed-command | |
340 (list | |
341 (if Man-sed-script | |
342 (concat "-e '" Man-sed-script "'") | |
343 "") | |
344 "-e '/^[\001-\032][\001-\032]*$/d'" | |
345 "-e '/\e[789]/s///g'" | |
346 "-e '/Reformatting page. Wait/d'" | |
347 "-e '/Reformatting entry. Wait/d'" | |
348 "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" | |
349 "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" | |
350 "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" | |
351 "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" | |
352 "-e '/^Printed[ \t][0-9].*[0-9]$/d'" | |
353 "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" | |
354 "-e '/^[A-za-z].*Last[ \t]change:/d'" | |
355 "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" | |
356 "-e '/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d'" | |
357 "-e '/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d'" | |
358 )) | |
359 (cons | |
360 Man-awk-command | |
361 (list | |
362 "'\n" | |
363 "BEGIN { blankline=0; anonblank=0; }\n" | |
364 "/^$/ { if (anonblank==0) next; }\n" | |
365 "{ anonblank=1; }\n" | |
366 "/^$/ { blankline++; next; }\n" | |
367 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" | |
368 "'" | |
369 )) | |
370 (if (not Man-uses-untabify-flag) | |
371 (cons | 341 (cons |
372 Man-untabify-command | 342 Man-sed-command |
373 Man-untabify-command-args) | 343 (list |
374 )) | 344 (if Man-sed-script |
375 "*Manpage cleaning filter command phrases. | 345 (concat "-e '" Man-sed-script "'") |
376 This variable contains a list of the following form: | 346 "") |
377 | 347 "-e '/^[\001-\032][\001-\032]*$/d'" |
378 '((command-string phrase-string*)*) | 348 "-e '/\e[789]/s///g'" |
379 | 349 "-e '/Reformatting page. Wait/d'" |
380 Each phrase-string is concatenated onto the command-string to form a | 350 "-e '/Reformatting entry. Wait/d'" |
381 command filter. The (standard) output (and standard error) of the Un*x | 351 "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" |
382 man command is piped through each command filter in the order the | 352 "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" |
383 commands appear in the association list. The final output is placed in | 353 "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" |
384 the manpage buffer.") | 354 "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" |
355 "-e '/^Printed[ \t][0-9].*[0-9]$/d'" | |
356 "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" | |
357 "-e '/^[A-za-z].*Last[ \t]change:/d'" | |
358 "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" | |
359 "-e '/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d'" | |
360 "-e '/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d'" | |
361 )) | |
362 (cons | |
363 Man-awk-command | |
364 (list | |
365 "'\n" | |
366 "BEGIN { blankline=0; anonblank=0; }\n" | |
367 "/^$/ { if (anonblank==0) next; }\n" | |
368 "{ anonblank=1; }\n" | |
369 "/^$/ { blankline++; next; }\n" | |
370 "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" | |
371 "'" | |
372 )) | |
373 (if (not Man-uses-untabify-flag) | |
374 (cons | |
375 Man-untabify-command | |
376 Man-untabify-command-args) | |
377 ))) | |
385 ) | 378 ) |
386 | 379 |
387 (defsubst Man-match-substring (&optional n string) | 380 (defsubst Man-match-substring (&optional n string) |
388 "Return the substring matched by the last search. | 381 "Return the substring matched by the last search. |
389 Optional arg N means return the substring matched by the Nth paren | 382 Optional arg N means return the substring matched by the Nth paren |
514 (if (string= input "") | 507 (if (string= input "") |
515 (if (string= default-entry "") | 508 (if (string= default-entry "") |
516 (error "No man args given") | 509 (error "No man args given") |
517 default-entry) | 510 default-entry) |
518 input)))) | 511 input)))) |
519 | |
520 ;; Init the man package variables, if not already done. | |
521 (Man-init-defvars) | |
522 | 512 |
523 ;; Possibly translate the "subject(section)" syntax into the | 513 ;; Possibly translate the "subject(section)" syntax into the |
524 ;; "section subject" syntax and possibly downcase the section. | 514 ;; "section subject" syntax and possibly downcase the section. |
525 (setq man-args (Man-translate-references man-args)) | 515 (setq man-args (Man-translate-references man-args)) |
526 | 516 |
1062 (Man-goto-page (1- Man-current-page)) | 1052 (Man-goto-page (1- Man-current-page)) |
1063 (if Man-circular-pages-flag | 1053 (if Man-circular-pages-flag |
1064 (Man-goto-page (length Man-page-list)) | 1054 (Man-goto-page (length Man-page-list)) |
1065 (error "You're looking at the first manpage in the buffer")))) | 1055 (error "You're looking at the first manpage in the buffer")))) |
1066 | 1056 |
1057 ;; Init the man package variables, if not already done. | |
1058 (Man-init-defvars) | |
1059 | |
1067 (provide 'man) | 1060 (provide 'man) |
1068 | 1061 |
1069 ;;; man.el ends here | 1062 ;;; man.el ends here |