emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Enhancement for woman-parse-man.conf


From: Stefan Reichör
Subject: Enhancement for woman-parse-man.conf
Date: Thu, 19 Feb 2004 16:24:47 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (berkeley-unix)

Hi!

On my freebsd system the file /etc/manpath.config contains for
example the following lines:

MANDATORY_MANPATH       /usr/share/man
MANDATORY_MANPATH       /usr/share/openssl/man
#
# check if the directory exists and if it does, add it to MANPATH
#
OPTIONAL_MANPATH        /usr/local/man


The default implementation of woman-parse-man.conf only parses the
MANDATORY_MANPATH

I altered the function, now it parses also the OPTIONAL_MANPATH entries:

(defun woman-parse-man.conf ()
  "Parse if possible configuration file for man command.
Used only if MANPATH is not set or contains null components.
Look in `woman-man.conf-path' and return a value for `woman-manpath'.
Concatenate data from all lines in the config file of the form
  MANPATH  /usr/man
or
  MANDATORY_MANPATH  /usr/man
or
  OPTIONAL_MANPATH  /usr/man"
  ;; Functionality suggested by Charles Curley.
  (let ((path woman-man.conf-path)
        file manpath)
    (while (and
            path
            (not (and
                  (file-readable-p (setq file (car path)))
                  ;; If not a file then find the file:
                  (or (not (file-directory-p file))
                      (and
                       (setq file
                             (directory-files file t "man.*\\.conf" t))
                       (file-readable-p (setq file (car file)))))
                  ;; Parse the file -- if no MANPATH data ignore it:
                  (with-temp-buffer
                    (insert-file-contents file)
                    (while (re-search-forward
                            ;; `\(?: ... \)' is a "shy group"
                            "\
^[ \t]*\\(?:\\(?:MANDATORY\\|OPTIONAL\\)_\\)?MANPATH[ \t]+\\(\\S-+\\)" nil t)
                      (setq manpath (cons (match-string 1) manpath)))
                    manpath))
                 ))
      (setq path (cdr path)))
    (nreverse manpath)))


-- 
Stefan.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]