-(defsubst Man-init-defvars ()
- "Used for initialising variables based on the value of window-system.
-This is necessary if one wants to dump man.el with emacs."
-
- (defvar Man-fontify-manpage-flag t
- "*Make up the manpage with fonts.")
- ;; The following is necessary until fonts are implemented on
- ;; terminals.
- (setq Man-fontify-manpage-flag (and Man-fontify-manpage-flag
- window-system))
-
- (defconst Man-uses-untabify-flag t
- ;; don't use pr: it is buggy
- ;; (or (not (file-readable-p "/etc/passwd"))
- ;; (/= 0 (apply 'call-process
- ;; Man-untabify-command nil nil nil
- ;; (append Man-untabify-command-args
- ;; (list "/etc/passwd")))))
- "Use `untabify', because Man-untabify-command cannot do that.")
-
- (defconst Man-sed-script
- (cond
- (Man-fontify-manpage-flag
- nil)
- ((= 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script))
- Man-sysv-sed-script)
- ((= 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script))
- Man-berkeley-sed-script)
- (t
- nil))
- "Script for sed to nuke backspaces and ANSI codes from manpages.")
-
- (defvar Man-filter-list
- (list
- (cons
- Man-sed-command
- (list
- (if Man-sed-script
- (concat "-e '" Man-sed-script "'")
- "")
- "-e '/\e[789]/s///g'"
- "-e '/o\b+/s//o/g'"
- "-e '/|\b-[-|\b]*/s//+/g'"
- "-e '/^\\n$/D'"
- "-e '/[Nn]o such file or directory/d'"
- "-e '/Reformatting page. Wait/d'"
- "-e '/Reformatting entry. Wait/d'"
- "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'"
- "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'"
- "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'"
- "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'"
- "-e '/^Printed[ \t][0-9].*[0-9]$/d'"
- "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'"
- "-e '/^[A-za-z].*Last[ \t]change:/d'"
- "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'"
- ))
- (cons
- Man-awk-command
- (list
- "'\n"
- "BEGIN { blankline=0; anonblank=0; }\n"
- "/^$/ { if (anonblank==0) next; }\n"
- "{ anonblank=1; }\n"
- "/^$/ { blankline++; next; }\n"
- "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n"
- "'"
- ))
- (if (not Man-uses-untabify-flag)
+(defun Man-init-defvars ()
+ "Used for initialising variables based on display's color support.
+This is necessary if one wants to dump man.el with Emacs."
+
+ ;; Avoid possible error in call-process by using a directory that must exist.
+ (let ((default-directory "/"))
+ (setq Man-sed-script
+ (cond
+ (Man-fontify-manpage-flag
+ nil)
+ ((= 0 (call-process Man-sed-command nil nil nil Man-sysv-sed-script))
+ Man-sysv-sed-script)
+ ((= 0 (call-process Man-sed-command nil nil nil Man-berkeley-sed-script))
+ Man-berkeley-sed-script)
+ (t
+ nil))))
+
+ (setq Man-filter-list
+ ;; Avoid trailing nil which confuses customize.
+ (apply 'list