From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Fixes to let woman.el deal with MANPATH_MAP elements Date: Fri, 23 Mar 2007 11:29:25 +0100 Message-ID: <85tzwc2qyi.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1174645868 21567 80.91.229.12 (23 Mar 2007 10:31:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2007 10:31:08 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 23 11:31:01 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HUh2y-0005RE-5N for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 11:31:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUh4r-0005y5-3q for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 05:32:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HUh4n-0005xH-3s for emacs-devel@gnu.org; Fri, 23 Mar 2007 06:32:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HUh4k-0005vA-AW for emacs-devel@gnu.org; Fri, 23 Mar 2007 06:32:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUh4k-0005up-5L for emacs-devel@gnu.org; Fri, 23 Mar 2007 05:32:50 -0500 Original-Received: from mail-in-08.arcor-online.net ([151.189.21.48]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HUh2o-0000Qu-6x for emacs-devel@gnu.org; Fri, 23 Mar 2007 06:30:52 -0400 Original-Received: from mail-in-01-z2.arcor-online.net (mail-in-07-z2.arcor-online.net [151.189.8.19]) by mail-in-08.arcor-online.net (Postfix) with ESMTP id F1ED727B51E for ; Fri, 23 Mar 2007 11:29:26 +0100 (CET) Original-Received: from mail-in-10.arcor-online.net (mail-in-10.arcor-online.net [151.189.21.50]) by mail-in-01-z2.arcor-online.net (Postfix) with ESMTP id E45952C6BFE for ; Fri, 23 Mar 2007 11:29:26 +0100 (CET) Original-Received: from lola.goethe.zz (dslb-084-061-035-141.pools.arcor-ip.net [84.61.35.141]) by mail-in-10.arcor-online.net (Postfix) with ESMTP id AC28C24D4B9 for ; Fri, 23 Mar 2007 11:29:26 +0100 (CET) Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id C275F1C4F93F; Fri, 23 Mar 2007 11:29:25 +0100 (CET) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux) X-detected-kernel: Error: This connection is not (no longer?) in the cache. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68374 Archived-At: --=-=-= It has been annoying to me that M-x woman RET fails to obey MANPATH_MAP elements in manpath.config. It also has been annoying to me that woman.el happily picked up manpath.config~ instead of manpath.config when available. Both problems appear fixed with the following rather straightforward patch. While it clearly fixes faulty behavior, it could be considered bordering on "new feature". Should I still apply it? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment *** woman.el 12 Mar 2007 20:24:09 +0100 1.55 --- woman.el 23 Mar 2007 09:45:53 +0100 *************** *** 547,557 **** (mapcar 'woman-Cyg-to-Win path) path)) "*List of dirs to search and/or files to try for man config file. ! A trailing separator (`/' for UNIX etc.) on directories is optional, ! and the filename is used if a directory specified is the first to ! contain the strings \"man\" and \".conf\" (in that order). ! If MANPATH is not set but a config file is found then it is parsed ! instead to provide a default value for `woman-manpath'." :type '(repeat string) :group 'woman-interface) --- 547,558 ---- (mapcar 'woman-Cyg-to-Win path) path)) "*List of dirs to search and/or files to try for man config file. ! A trailing separator (`/' for UNIX etc.) on directories is ! optional, and the filename is used if a directory specified is ! the first to start with \"man\" and has an extension starting ! with \".conf\". If MANPATH is not set but a config file is found ! then it is parsed instead to provide a default value for ! `woman-manpath'." :type '(repeat string) :group 'woman-interface) *************** *** 564,570 **** or MANDATORY_MANPATH /usr/man or ! OPTIONAL_MANPATH /usr/man" ;; Functionality suggested by Charles Curley. (let ((path woman-man.conf-path) file manpath) --- 565,573 ---- or MANDATORY_MANPATH /usr/man or ! OPTIONAL_MANPATH /usr/man ! or ! MANPATH_MAP /opt/bin /opt/man" ;; Functionality suggested by Charles Curley. (let ((path woman-man.conf-path) file manpath) *************** *** 576,582 **** (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 --- 579,585 ---- (or (not (file-directory-p file)) (and (setq file ! (directory-files file t "\\`man.*\\.conf[a-z]*\\'" t)) (file-readable-p (setq file (car file))))) ;; Parse the file -- if no MANPATH data ignore it: (with-temp-buffer *************** *** 584,591 **** (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))) --- 587,599 ---- (while (re-search-forward ;; `\(?: ... \)' is a "shy group" "\ ! ^[ \t]*\\(?:\\(?:MANDATORY_\\|OPTIONAL_\\)?MANPATH[ \t]+\\(\\S-+\\)\\|\ ! MANPATH_MAP[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)\\)" nil t) ! (add-to-list 'manpath ! (if (match-beginning 1) ! (match-string 1) ! (cons (match-string 2) ! (match-string 3))))) manpath)) )) (setq path (cdr path))) *************** *** 600,605 **** --- 608,618 ---- selected by the value of `woman-manpath-man-regexp'. Non-directory and unreadable files are ignored. + Elements can also be a cons cell indicating a mapping from PATH + to manual trees: if such an element's car is equal to a path + element of the environment variable PATH, the cdr of the cons + cell is included in the directory tree search. + If not set then the environment variable MANPATH is used. If no such environment variable is found, the default list is determined by consulting the man configuration file if found, which is determined by *************** *** 618,624 **** The MANPATH environment variable may be set using DOS semi-colon- separated or UN*X/Cygwin colon-separated syntax (but not mixed)." ! :type '(repeat string) :group 'woman-interface) (defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]" --- 631,637 ---- The MANPATH environment variable may be set using DOS semi-colon- separated or UN*X/Cygwin colon-separated syntax (but not mixed)." ! :type '(repeat (choice string (cons string string))) :group 'woman-interface) (defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]" *************** *** 1159,1165 **** Called both to generate and to check the cache!" ;; Must use substituted paths because values of env vars may change! (list woman-cache-level ! (mapcar 'substitute-in-file-name woman-manpath) (mapcar 'substitute-in-file-name woman-path))) (defun woman-read-directory-cache () --- 1172,1183 ---- Called both to generate and to check the cache!" ;; Must use substituted paths because values of env vars may change! (list woman-cache-level ! (let (lst path) ! (dolist (dir woman-manpath (nreverse lst)) ! (when (consp dir) ! (unless path (setq path (split-string (getenv "PATH") ":" t))) ! (setq dir (and (member (car dir) path) (cdr dir)))) ! (when dir (add-to-list 'lst (substitute-in-file-name dir))))) (mapcar 'substitute-in-file-name woman-path))) (defun woman-read-directory-cache () *************** *** 1320,1329 **** ;; Allow each path to be a single string or a list of strings: (if (not (listp woman-manpath)) (setq woman-manpath (list woman-manpath))) (if (not (listp woman-path)) (setq woman-path (list woman-path))) ! (let (dir head dirs) (while woman-manpath (setq dir (car woman-manpath) woman-manpath (cdr woman-manpath)) (if (and dir (woman-file-readable-p dir)) ;; NB: `parse-colon-path' creates null elements for ;; redundant (semi-)colons and trailing `/'s! --- 1338,1352 ---- ;; Allow each path to be a single string or a list of strings: (if (not (listp woman-manpath)) (setq woman-manpath (list woman-manpath))) (if (not (listp woman-path)) (setq woman-path (list woman-path))) ! (let (dir head dirs path) (while woman-manpath (setq dir (car woman-manpath) woman-manpath (cdr woman-manpath)) + (when (consp dir) + (unless path + (setq path (split-string (getenv "PATH") ":" t))) + (setq dir (and (member (car dir) path) + (cdr dir)))) (if (and dir (woman-file-readable-p dir)) ;; NB: `parse-colon-path' creates null elements for ;; redundant (semi-)colons and trailing `/'s! --=-=-= -- David Kastrup, Kriemhildstr. 15, 44793 Bochum --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--