;;; woman.el --- browse UN*X manual pages `wo (without) man'
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007 Free Software Foundation, Inc.
+;; 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Francis J. Wright <F.J.Wright@qmul.ac.uk>
;; Maintainer: FSF
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; (By default, WoMan will automatically define the dired keys "W" and
;; "w" when it loads, but only if they are not already defined. This
-;; behaviour is controlled by the user option `woman-dired-keys'.
+;; behavior is controlled by the user option `woman-dired-keys'.
;; Note that the `dired-x' (dired extra) package binds
;; `dired-copy-filename-as-kill' to the key "w" (as pointed out by Jim
;; Davidson), although "W" appears to be really unused. The `dired-x'
;; The *WoMan-Log* buffer
;; ======================
-;; This is modelled on the byte-compiler. It logs all files formatted
+;; This is modeled on the byte-compiler. It logs all files formatted
;; by WoMan, and if WoMan finds anything that it cannot handle then it
;; writes a warning to this buffer. If the variable `woman-show-log'
;; is non-nil (by default it is `nil') then WoMan automatically
(defcustom woman-man.conf-path
(let ((path '("/usr/lib" "/etc")))
- (if (eq system-type 'windows-nt)
- (mapcar 'woman-Cyg-to-Win path)
- path))
+ (cond ((eq system-type 'windows-nt)
+ (mapcar 'woman-Cyg-to-Win path))
+ ((eq system-type 'darwin)
+ (cons "/usr/share/misc" path))
+ (t 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
(setq path (cdr path)))
(nreverse manpath)))
+;; Autoload so set-locale-environment can operate on it.
+;;;###autoload
+(defcustom woman-locale nil
+ "String specifying a manual page locale, or nil.
+If a manual page is available in the specified locale
+\(e.g. \"sv_SE.ISO8859-1\"), it will be offered in preference to the
+default version. Normally, `set-locale-environment' sets this at startup."
+ :type '(choice string (const nil))
+ :group 'woman-interface
+ :version "23.1")
+
+;; FIXME Is this a sensible list of alternatives?
+(defun woman-expand-locale (locale)
+ "Expand a locale into a list suitable for man page lookup.
+Expands a locale of the form LANGUAGE_TERRITORY.CHARSET into the list:
+LANGUAGE_TERRITORY.CHARSET LANGUAGE_TERRITORY LANGUAGE.CHARSET LANGUAGE.
+The TERRITORY and CHARSET portions may be absent."
+ (string-match "\\([^._]*\\)\\(_[^.]*\\)?\\(\\..*\\)?" locale)
+ (let ((lang (match-string 1 locale))
+ (terr (match-string 2 locale))
+ (charset (match-string 3 locale)))
+ (delq nil (list locale
+ (and charset terr (concat lang terr))
+ (and charset terr (concat lang charset))
+ (if (or charset terr) lang)))))
+
+(defun woman-manpath-add-locales (manpath)
+ "Add locale-specific subdirectories to the elements of MANPATH.
+MANPATH is a list of the form of `woman-manpath'. Returns a list
+with those locale-specific subdirectories specified by the action
+of `woman-expand-locale' on `woman-locale' added, where they exist."
+ (if (zerop (length woman-locale))
+ manpath
+ (let ((subdirs (woman-expand-locale woman-locale))
+ lst dir)
+ (dolist (elem manpath (nreverse lst))
+ (dolist (sub subdirs)
+ (when (file-directory-p
+ (setq dir
+ ;; Use f-n-a-d because parse-colon-path does.
+ (file-name-as-directory
+ (expand-file-name sub (substitute-in-file-name
+ (if (consp elem)
+ (cdr elem)
+ elem))))))
+ (add-to-list 'lst (if (consp elem)
+ (cons (car elem) dir)
+ dir))))
+ ;; Non-locale-specific has lowest precedence.
+ (add-to-list 'lst elem)))))
+
(defcustom woman-manpath
- (or (woman-parse-colon-path (getenv "MANPATH"))
+ ;; Locales could also be added in woman-expand-directory-path.
+ (or (woman-manpath-add-locales
+ (woman-parse-colon-path (getenv "MANPATH")))
'("/usr/man" "/usr/share/man" "/usr/local/man"))
"List of DIRECTORY TREES to search for UN*X manual files.
Each element should be the name of a directory that contains
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)))
+ :version "23.1" ; added woman-manpath-add-locales
:group 'woman-interface)
(defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]"
(defcustom woman-use-own-frame ; window-system
(or (and (fboundp 'display-graphic-p) (display-graphic-p)) ; Emacs 21
- (memq window-system '(x w32))) ; Emacs 20
+ (memq window-system '(x w32 ns))) ; Emacs 20
"If non-nil then use a dedicated frame for displaying WoMan windows.
Only useful when run on a graphic display such as X or MS-Windows."
:type 'boolean
(setq symbol-fonts (cons font symbol-fonts))))
symbol-fonts))
+(declare-function x-list-fonts "xfaces.c"
+ (pattern &optional face frame maximum width))
+
(when woman-font-support
(make-face 'woman-symbol)
"Process .de/am xx yy -- (re)define/append macro xx; end at `..'.
\(Should be up to call of yy, which defaults to `.')
Optional argument APPEND, if non-nil, means append macro."
- ;; Modelled on woman-strings. BEWARE: Processing of .am is a hack!
+ ;; Modeled on woman-strings. BEWARE: Processing of .am is a hack!
;; Add support for .rm?
;; (skip-chars-forward " \t")
(if (eolp) ; ignore if no argument
(setq value (funcall op value (woman-parse-numeric-value))))
((looking-at "[<=>]=?") ; relational operators
(goto-char (match-end 0))
- (setq op (or (intern-soft (match-string 0))
- (intern-soft "=")))
+ (setq op (intern-soft
+ (if (string-equal (match-string 0) "==")
+ "="
+ (match-string 0))))
(setq value (if (funcall op value (woman-parse-numeric-value))
1 0)))
((memq (setq op (following-char)) '(?& ?:)) ; Boolean and / or
(insert " -- ")
(woman-forward-arg 'unquote 'concat)
;; Delete repeated arguments:
- (if (string-match (buffer-substring here (point))
+ (if (string-equal (buffer-substring here (point))
(buffer-substring start here))
- (delete-region here (point)))
- ))
+ (delete-region here (point)))))
;; Embolden heading (point is at end of heading):
(woman-set-face
(save-excursion (beginning-of-line) (point)) (point) 'woman-bold)