all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fixes to let woman.el deal with MANPATH_MAP elements
@ 2007-03-23 10:29 David Kastrup
  2007-03-23 14:16 ` Eli Zaretskii
  2007-03-23 18:00 ` Richard Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: David Kastrup @ 2007-03-23 10:29 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]


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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 6284 bytes --]

*** 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!

[-- Attachment #3: Type: text/plain, Size: 52 bytes --]



-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-03-31 15:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23 10:29 Fixes to let woman.el deal with MANPATH_MAP elements David Kastrup
2007-03-23 14:16 ` Eli Zaretskii
2007-03-23 18:34   ` David Kastrup
2007-03-23 20:03     ` David Kastrup
2007-03-23 20:12       ` Drew Adams
2007-03-23 20:25         ` David Kastrup
2007-03-23 21:09       ` David Kastrup
2007-03-23 18:00 ` Richard Stallman
2007-03-24 15:09   ` David Kastrup
2007-03-24 16:57     ` Eli Zaretskii
2007-03-24 17:07       ` David Kastrup
2007-03-24 17:39         ` Eli Zaretskii
2007-03-31 15:25   ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.