diff options
| -rw-r--r-- | lisp/man.el | 145 |
1 files changed, 69 insertions, 76 deletions
diff --git a/lisp/man.el b/lisp/man.el index 4fa5ae533d0..463f5a8e4e8 100644 --- a/lisp/man.el +++ b/lisp/man.el | |||
| @@ -101,14 +101,27 @@ | |||
| 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 |
| @@ -303,7 +316,7 @@ This regular expression should start with a `^' character.") | |||
| 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 | ||
| @@ -312,76 +325,56 @@ This is necessary if one wants to dump man.el with emacs." | |||
| 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) |
| @@ -517,9 +510,6 @@ If a buffer already exists for this man page, it will display immediately." | |||
| 517 | default-entry) | 510 | default-entry) |
| 518 | input)))) | 511 | input)))) |
| 519 | 512 | ||
| 520 | ;; Init the man package variables, if not already done. | ||
| 521 | (Man-init-defvars) | ||
| 522 | |||
| 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)) |
| @@ -1064,6 +1054,9 @@ Specify which reference to use; default is based on word at point." | |||
| 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 |