2000-05-08 14:32:17 +00:00
|
|
|
|
;;; woman.el --- browse UN*X manual pages `wo (without) man'
|
|
|
|
|
|
2012-04-16 18:46:46 +00:00
|
|
|
|
;; Copyright (C) 2000-2012 Free Software Foundation, Inc.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Author: Francis J. Wright <F.J.Wright@qmul.ac.uk>
|
2005-09-09 01:21:28 +00:00
|
|
|
|
;; Maintainer: FSF
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Keywords: help, unix
|
2004-06-26 11:38:14 +00:00
|
|
|
|
;; Adapted-By: Eli Zaretskii <eliz@gnu.org>
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Version: 0.551
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; URL: http://centaur.maths.qmul.ac.uk/Emacs/WoMan/
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; WoMan implements a subset of the formatting performed by the Emacs
|
|
|
|
|
;; `man' (or `manual-entry') command to format a UN*X manual `page'
|
|
|
|
|
;; for display, but without calling any external programs. It is
|
|
|
|
|
;; intended to emulate the whole of the -man macro package, plus those
|
|
|
|
|
;; ?roff requests that are most commonly used in man pages. However,
|
|
|
|
|
;; the emulation is modified to include the reformatting done by the
|
|
|
|
|
;; Emacs `man' command. No hyphenation is performed.
|
|
|
|
|
|
|
|
|
|
;; Advantages
|
|
|
|
|
|
|
|
|
|
;; Much more direct, does not require any external programs.
|
|
|
|
|
;; Supports completion on man page names.
|
|
|
|
|
|
|
|
|
|
;; Disadvantages
|
|
|
|
|
|
|
|
|
|
;; Not a complete emulation. Currently no support for eqn or tbl.
|
|
|
|
|
;; Slightly slower for large man pages (but usually faster for
|
|
|
|
|
;; small- and medium-size pages).
|
|
|
|
|
|
|
|
|
|
;; This browser works quite well on simple well-written man files. It
|
|
|
|
|
;; works less well on idiosyncratic files that `break the rules' or
|
|
|
|
|
;; use the more obscure ?roff requests directly. Current test results
|
|
|
|
|
;; are available in the file woman.status.
|
|
|
|
|
|
|
|
|
|
;; WoMan supports the use of compressed man files via
|
|
|
|
|
;; `auto-compression-mode' by turning it on if necessary. But you may
|
|
|
|
|
;; need to adjust the user option `woman-file-compression-regexp'.
|
|
|
|
|
|
|
|
|
|
;; Read on for (currently) the only documentation for WoMan!
|
|
|
|
|
|
|
|
|
|
;; See also the documentation for the WoMan interactive commands and
|
|
|
|
|
;; user option variables, all of which begin with the prefix `woman-'.
|
|
|
|
|
;; This can be done most easily by loading WoMan and then running the
|
|
|
|
|
;; command `woman-mini-help', or selecting the WoMan menu option `Mini
|
|
|
|
|
;; Help' when WoMan is running.
|
|
|
|
|
|
|
|
|
|
;; WoMan is still under development! Please let me know what doesn't
|
|
|
|
|
;; work -- I am adding and improving functionality as testing shows
|
|
|
|
|
;; that it is necessary. See below for guidance on reporting bugs.
|
|
|
|
|
|
|
|
|
|
;; Recommended use
|
|
|
|
|
;; ===============
|
|
|
|
|
|
|
|
|
|
;; Put this in your .emacs:
|
|
|
|
|
;; (autoload 'woman "woman"
|
|
|
|
|
;; "Decode and browse a UN*X man page." t)
|
|
|
|
|
;; (autoload 'woman-find-file "woman"
|
|
|
|
|
;; "Find, decode and browse a specific UN*X man-page file." t)
|
|
|
|
|
|
|
|
|
|
;; Then either (1 -- *RECOMMENDED*): If the `MANPATH' environment
|
|
|
|
|
;; variable is set then WoMan will use it; otherwise you may need to
|
|
|
|
|
;; reset the Lisp variable `woman-manpath', and you may also want to
|
|
|
|
|
;; set the Lisp variable `woman-path'. Please see the online
|
|
|
|
|
;; documentation for these variables. Now you can execute the
|
|
|
|
|
;; extended command `woman', enter or select a manual entry topic,
|
|
|
|
|
;; using completion, and if necessary select a filename, using
|
|
|
|
|
;; completion. By default, WoMan suggests the word nearest to the
|
|
|
|
|
;; cursor in the current buffer as the topic.
|
|
|
|
|
|
|
|
|
|
;; Or (2): Execute the extended command `woman-find-file' and enter a
|
|
|
|
|
;; filename, using completion. This mode of execution may be useful
|
|
|
|
|
;; for temporary files outside the standard UN*X manual directory
|
|
|
|
|
;; structure.
|
|
|
|
|
|
|
|
|
|
;; Or (3): Put the next two sexpr's in your .emacs:
|
|
|
|
|
;; (autoload 'woman-dired-find-file "woman"
|
|
|
|
|
;; "In dired, run the WoMan man-page browser on this file." t)
|
|
|
|
|
;; (add-hook 'dired-mode-hook
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; (lambda ()
|
|
|
|
|
;; (define-key dired-mode-map "W" 'woman-dired-find-file)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; and open the directory containing the man page file using dired,
|
|
|
|
|
;; put the cursor on the file, and press `W'.
|
|
|
|
|
|
|
|
|
|
;; In each case, the result should (!) be a buffer in Man mode showing
|
|
|
|
|
;; a formatted manual entry. When called from WoMan, Man mode should
|
|
|
|
|
;; work as advertised, but modified where necessary in the context of
|
|
|
|
|
;; WoMan. (However, `Man' will still invoke the standard Emacs
|
|
|
|
|
;; manual-browsing facility rather than `WoMan' -- this is
|
|
|
|
|
;; intentional!)
|
|
|
|
|
|
|
|
|
|
;; (By default, WoMan will automatically define the dired keys "W" and
|
|
|
|
|
;; "w" when it loads, but only if they are not already defined. This
|
2008-06-27 07:34:53 +00:00
|
|
|
|
;; behavior is controlled by the user option `woman-dired-keys'.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; 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'
|
|
|
|
|
;; package will over-write the WoMan binding to "w", whereas (by
|
|
|
|
|
;; default) WoMan will not overwrite the `dired-x' binding.)
|
|
|
|
|
|
2005-09-10 14:59:07 +00:00
|
|
|
|
;; Using the word at point as the default topic
|
|
|
|
|
;; ============================================
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2005-09-10 14:59:07 +00:00
|
|
|
|
;; The `woman' command uses the word nearest to point in the current
|
|
|
|
|
;; buffer as the default topic to look up if it matches the name of a
|
|
|
|
|
;; manual page installed on the system. The default topic can also be
|
|
|
|
|
;; used without confirmation by setting the user-option
|
|
|
|
|
;; `woman-use-topic-at-point' to t; thanks to Benjamin Riefenstahl for
|
|
|
|
|
;; suggesting this functionality.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2005-09-10 14:59:07 +00:00
|
|
|
|
;; The variable `woman-use-topic-at-point' can be rebound locally,
|
|
|
|
|
;; which may be useful to provide special private key bindings, e.g.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; (global-set-key "\C-cw"
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; (lambda ()
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; (interactive)
|
2005-09-10 14:59:07 +00:00
|
|
|
|
;; (let ((woman-use-topic-at-point t))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; (woman)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Customization, Hooks and Imenu
|
|
|
|
|
;; ==============================
|
|
|
|
|
|
|
|
|
|
;; WoMan supports the GNU Emacs 20+ customization facility, and puts
|
|
|
|
|
;; a customization group called `WoMan' in the `Help' group under the
|
|
|
|
|
;; top-level `Emacs' group. In order to be able to customize WoMan
|
|
|
|
|
;; without first loading it, add the following sexp to your .emacs:
|
|
|
|
|
|
|
|
|
|
;; (defgroup woman nil
|
|
|
|
|
;; "Browse UNIX manual pages `wo (without) man'."
|
|
|
|
|
;; :tag "WoMan" :group 'help :load "woman")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; WoMan currently runs two hooks: `woman-pre-format-hook' immediately
|
|
|
|
|
;; before formatting a buffer and `woman-post-format-hook' immediately
|
|
|
|
|
;; after formatting a buffer. These hooks can be used for special
|
|
|
|
|
;; customizations that require code to be executed, etc., although
|
|
|
|
|
;; most customization should be possible by setting WoMan user option
|
|
|
|
|
;; variables, e.g. in `.emacs' and should NOT require the use of the
|
|
|
|
|
;; hooks. `woman-pre-format-hook' might be appropriate for face
|
|
|
|
|
;; customization, whereas `woman-post-format-hook' might be
|
|
|
|
|
;; appropriate for installing a dynamic menu using `imenu' (although
|
|
|
|
|
;; it is better to use the built-in WoMan imenu support).
|
|
|
|
|
|
|
|
|
|
;; The WoMan menu provides an option to make a contents menu for the
|
|
|
|
|
;; current man page (using imenu). Alternatively, if you set the
|
|
|
|
|
;; variable `woman-imenu' to `t' then WoMan will do it automatically
|
|
|
|
|
;; for every man page. The menu title is the value of the variable
|
|
|
|
|
;; `woman-imenu-title', which is "CONTENTS" by default. By default,
|
|
|
|
|
;; the menu shows manual sections and subsections, but you can change
|
|
|
|
|
;; this by changing the value of `woman-imenu-generic-expression'.
|
|
|
|
|
;; This facility is not yet widely tested and may be fooled by obscure
|
|
|
|
|
;; man pages that `break the rules'.
|
|
|
|
|
|
|
|
|
|
;; WoMan is configured not to replace spaces in an imenu *Completion*
|
|
|
|
|
;; buffer. For further documentation of the use of imenu, such as
|
|
|
|
|
;; menu sorting, see the source file imenu.el, which is distributed
|
|
|
|
|
;; with GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
;; Howard Melman made (essentially) the following suggestions, which
|
|
|
|
|
;; are slightly different from the expression that I currently use.
|
|
|
|
|
;; You may prefer one of Howard's suggestions, which I think assume
|
|
|
|
|
;; that `case-fold-search' is `t' (which it is by default):
|
|
|
|
|
|
|
|
|
|
;; (setq woman-imenu-generic-expression
|
|
|
|
|
;; '((nil "^\\( \\)?\\([A-Z][A-Z ]+[A-Z]\\)[ \t]*$" 2)))
|
|
|
|
|
|
|
|
|
|
;; will give support for .SH and .SS, though it won't show the heading
|
|
|
|
|
;; name hierarchy. If you just want .SH in the imenu then use:
|
|
|
|
|
|
|
|
|
|
;; (setq woman-imenu-generic-expression
|
|
|
|
|
;; '((nil "^\\([A-Z][A-Z ]+[A-Z]\\)[ \t]*$" 1)))
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Vertical spacing and blank lines
|
|
|
|
|
;; ================================
|
|
|
|
|
|
|
|
|
|
;; The number of consecutive blank lines in the formatted buffer
|
|
|
|
|
;; should be either 0 or 1. A blank line should leave a space like
|
|
|
|
|
;; .sp 1 (p. 14). Current policy is to output vertical space only
|
|
|
|
|
;; immediately before text is output.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Horizontal and vertical spacing and resolution
|
|
|
|
|
;; ==============================================
|
|
|
|
|
|
|
|
|
|
;; WoMan currently assumes 10 characters per inch horizontally, hence
|
|
|
|
|
;; a horizontal resolution of 24 basic units, and 5 lines per inch
|
|
|
|
|
;; vertically, hence a vertical resolution of 48 basic units. (nroff
|
|
|
|
|
;; uses 240 per inch).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; The *WoMan-Log* buffer
|
|
|
|
|
;; ======================
|
|
|
|
|
|
2008-06-27 02:07:30 +00:00
|
|
|
|
;; This is modeled on the byte-compiler. It logs all files formatted
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; 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
|
|
|
|
|
;; displays this buffer. Many WoMan warnings can be completely
|
|
|
|
|
;; ignored, because they are reporting the fact that WoMan has ignored
|
|
|
|
|
;; requests that it is correct to ignore. In some future version this
|
|
|
|
|
;; level of paranoia will be reduced, but not until WoMan is more
|
|
|
|
|
;; reliable. At present, all warnings should be treated with some
|
|
|
|
|
;; suspicion. Uninterpreted escape sequences are also logged (in some
|
|
|
|
|
;; cases).
|
|
|
|
|
|
|
|
|
|
;; Uninterpreted ?roff requests can optionally be left in the
|
|
|
|
|
;; formatted buffer to indicate precisely where they occur by
|
|
|
|
|
;; resetting the variable `woman-ignore' to `nil' (by default it is
|
|
|
|
|
;; `t').
|
|
|
|
|
|
|
|
|
|
;; Automatic initiation of woman decoding
|
|
|
|
|
|
|
|
|
|
;; (Probably not a good idea. If you use it, be careful!)
|
|
|
|
|
|
|
|
|
|
;; Put something like this in your .emacs. The call to
|
|
|
|
|
;; set-visited-file-name is to avoid font-locking triggered by
|
|
|
|
|
;; automatic major mode selection.
|
|
|
|
|
|
|
|
|
|
;; (autoload 'woman-decode-region "woman")
|
|
|
|
|
|
|
|
|
|
;; (setq format-alist
|
|
|
|
|
;; (cons
|
|
|
|
|
;; '(man "UN*X man-page source format" "\\.\\(TH\\|ig\\) "
|
|
|
|
|
;; woman-decode-region nil nil
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; (lambda (arg)
|
|
|
|
|
;; set-visited-file-name
|
|
|
|
|
;; (file-name-sans-extension buffer-file-name)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; format-alist))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Reporting Bugs
|
|
|
|
|
;; ==============
|
|
|
|
|
|
|
|
|
|
;; If WoMan fails completely, or formats a file incorrectly
|
|
|
|
|
;; (i.e. obviously wrongly or significantly differently from man) or
|
|
|
|
|
;; inelegantly, then please
|
|
|
|
|
|
|
|
|
|
;; (a) check that you are running the latest version of woman.el
|
|
|
|
|
;; available from my web site (see above),
|
|
|
|
|
|
|
|
|
|
;; (b) check that the problem is not already described in the file
|
|
|
|
|
;; woman.status, also available from my web site.
|
|
|
|
|
|
|
|
|
|
;; If both of the above are true then please email me the entry from
|
|
|
|
|
;; the *WoMan-Log* buffer relating to the problem file, together with
|
|
|
|
|
;; a brief description of the problem. Please indicate where you got
|
|
|
|
|
;; the source file from, but do not send it to me unless I ask you to!
|
|
|
|
|
;; Thanks. (There is at present no automated bug-reporting facility
|
|
|
|
|
;; for WoMan.)
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
;; NOTE:
|
|
|
|
|
|
|
|
|
|
;; CASE-DEPENDENCE OF FILENAMES. By default, WoMan ignores case in
|
|
|
|
|
;; file pathnames only when it seems appropriate. MS-Windows users
|
|
|
|
|
;; who want complete case independence should set the NTEmacs variable
|
|
|
|
|
;; `w32-downcase-file-names' to `t' and use all lower case when
|
|
|
|
|
;; setting WoMan file paths.
|
|
|
|
|
|
|
|
|
|
;; (1) INCOMPATIBLE CHANGE! WoMan no longer uses a persistent topic
|
|
|
|
|
;; cache by default. (It caused too much confusion!) Explicitly set
|
|
|
|
|
;; the variable `woman-cache-filename' to save the cache between Emacs
|
|
|
|
|
;; sessions. This is recommended only if the command `woman' is too
|
|
|
|
|
;; slow the first time that it is run in an Emacs session, while it
|
|
|
|
|
;; builds its cache in main memory, which MAY be VERY slow.
|
|
|
|
|
|
|
|
|
|
;; (2) The user option `woman-cache-level' controls the amount of
|
|
|
|
|
;; information cached (in main memory and, optionally, saved to disc).
|
|
|
|
|
|
|
|
|
|
;; (3) UPDATING THE CACHE. A prefix argument always causes the
|
|
|
|
|
;; `woman' command (only) to rebuild its topic cache, and to re-save
|
|
|
|
|
;; it to `woman-cache-filename' if this variable has a non-nil value.
|
|
|
|
|
;; This is necessary if the NAMES (not contents) of any of the
|
|
|
|
|
;; directories or files in the paths specified by `woman-manpath' or
|
|
|
|
|
;; `woman-path' change. If WoMan user options that affect the cache
|
|
|
|
|
;; are changed then WoMan will automatically update its cache file on
|
|
|
|
|
;; disc (if one is in use) the next time it is run in a new Emacs
|
|
|
|
|
;; session.
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; TO DO
|
|
|
|
|
;; =====
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Reconsider case sensitivity of file names.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; MUST PROCESS .if, .nr IN ORDER ENCOUNTERED IN FILE! (rcsfile, mf).
|
|
|
|
|
;; Allow general delimiter in `\v', cf. `\h'.
|
|
|
|
|
;; Improve major-mode documentation.
|
|
|
|
|
;; Pre-process conditionals in macro bodies if possible for speed?
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Emulate more complete preprocessor support for tbl (.TS/.TE)
|
|
|
|
|
;; Emulate some preprocessor support for eqn (.EQ/.EN)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Re-write filling and adjusting code!
|
|
|
|
|
;; Allow word wrap at comma (for long option lists)?
|
|
|
|
|
;; Buffer list handling not quite right.
|
|
|
|
|
;; Make 10 or 12 pitch (cpi) optional -- 12 => ll = 78
|
|
|
|
|
;; Use unpaddable space for tabbing?
|
|
|
|
|
;; Tidy up handling of fonts when filling and adjusting
|
|
|
|
|
;; -- see text/text properties?
|
|
|
|
|
;; Improve speed
|
|
|
|
|
;; Add font-lock support (for quoted strings, etc.)?
|
|
|
|
|
;; Optionally save large files in enriched format?
|
|
|
|
|
;; Add apropos facility by searching NAME (?) entry in man files?
|
|
|
|
|
;; Documentation -- optional auto-display of formatted WoMan man page?
|
|
|
|
|
;; Implement a bug reporter?
|
|
|
|
|
;; Support diversion and traps (to some extent) - for Tcl/tk pages?
|
|
|
|
|
;; Add a menu of WoMan buffers?
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Fix .fc properly?
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Implementation strategy [this description is now well out of date!]
|
|
|
|
|
;; -- three main passes, each to process respectively:
|
|
|
|
|
|
|
|
|
|
;; 1) non-breaking `.' requests including font macros
|
|
|
|
|
;; 2) \ escape sequences, mainly special characters and font changes
|
|
|
|
|
;; 3) breaking `.' requests, mainly filling and justification
|
|
|
|
|
|
|
|
|
|
;; For each pass, a control function finds and pre-processes the
|
|
|
|
|
;; escape or request and then calls the appropriate function to
|
|
|
|
|
;; perform the required formatting. Based originally on enriched.el
|
|
|
|
|
;; and format.el.
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; The background information that made this project possible is
|
|
|
|
|
;; freely available courtesy of Bell Labs from
|
|
|
|
|
;; http://cm.bell-labs.com/7thEdMan/
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
2012-07-25 05:48:19 +00:00
|
|
|
|
;; Acknowledgments
|
|
|
|
|
;; ===============
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; For Heather, Kathryn and Madelyn, the women in my life
|
|
|
|
|
;; (although they will probably never use it)!
|
|
|
|
|
|
|
|
|
|
;; I also thank the following for helpful suggestions, bug reports,
|
|
|
|
|
;; code fragments, general interest, etc.:
|
|
|
|
|
;; Jari Aalto <jari.aalto@cs.tpu.fi>
|
|
|
|
|
;; Dean Andrews <dean@dra.com>
|
2006-04-06 08:44:24 +00:00
|
|
|
|
;; Juanma Barranquero <lekktu@gmail.com>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Karl Berry <kb@cs.umb.edu>
|
|
|
|
|
;; Jim Chapman <jchapman@netcomuk.co.uk>
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Kin Cho <kin@neoscale.com>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Frederic Corne <frederic.corne@erli.fr>
|
|
|
|
|
;; Peter Craft <craft@alacritech.com>
|
|
|
|
|
;; Charles Curley <ccurley@trib.com>
|
|
|
|
|
;; Jim Davidson <jdavidso@teknowledge.com>
|
|
|
|
|
;; Kevin D'Elia <Kevin.DElia@mci.com>
|
|
|
|
|
;; John Fitch <jpff@maths.bath.ac.uk>
|
|
|
|
|
;; Hans Frosch <jwfrosch@rish.b17c.ingr.com>
|
|
|
|
|
;; Guy Gascoigne-Piggford <ggp@informix.com>
|
|
|
|
|
;; Brian Gorka <gorkab@sanchez.com>
|
|
|
|
|
;; Nicolai Henriksen <nhe@lyngso-industri.dk>
|
|
|
|
|
;; Thomas Herchenroeder <the@software-ag.de>
|
|
|
|
|
;; Alexander Hinds <ahinds@thegrid.net>
|
|
|
|
|
;; Stefan Hornburg <sth@hacon.de>
|
|
|
|
|
;; Theodore Jump <tjump@cais.com>
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;; David Kastrup <dak@gnu.org>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Paul Kinnucan <paulk@mathworks.com>
|
|
|
|
|
;; Jonas Linde <jonas@init.se>
|
|
|
|
|
;; Andrew McRae <andrewm@optimation.co.nz>
|
|
|
|
|
;; Howard Melman <howard@silverstream.com>
|
|
|
|
|
;; Dennis Pixton <dennis@math.binghamton.edu>
|
|
|
|
|
;; T. V. Raman <raman@Adobe.COM>
|
|
|
|
|
;; Bruce Ravel <bruce.ravel@nist.gov>
|
|
|
|
|
;; Benjamin Riefenstahl <benny@crocodial.de>
|
|
|
|
|
;; Kevin Ruland <kruland@seistl.com>
|
|
|
|
|
;; Tom Schutter <tom@platte.com>
|
|
|
|
|
;; Wei-Xue Shi <wxshi@ma.neweb.ne.jp>
|
|
|
|
|
;; Fabio Somenzi <fabio@joplin.colorado.edu>
|
|
|
|
|
;; Karel Sprenger <ks@ic.uva.nl>
|
|
|
|
|
;; Chris Szurgot <szurgot@itribe.net>
|
|
|
|
|
;; Paul A. Thompson <pat@po.cwru.edu>
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Arrigo Triulzi <arrigo@maths.qmw.ac.uk>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Geoff Voelker <voelker@cs.washington.edu>
|
2005-09-09 12:21:26 +00:00
|
|
|
|
;; Eli Zaretskii <eliz@gnu.org>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(defvar woman-version "0.551 (beta)" "WoMan version information.")
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(require 'man)
|
2005-10-18 04:21:51 +00:00
|
|
|
|
(require 'button)
|
2006-04-06 08:44:24 +00:00
|
|
|
|
(define-button-type 'WoMan-xref-man-page
|
2005-10-18 04:21:51 +00:00
|
|
|
|
:supertype 'Man-abstract-xref-man-page
|
2006-04-04 16:46:03 +00:00
|
|
|
|
'func (lambda (arg)
|
|
|
|
|
(woman
|
|
|
|
|
;; `woman' cannot deal with arguments that contain a
|
|
|
|
|
;; section name, like close(2), so strip the section name.
|
|
|
|
|
(if (string-match Man-reference-regexp arg)
|
2006-04-06 08:44:24 +00:00
|
|
|
|
(substring arg 0 (match-end 1))
|
2006-04-04 16:46:03 +00:00
|
|
|
|
arg))))
|
2005-10-18 04:21:51 +00:00
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(eval-when-compile ; to avoid compiler warnings
|
|
|
|
|
(require 'dired)
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(require 'cl-lib)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(require 'apropos))
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defun woman-mapcan (fn x)
|
2000-05-24 11:35:22 +00:00
|
|
|
|
"Return concatenated list of FN applied to successive `car' elements of X.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
FN must return a list, cons or nil. Useful for splicing into a list."
|
|
|
|
|
;; Based on the Standard Lisp function MAPCAN but with args swapped!
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;; More concise implementation than the recursive one. -- dak
|
|
|
|
|
(apply #'nconc (mapcar fn x)))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(defun woman-parse-colon-path (paths)
|
|
|
|
|
"Explode search path string PATHS into a list of directory names.
|
|
|
|
|
Allow Cygwin colon-separated search paths on Microsoft platforms.
|
2000-05-24 11:35:22 +00:00
|
|
|
|
Replace null components by calling `woman-parse-man.conf'.
|
2002-10-23 09:08:20 +00:00
|
|
|
|
As a special case, if PATHS is nil then replace it by calling
|
|
|
|
|
`woman-parse-man.conf'."
|
2000-05-24 11:35:22 +00:00
|
|
|
|
;; Based on suggestions by Jari Aalto and Eli Zaretskii.
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; parse-colon-path returns nil for a null path component and
|
|
|
|
|
;; an empty substring of MANPATH denotes the default list.
|
|
|
|
|
(if (memq system-type '(windows-nt ms-dos))
|
|
|
|
|
(cond ((null paths)
|
|
|
|
|
(mapcar 'woman-Cyg-to-Win (woman-parse-man.conf)))
|
|
|
|
|
((string-match ";" paths)
|
|
|
|
|
;; Assume DOS-style path-list...
|
|
|
|
|
(woman-mapcan ; splice list into list
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(if x
|
|
|
|
|
(list x)
|
|
|
|
|
(mapcar 'woman-Cyg-to-Win (woman-parse-man.conf))))
|
|
|
|
|
(parse-colon-path paths)))
|
|
|
|
|
((string-match "\\`[a-zA-Z]:" paths)
|
|
|
|
|
;; Assume single DOS-style path...
|
2009-03-07 14:36:36 +00:00
|
|
|
|
(list paths))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(t
|
|
|
|
|
;; Assume UNIX/Cygwin-style path-list...
|
|
|
|
|
(woman-mapcan ; splice list into list
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(mapcar 'woman-Cyg-to-Win
|
|
|
|
|
(if x (list x) (woman-parse-man.conf))))
|
|
|
|
|
(let ((path-separator ":"))
|
|
|
|
|
(parse-colon-path paths)))))
|
|
|
|
|
;; Assume host-default-style path-list...
|
|
|
|
|
(woman-mapcan ; splice list into list
|
|
|
|
|
(lambda (x) (if x (list x) (woman-parse-man.conf)))
|
|
|
|
|
(parse-colon-path (or paths "")))))
|
|
|
|
|
|
|
|
|
|
(defun woman-Cyg-to-Win (file)
|
|
|
|
|
"Convert an absolute filename FILE from Cygwin to Windows form."
|
2007-03-31 15:22:14 +00:00
|
|
|
|
;; MANPATH_MAP conses are not converted since they presumably map
|
|
|
|
|
;; Cygwin to Cygwin form.
|
|
|
|
|
(if (consp file)
|
|
|
|
|
file
|
|
|
|
|
;; Code taken from w32-symlinks.el
|
|
|
|
|
(if (eq (aref file 0) ?/)
|
|
|
|
|
;; Try to use Cygwin mount table via `cygpath.exe'.
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
;; cygpath -m file
|
|
|
|
|
(call-process "cygpath" nil t nil "-m" file)
|
|
|
|
|
(buffer-substring 1 (buffer-size)))
|
|
|
|
|
(error
|
|
|
|
|
;; Assume no `cygpath' program available.
|
|
|
|
|
;; Hack /cygdrive/x/ or /x/ or (obsolete) //x/ to x:/
|
|
|
|
|
(when (string-match "\\`\\(/cygdrive\\|/\\)?/./" file)
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(if (match-beginning 1) ; /cygdrive/x/ or //x/ -> /x/
|
2007-03-31 15:22:14 +00:00
|
|
|
|
(setq file (substring file (match-end 1))))
|
|
|
|
|
(aset file 0 (aref file 1)) ; /x/ -> xx/
|
|
|
|
|
(aset file 1 ?:)) ; xx/ -> x:/
|
|
|
|
|
file))
|
|
|
|
|
file)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; User options:
|
|
|
|
|
|
|
|
|
|
;; NB: Group identifiers must be lowercase!
|
|
|
|
|
|
|
|
|
|
(defgroup woman nil
|
|
|
|
|
"Browse UNIX manual pages `wo (without) man'."
|
|
|
|
|
:tag "WoMan"
|
|
|
|
|
:group 'help)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-show-log nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then show the *WoMan-Log* buffer if appropriate.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
I.e. if any warning messages are written to it. Default is nil."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-pre-format-hook nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Hook run by WoMan immediately before formatting a buffer.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Change only via `Customization' or the function `add-hook'."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'woman)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-post-format-hook nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Hook run by WoMan immediately after formatting a buffer.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Change only via `Customization' or the function `add-hook'."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'woman)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Interface options
|
|
|
|
|
|
|
|
|
|
(defgroup woman-interface nil
|
|
|
|
|
"Interface options for browsing UNIX manual pages `wo (without) man'."
|
|
|
|
|
:tag "WoMan Interface"
|
|
|
|
|
:group 'woman)
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defcustom woman-man.conf-path
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(let ((path '("/usr/lib" "/etc")))
|
2008-07-15 18:15:18 +00:00
|
|
|
|
(cond ((eq system-type 'windows-nt)
|
|
|
|
|
(mapcar 'woman-Cyg-to-Win path))
|
|
|
|
|
((eq system-type 'darwin)
|
|
|
|
|
(cons "/usr/share/misc" path))
|
|
|
|
|
(t path)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"List of dirs to search and/or files to try for man config file.
|
2007-03-31 15:22:14 +00:00
|
|
|
|
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'."
|
2000-05-22 07:01:17 +00:00
|
|
|
|
:type '(repeat string)
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defun woman-parse-man.conf ()
|
2002-10-23 09:08:20 +00:00
|
|
|
|
"Parse if possible configuration file for man command.
|
2000-05-24 11:35:22 +00:00
|
|
|
|
Used only if MANPATH is not set or contains null components.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
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
|
2002-10-23 09:08:20 +00:00
|
|
|
|
MANPATH /usr/man
|
2000-07-04 04:46:05 +00:00
|
|
|
|
or
|
2004-03-07 14:54:35 +00:00
|
|
|
|
MANDATORY_MANPATH /usr/man
|
|
|
|
|
or
|
2007-03-31 15:22:14 +00:00
|
|
|
|
OPTIONAL_MANPATH /usr/man
|
|
|
|
|
or
|
|
|
|
|
MANPATH_MAP /opt/bin /opt/man"
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; 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
|
2007-03-31 15:22:14 +00:00
|
|
|
|
(directory-files file t "\\`man.*\\.conf[a-z]*\\'" t))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(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
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; `\(?: ... \)' is a "shy group"
|
|
|
|
|
"\
|
2007-03-31 15:22:14 +00:00
|
|
|
|
^[ \t]*\\(?:\\(?:MANDATORY_\\|OPTIONAL_\\)?MANPATH[ \t]+\\(\\S-+\\)\\|\
|
|
|
|
|
MANPATH_MAP[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)\\)" nil t)
|
|
|
|
|
(add-to-list 'manpath
|
|
|
|
|
(if (match-beginning 1)
|
2007-09-25 11:17:39 +00:00
|
|
|
|
(match-string 1)
|
2007-03-31 15:22:14 +00:00
|
|
|
|
(cons (match-string 2)
|
|
|
|
|
(match-string 3)))))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
manpath))
|
|
|
|
|
))
|
|
|
|
|
(setq path (cdr path)))
|
|
|
|
|
(nreverse manpath)))
|
|
|
|
|
|
2008-02-08 20:43:50 +00:00
|
|
|
|
;; 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)))))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defcustom woman-manpath
|
2008-02-08 20:43:50 +00:00
|
|
|
|
;; Locales could also be added in woman-expand-directory-path.
|
|
|
|
|
(or (woman-manpath-add-locales
|
|
|
|
|
(woman-parse-colon-path (getenv "MANPATH")))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
'("/usr/man" "/usr/share/man" "/usr/local/man"))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"List of DIRECTORY TREES to search for UN*X manual files.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Each element should be the name of a directory that contains
|
|
|
|
|
subdirectories of the form `man?', or more precisely subdirectories
|
|
|
|
|
selected by the value of `woman-manpath-man-regexp'. Non-directory
|
2000-05-22 07:01:17 +00:00
|
|
|
|
and unreadable files are ignored.
|
|
|
|
|
|
2007-03-31 15:22:14 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
If not set then the environment variable MANPATH is used. If no such
|
|
|
|
|
environment variable is found, the default list is determined by
|
2002-10-23 09:08:20 +00:00
|
|
|
|
consulting the man configuration file if found, which is determined by
|
|
|
|
|
the user option `woman-man.conf-path'. An empty substring of MANPATH
|
|
|
|
|
denotes the default list.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Any environment variables (names must have the UN*X-style form $NAME,
|
2002-10-23 09:08:20 +00:00
|
|
|
|
e.g. $HOME, $EMACSDATA, $emacs_dir) are evaluated first but each
|
2000-05-08 14:32:17 +00:00
|
|
|
|
element must evaluate to a SINGLE directory name. Trailing `/'s are
|
|
|
|
|
ignored. (Specific directories in `woman-path' are also searched.)
|
|
|
|
|
|
|
|
|
|
Microsoft platforms:
|
|
|
|
|
I recommend including drive letters explicitly, e.g.
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(\"C:/Cygwin/usr/man/\" \"C:/Cygwin/usr/local/man\").
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
The MANPATH environment variable may be set using DOS semi-colon-
|
2002-10-23 09:08:20 +00:00
|
|
|
|
separated or UN*X/Cygwin colon-separated syntax (but not mixed)."
|
2007-03-31 15:22:14 +00:00
|
|
|
|
:type '(repeat (choice string (cons string string)))
|
2008-02-08 20:43:50 +00:00
|
|
|
|
:version "23.1" ; added woman-manpath-add-locales
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-manpath-man-regexp "[Mm][Aa][Nn]"
|
|
|
|
|
"Regexp to match man directories UNDER `woman-manpath' directories.
|
|
|
|
|
These normally have names of the form `man?'. Its default value is
|
|
|
|
|
\"[Mm][Aa][Nn]\", which is case-insensitive mainly for the benefit of
|
|
|
|
|
Microsoft platforms. Its purpose is to avoid `cat?', `.', `..', etc."
|
|
|
|
|
;; Based on a suggestion by Wei-Xue Shi.
|
|
|
|
|
:type 'string
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-path
|
|
|
|
|
(if (eq system-type 'ms-dos) '("$DJDIR/info" "$DJDIR/man/cat[1-9onlp]"))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"List of SPECIFIC DIRECTORIES to search for UN*X manual files.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
For example
|
|
|
|
|
|
|
|
|
|
(\"/emacs/etc\").
|
|
|
|
|
|
|
|
|
|
These directories are searched in addition to the directory trees
|
|
|
|
|
specified in `woman-manpath'. Each element should be a directory
|
|
|
|
|
string or nil, which represents the current directory when the path is
|
|
|
|
|
expanded and cached. However, the last component (only) of each
|
|
|
|
|
directory string is treated as a regexp \(Emacs, not shell) and the
|
|
|
|
|
string is expanded into a list of matching directories. Non-directory
|
|
|
|
|
and unreadable files are ignored. The default value is nil.
|
|
|
|
|
|
|
|
|
|
Any environment variables (which must have the UN*X-style form $NAME,
|
2002-10-23 09:08:20 +00:00
|
|
|
|
e.g. $HOME, $EMACSDATA, $emacs_dir) are evaluated first but each
|
2000-05-08 14:32:17 +00:00
|
|
|
|
element must evaluate to a SINGLE directory name (regexp, see above).
|
|
|
|
|
For example
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(\"$EMACSDATA\") [or equivalently (\"$emacs_dir/etc\")].
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
Trailing `/'s are discarded. (The directory trees in `woman-manpath'
|
|
|
|
|
are also searched.) On Microsoft platforms I recommend including
|
|
|
|
|
drive letters explicitly."
|
|
|
|
|
:type '(repeat (choice string (const nil)))
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-cache-level 2
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"The level of topic caching.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
1 - cache only the topic and directory lists
|
|
|
|
|
(the only level before version 0.34 - only for compatibility);
|
|
|
|
|
2 - cache also the directories for each topic
|
|
|
|
|
(faster, without using much more memory);
|
|
|
|
|
3 - cache also the actual filenames for each topic
|
|
|
|
|
(fastest, but uses twice as much memory).
|
|
|
|
|
The default value is currently 2, a good general compromise.
|
|
|
|
|
If the `woman' command is slow to find files then try 3, which may be
|
|
|
|
|
particularly beneficial with large remote-mounted man directories.
|
|
|
|
|
Run the `woman' command with a prefix argument or delete the cache
|
|
|
|
|
file `woman-cache-filename' for a change to take effect.
|
|
|
|
|
\(Values < 1 behave like 1; values > 3 behave like 3.)"
|
|
|
|
|
:type '(choice (const :tag "Minimal" 1)
|
|
|
|
|
(const :tag "Default" 2)
|
|
|
|
|
(const :tag "Maximal" 3))
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-cache-filename nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"The full pathname of the WoMan directory and topic cache file.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
It is used to save and restore the cache between sessions. This is
|
|
|
|
|
especially useful with remote-mounted man page files! The default
|
|
|
|
|
value of nil suppresses this action. The `standard' non-nil
|
|
|
|
|
filename is \"~/.wmncach.el\". Remember that a prefix argument forces
|
|
|
|
|
the `woman' command to update and re-write the cache."
|
|
|
|
|
:type '(choice (const :tag "None" nil)
|
|
|
|
|
(const :tag "~/.wmncach.el" "~/.wmncach.el")
|
|
|
|
|
file)
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-dired-keys t
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"List of `dired' mode keys to define to run WoMan on current file.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
E.g. '(\"w\" \"W\"), or any non-null atom to automatically define
|
|
|
|
|
\"w\" and \"W\" if they are unbound, or nil to do nothing.
|
|
|
|
|
Default is t."
|
|
|
|
|
:type '(choice (const :tag "None" nil)
|
|
|
|
|
(repeat string)
|
|
|
|
|
(other :tag "Auto" t))
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-imenu-generic-expression
|
|
|
|
|
'((nil "\n\\([A-Z].*\\)" 1) ; SECTION, but not TITLE
|
|
|
|
|
("*Subsections*" "^ \\([A-Z].*\\)" 1))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Imenu support for Sections and Subsections.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
An alist with elements of the form (MENU-TITLE REGEXP INDEX) --
|
|
|
|
|
see the documentation for `imenu-generic-expression'."
|
|
|
|
|
:type 'sexp
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-imenu nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then WoMan adds a Contents menu to the menubar.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
It does this by calling `imenu-add-to-menubar'. Default is nil."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-imenu-title "CONTENTS"
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"The title to use if WoMan adds a Contents menu to the menubar.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Default is \"CONTENTS\"."
|
|
|
|
|
:type 'string
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(defcustom woman-use-topic-at-point-default nil
|
|
|
|
|
;; `woman-use-topic-at-point' may be let-bound when woman is loaded,
|
|
|
|
|
;; in which case its global value does not get defined.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; `woman-file-name' sets it to this value if it is unbound.
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Default value for `woman-use-topic-at-point'."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type '(choice (const :tag "Yes" t)
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(const :tag "No" nil))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(defcustom woman-use-topic-at-point woman-use-topic-at-point-default
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Control use of the word at point as the default topic.
|
2005-09-10 14:59:07 +00:00
|
|
|
|
If non-nil the `woman' command uses the word at point automatically,
|
|
|
|
|
without interactive confirmation, if it exists as a topic."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type '(choice (const :tag "Yes" t)
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(const :tag "No" nil))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defvar woman-file-regexp nil
|
|
|
|
|
"Regexp used to select (possibly compressed) man source files, e.g.
|
2010-09-25 21:42:48 +00:00
|
|
|
|
\"\\.\\([0-9lmnt]\\w*\\)\\(\\.\\(g?z\\|bz2\\|xz\\)\\)?\\'\".
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Built automatically from the customizable user options
|
|
|
|
|
`woman-uncompressed-file-regexp' and `woman-file-compression-regexp'.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-uncompressed-file-regexp) ; for the compiler
|
|
|
|
|
(defvar woman-file-compression-regexp) ; for the compiler
|
|
|
|
|
|
|
|
|
|
(defun set-woman-file-regexp (symbol value)
|
|
|
|
|
"Bind SYMBOL to VALUE and set `woman-file-regexp' as per user customizations.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Used as :set cookie by Customize when customizing the user options
|
2000-05-08 14:32:17 +00:00
|
|
|
|
`woman-uncompressed-file-regexp' and `woman-file-compression-regexp'."
|
|
|
|
|
(set-default symbol value)
|
|
|
|
|
(and (boundp 'woman-uncompressed-file-regexp)
|
|
|
|
|
(boundp 'woman-file-compression-regexp)
|
|
|
|
|
(setq woman-file-regexp
|
|
|
|
|
(concat woman-uncompressed-file-regexp
|
|
|
|
|
"\\("
|
|
|
|
|
(substring woman-file-compression-regexp 0 -2)
|
|
|
|
|
"\\)?\\'"))))
|
|
|
|
|
|
|
|
|
|
(defcustom woman-uncompressed-file-regexp
|
|
|
|
|
"\\.\\([0-9lmnt]\\w*\\)" ; disallow no extension
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Do not change this unless you are sure you know what you are doing!
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Regexp used to select man source files (ignoring any compression extension).
|
|
|
|
|
|
|
|
|
|
The SysV standard man pages use two character suffixes, and this is
|
|
|
|
|
becoming more common in the GNU world. For example, the man pages
|
|
|
|
|
in the ncurses package include `toe.1m', `form.3x', etc.
|
|
|
|
|
|
|
|
|
|
Note: an optional compression regexp will be appended, so this regexp
|
|
|
|
|
MUST NOT end with any kind of string terminator such as $ or \\'."
|
|
|
|
|
:type 'regexp
|
|
|
|
|
:set 'set-woman-file-regexp
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-file-compression-regexp
|
2010-09-25 21:42:48 +00:00
|
|
|
|
"\\.\\(g?z\\|bz2\\|xz\\)\\'"
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Do not change this unless you are sure you know what you are doing!
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Regexp used to match compressed man file extensions for which
|
2000-05-22 07:01:17 +00:00
|
|
|
|
decompressors are available and handled by auto-compression mode,
|
2010-09-25 21:42:48 +00:00
|
|
|
|
e.g. \"\\\\.\\\\(g?z\\\\|bz2\\\\|xz\\\\)\\\\'\" for `gzip', `bzip2', or `xz'.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Should begin with \\. and end with \\' and MUST NOT be optional."
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Should be compatible with car of
|
|
|
|
|
;; `jka-compr-file-name-handler-entry', but that is unduly
|
|
|
|
|
;; complicated, includes an inappropriate extension (.tgz) and is
|
|
|
|
|
;; not loaded by default!
|
2010-09-25 21:42:48 +00:00
|
|
|
|
:version "24.1" ; added xz
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'regexp
|
|
|
|
|
:set 'set-woman-file-regexp
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(defcustom woman-use-own-frame nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then use a dedicated frame for displaying WoMan windows.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Only useful when run on a graphic display such as X or MS-Windows."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-interface)
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Formatting options
|
|
|
|
|
|
|
|
|
|
(defgroup woman-formatting nil
|
|
|
|
|
"Formatting options for browsing UNIX manual pages `wo (without) man'."
|
|
|
|
|
:tag "WoMan Formatting"
|
|
|
|
|
:group 'woman)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-fill-column 65
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Right margin for formatted text -- default is 65."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-fill-frame nil
|
|
|
|
|
;; Based loosely on a suggestion by Theodore Jump:
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then most of the window width is used."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-default-indent 5
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"Default prevailing indent set by -man macros -- default is 5.
|
2002-10-23 09:08:20 +00:00
|
|
|
|
Set this variable to 7 to emulate GNU man formatting."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-bold-headings t
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then embolden section and subsection headings. Default is t.
|
2005-06-10 14:09:51 +00:00
|
|
|
|
Heading emboldening is NOT standard `man' behavior."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-ignore t
|
2007-10-13 19:36:00 +00:00
|
|
|
|
"If non-nil then unrecognized requests etc. are ignored. Default is t.
|
2005-06-10 14:09:51 +00:00
|
|
|
|
This gives the standard ?roff behavior. If nil then they are left in
|
2000-05-08 14:32:17 +00:00
|
|
|
|
the buffer, which may aid debugging."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
2004-03-13 13:06:48 +00:00
|
|
|
|
(defcustom woman-preserve-ascii t
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil, preserve ASCII characters in the WoMan buffer.
|
2004-03-13 13:06:48 +00:00
|
|
|
|
Otherwise, to save time, some backslashes and spaces may be
|
|
|
|
|
represented differently (as the values of the variables
|
|
|
|
|
`woman-escaped-escape-char' and `woman-unpadded-space-char'
|
|
|
|
|
respectively) so that the buffer content is strictly wrong even though
|
|
|
|
|
it should display correctly. This should be irrelevant unless the
|
|
|
|
|
buffer text is searched, copied or saved to a file."
|
|
|
|
|
;; This option should probably be removed!
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defcustom woman-emulation 'nroff
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"WoMan emulation, currently either nroff or troff. Default is nroff.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Troff emulation is experimental and largely untested.
|
|
|
|
|
\(Add groff later?)"
|
|
|
|
|
:type '(choice (const nroff) (const troff))
|
|
|
|
|
:group 'woman-formatting)
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Faces:
|
|
|
|
|
|
|
|
|
|
(defgroup woman-faces nil
|
|
|
|
|
"Face options for browsing UNIX manual pages `wo (without) man'."
|
|
|
|
|
:tag "WoMan Faces"
|
|
|
|
|
:group 'woman
|
|
|
|
|
:group 'faces)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-fontify
|
|
|
|
|
(or (and (fboundp 'display-color-p) (display-color-p))
|
|
|
|
|
(and (fboundp 'display-graphic-p) (display-graphic-p))
|
|
|
|
|
(x-display-color-p))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then WoMan assumes that face support is available.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
It defaults to a non-nil value if the display supports either colors
|
|
|
|
|
or different fonts."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-faces)
|
|
|
|
|
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(defface woman-italic
|
2009-07-06 02:17:31 +00:00
|
|
|
|
'((t :inherit italic))
|
2000-10-23 05:37:24 +00:00
|
|
|
|
"Face for italic font in man pages."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-faces)
|
2009-09-01 07:24:13 +00:00
|
|
|
|
(define-obsolete-face-alias 'woman-italic-face 'woman-italic "22.1")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(defface woman-bold
|
2009-07-06 02:17:31 +00:00
|
|
|
|
'((t :inherit bold))
|
2000-10-23 05:37:24 +00:00
|
|
|
|
"Face for bold font in man pages."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-faces)
|
2009-09-01 07:24:13 +00:00
|
|
|
|
(define-obsolete-face-alias 'woman-bold-face 'woman-bold "22.1")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(defface woman-unknown
|
2009-07-06 02:17:31 +00:00
|
|
|
|
'((t :inherit font-lock-warning-face))
|
2000-10-23 05:37:24 +00:00
|
|
|
|
"Face for all unknown fonts in man pages."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-faces)
|
2009-09-01 07:24:13 +00:00
|
|
|
|
(define-obsolete-face-alias 'woman-unknown-face 'woman-unknown "22.1")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(defface woman-addition
|
2009-07-06 02:17:31 +00:00
|
|
|
|
'((t :inherit font-lock-builtin-face))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
"Face for all WoMan additions to man pages."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:group 'woman-faces)
|
2009-09-01 07:24:13 +00:00
|
|
|
|
(define-obsolete-face-alias 'woman-addition-face 'woman-addition "22.1")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-10-23 05:37:24 +00:00
|
|
|
|
(defun woman-default-faces ()
|
2005-06-10 14:09:51 +00:00
|
|
|
|
"Set foreground colors of italic and bold faces to their default values."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(interactive)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(face-spec-set 'woman-italic (face-user-default-spec 'woman-italic))
|
|
|
|
|
(face-spec-set 'woman-bold (face-user-default-spec 'woman-bold)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-10-23 05:37:24 +00:00
|
|
|
|
(defun woman-monochrome-faces ()
|
2005-06-10 14:09:51 +00:00
|
|
|
|
"Set foreground colors of italic and bold faces to that of the default face.
|
2000-10-23 05:37:24 +00:00
|
|
|
|
This is usually either black or white."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(interactive)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(set-face-foreground 'woman-italic 'unspecified)
|
|
|
|
|
(set-face-foreground 'woman-bold 'unspecified))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Experimental font support, initially only for MS-Windows.
|
|
|
|
|
(defconst woman-font-support
|
2000-05-24 11:35:22 +00:00
|
|
|
|
(eq window-system 'w32) ; Support X later!
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"If non-nil then non-ASCII characters and symbol font supported.")
|
|
|
|
|
|
|
|
|
|
(defun woman-select-symbol-fonts (fonts)
|
|
|
|
|
"Select symbol fonts from a list FONTS of font name strings."
|
|
|
|
|
(let (symbol-fonts)
|
|
|
|
|
;; With NTEmacs 20.5, the PATTERN option to `x-list-fonts' does
|
|
|
|
|
;; not seem to work and fonts may be repeated, so ...
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(dolist (font fonts)
|
|
|
|
|
(and (string-match "-Symbol-" font)
|
|
|
|
|
(not (member font symbol-fonts))
|
|
|
|
|
(setq symbol-fonts (cons font symbol-fonts))))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
symbol-fonts))
|
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
|
(declare-function x-list-fonts "xfaces.c"
|
|
|
|
|
(pattern &optional face frame maximum width))
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(when woman-font-support
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(make-face 'woman-symbol)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Set the symbol font only if `woman-use-symbol-font' is true, to
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; avoid unnecessarily upsetting the line spacing in NTEmacs 20.5!
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defcustom woman-use-extended-font t
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then may use non-ASCII characters from the default font."
|
2000-05-22 07:01:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-faces)
|
|
|
|
|
|
|
|
|
|
(defcustom woman-use-symbol-font nil
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"If non-nil then may use the symbol font.
|
2005-09-09 12:30:03 +00:00
|
|
|
|
It is off by default, mainly because it may change the line spacing
|
|
|
|
|
\(in NTEmacs 20.5)."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'woman-faces)
|
|
|
|
|
|
|
|
|
|
(defconst woman-symbol-font-list
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(or (woman-select-symbol-fonts (x-list-fonts "*" 'default))
|
|
|
|
|
(woman-select-symbol-fonts (x-list-fonts "*")))
|
|
|
|
|
"Symbol font(s), preferably same size as default when WoMan was loaded.")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defcustom woman-symbol-font (car woman-symbol-font-list)
|
2007-09-07 02:45:28 +00:00
|
|
|
|
"A string describing the symbol font to use for special characters.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
It should be compatible with, and the same size as, the default text font.
|
|
|
|
|
Under MS-Windows, the default is
|
|
|
|
|
\"-*-Symbol-normal-r-*-*-*-*-96-96-p-*-ms-symbol\"."
|
|
|
|
|
:type `(choice
|
2000-05-22 07:01:17 +00:00
|
|
|
|
,@(mapcar (lambda (x) (list 'const x))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
woman-symbol-font-list)
|
|
|
|
|
string)
|
|
|
|
|
:group 'woman-faces)
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; For non windows-nt ...
|
|
|
|
|
(defvar woman-use-extended-font nil)
|
|
|
|
|
(defvar woman-use-symbol-font nil)
|
|
|
|
|
(defvar woman-symbol-font nil)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Internal variables:
|
|
|
|
|
|
|
|
|
|
(defconst woman-justify-list
|
|
|
|
|
'(left right center full)
|
|
|
|
|
"Justify styles for `fill-region-as-paragraph'.")
|
|
|
|
|
(defconst woman-adjust-left 0 ; == adjust off, noadjust
|
|
|
|
|
"Adjustment indicator `l' -- adjust left margin only.")
|
|
|
|
|
(defconst woman-adjust-right 1
|
|
|
|
|
"Adjustment indicator `r' -- adjust right margin only.")
|
|
|
|
|
(defconst woman-adjust-center 2
|
|
|
|
|
"Adjustment indicator `c' -- center.")
|
|
|
|
|
(defconst woman-adjust-both 3 ; default -- adj,both
|
|
|
|
|
"Adjustment indicator `b' or `n' -- adjust both margins.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-adjust woman-adjust-both
|
|
|
|
|
"Current adjustment number-register value.")
|
|
|
|
|
(defvar woman-adjust-previous woman-adjust
|
|
|
|
|
"Previous adjustment number-register value.")
|
|
|
|
|
(defvar woman-justify
|
|
|
|
|
(nth woman-adjust woman-justify-list) ; use vector?
|
|
|
|
|
"Current justification style for `fill-region-as-paragraph'.")
|
|
|
|
|
(defvar woman-justify-previous woman-justify
|
|
|
|
|
"Previous justification style for `fill-region-as-paragraph'.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-left-margin woman-default-indent
|
|
|
|
|
"Current left margin.")
|
|
|
|
|
(defvar woman-prevailing-indent woman-default-indent
|
|
|
|
|
"Current prevailing indent.")
|
|
|
|
|
(defvar woman-interparagraph-distance 1
|
|
|
|
|
"Interparagraph distance in lines.
|
|
|
|
|
Set by .PD; used by .SH, .SS, .TP, .LP, .PP, .P, .IP, .HP.")
|
|
|
|
|
(defvar woman-leave-blank-lines nil
|
|
|
|
|
"Blank lines to leave as vertical space.")
|
|
|
|
|
(defconst woman-tab-width 5
|
|
|
|
|
"Default tab width set by -man macros.")
|
|
|
|
|
(defvar woman-nofill nil
|
|
|
|
|
"Current fill mode: nil for filling.")
|
|
|
|
|
(defvar woman-RS-left-margin nil
|
|
|
|
|
"Left margin stack for nested use of `.RS/.RE'.")
|
|
|
|
|
(defvar woman-RS-prevailing-indent nil
|
|
|
|
|
"Prevailing indent stack for nested use of `.RS/.RE'.")
|
|
|
|
|
(defvar woman-nospace nil
|
|
|
|
|
"Current no-space mode: nil for normal spacing.
|
|
|
|
|
Set by `.ns' request; reset by any output or `.rs' request")
|
2011-04-19 13:44:55 +00:00
|
|
|
|
;; Used for message logging
|
|
|
|
|
(defvar WoMan-current-file nil) ; bound in woman-really-find-file
|
|
|
|
|
(defvar WoMan-Log-header-point-max nil)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defsubst woman-reset-nospace ()
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Set `woman-nospace' to nil."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq woman-nospace nil))
|
|
|
|
|
|
|
|
|
|
(defconst woman-request-regexp "^[.'][ \t]*\\(\\S +\\) *"
|
|
|
|
|
;; Was "^\\.[ \t]*\\([a-z0-9]+\\) *" but cvs.1 uses a macro named
|
|
|
|
|
;; "`" and CGI.man uses a macro named "''"!
|
|
|
|
|
;; CGI.man uses ' as control character in places -- it *should*
|
|
|
|
|
;; suppress breaks!
|
|
|
|
|
;; Could end with "\\( +\\|$\\)" instead of " *"
|
|
|
|
|
"Regexp to match a ?roff request plus trailing white space.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-imenu-done nil
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Buffer-local: set to true if function `woman-imenu' has been called.")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(make-variable-buffer-local 'woman-imenu-done)
|
|
|
|
|
|
|
|
|
|
;; From imenu.el -- needed when reformatting a file in its old buffer.
|
|
|
|
|
;; The latest buffer index used to update the menu bar menu.
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'imenu))
|
|
|
|
|
(make-variable-buffer-local 'imenu--last-menubar-index-alist)
|
|
|
|
|
|
|
|
|
|
(defvar woman-buffer-alist nil
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"An alist representing WoMan buffers that are already decoded.
|
|
|
|
|
Each element is of the form (FILE-NAME . BUFFER-NAME).")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defvar woman-buffer-number 0
|
|
|
|
|
"Ordinal number of current buffer entry in `woman-buffer-alist'.
|
|
|
|
|
The ordinal numbers start from 0.")
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defvar woman-if-conditions-true '(?n ?e ?o)
|
|
|
|
|
"List of one-character built-in condition names that are true.
|
|
|
|
|
Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff).
|
|
|
|
|
Default is '(?n ?e ?o). Set via `woman-emulation'.")
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;; Specialized utility functions:
|
|
|
|
|
|
|
|
|
|
;;; Fast deletion without saving on the kill ring (cf. simple.el):
|
|
|
|
|
|
|
|
|
|
(defun woman-delete-line (&optional arg)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Delete rest of current line; if all blank then delete thru newline.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
With a numeric argument ARG, delete that many lines from point.
|
|
|
|
|
Negative arguments delete lines backward."
|
|
|
|
|
;; This is a non-interactive version of kill-line in simple.el that
|
|
|
|
|
;; deletes instead of killing and assumes kill-whole-line is nil,
|
|
|
|
|
;; which is essential!
|
|
|
|
|
(delete-region (point)
|
|
|
|
|
(progn
|
|
|
|
|
(if arg
|
|
|
|
|
(forward-line arg)
|
|
|
|
|
(if (eobp)
|
|
|
|
|
(signal 'end-of-buffer nil))
|
|
|
|
|
(if (looking-at "[ \t]*$")
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(end-of-line)))
|
|
|
|
|
(point))))
|
|
|
|
|
|
|
|
|
|
(defsubst woman-delete-whole-line ()
|
|
|
|
|
"Delete current line from beginning including eol."
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman-delete-line 1))
|
|
|
|
|
|
|
|
|
|
(defsubst woman-delete-following-space ()
|
|
|
|
|
"Delete all spaces and tabs FOLLOWING point (cf. `delete-horizontal-space')."
|
|
|
|
|
;; cf. delete-horizontal-space in simple.el:
|
|
|
|
|
(delete-region (point) (progn (skip-chars-forward " \t") (point))))
|
|
|
|
|
|
|
|
|
|
(defsubst woman-delete-match (subexp)
|
|
|
|
|
"Delete subexpression SUBEXP of buffer text matched by last search."
|
|
|
|
|
(delete-region (match-beginning subexp) (match-end subexp)))
|
|
|
|
|
|
|
|
|
|
;; delete-char does not kill by default
|
|
|
|
|
;; delete-backward-char does not kill by default
|
|
|
|
|
;; delete-horizontal-space does not kill
|
|
|
|
|
;; delete-blank-lines does not kill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; File handling:
|
|
|
|
|
|
|
|
|
|
(defvar woman-expanded-directory-path nil
|
|
|
|
|
"Expanded directory list cache. Resetting to nil forces update.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-topic-all-completions nil
|
|
|
|
|
"Expanded topic alist cache. Resetting to nil forces update.")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun woman (&optional topic re-cache)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Browse UN*X man page for TOPIC (Without using external Man program).
|
2000-05-08 14:32:17 +00:00
|
|
|
|
The major browsing mode used is essentially the standard Man mode.
|
|
|
|
|
Choose the filename for the man page using completion, based on the
|
|
|
|
|
topic selected from the directories specified in `woman-manpath' and
|
|
|
|
|
`woman-path'. The directory expansions and topics are cached for
|
|
|
|
|
speed, but a non-nil interactive argument forces the caches to be
|
|
|
|
|
updated (e.g. to re-interpret the current directory).
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Used non-interactively, arguments are optional: if given then TOPIC
|
|
|
|
|
should be a topic string and non-nil RE-CACHE forces re-caching."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(interactive (list nil current-prefix-arg))
|
|
|
|
|
;; The following test is for non-interactive calls via gnudoit etc.
|
2004-10-26 08:36:11 +00:00
|
|
|
|
(if (or (not (stringp topic)) (string-match "\\S " topic))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let ((file-name (woman-file-name topic re-cache)))
|
|
|
|
|
(if file-name
|
|
|
|
|
(woman-find-file file-name)
|
|
|
|
|
(message
|
|
|
|
|
"WoMan Error: No matching manual files found in search path")
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(ding)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(message "WoMan Error: No topic specified in non-interactive call")
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(ding)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Allow WoMan to be called via the standard Help menu:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(define-key-after menu-bar-manuals-menu [woman]
|
|
|
|
|
'(menu-item "Read Man Page (WoMan)..." woman
|
|
|
|
|
:help "Man-page documentation Without Man") t)
|
|
|
|
|
|
|
|
|
|
(defvar woman-cached-data nil
|
|
|
|
|
"A list of cached data used to determine cache validity.
|
|
|
|
|
Set from the cache by `woman-read-directory-cache'.")
|
|
|
|
|
|
|
|
|
|
(defun woman-cached-data ()
|
|
|
|
|
"Generate a list of data used to determine cache validity.
|
|
|
|
|
Called both to generate and to check the cache!"
|
|
|
|
|
;; Must use substituted paths because values of env vars may change!
|
|
|
|
|
(list woman-cache-level
|
2007-03-31 15:22:14 +00:00
|
|
|
|
(let (lst path)
|
|
|
|
|
(dolist (dir woman-manpath (nreverse lst))
|
|
|
|
|
(when (consp dir)
|
|
|
|
|
(unless path
|
|
|
|
|
(setq path
|
|
|
|
|
(split-string (getenv "PATH") path-separator t)))
|
|
|
|
|
(setq dir (and (member (car dir) path) (cdr dir))))
|
|
|
|
|
(when dir (add-to-list 'lst (substitute-in-file-name dir)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(mapcar 'substitute-in-file-name woman-path)))
|
|
|
|
|
|
|
|
|
|
(defun woman-read-directory-cache ()
|
|
|
|
|
"Load the directory and topic cache.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
It is loaded from the file named by the variable `woman-cache-filename'.
|
|
|
|
|
Return t if the file exists, nil otherwise."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(and
|
|
|
|
|
woman-cache-filename
|
|
|
|
|
(load woman-cache-filename t nil t) ; file exists
|
|
|
|
|
(equal woman-cached-data (woman-cached-data)))) ; cache valid
|
|
|
|
|
|
|
|
|
|
(defun woman-write-directory-cache ()
|
|
|
|
|
"Save the directory and topic cache.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
It is saved to the file named by the variable `woman-cache-filename'."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if woman-cache-filename
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(with-current-buffer (generate-new-buffer "WoMan tmp buffer")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Make a temporary buffer; name starting with space "hides" it.
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(let ((standard-output (current-buffer))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(backup-inhibited t))
|
|
|
|
|
;; (switch-to-buffer standard-output t) ; only for debugging
|
|
|
|
|
(buffer-disable-undo standard-output)
|
|
|
|
|
(princ
|
|
|
|
|
";;; WoMan directory and topic cache -- generated automatically\n")
|
|
|
|
|
(print
|
|
|
|
|
;; For data validity check:
|
|
|
|
|
`(setq woman-cached-data ',(woman-cached-data)))
|
|
|
|
|
(print
|
|
|
|
|
`(setq woman-expanded-directory-path
|
|
|
|
|
',woman-expanded-directory-path))
|
|
|
|
|
(print
|
|
|
|
|
`(setq woman-topic-all-completions
|
|
|
|
|
',woman-topic-all-completions))
|
|
|
|
|
(write-file woman-cache-filename) ; write CURRENT buffer
|
|
|
|
|
(kill-buffer standard-output)
|
|
|
|
|
))))
|
|
|
|
|
|
2006-09-02 23:29:18 +00:00
|
|
|
|
(defvaralias 'woman-topic-history 'Man-topic-history)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defvar woman-file-history nil "File-name read history.")
|
|
|
|
|
|
|
|
|
|
(defun woman-file-name (topic &optional re-cache)
|
|
|
|
|
"Get the name of the UN*X man-page file describing a chosen TOPIC.
|
2005-09-10 14:59:07 +00:00
|
|
|
|
When `woman' is called interactively, the word at point may be
|
|
|
|
|
automatically used as the topic, if the value of the user option
|
|
|
|
|
`woman-use-topic-at-point' is non-nil. Return nil if no file can
|
|
|
|
|
be found. Optional argument RE-CACHE, if non-nil, forces the
|
|
|
|
|
cache to be re-read."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Handle the caching of the directory and topic lists:
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(unless (and (not re-cache)
|
|
|
|
|
(or
|
|
|
|
|
(and woman-expanded-directory-path woman-topic-all-completions)
|
|
|
|
|
(woman-read-directory-cache)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(message "Building list of manual directory expansions...")
|
|
|
|
|
(setq woman-expanded-directory-path
|
|
|
|
|
(woman-expand-directory-path woman-manpath woman-path))
|
|
|
|
|
(message "Building completion list of all manual topics...")
|
|
|
|
|
(setq woman-topic-all-completions
|
|
|
|
|
(woman-topic-all-completions woman-expanded-directory-path))
|
|
|
|
|
(woman-write-directory-cache))
|
|
|
|
|
;; There is a problem in that I want to offer case-insensitive
|
|
|
|
|
;; completions, but to return only a case-sensitive match. This
|
|
|
|
|
;; does not seem to work properly by default, so I re-do the
|
|
|
|
|
;; completion if necessary.
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(let (files)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(or (stringp topic)
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(and (if (boundp 'woman-use-topic-at-point)
|
|
|
|
|
woman-use-topic-at-point
|
|
|
|
|
;; Was let-bound when file loaded, so ...
|
|
|
|
|
(setq woman-use-topic-at-point woman-use-topic-at-point-default))
|
|
|
|
|
(setq topic (or (current-word t) "")) ; only within or adjacent to word
|
|
|
|
|
(test-completion topic woman-topic-all-completions))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq topic
|
2005-09-10 14:59:07 +00:00
|
|
|
|
(let* ((word-at-point (current-word))
|
|
|
|
|
(default
|
|
|
|
|
(when (and word-at-point
|
|
|
|
|
(test-completion
|
|
|
|
|
word-at-point woman-topic-all-completions))
|
|
|
|
|
word-at-point)))
|
|
|
|
|
(completing-read
|
|
|
|
|
(if default
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(format "Manual entry (default %s): " default)
|
2005-09-10 14:59:07 +00:00
|
|
|
|
"Manual entry: ")
|
|
|
|
|
woman-topic-all-completions nil 1
|
|
|
|
|
nil
|
|
|
|
|
'woman-topic-history
|
|
|
|
|
default))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Note that completing-read always returns a string.
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(unless (= (length topic) 0)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(cond
|
|
|
|
|
((setq files (woman-file-name-all-completions topic)))
|
|
|
|
|
;; Complete topic more carefully, i.e. use the completion
|
|
|
|
|
;; rather than the string entered by the user:
|
|
|
|
|
((setq files (all-completions topic woman-topic-all-completions))
|
|
|
|
|
(while (/= (length topic) (length (car files)))
|
|
|
|
|
(setq files (cdr files)))
|
|
|
|
|
(setq files (woman-file-name-all-completions (car files)))))
|
|
|
|
|
(cond
|
|
|
|
|
((null files) nil) ; no file found for topic.
|
|
|
|
|
((null (cdr files)) (car (car files))) ; only 1 file for topic.
|
|
|
|
|
(t
|
|
|
|
|
;; Multiple files for topic, so must select 1.
|
|
|
|
|
;; Unread the command event (TAB = ?\t = 9) that runs the command
|
|
|
|
|
;; `minibuffer-complete' in order to automatically complete the
|
|
|
|
|
;; minibuffer contents as far as possible.
|
2005-09-09 12:30:03 +00:00
|
|
|
|
(setq unread-command-events '(9)) ; and delete any type-ahead!
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(completing-read "Manual file: " files nil 1
|
2005-09-09 12:30:03 +00:00
|
|
|
|
(try-completion "" files) 'woman-file-history))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-select (predicate list)
|
|
|
|
|
"Select unique elements for which PREDICATE is true in LIST.
|
|
|
|
|
\(Note that this function changes the value of LIST.)"
|
|
|
|
|
;; Intended to be fast by avoiding recursion and list copying.
|
|
|
|
|
(while (and list
|
|
|
|
|
(or
|
|
|
|
|
(member (car list) (cdr list))
|
|
|
|
|
(not (funcall predicate (car list)))))
|
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
(if list
|
|
|
|
|
(let ((newlist list) cdr_list)
|
|
|
|
|
(while (setq cdr_list (cdr list))
|
|
|
|
|
(if (and
|
|
|
|
|
(not (member (car cdr_list) (cdr cdr_list)))
|
|
|
|
|
(funcall predicate (car cdr_list)))
|
|
|
|
|
(setq list cdr_list)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setcdr list (cdr cdr_list))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
newlist)))
|
|
|
|
|
|
|
|
|
|
(defun woman-file-readable-p (dir)
|
|
|
|
|
"Return t if DIR is readable, otherwise log a warning."
|
|
|
|
|
(or (file-readable-p dir)
|
|
|
|
|
(WoMan-warn "Ignoring unreadable `manpath' directory tree `%s'!" dir)))
|
|
|
|
|
|
|
|
|
|
(defun woman-directory-files (head dir)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Return a sorted list of files in directory HEAD matching regexp in DIR.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Value is a sorted list of the absolute pathnames of all the files in
|
|
|
|
|
directory HEAD, or the current directory if HEAD is nil, that match the
|
|
|
|
|
regexp that is the final component of DIR. Log a warning if list is empty."
|
|
|
|
|
(or (directory-files
|
|
|
|
|
(or head (directory-file-name default-directory)) ; was "."
|
|
|
|
|
t
|
|
|
|
|
(file-name-nondirectory dir))
|
|
|
|
|
(WoMan-warn "No directories match `woman-path' entry `%s'!" dir)))
|
|
|
|
|
|
|
|
|
|
(defun woman-file-accessible-directory-p (dir)
|
|
|
|
|
"Return t if DIR is accessible, otherwise log a warning."
|
|
|
|
|
(or (file-accessible-directory-p dir)
|
|
|
|
|
(WoMan-warn "Ignoring inaccessible `man-page' directory `%s'!" dir)))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun woman-expand-directory-path (path-dirs path-regexps)
|
|
|
|
|
"Expand the manual directories in PATH-DIRS and PATH-REGEXPS.
|
|
|
|
|
PATH-DIRS should be a list of general manual directories (like
|
|
|
|
|
`woman-manpath'), while PATH-REGEXPS should be a list of specific
|
|
|
|
|
manual directory regexps (like `woman-path').
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Ignore any paths that are unreadable or not directories."
|
|
|
|
|
;; Allow each path to be a single string or a list of strings:
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(if (not (listp path-dirs)) (setq path-dirs (list path-dirs)))
|
|
|
|
|
(if (not (listp path-regexps)) (setq path-regexps (list path-regexps)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(let (head dirs path)
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(dolist (dir path-dirs)
|
2007-03-31 15:22:14 +00:00
|
|
|
|
(when (consp dir)
|
|
|
|
|
(unless path
|
|
|
|
|
(setq path (split-string (getenv "PATH") path-separator t)))
|
|
|
|
|
(setq dir (and (member (car dir) path)
|
|
|
|
|
(cdr dir))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (and dir (woman-file-readable-p dir))
|
|
|
|
|
;; NB: `parse-colon-path' creates null elements for
|
|
|
|
|
;; redundant (semi-)colons and trailing `/'s!
|
|
|
|
|
;; If does not actually matter here if dir ends with `/'.
|
|
|
|
|
;; Need regexp "man" here to avoid "cat?", `.', `..', etc.
|
|
|
|
|
(setq dir (woman-canonicalize-dir dir)
|
|
|
|
|
dirs (nconc dirs (directory-files
|
|
|
|
|
dir t woman-manpath-man-regexp)))))
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(dolist (dir path-regexps)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (or (null dir)
|
|
|
|
|
(null (setq dir (woman-canonicalize-dir dir)
|
|
|
|
|
head (file-name-directory dir)))
|
|
|
|
|
(woman-file-readable-p head))
|
|
|
|
|
(setq dirs
|
|
|
|
|
(if dir
|
|
|
|
|
(nconc dirs (woman-directory-files head dir))
|
|
|
|
|
(cons (directory-file-name default-directory) dirs))
|
|
|
|
|
;; was "." -- at head of list for later filtering
|
|
|
|
|
)))
|
|
|
|
|
(woman-select 'woman-file-accessible-directory-p dirs)))
|
|
|
|
|
|
|
|
|
|
(defun woman-canonicalize-dir (dir)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Canonicalize the directory name DIR.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Any UN*X-style environment variables are evaluated first."
|
|
|
|
|
(setq dir (expand-file-name (substitute-in-file-name dir)))
|
|
|
|
|
;; A path that ends with / matches all directories in it,
|
|
|
|
|
;; including `.' and `..', so remove any trailing / !!!
|
|
|
|
|
(if (string= (substring dir -1) "/")
|
|
|
|
|
(setq dir (substring dir 0 -1)))
|
2003-01-31 15:24:20 +00:00
|
|
|
|
(if (memq system-type '(windows-nt ms-dos cygwin)) ; what else?
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Match capitalization used by `file-name-directory':
|
|
|
|
|
(setq dir (concat (file-name-directory dir)
|
|
|
|
|
(file-name-nondirectory dir))))
|
|
|
|
|
dir)
|
|
|
|
|
|
|
|
|
|
(defsubst woman-not-member (dir path)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Return t if DIR is not a member of the list PATH, nil otherwise.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
If DIR is `.' it is first replaced by the current directory."
|
|
|
|
|
(not (member dir path)))
|
|
|
|
|
|
|
|
|
|
(defun woman-topic-all-completions (path)
|
|
|
|
|
"Return an alist of the man files in all man directories in the list PATH.
|
|
|
|
|
The cdr of each alist element is the path-index / filename."
|
|
|
|
|
;; Support 3 levels of caching: each element of the alist `files'
|
|
|
|
|
;; will be a list of the first `woman-cache-level' elements of the
|
|
|
|
|
;; following list: (topic path-index filename). This alist `files'
|
|
|
|
|
;; is re-processed by `woman-topic-all-completions-merge'.
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(let (dir files (path-index 0)) ; indexing starts at zero
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(while path
|
2004-06-03 19:53:53 +00:00
|
|
|
|
(setq dir (pop path))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (woman-not-member dir path) ; use each directory only once!
|
2004-06-03 19:53:53 +00:00
|
|
|
|
(push (woman-topic-all-completions-1 dir path-index)
|
|
|
|
|
files))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq path-index (1+ path-index)))
|
2011-11-14 20:23:26 +00:00
|
|
|
|
;; Uniquify topics:
|
2011-11-09 06:10:51 +00:00
|
|
|
|
;; Concatenate all lists with a single nconc call to
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;; avoid retraversing the first lists repeatedly -- dak
|
|
|
|
|
(woman-topic-all-completions-merge
|
|
|
|
|
(apply #'nconc files))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-topic-all-completions-1 (dir path-index)
|
2000-05-24 11:35:22 +00:00
|
|
|
|
"Return an alist of the man topics in directory DIR with index PATH-INDEX.
|
|
|
|
|
A topic is a filename sans type-related extensions.
|
|
|
|
|
Support 3 levels of caching: each element of the alist will be a list
|
|
|
|
|
of the first `woman-cache-level' elements from the following list:
|
|
|
|
|
\(topic path-index filename)."
|
|
|
|
|
;; This function used to check that each file in the directory was
|
|
|
|
|
;; not itself a directory, but this is very slow and should be
|
|
|
|
|
;; unnecessary. So let us assume that `woman-file-regexp' will
|
|
|
|
|
;; filter out any directories, which probably should not be there
|
|
|
|
|
;; anyway, i.e. it is a user error!
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Don't sort files: we do that when merging, anyway. -- dak
|
|
|
|
|
(let (newlst (lst (directory-files dir nil woman-file-regexp t))
|
|
|
|
|
;; Make an explicit regexp for stripping extension and
|
|
|
|
|
;; compression extension: file-name-sans-extension is a
|
|
|
|
|
;; far too costly function. -- dak
|
|
|
|
|
(ext (format "\\(\\.[^.\\/]*\\)?\\(%s\\)?\\'"
|
|
|
|
|
woman-file-compression-regexp)))
|
|
|
|
|
;; Use a loop instead of mapcar in order to avoid the speed
|
|
|
|
|
;; penalty of binding function arguments. -- dak
|
|
|
|
|
(dolist (file lst newlst)
|
|
|
|
|
(push
|
|
|
|
|
(cons
|
|
|
|
|
(if (string-match ext file)
|
|
|
|
|
(substring file 0 (match-beginning 0))
|
|
|
|
|
file)
|
|
|
|
|
(and (> woman-cache-level 1)
|
|
|
|
|
(cons
|
|
|
|
|
path-index
|
|
|
|
|
(and (> woman-cache-level 2)
|
|
|
|
|
(list file)))))
|
|
|
|
|
newlst))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-topic-all-completions-merge (alist)
|
|
|
|
|
"Merge the alist ALIST so that the keys are unique.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Also make each path-info component into a list.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
\(Note that this function changes the value of ALIST.)"
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;; Replaces unreadably "optimized" O(n^2) implementation.
|
|
|
|
|
;; Instead we use sorting to merge stuff efficiently. -- dak
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(let (newalist)
|
2004-06-03 19:53:53 +00:00
|
|
|
|
;; Sort list into reverse order
|
|
|
|
|
(setq alist (sort alist (lambda(x y) (string< (car y) (car x)))))
|
|
|
|
|
;; merge duplicate keys.
|
|
|
|
|
(if (> woman-cache-level 1)
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(dolist (elt alist)
|
2004-06-03 19:53:53 +00:00
|
|
|
|
(if (equal (car elt) (caar newalist))
|
|
|
|
|
(unless (member (cdr elt) (cdar newalist))
|
|
|
|
|
(setcdr (car newalist) (cons (cdr elt)
|
|
|
|
|
(cdar newalist))))
|
|
|
|
|
(setcdr elt (list (cdr elt)))
|
|
|
|
|
(push elt newalist)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
;; woman-cache-level = 1 => elements are single-element lists ...
|
|
|
|
|
(dolist (elt alist)
|
2004-06-03 19:53:53 +00:00
|
|
|
|
(unless (equal (car elt) (caar newalist))
|
|
|
|
|
(push elt newalist))))
|
|
|
|
|
newalist))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-file-name-all-completions (topic)
|
|
|
|
|
"Return an alist of the files in all man directories that match TOPIC."
|
|
|
|
|
;; Support 3 levels of caching: each element of
|
|
|
|
|
;; woman-topic-all-completions is a list of one of the forms:
|
|
|
|
|
;; (topic)
|
|
|
|
|
;; (topic (path-index) (path-index) ... )
|
|
|
|
|
;; (topic (path-index filename) (path-index filename) ... )
|
2010-10-22 23:38:34 +00:00
|
|
|
|
;; where there are no duplicates in the value lists.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Topic must match first `word' of filename, so ...
|
|
|
|
|
(let ((topic-regexp
|
|
|
|
|
(concat
|
|
|
|
|
"\\`" (regexp-quote topic) ; first `word'
|
|
|
|
|
"\\(\\..+\\)*" ; optional subsequent `words'
|
|
|
|
|
woman-file-regexp)) ; extension
|
|
|
|
|
(topics woman-topic-all-completions)
|
|
|
|
|
(path woman-expanded-directory-path)
|
|
|
|
|
dir files)
|
|
|
|
|
(if (cdr (car topics))
|
|
|
|
|
;; Use cached path-info to locate files for each topic:
|
|
|
|
|
(let ((path-info (cdr (assoc topic topics)))
|
|
|
|
|
filename)
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(dolist (elt path-info)
|
|
|
|
|
(setq dir (nth (car elt) path)
|
|
|
|
|
filename (car (cdr elt))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
files (nconc files
|
|
|
|
|
;; Find the actual file name:
|
|
|
|
|
(if filename
|
|
|
|
|
(list (concat dir "/" filename))
|
|
|
|
|
(directory-files dir t topic-regexp)
|
|
|
|
|
)))))
|
|
|
|
|
;; Search path for the files for each topic:
|
|
|
|
|
(while path
|
|
|
|
|
(setq dir (car path)
|
|
|
|
|
path (cdr path))
|
|
|
|
|
(if (woman-not-member dir path) ; use each directory only once!
|
|
|
|
|
(setq files (nconc files
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(directory-files dir t topic-regexp))))))
|
|
|
|
|
(mapcar 'list files)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-05-24 11:35:22 +00:00
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;;; dired support
|
|
|
|
|
|
|
|
|
|
(defun woman-dired-define-key (key)
|
|
|
|
|
"Bind the argument KEY to the command `woman-dired-find-file'."
|
|
|
|
|
(define-key dired-mode-map key 'woman-dired-find-file))
|
|
|
|
|
|
|
|
|
|
(defsubst woman-dired-define-key-maybe (key)
|
|
|
|
|
"If KEY is undefined in Dired, bind it to command `woman-dired-find-file'."
|
2005-01-15 12:46:54 +00:00
|
|
|
|
(if (or (eq (lookup-key dired-mode-map key) 'undefined)
|
|
|
|
|
(null (lookup-key dired-mode-map key)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-dired-define-key key)))
|
|
|
|
|
|
|
|
|
|
(defun woman-dired-define-keys ()
|
|
|
|
|
"Define dired keys to run WoMan according to `woman-dired-keys'."
|
|
|
|
|
(if woman-dired-keys
|
|
|
|
|
(if (listp woman-dired-keys)
|
2007-09-25 11:17:39 +00:00
|
|
|
|
(mapc 'woman-dired-define-key woman-dired-keys)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-dired-define-key-maybe "w")
|
|
|
|
|
(woman-dired-define-key-maybe "W")))
|
|
|
|
|
(define-key-after (lookup-key dired-mode-map [menu-bar immediate])
|
|
|
|
|
[woman] '("Read Man Page (WoMan)" . woman-dired-find-file) 'view))
|
|
|
|
|
|
|
|
|
|
(if (featurep 'dired)
|
|
|
|
|
(woman-dired-define-keys)
|
|
|
|
|
(add-hook 'dired-mode-hook 'woman-dired-define-keys))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun woman-dired-find-file ()
|
|
|
|
|
"In dired, run the WoMan man-page browser on this file."
|
|
|
|
|
(interactive)
|
|
|
|
|
;; dired-get-filename is defined in dired.el
|
|
|
|
|
(woman-find-file (dired-get-filename)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; tar-mode support
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defvar global-font-lock-mode) ; defined in font-core.el
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-tar-extract-file ()
|
|
|
|
|
"In tar mode, run the WoMan man-page browser on this file."
|
|
|
|
|
(interactive)
|
|
|
|
|
(or (eq major-mode 'tar-mode)
|
|
|
|
|
(error "`woman-tar-extract-file' can be used only in `tar-mode'"))
|
|
|
|
|
(buffer-disable-undo)
|
|
|
|
|
(let (global-font-lock-mode)
|
|
|
|
|
(funcall (symbol-function 'tar-extract)) ; defined in tar-mode
|
|
|
|
|
(let ((WoMan-current-file buffer-file-name)) ; used for message logging
|
|
|
|
|
(rename-buffer
|
|
|
|
|
(woman-make-bufname (file-name-nondirectory buffer-file-name)))
|
|
|
|
|
(woman-process-buffer)
|
|
|
|
|
(goto-char (point-min)))))
|
|
|
|
|
|
|
|
|
|
(defvar woman-last-file-name nil
|
|
|
|
|
"The full pathname of the last file formatted by WoMan.")
|
|
|
|
|
|
|
|
|
|
(defun woman-reformat-last-file ()
|
|
|
|
|
"Reformat last file, e.g. after changing fill column."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if woman-last-file-name
|
|
|
|
|
(woman-find-file woman-last-file-name t)
|
|
|
|
|
(call-interactively 'woman-find-file)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun woman-find-file (file-name &optional reformat)
|
|
|
|
|
"Find, decode and browse a specific UN*X man-page source file FILE-NAME.
|
|
|
|
|
Use existing buffer if possible; reformat only if prefix arg given.
|
|
|
|
|
When called interactively, optional argument REFORMAT forces reformatting
|
2000-05-22 07:01:17 +00:00
|
|
|
|
of an existing WoMan buffer formatted earlier.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
No external programs are used, except that `gunzip' will be used to
|
|
|
|
|
decompress the file if appropriate. See the documentation for the
|
|
|
|
|
`woman' command for further details."
|
|
|
|
|
(interactive "fBrowse UN*X manual file: \nP")
|
|
|
|
|
(setq woman-last-file-name
|
|
|
|
|
(setq file-name (expand-file-name file-name))) ; to canonicalize
|
|
|
|
|
(let ((alist-tail woman-buffer-alist) exists)
|
|
|
|
|
(setq woman-buffer-number 0)
|
|
|
|
|
(while (and alist-tail (not (string= file-name (car (car alist-tail)))))
|
|
|
|
|
(setq alist-tail (cdr alist-tail)
|
|
|
|
|
woman-buffer-number (1+ woman-buffer-number)))
|
|
|
|
|
(or (and (setq exists
|
|
|
|
|
(and alist-tail (WoMan-find-buffer))) ; buffer exists
|
|
|
|
|
(not reformat))
|
|
|
|
|
;; Format new buffer or reformat current buffer:
|
|
|
|
|
(let* ((bufname (file-name-nondirectory file-name))
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
(compressed
|
|
|
|
|
(not (not (string-match woman-file-compression-regexp bufname)))))
|
|
|
|
|
(if compressed
|
|
|
|
|
(setq bufname (file-name-sans-extension bufname)))
|
|
|
|
|
(setq bufname (if exists
|
|
|
|
|
(buffer-name)
|
|
|
|
|
(woman-make-bufname bufname)))
|
|
|
|
|
(woman-really-find-file file-name compressed bufname)
|
|
|
|
|
(or exists
|
|
|
|
|
(setq woman-buffer-alist
|
|
|
|
|
(cons (cons file-name bufname) woman-buffer-alist)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
woman-buffer-number 0)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(Man-build-section-alist)
|
|
|
|
|
(Man-build-references-alist)
|
|
|
|
|
(goto-char (point-min)))
|
|
|
|
|
|
|
|
|
|
(defun woman-make-bufname (bufname)
|
|
|
|
|
"Create an unambiguous buffer name from BUFNAME."
|
2009-12-02 03:02:10 +00:00
|
|
|
|
;; See Bug#5038. Any compression extension has already been removed.
|
|
|
|
|
;; Go from eg "host.conf.5" to "5 host.conf".
|
2009-12-02 03:01:44 +00:00
|
|
|
|
(let ((dot (string-match "\\.[^.]*\\'" bufname)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if dot (setq bufname (concat
|
|
|
|
|
(substring bufname (1+ dot)) " "
|
|
|
|
|
(substring bufname 0 dot))))
|
|
|
|
|
(generate-new-buffer-name ; ensure uniqueness
|
|
|
|
|
(concat "*WoMan " bufname "*"))))
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defvar woman-frame nil
|
|
|
|
|
"Dedicated frame used for displaying WoMan windows.")
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-really-find-file (filename compressed bufname)
|
|
|
|
|
"Find, decompress, and decode a UN*X man page FILENAME.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
If COMPRESSED is non-nil, turn on auto-compression mode to decompress
|
|
|
|
|
the file if necessary. Set buffer name BUFNAME and major mode.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Do not call directly!"
|
|
|
|
|
(let ((WoMan-current-file filename)) ; used for message logging
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(if woman-use-own-frame
|
|
|
|
|
(select-frame
|
|
|
|
|
(or (and (frame-live-p woman-frame) woman-frame)
|
|
|
|
|
(setq woman-frame (make-frame)))))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(set-buffer (get-buffer-create bufname))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(switch-to-buffer (current-buffer))
|
|
|
|
|
(error (pop-to-buffer (current-buffer))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(buffer-disable-undo)
|
|
|
|
|
(setq buffer-read-only nil)
|
|
|
|
|
(erase-buffer) ; NEEDED for reformat
|
|
|
|
|
(woman-insert-file-contents filename compressed)
|
|
|
|
|
;; Set buffer's default directory to that of the file.
|
|
|
|
|
(setq default-directory (file-name-directory filename))
|
|
|
|
|
(set (make-local-variable 'backup-inhibited) t)
|
|
|
|
|
(set-visited-file-name "")
|
|
|
|
|
(woman-process-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun woman-process-buffer ()
|
|
|
|
|
"The second half of `woman-really-find-file'!"
|
|
|
|
|
(interactive)
|
|
|
|
|
;; Check (crudely) that this really is likely to be in UN*X
|
|
|
|
|
;; man-page source format, assuming we are at point-min:
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(if (re-search-forward "^[.']" 1000 t)
|
|
|
|
|
(woman-decode-buffer)
|
|
|
|
|
(message
|
|
|
|
|
"File appears to be pre-formatted -- using source file may be better.")
|
|
|
|
|
(woman-man-buffer))
|
|
|
|
|
(woman-mode))
|
|
|
|
|
|
|
|
|
|
(defun woman-man-buffer ()
|
|
|
|
|
"Post-process an nroff-preformatted man buffer."
|
|
|
|
|
;; Kill all leading whitespace:
|
|
|
|
|
(if (looking-at "\\s-+") (woman-delete-match 0))
|
|
|
|
|
;; Delete all page footer/header pairs:
|
|
|
|
|
(re-search-forward ".*") ; match header
|
|
|
|
|
;; Footer conventionally has page number at right, so ...
|
|
|
|
|
(let ((regex (concat
|
|
|
|
|
"^.*[0-9]\n\\s-*" ; footer and following blank lines
|
|
|
|
|
(regexp-quote (match-string 0)) ; header
|
|
|
|
|
"\\s-*\n"))) ; following blank lines
|
|
|
|
|
(while (re-search-forward regex nil 1) ; finish at eob
|
|
|
|
|
(woman-delete-match 0)))
|
|
|
|
|
;; Delete last text line (footer) and all following blank lines:
|
|
|
|
|
(re-search-backward "\\S-")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if (looking-at ".*[0-9]$")
|
|
|
|
|
(delete-region (point) (point-max)))
|
|
|
|
|
|
|
|
|
|
;; Squeeze multiple blank lines:
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward "^[ \t]*\n\\([ \t]*\n\\)+" nil t)
|
|
|
|
|
(replace-match "\n" t t))
|
|
|
|
|
|
2000-06-15 12:31:55 +00:00
|
|
|
|
;; CJK characters are underlined by double-sized "__".
|
|
|
|
|
;; (Code lifted from man.el, with trivial changes.)
|
|
|
|
|
(if (< (buffer-size) (position-bytes (point-max)))
|
|
|
|
|
;; Multibyte characters exist.
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward "__\b\b" nil t)
|
|
|
|
|
(backward-delete-char 4)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(woman-set-face (point) (1+ (point)) 'woman-italic))
|
2000-06-15 12:31:55 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward "\b\b__" nil t)
|
|
|
|
|
(backward-delete-char 4)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(woman-set-face (1- (point)) (point) 'woman-italic))))
|
2000-06-15 12:31:55 +00:00
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Interpret overprinting to indicate bold face:
|
|
|
|
|
(goto-char (point-min))
|
2000-06-15 12:31:55 +00:00
|
|
|
|
(while (re-search-forward "\\(.\\)\\(\\(+\\1\\)+\\)" nil t)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-delete-match 2)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(woman-set-face (1- (point)) (point) 'woman-bold))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Interpret underlining to indicate italic face:
|
|
|
|
|
;; (Must be AFTER emboldening to interpret bold _ correctly!)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward "_" nil t)
|
|
|
|
|
(delete-char -2)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(woman-set-face (point) (1+ (point)) 'woman-italic))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Leave any other uninterpreted ^H's in the buffer for now! (They
|
|
|
|
|
;; might indicate composite special characters, which could be
|
|
|
|
|
;; interpreted if I knew what to expect.)
|
|
|
|
|
|
|
|
|
|
;; Optionally embolden section and subsection headings
|
|
|
|
|
;; (cf. `woman-imenu-generic-expression'):
|
|
|
|
|
(cond
|
|
|
|
|
(woman-bold-headings
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(while (re-search-forward "^\\( \\)?\\([A-Z].*\\)" nil t)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-set-face (match-beginning 2) (match-end 2) 'woman-bold)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-insert-file-contents (filename compressed)
|
|
|
|
|
"Insert file FILENAME into the current buffer.
|
|
|
|
|
If COMPRESSED is t, or is non-nil and the filename implies compression,
|
2000-05-22 07:01:17 +00:00
|
|
|
|
then turn on auto-compression mode to decompress the file.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Leave point at end of new text. Return length of inserted text."
|
|
|
|
|
;; Leaves point at end of inserted text in GNU Emacs 20.3, but at
|
|
|
|
|
;; start in 19.34!
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
;; Co-operate with auto-compression mode:
|
|
|
|
|
(if (and compressed
|
|
|
|
|
(or (eq compressed t)
|
|
|
|
|
(string-match woman-file-compression-regexp filename))
|
|
|
|
|
;; (not auto-compression-mode)
|
|
|
|
|
(not (rassq 'jka-compr-handler file-name-handler-alist)) )
|
|
|
|
|
;; (error "Compressed file requires Auto File Decompression turned on")
|
|
|
|
|
(auto-compression-mode 1))
|
|
|
|
|
(nth 1
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(insert-file-contents filename nil)
|
|
|
|
|
(file-error
|
|
|
|
|
;; Run find-file-not-found-hooks until one returns non-nil.
|
|
|
|
|
;; (run-hook-with-args-until-success 'find-file-not-found-hooks)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(insert "\n***** File " filename " not found! *****\n\n")))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Major mode (Man) interface:
|
|
|
|
|
|
2007-09-10 03:22:12 +00:00
|
|
|
|
(defvar woman-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map Man-mode-map)
|
|
|
|
|
|
|
|
|
|
(define-key map "R" 'woman-reformat-last-file)
|
|
|
|
|
(define-key map "w" 'woman)
|
|
|
|
|
(define-key map "\en" 'WoMan-next-manpage)
|
|
|
|
|
(define-key map "\ep" 'WoMan-previous-manpage)
|
|
|
|
|
(define-key map [M-mouse-2] 'woman-follow-word)
|
|
|
|
|
|
|
|
|
|
;; We don't need to call `man' when we are in `woman-mode'.
|
|
|
|
|
(define-key map [remap man] 'woman)
|
|
|
|
|
(define-key map [remap man-follow] 'woman-follow)
|
|
|
|
|
map)
|
|
|
|
|
"Keymap for woman mode.")
|
2006-08-28 15:40:21 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-follow (topic)
|
|
|
|
|
"Get a Un*x manual page of the item under point and put it in a buffer."
|
|
|
|
|
(interactive (list (Man-default-man-entry)))
|
|
|
|
|
(if (or (not topic)
|
|
|
|
|
(string= topic ""))
|
|
|
|
|
(error "No item under point")
|
|
|
|
|
(woman (if (string-match Man-reference-regexp topic)
|
|
|
|
|
(substring topic 0 (match-end 1))
|
|
|
|
|
topic))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2001-10-07 12:41:03 +00:00
|
|
|
|
(defun woman-follow-word (event)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
"Run WoMan with word under mouse as topic.
|
|
|
|
|
Argument EVENT is the invoking mouse event."
|
|
|
|
|
(interactive "e") ; mouse event
|
2001-10-07 12:41:03 +00:00
|
|
|
|
(goto-char (posn-point (event-start event)))
|
2003-09-22 15:15:26 +00:00
|
|
|
|
(woman (or (current-word t) "")))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; WoMan menu bar and pop-up menu:
|
2002-05-13 15:41:00 +00:00
|
|
|
|
(easy-menu-define
|
|
|
|
|
woman-menu ; (SYMBOL MAPS DOC MENU)
|
|
|
|
|
;; That comment was moved after the symbol `woman-menu' to make
|
|
|
|
|
;; find-function-search-for-symbol work. -- rost
|
2000-05-08 14:32:17 +00:00
|
|
|
|
woman-mode-map
|
|
|
|
|
"WoMan Menu"
|
|
|
|
|
`("WoMan"
|
|
|
|
|
["WoMan..." woman t] ; [NAME CALLBACK ENABLE]
|
|
|
|
|
"--"
|
|
|
|
|
["Next Section" Man-next-section t]
|
|
|
|
|
["Previous Section" Man-previous-section t]
|
|
|
|
|
["Goto Section..." Man-goto-section t]
|
|
|
|
|
["Goto See-Also Section" Man-goto-see-also-section t]
|
|
|
|
|
["Follow Reference..." Man-follow-manual-reference t]
|
|
|
|
|
"--"
|
|
|
|
|
["Previous WoMan Buffer" WoMan-previous-manpage t]
|
|
|
|
|
["Next WoMan Buffer" WoMan-next-manpage t]
|
|
|
|
|
["Bury WoMan Buffer" Man-quit t]
|
|
|
|
|
["Kill WoMan Buffer" Man-kill t]
|
|
|
|
|
"--"
|
|
|
|
|
;; ["Toggle Fill Frame Width" woman-toggle-fill-frame t]
|
|
|
|
|
["Use Full Frame Width" woman-toggle-fill-frame
|
|
|
|
|
:active t :style toggle :selected woman-fill-frame]
|
2000-05-22 07:01:17 +00:00
|
|
|
|
["Reformat Last Man Page" woman-reformat-last-file t]
|
2000-10-23 05:37:24 +00:00
|
|
|
|
["Use Monochrome Main Faces" woman-monochrome-faces t]
|
|
|
|
|
["Use Default Main Faces" woman-default-faces t]
|
2000-05-08 14:32:17 +00:00
|
|
|
|
["Make Contents Menu" (woman-imenu t) (not woman-imenu-done)]
|
|
|
|
|
"--"
|
|
|
|
|
["Describe (Wo)Man Mode" describe-mode t]
|
|
|
|
|
["Mini Help" woman-mini-help t]
|
|
|
|
|
,@(if (fboundp 'customize-group)
|
|
|
|
|
'(["Customize..." (customize-group 'woman) t]))
|
|
|
|
|
["Show Version" (message "WoMan %s" woman-version) t]
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"--"
|
|
|
|
|
("Advanced"
|
|
|
|
|
["View Source" (view-file woman-last-file-name) woman-last-file-name]
|
|
|
|
|
["Show Log" (switch-to-buffer-other-window "*WoMan-Log*" t) t]
|
|
|
|
|
["Extended Font" woman-toggle-use-extended-font
|
|
|
|
|
:included woman-font-support
|
|
|
|
|
:active t :style toggle :selected woman-use-extended-font]
|
|
|
|
|
["Symbol Font" woman-toggle-use-symbol-font
|
|
|
|
|
:included woman-font-support
|
|
|
|
|
:active t :style toggle :selected woman-use-symbol-font]
|
|
|
|
|
["Font Map" woman-display-extended-fonts
|
|
|
|
|
:included woman-font-support
|
|
|
|
|
:active woman-use-symbol-font]
|
|
|
|
|
"--"
|
|
|
|
|
"Emulation"
|
|
|
|
|
["nroff" (woman-reset-emulation 'nroff)
|
|
|
|
|
:active t :style radio :selected (eq woman-emulation 'nroff)]
|
|
|
|
|
["troff" (woman-reset-emulation 'troff)
|
|
|
|
|
:active t :style radio :selected (eq woman-emulation 'troff)]
|
|
|
|
|
)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
))
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defun woman-toggle-use-extended-font ()
|
|
|
|
|
"Toggle `woman-use-extended-font' and reformat, for menu use."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq woman-use-extended-font (not woman-use-extended-font))
|
|
|
|
|
(woman-reformat-last-file))
|
|
|
|
|
|
|
|
|
|
(defun woman-toggle-use-symbol-font ()
|
|
|
|
|
"Toggle `woman-use-symbol-font' and reformat, for menu use."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq woman-use-symbol-font (not woman-use-symbol-font))
|
|
|
|
|
(woman-reformat-last-file))
|
|
|
|
|
|
|
|
|
|
(defun woman-reset-emulation (value)
|
|
|
|
|
"Reset `woman-emulation' to VALUE and reformat, for menu use."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq woman-emulation value)
|
|
|
|
|
(woman-reformat-last-file))
|
|
|
|
|
|
2010-04-12 16:09:47 +00:00
|
|
|
|
(defvar bookmark-make-record-function)
|
2005-06-13 08:22:34 +00:00
|
|
|
|
(put 'woman-mode 'mode-class 'special)
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-mode ()
|
|
|
|
|
"Turn on (most of) Man mode to browse a buffer formatted by WoMan.
|
|
|
|
|
WoMan is an ELisp emulation of much of the functionality of the Emacs
|
|
|
|
|
`man' command running the standard UN*X man and ?roff programs.
|
|
|
|
|
WoMan author: F.J.Wright@Maths.QMW.ac.uk
|
|
|
|
|
WoMan version: see `woman-version'.
|
|
|
|
|
See `Man-mode' for additional details."
|
|
|
|
|
(let ((Man-build-page-list (symbol-function 'Man-build-page-list))
|
|
|
|
|
(Man-strip-page-headers (symbol-function 'Man-strip-page-headers))
|
|
|
|
|
(Man-unindent (symbol-function 'Man-unindent))
|
|
|
|
|
(Man-goto-page (symbol-function 'Man-goto-page)))
|
|
|
|
|
;; Prevent inappropriate operations:
|
|
|
|
|
(fset 'Man-build-page-list 'ignore)
|
|
|
|
|
(fset 'Man-strip-page-headers 'ignore)
|
|
|
|
|
(fset 'Man-unindent 'ignore)
|
|
|
|
|
(fset 'Man-goto-page 'ignore)
|
|
|
|
|
(unwind-protect
|
2005-06-13 08:22:34 +00:00
|
|
|
|
(delay-mode-hooks (Man-mode))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Restore the status quo:
|
|
|
|
|
(fset 'Man-build-page-list Man-build-page-list)
|
|
|
|
|
(fset 'Man-strip-page-headers Man-strip-page-headers)
|
|
|
|
|
(fset 'Man-unindent Man-unindent)
|
2009-03-07 15:30:05 +00:00
|
|
|
|
(fset 'Man-goto-page Man-goto-page)
|
|
|
|
|
(setq tab-width woman-tab-width)))
|
2005-06-13 08:22:34 +00:00
|
|
|
|
(setq major-mode 'woman-mode
|
|
|
|
|
mode-name "WoMan")
|
|
|
|
|
;; Don't show page numbers like Man-mode does. (Online documents do
|
|
|
|
|
;; not have pages)
|
|
|
|
|
(kill-local-variable 'mode-line-buffer-identification)
|
|
|
|
|
(use-local-map woman-mode-map)
|
|
|
|
|
;; Imenu support:
|
|
|
|
|
(set (make-local-variable 'imenu-generic-expression)
|
|
|
|
|
;; `make-local-variable' in case imenu not yet loaded!
|
|
|
|
|
woman-imenu-generic-expression)
|
|
|
|
|
(set (make-local-variable 'imenu-space-replacement) " ")
|
2010-04-12 15:17:29 +00:00
|
|
|
|
;; Bookmark support.
|
|
|
|
|
(set (make-local-variable 'bookmark-make-record-function)
|
|
|
|
|
'woman-bookmark-make-record)
|
2005-06-13 08:22:34 +00:00
|
|
|
|
;; For reformat ...
|
|
|
|
|
;; necessary when reformatting a file in its old buffer:
|
|
|
|
|
(setq imenu--last-menubar-index-alist nil)
|
|
|
|
|
;; necessary to avoid re-installing the same imenu:
|
|
|
|
|
(setq woman-imenu-done nil)
|
|
|
|
|
(if woman-imenu (woman-imenu))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
2005-10-18 04:21:51 +00:00
|
|
|
|
(Man-highlight-references 'WoMan-xref-man-page))
|
2005-06-13 08:22:34 +00:00
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(run-mode-hooks 'woman-mode-hook))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-imenu (&optional redraw)
|
|
|
|
|
"Add a \"Contents\" menu to the menubar.
|
|
|
|
|
Optional argument REDRAW, if non-nil, forces mode line to be updated."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if woman-imenu-done
|
|
|
|
|
;; This is PRIMARILY to avoid a bug in imenu-add-to-menubar that
|
|
|
|
|
;; causes it to corrupt the menu bar if it is run more than once
|
|
|
|
|
;; in the same buffer.
|
|
|
|
|
()
|
|
|
|
|
(setq woman-imenu-done t)
|
|
|
|
|
(imenu-add-to-menubar woman-imenu-title)
|
|
|
|
|
(if redraw (force-mode-line-update))))
|
|
|
|
|
|
|
|
|
|
(defun woman-toggle-fill-frame ()
|
|
|
|
|
"Toggle formatting to fill (most of) the width of the current frame."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq woman-fill-frame (not woman-fill-frame))
|
|
|
|
|
(message "Woman fill column set to %s."
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(if woman-fill-frame "frame width" woman-fill-column)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-mini-help ()
|
|
|
|
|
"Display WoMan commands and user options in an `apropos' buffer."
|
|
|
|
|
;; Based on apropos-command in apropos.el
|
|
|
|
|
(interactive)
|
|
|
|
|
(require 'apropos)
|
|
|
|
|
(let ((message
|
|
|
|
|
(let ((standard-output (get-buffer-create "*Apropos*")))
|
2009-08-21 07:24:26 +00:00
|
|
|
|
(help-print-return-message 'identity))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq apropos-accumulator
|
|
|
|
|
(apropos-internal "woman"
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(lambda (symbol)
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(and
|
|
|
|
|
(or (commandp symbol)
|
2012-04-09 12:36:01 +00:00
|
|
|
|
(custom-variable-p symbol))
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(not (get symbol 'apropos-inhibit))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Find documentation strings:
|
|
|
|
|
(let ((p apropos-accumulator)
|
|
|
|
|
doc symbol)
|
|
|
|
|
(while p
|
|
|
|
|
(setcar p (list ; must have 3 elements:
|
|
|
|
|
(setq symbol (car p)) ; 1. name
|
|
|
|
|
(if (functionp symbol) ; 2. command doc
|
|
|
|
|
(if (setq doc (documentation symbol t))
|
|
|
|
|
(substring doc 0 (string-match "\n" doc))
|
|
|
|
|
"(not documented)"))
|
2012-04-09 12:36:01 +00:00
|
|
|
|
(if (custom-variable-p symbol) ; 3. variable doc
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (setq doc (documentation-property
|
|
|
|
|
symbol 'variable-documentation t))
|
|
|
|
|
(substring doc 0 (string-match "\n" doc))))))
|
|
|
|
|
(setq p (cdr p))))
|
|
|
|
|
;; Output the result:
|
|
|
|
|
(and (apropos-print t nil)
|
|
|
|
|
message
|
2005-09-18 12:25:02 +00:00
|
|
|
|
(message "%s" message))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun WoMan-getpage-in-background (topic)
|
|
|
|
|
"Use TOPIC to start WoMan from `Man-follow-manual-reference'."
|
|
|
|
|
;; topic is a string, generally of the form "section topic"
|
|
|
|
|
(let ((s (string-match " " topic)))
|
|
|
|
|
(if s (setq topic (substring topic (1+ s))))
|
|
|
|
|
(woman topic)))
|
|
|
|
|
|
|
|
|
|
(defvar WoMan-Man-start-time nil
|
|
|
|
|
"Used to record formatting time used by the `man' command.")
|
|
|
|
|
|
2005-09-07 21:23:36 +00:00
|
|
|
|
;; Both advices are disabled because "a file in Emacs should not put
|
|
|
|
|
;; advice on a function in Emacs" (see Info node "(elisp)Advising
|
|
|
|
|
;; Functions"). Counting the formatting time is useful for
|
2011-11-17 09:09:20 +00:00
|
|
|
|
;; developing, but less applicable for daily use. The advice for
|
2005-09-07 21:23:36 +00:00
|
|
|
|
;; `Man-getpage-in-background' can be discarded, because the
|
|
|
|
|
;; key-binding in `woman-mode-map' has been remapped to call `woman'
|
|
|
|
|
;; but `man'. Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
|
|
|
|
|
|
;; (defadvice Man-getpage-in-background
|
|
|
|
|
;; (around Man-getpage-in-background-advice (topic) activate)
|
|
|
|
|
;; "Use WoMan unless invoked outside a WoMan buffer or invoked explicitly.
|
|
|
|
|
;; Otherwise use Man and record start of formatting time."
|
|
|
|
|
;; (if (and (eq major-mode 'woman-mode)
|
|
|
|
|
;; (not (eq (caar command-history) 'man)))
|
|
|
|
|
;; (WoMan-getpage-in-background topic)
|
|
|
|
|
;; ;; Initiates man processing
|
|
|
|
|
;; (setq WoMan-Man-start-time (current-time))
|
|
|
|
|
;; ad-do-it))
|
|
|
|
|
|
|
|
|
|
;; (defadvice Man-bgproc-sentinel
|
|
|
|
|
;; (after Man-bgproc-sentinel-advice activate)
|
|
|
|
|
;; ;; Terminates man processing
|
|
|
|
|
;; "Report formatting time."
|
|
|
|
|
;; (let* ((time (current-time))
|
|
|
|
|
;; (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536)
|
|
|
|
|
;; (- (cadr time) (cadr WoMan-Man-start-time)))))
|
|
|
|
|
;; (message "Man formatting done in %d seconds" time)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Buffer handling:
|
|
|
|
|
|
|
|
|
|
(defun WoMan-previous-manpage ()
|
|
|
|
|
"Find the previous WoMan buffer."
|
|
|
|
|
;; Assumes currently in a WoMan buffer!
|
|
|
|
|
(interactive)
|
|
|
|
|
(WoMan-find-buffer) ; find current existing buffer
|
|
|
|
|
(if (null (cdr woman-buffer-alist))
|
|
|
|
|
(error "No previous WoMan buffer"))
|
|
|
|
|
(if (>= (setq woman-buffer-number (1+ woman-buffer-number))
|
|
|
|
|
(length woman-buffer-alist))
|
|
|
|
|
(setq woman-buffer-number 0))
|
|
|
|
|
(if (WoMan-find-buffer)
|
|
|
|
|
()
|
|
|
|
|
(if (< (setq woman-buffer-number (1- woman-buffer-number)) 0)
|
|
|
|
|
(setq woman-buffer-number (1- (length woman-buffer-alist))))
|
|
|
|
|
(WoMan-previous-manpage)))
|
|
|
|
|
|
|
|
|
|
(defun WoMan-next-manpage ()
|
|
|
|
|
"Find the next WoMan buffer."
|
|
|
|
|
;; Assumes currently in a WoMan buffer!
|
|
|
|
|
(interactive)
|
|
|
|
|
(WoMan-find-buffer) ; find current existing buffer
|
|
|
|
|
(if (null (cdr woman-buffer-alist))
|
|
|
|
|
(error "No next WoMan buffer"))
|
|
|
|
|
(if (< (setq woman-buffer-number (1- woman-buffer-number)) 0)
|
|
|
|
|
(setq woman-buffer-number (1- (length woman-buffer-alist))))
|
|
|
|
|
(if (WoMan-find-buffer)
|
|
|
|
|
()
|
|
|
|
|
(WoMan-next-manpage)))
|
|
|
|
|
|
|
|
|
|
(defun WoMan-find-buffer ()
|
|
|
|
|
"Switch to buffer corresponding to `woman-buffer-number' and return it.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
If such a buffer does not exist then remove its association from the
|
|
|
|
|
alist in `woman-buffer-alist' and return nil."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (zerop woman-buffer-number)
|
|
|
|
|
(let ((buffer (get-buffer (cdr (car woman-buffer-alist)))))
|
|
|
|
|
(if buffer
|
|
|
|
|
(switch-to-buffer buffer)
|
|
|
|
|
;; Delete alist element:
|
|
|
|
|
(setq woman-buffer-alist (cdr woman-buffer-alist))
|
|
|
|
|
nil))
|
|
|
|
|
(let* ((prev-ptr (nthcdr (1- woman-buffer-number) woman-buffer-alist))
|
|
|
|
|
(buffer (get-buffer (cdr (car (cdr prev-ptr))))))
|
|
|
|
|
(if buffer
|
|
|
|
|
(switch-to-buffer buffer)
|
|
|
|
|
;; Delete alist element:
|
|
|
|
|
(setcdr prev-ptr (cdr (cdr prev-ptr)))
|
|
|
|
|
(if (>= woman-buffer-number (length woman-buffer-alist))
|
|
|
|
|
(setq woman-buffer-number 0))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
nil))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Syntax and display tables:
|
|
|
|
|
|
|
|
|
|
(defconst woman-escaped-escape-char ?
|
|
|
|
|
;; An arbitrary unused control character
|
|
|
|
|
"Internal character representation of escaped escape characters.")
|
|
|
|
|
(defconst woman-escaped-escape-string
|
|
|
|
|
(char-to-string woman-escaped-escape-char)
|
|
|
|
|
"Internal string representation of escaped escape characters.")
|
|
|
|
|
|
|
|
|
|
(defconst woman-unpadded-space-char ?
|
|
|
|
|
;; An arbitrary unused control character
|
|
|
|
|
"Internal character representation of unpadded space characters.")
|
|
|
|
|
(defconst woman-unpadded-space-string
|
|
|
|
|
(char-to-string woman-unpadded-space-char)
|
|
|
|
|
"Internal string representation of unpadded space characters.")
|
|
|
|
|
|
2007-09-10 03:22:12 +00:00
|
|
|
|
(defvar woman-syntax-table
|
|
|
|
|
(let ((st (make-syntax-table)))
|
|
|
|
|
;; The following internal chars must NOT have whitespace syntax:
|
|
|
|
|
(modify-syntax-entry woman-unpadded-space-char "." st)
|
|
|
|
|
(modify-syntax-entry woman-escaped-escape-char "." st)
|
|
|
|
|
st)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
"Syntax table to support special characters used internally by WoMan.")
|
|
|
|
|
|
|
|
|
|
(defun woman-set-buffer-display-table ()
|
|
|
|
|
"Set up a display table for a WoMan buffer.
|
|
|
|
|
This display table is used for displaying internal special characters, but
|
|
|
|
|
does not interfere with any existing display table, e.g. for displaying
|
|
|
|
|
European characters."
|
|
|
|
|
(setq buffer-display-table
|
|
|
|
|
;; The following test appears to be necessary on some
|
|
|
|
|
;; non-Windows platforms, e.g. Solaris 2.6 when running on a
|
|
|
|
|
;; tty. Thanks to T. V. Raman <raman@Adobe.COM>.
|
|
|
|
|
;; The MS-DOS terminal also sets standard-display-table to
|
|
|
|
|
;; a non-nil value.
|
|
|
|
|
(if standard-display-table ; default is nil !!!
|
|
|
|
|
(copy-sequence standard-display-table)
|
|
|
|
|
(make-display-table)))
|
|
|
|
|
;; Display the following internal chars correctly:
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(aset buffer-display-table woman-unpadded-space-char [?\s])
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(aset buffer-display-table woman-escaped-escape-char [?\\]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; The main decoding driver:
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-mode) ; for the compiler
|
|
|
|
|
|
|
|
|
|
(defun woman-decode-buffer ()
|
|
|
|
|
"Decode a buffer in UN*X man-page source format.
|
|
|
|
|
No external programs are used."
|
|
|
|
|
(interactive) ; mainly for testing
|
|
|
|
|
(WoMan-log-begin)
|
|
|
|
|
(run-hooks 'woman-pre-format-hook)
|
|
|
|
|
(and (boundp 'font-lock-mode) font-lock-mode (font-lock-mode -1))
|
|
|
|
|
;; (fundamental-mode)
|
2011-07-01 04:52:27 +00:00
|
|
|
|
(let ((start-time (current-time))
|
|
|
|
|
time)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(message "WoMan formatting buffer...")
|
|
|
|
|
; (goto-char (point-min))
|
|
|
|
|
; (cond
|
|
|
|
|
; ((re-search-forward "^\\.[ \t]*TH" nil t) ; wrong format if not found?
|
|
|
|
|
; (beginning-of-line)
|
|
|
|
|
; (delete-region (point-min) (point))) ; potentially dangerous!
|
|
|
|
|
; (t (message "WARNING: .TH request not found -- not man-page format?")))
|
|
|
|
|
(woman-decode-region (point-min) (point-max))
|
2011-07-01 04:52:27 +00:00
|
|
|
|
(setq time (float-time (time-since start-time)))
|
|
|
|
|
(message "WoMan formatting buffer...done in %g seconds" time)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(WoMan-log-end time))
|
|
|
|
|
(run-hooks 'woman-post-format-hook))
|
|
|
|
|
|
|
|
|
|
(defvar woman-string-alist ; rebound in woman-decode-region
|
|
|
|
|
'(("S" . "") ("R" . "(Reg.)") ("Tm" . "(TM)")
|
|
|
|
|
("lq" . "\"") ("rq" . "\"")
|
|
|
|
|
("''" . "\"") ; needed for gcc.1
|
|
|
|
|
(".T" . "") ; output device from -T option?
|
|
|
|
|
)
|
|
|
|
|
"Alist of strings predefined in the -man macro package `tmac.an'.")
|
|
|
|
|
|
|
|
|
|
(defvar woman-negative-vertical-space nil ; rebound in woman-decode-region
|
|
|
|
|
"Set to t if .sp N with N < 0 encountered.")
|
|
|
|
|
|
|
|
|
|
(defun woman-pre-process-region (from to)
|
|
|
|
|
"Pre-process escapes and comments in the region of text between FROM and TO.
|
|
|
|
|
To be called on original buffer and any .so insertions."
|
|
|
|
|
;; Hide escaped escapes \\ and printable escapes \e very early
|
|
|
|
|
;; (to be re-instated as just \ very late!):
|
|
|
|
|
(goto-char from)
|
|
|
|
|
;; .eo turns off escape character processing
|
|
|
|
|
(while (re-search-forward "\\(\\\\[\\e]\\)\\|^\\.eo" to t) ; \\
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(if (match-beginning 1)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(replace-match woman-escaped-escape-string t t)
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
;; .ec turns on escape character processing (and sets the
|
|
|
|
|
;; escape character to its argument, if any, which I'm ignoring
|
|
|
|
|
;; for now!)
|
|
|
|
|
(while (and (re-search-forward "\\(\\\\\\)\\|^\\.ec" to t) ; \
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(match-beginning 1))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(replace-match woman-escaped-escape-string t t))
|
|
|
|
|
;; ***** Need test for .ec arg and warning here! *****
|
|
|
|
|
(woman-delete-whole-line)))
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Delete comments .\"<anything>, \"<anything> and null requests.
|
|
|
|
|
;; (However, should null . requests cause a break?)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char from)
|
|
|
|
|
(while (re-search-forward "^[.'][ \t]*\\(\\\\\".*\\)?\n\\|\\\\\".*" to t)
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(woman-delete-match 0)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-non-underline-faces ()
|
|
|
|
|
"Prepare non-underlined versions of underlined faces."
|
|
|
|
|
(let ((face-list (face-list)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(dolist (face face-list)
|
|
|
|
|
(let ((face-name (symbol-name face)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (and (string-match "\\`woman-" face-name)
|
|
|
|
|
(face-underline-p face))
|
|
|
|
|
(let ((face-no-ul (intern (concat face-name "-no-ul"))))
|
|
|
|
|
(copy-face face face-no-ul)
|
2012-11-17 01:29:24 +00:00
|
|
|
|
(set-face-underline face-no-ul nil)))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Preprocessors
|
|
|
|
|
;; =============
|
|
|
|
|
|
|
|
|
|
;; This information is based on documentation for the man command by
|
|
|
|
|
;; Graeme W. Wilford <G.Wilford@ee.surrey.ac.uk>
|
|
|
|
|
|
|
|
|
|
;; First, the environment variable $MANROFFSEQ is interrogated, and if
|
|
|
|
|
;; not set then the initial line of the nroff file is parsed for a
|
|
|
|
|
;; preprocessor string. To contain a valid preprocessor string, the
|
|
|
|
|
;; first line must resemble
|
|
|
|
|
;;
|
|
|
|
|
;; '\" <string>
|
|
|
|
|
;;
|
|
|
|
|
;; where string can be any combination of the following letters that
|
|
|
|
|
;; specify the sequence of preprocessors to run before nroff or
|
|
|
|
|
;; troff/groff. Not all installations will have a full set of
|
|
|
|
|
;; preprocessors. Some of the preprocessors and the letters used to
|
|
|
|
|
;; designate them are: eqn (e), grap (g), pic (p), tbl (t), vgrind
|
|
|
|
|
;; (v), refer (r). This option overrides the $MANROFFSEQ environment
|
|
|
|
|
;; variable. zsoelim is always run as the very first preprocessor.
|
|
|
|
|
|
|
|
|
|
(defvar woman-emulate-tbl nil
|
|
|
|
|
"True if WoMan should emulate the tbl preprocessor.
|
|
|
|
|
This applies to text between .TE and .TS directives.
|
|
|
|
|
Currently set only from '\" t in the first line of the source file.")
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun woman-decode-region (from _to)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
"Decode the region between FROM and TO in UN*X man-page source format."
|
|
|
|
|
;; Suitable for use in format-alist.
|
|
|
|
|
;; But this requires care to control major mode implied font locking.
|
|
|
|
|
;; Must return the new end of file. See format.el for details.
|
|
|
|
|
;; NB: The `to' argument is bogus: it is not currently used, and if
|
|
|
|
|
;; it were it would need to be a marker rather than a position!
|
|
|
|
|
;; First force the correct environment:
|
|
|
|
|
(let ((case-fold-search nil) ; This is necessary!
|
|
|
|
|
(woman-string-alist woman-string-alist)
|
|
|
|
|
(woman-fill-column woman-fill-column)
|
|
|
|
|
woman-negative-vertical-space)
|
|
|
|
|
(setq woman-left-margin woman-default-indent
|
|
|
|
|
woman-prevailing-indent woman-default-indent
|
|
|
|
|
woman-interparagraph-distance 1
|
|
|
|
|
woman-leave-blank-lines nil
|
|
|
|
|
woman-RS-left-margin nil
|
|
|
|
|
woman-RS-prevailing-indent nil
|
|
|
|
|
woman-adjust woman-adjust-both
|
|
|
|
|
woman-justify (nth woman-adjust woman-justify-list)
|
|
|
|
|
woman-nofill nil)
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(setq woman-if-conditions-true
|
|
|
|
|
(cons (string-to-char (symbol-name woman-emulation)) '(?e ?o)))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Prepare non-underlined versions of underlined faces:
|
|
|
|
|
(woman-non-underline-faces)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
;; Set font of `woman-symbol' face to `woman-symbol-font' if
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; `woman-symbol-font' is well defined.
|
|
|
|
|
(and woman-use-symbol-font
|
|
|
|
|
(stringp woman-symbol-font)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(set-face-font 'woman-symbol woman-symbol-font
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(and (frame-live-p woman-frame) woman-frame)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2012-11-06 01:49:44 +00:00
|
|
|
|
(setq-local adaptive-fill-mode nil) ; No special "%" "#" etc filling.
|
|
|
|
|
|
|
|
|
|
;; Set syntax and display tables:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(set-syntax-table woman-syntax-table)
|
|
|
|
|
(woman-set-buffer-display-table)
|
|
|
|
|
|
|
|
|
|
;; Based loosely on a suggestion by Theodore Jump:
|
|
|
|
|
(if (or woman-fill-frame
|
|
|
|
|
(not (and (integerp woman-fill-column) (> woman-fill-column 0))))
|
2004-03-23 07:35:35 +00:00
|
|
|
|
(setq woman-fill-column (- (window-width) woman-default-indent)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Check for preprocessor requests:
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(if (looking-at "'\\\\\"[ \t]*\\([a-z]+\\)")
|
|
|
|
|
(let ((letters (append (match-string 1) nil)))
|
|
|
|
|
(if (memq ?t letters)
|
|
|
|
|
(setq woman-emulate-tbl t
|
|
|
|
|
letters (delete ?t letters)))
|
|
|
|
|
(if letters
|
|
|
|
|
(WoMan-warn "Unhandled preprocessor request letters %s"
|
|
|
|
|
(concat letters)))
|
|
|
|
|
(woman-delete-line 1)))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-pre-process-region from nil)
|
|
|
|
|
;; Process ignore requests, macro definitions,
|
|
|
|
|
;; conditionals and switch source requests:
|
|
|
|
|
(woman0-roff-buffer from)
|
|
|
|
|
|
2007-04-10 19:35:34 +00:00
|
|
|
|
;; Check for macro sets that woman cannot handle. We can only
|
|
|
|
|
;; because do this after processing source-switch directives.
|
2007-04-10 19:30:12 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
(unless (and (re-search-forward "^\\.SH[ \n]" (point-max) t)
|
|
|
|
|
(progn (goto-char (point-min))
|
|
|
|
|
(re-search-forward "^\\.TH[ \n]" (point-max) t))
|
|
|
|
|
(progn (goto-char (point-min))
|
|
|
|
|
(not (re-search-forward "^\\.\\([pnil]p\\|sh\\)[ \n]"
|
|
|
|
|
(point-max) t))))
|
|
|
|
|
(error "WoMan can only format man pages written with the usual `-man' macros")))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Process \k escapes BEFORE changing tab width (?):
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman-mark-horizonal-position)
|
|
|
|
|
|
|
|
|
|
;; Set buffer-local variables:
|
|
|
|
|
(setq fill-column woman-fill-column
|
|
|
|
|
tab-width woman-tab-width)
|
|
|
|
|
|
|
|
|
|
;; Hide unpaddable and digit-width spaces \(space) and \0:
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(while (re-search-forward "\\\\[ 0]" nil t)
|
|
|
|
|
(replace-match woman-unpadded-space-string t t))
|
|
|
|
|
|
|
|
|
|
;; Discard optional hyphen \%; concealed newlines \<newline>;
|
|
|
|
|
;; point-size change function \sN,\s+N, \s-N:
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(while (re-search-forward "\\\\\\([%\n]\\|s[-+]?[0-9]+\\)" nil t)
|
|
|
|
|
(woman-delete-match 0))
|
|
|
|
|
|
|
|
|
|
;; BEWARE: THIS SHOULD PROBABLY ALL BE DONE MUCH LATER!!!!!
|
|
|
|
|
;; Process trivial escapes \-, \`, \.
|
|
|
|
|
;; (\' must be done after tab processing!):
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(while (re-search-forward "\\\\\\([-`.]\\)" nil t)
|
|
|
|
|
(replace-match "\\1"))
|
|
|
|
|
;; NB: Must keep ALL zero-width characters \&, \|, and \^ until
|
|
|
|
|
;; ALL requests processed!
|
|
|
|
|
|
|
|
|
|
;; Process no-break requests and macros (including font-change macros):
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman1-roff-buffer)
|
|
|
|
|
|
|
|
|
|
;; Process strings and special character escapes \(xx:
|
|
|
|
|
;; (Must do this BEFORE fontifying!)
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman-strings)
|
|
|
|
|
;; Special chars moved after translation in
|
|
|
|
|
;; `woman2-process-escapes' (for pic.1):
|
|
|
|
|
; (goto-char from)
|
|
|
|
|
; (woman-special-characters)
|
|
|
|
|
|
|
|
|
|
;; Process standard font-change requests and escapes:
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman-change-fonts)
|
|
|
|
|
|
|
|
|
|
;; 1/2 em vertical motion \d, \u and general local vertical motion
|
|
|
|
|
;; \v'+/-N' simulated using TeX ^ and _ symbols for now.
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(let ((first t)) ; assume no nesting!
|
|
|
|
|
(while (re-search-forward "\\\\\\([du]\\|v'[^']*'\\)" nil t)
|
|
|
|
|
(let* ((esc (match-string 1))
|
|
|
|
|
(repl (if (or (= (aref esc 0) ?u)
|
|
|
|
|
(and (>= (length esc) 2) (= (aref esc 2) ?-)))
|
|
|
|
|
"^" "_")))
|
|
|
|
|
(cond (first
|
|
|
|
|
(replace-match repl nil t)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(put-text-property (1- (point)) (point) 'face 'woman-addition)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(WoMan-warn
|
|
|
|
|
"Initial vertical motion escape \\%s simulated" esc)
|
|
|
|
|
(WoMan-log
|
|
|
|
|
" by TeX `%s' in woman-addition-face!" repl))
|
|
|
|
|
(t
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(WoMan-warn
|
|
|
|
|
"Terminal vertical motion escape \\%s ignored!" esc)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setq first (not first)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Process formatting macros
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman2-roff-buffer)
|
|
|
|
|
|
|
|
|
|
;; Go back and process negative vertical space if necessary:
|
|
|
|
|
(if woman-negative-vertical-space
|
|
|
|
|
(woman-negative-vertical-space from))
|
|
|
|
|
|
2012-07-07 10:06:38 +00:00
|
|
|
|
(when woman-preserve-ascii
|
|
|
|
|
;; Re-instate escaped escapes to just `\' and unpaddable spaces
|
|
|
|
|
;; to just `space'. This is not necessary for display since
|
|
|
|
|
;; there are display table entries for the escaped chars, but it
|
|
|
|
|
;; is necessary if the buffer might be saved as ASCII.
|
|
|
|
|
;;
|
|
|
|
|
;; `subst-char-in-region' preserves text properties on the
|
|
|
|
|
;; characters, which is necessary for bold, underline, etc on
|
|
|
|
|
;; \e. There's usually no face on spaces, but if there is then
|
|
|
|
|
;; it's good to keep that too.
|
|
|
|
|
(subst-char-in-region from (point-max)
|
|
|
|
|
woman-escaped-escape-char ?\\)
|
|
|
|
|
(subst-char-in-region from (point-max)
|
|
|
|
|
woman-unpadded-space-char ?\s))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Must return the new end of file if used in format-alist.
|
|
|
|
|
(point-max)))
|
|
|
|
|
|
|
|
|
|
(defun woman-horizontal-escapes (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Process \\h'+/-N' local horizontal motion escapes upto TO.
|
|
|
|
|
Implements arbitrary forward and non-overlapping backward motion.
|
|
|
|
|
Preserves location of `point'."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Moved from `woman-decode-region' for version 0.50.
|
|
|
|
|
;; N may include width escape \w'...' (but may already be processed!
|
|
|
|
|
(let ((from (point)))
|
|
|
|
|
(while (re-search-forward
|
|
|
|
|
;; Delimiter can be a special char escape sequence \(.. or
|
|
|
|
|
;; a single normal char (usually '):
|
|
|
|
|
"\\\\h\\(\\\\(..\\|.\\)\\(|\\)?"
|
|
|
|
|
to t)
|
|
|
|
|
(let ((from (match-beginning 0))
|
|
|
|
|
(delim (regexp-quote (match-string 1)))
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(absolute (match-beginning 2)) ; absolute position?
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(N (woman-parse-numeric-arg)) ; distance
|
|
|
|
|
to
|
|
|
|
|
msg) ; for warning
|
|
|
|
|
(if (not (looking-at delim))
|
|
|
|
|
;; Warn but leave escape in buffer unprocessed:
|
|
|
|
|
(WoMan-warn
|
|
|
|
|
"Local horizontal motion (%s) delimiter error!"
|
|
|
|
|
(buffer-substring from (1+ (point)))) ; point at end of arg
|
|
|
|
|
(setq to (match-end 0)
|
|
|
|
|
;; For possible warning -- save before deleting:
|
|
|
|
|
msg (buffer-substring from to))
|
|
|
|
|
(delete-region from to)
|
|
|
|
|
(if absolute ; make relative
|
|
|
|
|
(setq N (- N (current-column))))
|
|
|
|
|
(if (>= N 0)
|
|
|
|
|
;; Move forward by inserting hard spaces:
|
|
|
|
|
(insert-char woman-unpadded-space-char N)
|
|
|
|
|
;; Move backwards by deleting space,
|
|
|
|
|
;; first backwards then forwards:
|
|
|
|
|
(while (and
|
|
|
|
|
(<= (setq N (1+ N)) 0)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(cond ((memq (preceding-char) '(?\s ?\t))
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
|
(delete-char -1) t)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
((memq (following-char) '(?\s ?\t))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(delete-char 1) t)
|
|
|
|
|
(t nil))))
|
|
|
|
|
(if (<= N 0)
|
|
|
|
|
(WoMan-warn
|
2009-07-06 02:17:31 +00:00
|
|
|
|
"Negative horizontal motion (%s) would overwrite!" msg))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char from)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Process ignore requests (.ig), conditionals (.if etc.),
|
|
|
|
|
;; source-switch (.so), macro definitions (.de etc.) and macro
|
|
|
|
|
;; expansions.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defvar woman0-if-to) ; marker bound in woman0-roff-buffer
|
|
|
|
|
(defvar woman0-macro-alist) ; bound in woman0-roff-buffer
|
|
|
|
|
(defvar woman0-search-regex) ; bound in woman0-roff-buffer
|
|
|
|
|
(defvar woman0-search-regex-start ; bound in woman0-roff-buffer
|
|
|
|
|
"^[.'][ \t]*\\(ig\\|if\\|ie\\|el\\|so\\|rn\\|de\\|am")
|
|
|
|
|
(defconst woman0-search-regex-end "\\)\\([ \t]+\\|$\\)")
|
|
|
|
|
;; May need other terminal characters, e.g. \, but NOT \n!
|
|
|
|
|
;; Alternatively, force maximal match (Posix?)
|
|
|
|
|
|
|
|
|
|
(defvar woman0-rename-alist) ; bound in woman0-roff-buffer
|
|
|
|
|
|
|
|
|
|
(defun woman0-roff-buffer (from)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Process conditional-type requests and user-defined macros.
|
|
|
|
|
Start at FROM and re-scan new text as appropriate."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char from)
|
|
|
|
|
(let ((woman0-if-to (make-marker))
|
2010-11-05 08:16:55 +00:00
|
|
|
|
woman-request woman0-macro-alist
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman0-search-regex-start woman0-search-regex-start)
|
|
|
|
|
(woman0-search-regex
|
|
|
|
|
(concat woman0-search-regex-start woman0-search-regex-end))
|
2011-01-28 21:20:40 +00:00
|
|
|
|
processed-first-hunk
|
2000-05-08 14:32:17 +00:00
|
|
|
|
woman0-rename-alist)
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(set-marker-insertion-type woman0-if-to t)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(while (re-search-forward woman0-search-regex nil t)
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(setq woman-request (match-string 1))
|
2011-01-28 21:20:40 +00:00
|
|
|
|
|
|
|
|
|
;; Process escape sequences prior to first request (Bug#7843).
|
|
|
|
|
(unless processed-first-hunk
|
|
|
|
|
(setq processed-first-hunk t)
|
|
|
|
|
(let ((process-escapes-to-marker (point-marker)))
|
|
|
|
|
(set-marker-insertion-type process-escapes-to-marker t)
|
|
|
|
|
(save-match-data
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman2-process-escapes process-escapes-to-marker)))))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(cond ((string= woman-request "ig") (woman0-ig))
|
|
|
|
|
((string= woman-request "if") (woman0-if "if"))
|
|
|
|
|
((string= woman-request "ie") (woman0-if "ie"))
|
|
|
|
|
((string= woman-request "el") (woman0-el))
|
|
|
|
|
((string= woman-request "so") (woman0-so))
|
|
|
|
|
((string= woman-request "rn") (woman0-rn))
|
|
|
|
|
((string= woman-request "de") (woman0-de))
|
|
|
|
|
((string= woman-request "am") (woman0-de 'append))
|
|
|
|
|
(t (woman0-macro woman-request))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(set-marker woman0-if-to nil)
|
|
|
|
|
(woman0-rename)
|
|
|
|
|
;; Should now re-run `woman0-roff-buffer' if any renaming was
|
|
|
|
|
;; done, but let's just hope this is not necessary for now!
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(defun woman0-ig ()
|
|
|
|
|
".ig yy -- Discard input up to `.yy', which defaults to `..')."
|
|
|
|
|
;; The terminal request MUST begin with . (not ')!
|
|
|
|
|
(looking-at "\\(\\S +\\)?")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((yy (or (match-string 1) "."))
|
|
|
|
|
(from (point)))
|
|
|
|
|
(if (re-search-forward
|
|
|
|
|
(concat "^\\.[ \t]*" (regexp-quote yy) ".*\n") nil t)
|
|
|
|
|
(delete-region from (point))
|
|
|
|
|
(WoMan-warn
|
|
|
|
|
"ig request ignored -- terminator `.%s' not found!" yy)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-delete-line 1))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defsubst woman0-process-escapes (from to)
|
|
|
|
|
"Process escapes within an if/ie condition between FROM and TO."
|
|
|
|
|
(woman-strings to)
|
|
|
|
|
(goto-char from) ; necessary!
|
|
|
|
|
;; Strip font-change escapes:
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(while (re-search-forward "\\\\f\\(\\[[^]]+\\]\\|(..\\|.\\)" to t)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-delete-match 0))
|
|
|
|
|
(goto-char from) ; necessary!
|
|
|
|
|
(woman2-process-escapes to 'numeric))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; request does not appear to be used dynamically by any callees.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman0-if (request)
|
|
|
|
|
".if/ie c anything -- Discard unless c evaluates to true.
|
|
|
|
|
Remember condition for use by a subsequent `.el'.
|
|
|
|
|
REQUEST is the invoking directive without the leading dot."
|
|
|
|
|
;; c evaluates to a one-character built-in condition name or
|
|
|
|
|
;; 'string1'string2' or a number > 0, prefix ! negates.
|
|
|
|
|
;; \{ ... \} for multi-line use.
|
|
|
|
|
;; Leaves point at start of new text.
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
;; (delete-horizontal-space)
|
|
|
|
|
;; Process escapes in condition:
|
|
|
|
|
(let ((from (point)) negated n (c 0))
|
|
|
|
|
(set-marker woman0-if-to
|
|
|
|
|
(save-excursion (skip-syntax-forward "^ ") (point)))
|
|
|
|
|
;; Process condition:
|
|
|
|
|
(if (setq negated (= (following-char) ?!)) (delete-char 1))
|
|
|
|
|
(cond
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; ((looking-at "[no]") (setq c t)) ; accept n(roff) and o(dd page)
|
|
|
|
|
;; ((looking-at "[te]") (setq c nil)) ; reject t(roff) and e(ven page)
|
2012-08-26 10:29:37 +00:00
|
|
|
|
;; Per groff ".if v" is recognized as false (it means -Tversatec).
|
2012-08-07 03:57:05 +00:00
|
|
|
|
((looking-at "[ntoev]")
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(setq c (memq (following-char) woman-if-conditions-true)))
|
2011-11-20 02:29:42 +00:00
|
|
|
|
;; Unrecognized letter so reject:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
((looking-at "[A-Za-z]") (setq c nil)
|
2005-06-16 16:12:40 +00:00
|
|
|
|
(WoMan-warn "%s %s -- unrecognized condition name rejected!"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
request (match-string 0)))
|
|
|
|
|
;; Accept strings if identical:
|
|
|
|
|
((save-restriction
|
|
|
|
|
(narrow-to-region from woman0-if-to)
|
|
|
|
|
;; String delimiter can be any non-numeric character,
|
|
|
|
|
;; including a special character escape:
|
|
|
|
|
(looking-at "\\(\\\\(..\\|[^0-9]\\)\\(.*\\)\\1\\(.*\\)\\1\\'"))
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(let ((end1 (copy-marker (match-end 2) t))) ; End of first string.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Delete 2nd and 3rd delimiters to avoid processing them:
|
|
|
|
|
(delete-region (match-end 3) woman0-if-to)
|
|
|
|
|
(delete-region (match-end 2) (match-beginning 3))
|
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(woman0-process-escapes (point) woman0-if-to)
|
|
|
|
|
(setq c (string= (buffer-substring (point) end1)
|
|
|
|
|
(buffer-substring end1 woman0-if-to)))
|
|
|
|
|
(set-marker end1 nil)
|
|
|
|
|
(goto-char from)))
|
|
|
|
|
;; Accept numeric value if > 0:
|
|
|
|
|
((numberp (setq n (progn
|
|
|
|
|
(woman0-process-escapes from woman0-if-to)
|
|
|
|
|
(woman-parse-numeric-arg))))
|
|
|
|
|
(setq c (> n 0))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(goto-char from)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eq c 0)
|
|
|
|
|
(woman-if-ignore woman0-if-to request) ; ERROR!
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-if-body request woman0-if-to (eq c negated)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; request is not used dynamically by any callees.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-if-body (request to delete) ; should be reversed as `accept'?
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Process if-body, including \\{ ... \\}.
|
|
|
|
|
REQUEST is the invoking directive without the leading dot.
|
|
|
|
|
If TO is non-nil then delete the if-body.
|
|
|
|
|
If DELETE is non-nil then delete from point."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Assume concealed newlines already processed.
|
|
|
|
|
(let ((from (point)))
|
|
|
|
|
(if to (delete-region (point) to))
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(cond (;;(looking-at "[^{\n]*\\\\{\\s *") ; multi-line
|
|
|
|
|
;; allow escaped newlines:
|
|
|
|
|
(looking-at "[^{\n]*\\(\\\\\n\\)*\\\\{\\s *\\(\\\\\n\\)*") ; multi-line
|
|
|
|
|
;; including preceding .if(s) and following newline
|
|
|
|
|
(let ((from (point)))
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
;; Allow for nested \{ ... \} -- BUT BEWARE that this
|
|
|
|
|
;; algorithm only supports one level of nesting!
|
|
|
|
|
(while
|
|
|
|
|
(and (re-search-forward
|
|
|
|
|
;; "\\(\\\\{\\)\\|\\(\n[.']\\)?[ \t]*\\\\}[ \t]*"
|
|
|
|
|
;; Interpret bogus `el \}' as `el \{',
|
|
|
|
|
;; especially for Tcl/Tk man pages:
|
|
|
|
|
"\\(\\\\{\\|el[ \t]*\\\\}\\)\\|\\(\n[.']\\)?[ \t]*\\\\}[ \t]*")
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(match-beginning 1))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(re-search-forward "\\\\}"))
|
|
|
|
|
(delete-region (if delete from (match-beginning 0)) (point))
|
|
|
|
|
(if (looking-at "^$") (delete-char 1))
|
|
|
|
|
))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(delete (woman-delete-line 1))) ; single-line
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Process matching .el anything:
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(cond ((string= request "ie")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Discard unless previous .ie c `evaluated to false'.
|
2011-09-09 06:23:47 +00:00
|
|
|
|
;; IIUC, an .ie must be followed by an .el.
|
|
|
|
|
;; (An if with no else uses .if rather than .ie.)
|
|
|
|
|
;; TODO warn if no .el found?
|
|
|
|
|
;; The .el should come immediately after the .ie (modulo
|
|
|
|
|
;; comments etc), but this searches to eob.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(cond ((re-search-forward "^[.'][ \t]*el[ \t]*" nil t)
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(woman-if-body "el" nil (not delete)))))
|
2011-09-09 06:23:47 +00:00
|
|
|
|
;;; FIXME neither the comment nor the code here make sense to me.
|
|
|
|
|
;;; This branch was executed for an else (any else, AFAICS).
|
|
|
|
|
;;; At this point, the else in question has already been processed above.
|
|
|
|
|
;;; The re-search will find the _next_ else, if there is one, and
|
|
|
|
|
;;; delete it. If there is one, it belongs to another if block. (Bug#9447)
|
|
|
|
|
;;; woman0-el does not need this bit either.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Got here after processing a single-line `.ie' as a body
|
|
|
|
|
;; clause to be discarded:
|
2011-09-09 06:23:47 +00:00
|
|
|
|
;;; ((string= request "el")
|
|
|
|
|
;;; (cond ((re-search-forward "^[.'][ \t]*el[ \t]*" nil t)
|
|
|
|
|
;;; (woman-delete-match 0)
|
|
|
|
|
;;; (woman-if-body "el" nil t)))))
|
|
|
|
|
)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(goto-char from)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman0-el ()
|
|
|
|
|
"Isolated .el request -- should not happen!"
|
|
|
|
|
(WoMan-warn "el request without matching `ie' rejected!")
|
|
|
|
|
(cond (woman-ignore
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(woman-if-body "el" nil t))
|
|
|
|
|
(t ; Ignore -- leave in buffer
|
|
|
|
|
;; This does not work too well, but it's only for debugging!
|
|
|
|
|
(skip-chars-forward "^ \t")
|
|
|
|
|
(if (looking-at "[ \t]*\\{") (search-forward "\\}"))
|
|
|
|
|
(forward-line 1))))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; request is not used dynamically by any callees.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-if-ignore (to request)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Ignore but warn about an if request ending at TO, named REQUEST."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(WoMan-warn-ignored request "ignored -- condition not handled!")
|
|
|
|
|
(if woman-ignore
|
|
|
|
|
(woman-if-body request to t)
|
|
|
|
|
;; Ignore -- leave in buffer
|
|
|
|
|
;; This does not work too well, but it's only for debugging!
|
|
|
|
|
(skip-chars-forward "^ \t")
|
|
|
|
|
(if (looking-at "[ \t]*\\{") (search-forward "\\}"))
|
|
|
|
|
(forward-line 1)))
|
|
|
|
|
|
|
|
|
|
(defun woman0-so ()
|
|
|
|
|
".so filename -- Switch source file. `.so' requests may be nested."
|
|
|
|
|
;; Leaves point at start of new text.
|
|
|
|
|
;; (skip-chars-forward " \t")
|
|
|
|
|
(let* ((beg (point))
|
|
|
|
|
(end (progn (woman-forward-arg 'unquote) (point)))
|
|
|
|
|
(name (buffer-substring beg end))
|
|
|
|
|
(filename name))
|
|
|
|
|
;; If the specified file does not exist in this ...
|
|
|
|
|
(or (file-exists-p filename)
|
|
|
|
|
;; or the parent directory ...
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(setq filename (concat "../" name)))
|
|
|
|
|
;; then use the WoMan search mechanism to find the filename ...
|
|
|
|
|
(setq filename
|
|
|
|
|
(woman-file-name
|
* lisp/files.el (file-name-base): New convenience function.
* lisp/autoinsert.el, lisp/cus-dep.el, lisp/doc-view.el, lisp/image-dired.el,
* lisp/woman.el, lisp/eshell/esh-cmd.el, lisp/progmodes/ada-xref.el,
* lisp/progmodes/cc-defs.el, lisp/progmodes/cperl-mode.el,
* lisp/progmodes/flymake.el, lisp/progmodes/gud.el, lisp/progmodes/idlwave.el,
* lisp/textmodes/ispell.el, lisp/textmodes/reftex-ref.el,
* lisp/textmodes/tex-mode.el: Use it.
Did not touch cedet and org because they are maintained elsewhere.
2012-06-26 16:23:01 +00:00
|
|
|
|
(file-name-base name)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Cannot find the file, so ...
|
|
|
|
|
(kill-buffer (current-buffer))
|
|
|
|
|
(error "File `%s' not found" name))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman-delete-line 1)
|
2006-09-22 21:35:30 +00:00
|
|
|
|
(let* ((from (point))
|
|
|
|
|
(length (woman-insert-file-contents filename 0))
|
|
|
|
|
(to (copy-marker (+ from length) t)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-pre-process-region from to)
|
|
|
|
|
(set-marker to nil)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(goto-char from))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Process macro definitions:
|
|
|
|
|
|
|
|
|
|
(defun woman0-rn ()
|
|
|
|
|
"Process .rn xx yy -- rename macro xx to yy."
|
|
|
|
|
;; For now, done backwards AFTER all macro expansion.
|
|
|
|
|
;; Should also allow requests and strings to be renamed!
|
|
|
|
|
(if (eolp) ; ignore if no argument
|
|
|
|
|
()
|
|
|
|
|
(let* ((beg (point))
|
|
|
|
|
(end (progn (woman-forward-arg 'unquote 'concat) (point)))
|
|
|
|
|
(old (buffer-substring beg end))
|
|
|
|
|
new)
|
|
|
|
|
(if (eolp) ; ignore if no argument
|
|
|
|
|
()
|
|
|
|
|
(setq beg (point)
|
|
|
|
|
end (progn (woman-forward-arg 'unquote) (point))
|
|
|
|
|
new (buffer-substring beg end)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
woman0-rename-alist (cons (cons new old) woman0-rename-alist)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-delete-whole-line))
|
|
|
|
|
|
|
|
|
|
(defun woman0-rename ()
|
|
|
|
|
"Effect renaming required by .rn requests."
|
|
|
|
|
;; For now, do this backwards AFTER all macro expansion.
|
2007-10-13 02:56:31 +00:00
|
|
|
|
(dolist (new woman0-rename-alist)
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(let ((old (cdr new))
|
|
|
|
|
(new (car new)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(setq new (concat "^[.'][ \t]*" (regexp-quote new)))
|
|
|
|
|
(setq old (concat "." old))
|
|
|
|
|
(while (re-search-forward new nil t)
|
|
|
|
|
(replace-match old nil t)))))
|
|
|
|
|
|
|
|
|
|
(defconst woman-unescape-regex
|
|
|
|
|
(concat woman-escaped-escape-string
|
|
|
|
|
"\\(" woman-escaped-escape-string "\\)?"))
|
|
|
|
|
|
|
|
|
|
(defsubst woman-unescape (macro)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Replace escape sequences in the body of MACRO.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Replaces || by |, but | by \, where | denotes the internal escape."
|
|
|
|
|
(let (start)
|
|
|
|
|
(while (setq start (string-match woman-unescape-regex macro start))
|
|
|
|
|
(setq macro
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(if (match-beginning 1)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(replace-match "" t t macro 1)
|
|
|
|
|
(replace-match "\\" t t macro))
|
|
|
|
|
start (1+ start)))
|
|
|
|
|
macro))
|
|
|
|
|
|
|
|
|
|
(defun woman0-de (&optional append)
|
|
|
|
|
"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."
|
2008-06-27 02:41:14 +00:00
|
|
|
|
;; Modeled on woman-strings. BEWARE: Processing of .am is a hack!
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Add support for .rm?
|
|
|
|
|
;; (skip-chars-forward " \t")
|
|
|
|
|
(if (eolp) ; ignore if no argument
|
|
|
|
|
()
|
|
|
|
|
(looking-at "[^ \t\n]+") ; macro name
|
|
|
|
|
(let* ((macro (match-string 0)) from
|
|
|
|
|
(previous (assoc macro woman0-macro-alist)))
|
|
|
|
|
(if (not previous)
|
|
|
|
|
(setq woman0-search-regex-start
|
|
|
|
|
(concat woman0-search-regex-start "\\|" (regexp-quote macro))
|
|
|
|
|
woman0-search-regex
|
|
|
|
|
(concat woman0-search-regex-start woman0-search-regex-end)
|
|
|
|
|
))
|
|
|
|
|
;; Macro body runs from start of next line to line
|
|
|
|
|
;; beginning with `..'."
|
|
|
|
|
;; The terminal request MUST begin with `.' (not ')!
|
|
|
|
|
(forward-line)
|
|
|
|
|
(setq from (point))
|
|
|
|
|
(re-search-forward "^\\.[ \t]*\\.")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((body (woman-unescape (buffer-substring from (point)))))
|
|
|
|
|
(if (and append previous)
|
|
|
|
|
(setq previous (cdr previous)
|
|
|
|
|
body (concat body (cdr previous))
|
|
|
|
|
append (car previous)
|
|
|
|
|
))
|
|
|
|
|
(setq macro (cons macro (cons append body))))
|
|
|
|
|
;; This should be an update, but consing a new string
|
|
|
|
|
;; onto the front of the alist has the same effect:
|
|
|
|
|
(setq woman0-macro-alist (cons macro woman0-macro-alist))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(delete-region from (point))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(backward-char))) ; return to end of .de/am line
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(beginning-of-line) ; delete .de/am line
|
|
|
|
|
(woman-delete-line 1))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; request may be used dynamically (woman-interpolate-macro calls
|
|
|
|
|
;; woman-forward-arg).
|
|
|
|
|
(defun woman0-macro (woman-request)
|
|
|
|
|
"Process the macro call named WOMAN-REQUEST."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Leaves point at start of new text.
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(let ((macro (assoc woman-request woman0-macro-alist)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if macro
|
|
|
|
|
(woman-interpolate-macro (cdr macro))
|
|
|
|
|
;; SHOULD DELETE THE UNINTERPRETED REQUEST!!!!!
|
|
|
|
|
;; Output this message once only per call (cf. strings)?
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(WoMan-warn "Undefined macro %s not interpolated!" woman-request))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-interpolate-macro (macro)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Interpolate (.de) or append (.am) expansion of MACRO into the buffer."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Could make this more efficient by checking which arguments are
|
|
|
|
|
;; actually used in the expansion!
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
;; Process arguments:
|
|
|
|
|
(let ((argno 0) (append (car macro))
|
|
|
|
|
argno-string formal-arg from actual-arg start)
|
|
|
|
|
(setq macro (cdr macro))
|
|
|
|
|
(while (not (eolp))
|
|
|
|
|
;; Get next actual arg:
|
|
|
|
|
(setq argno (1+ argno))
|
|
|
|
|
(setq argno-string (format "%d" argno))
|
|
|
|
|
(setq formal-arg (concat "\\\\\\$" argno-string)) ; regexp
|
|
|
|
|
(setq from (point))
|
|
|
|
|
(woman-forward-arg 'unquote 'noskip)
|
|
|
|
|
(setq actual-arg (buffer-substring from (point)))
|
|
|
|
|
(skip-chars-forward " \t") ; now skip following whitespace!
|
|
|
|
|
;; Replace formal arg with actual arg:
|
|
|
|
|
(setq start nil)
|
|
|
|
|
(while (setq start (string-match formal-arg macro start))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setq macro (replace-match actual-arg t t macro))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Delete any remaining formal arguments:
|
|
|
|
|
(setq start nil)
|
|
|
|
|
(while
|
|
|
|
|
(setq start (string-match "\\\\\\$." macro start))
|
|
|
|
|
(setq macro (replace-match "" t t macro)))
|
|
|
|
|
;; Replace .$ number register with actual arg:
|
|
|
|
|
;; (Do this properly via register mechanism later!)
|
|
|
|
|
(setq start nil)
|
|
|
|
|
(while
|
|
|
|
|
(setq start (string-match "\\\\n(\\.\\$" macro start)) ; regexp
|
|
|
|
|
(setq macro (replace-match argno-string t t macro)))
|
|
|
|
|
(if append
|
|
|
|
|
(forward-char)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman-delete-line 1))
|
|
|
|
|
(save-excursion ; leave point at start of new text
|
|
|
|
|
(insert macro))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Process strings:
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(defun woman-match-name ()
|
|
|
|
|
"Match and move over name of form: x, (xx or [xxx...].
|
|
|
|
|
Applies to number registers, fonts, strings/macros/diversions, and
|
|
|
|
|
special characters."
|
|
|
|
|
(cond ((= (following-char) ?\[ )
|
|
|
|
|
(forward-char)
|
|
|
|
|
(re-search-forward "[^]]+")
|
|
|
|
|
(forward-char)) ; skip closing ]
|
|
|
|
|
((= (following-char) ?\( )
|
|
|
|
|
(forward-char)
|
|
|
|
|
(re-search-forward ".."))
|
|
|
|
|
(t (re-search-forward "."))))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-strings (&optional to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Process ?roff string requests and escape sequences up to buffer position TO.
|
|
|
|
|
Strings are defined/updated by `.ds xx string' requests and
|
|
|
|
|
interpolated by `\*x' and `\*(xx' escapes."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Add support for .as and .rm?
|
|
|
|
|
(while
|
|
|
|
|
;; Find .ds requests and \* escapes:
|
|
|
|
|
(re-search-forward "\\(^[.'][ \t]*ds\\)\\|\\\\\\*" to t)
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(cond ((match-beginning 1) ; .ds
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(if (eolp) ; ignore if no argument
|
|
|
|
|
()
|
|
|
|
|
(re-search-forward "[^ \t\n]+")
|
|
|
|
|
(let ((string (match-string 0)))
|
|
|
|
|
(skip-chars-forward " \t")
|
2012-07-07 10:06:38 +00:00
|
|
|
|
(if (= ?\" (following-char))
|
|
|
|
|
;; Double-quote starts a string, eg.
|
|
|
|
|
;; .ds foo "blah...
|
|
|
|
|
;; is value blah... through to newline. There's no
|
|
|
|
|
;; closing " (per the groff manual), but rather any
|
|
|
|
|
;; further " is included literally in the string. Eg.
|
|
|
|
|
;; .ds foo ""
|
|
|
|
|
;; sets foo to a single " character.
|
|
|
|
|
(forward-char))
|
|
|
|
|
(setq string (cons string
|
|
|
|
|
(buffer-substring (point)
|
|
|
|
|
(line-end-position))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; This should be an update, but consing a new string
|
|
|
|
|
;; onto the front of the alist has the same effect:
|
|
|
|
|
(setq woman-string-alist (cons string woman-string-alist))
|
|
|
|
|
))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman-delete-line 1))
|
|
|
|
|
(t ; \*
|
|
|
|
|
(let ((beg (match-beginning 0)))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(woman-match-name)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let* ((stringname (match-string 0))
|
|
|
|
|
(string (assoc stringname woman-string-alist)))
|
|
|
|
|
(cond (string
|
|
|
|
|
(delete-region beg (point))
|
|
|
|
|
;; Temporary hack in case string starts with a
|
|
|
|
|
;; control character:
|
|
|
|
|
(if (bolp) (insert-before-markers "\\&"))
|
|
|
|
|
(insert-before-markers (cdr string)))
|
|
|
|
|
(t
|
|
|
|
|
(WoMan-warn "Undefined string %s not interpolated!"
|
|
|
|
|
stringname)
|
|
|
|
|
(cond (woman-ignore
|
|
|
|
|
;; Output above message once only per call
|
|
|
|
|
(delete-region beg (point))
|
|
|
|
|
(setq woman-string-alist
|
|
|
|
|
(cons (cons stringname "")
|
2009-07-06 02:17:31 +00:00
|
|
|
|
woman-string-alist))))))))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Process special character escapes \(xx:
|
|
|
|
|
|
|
|
|
|
(defconst woman-special-characters
|
|
|
|
|
;; To be built heuristically as required!
|
|
|
|
|
;; MUST insert all characters as strings for correct conversion to
|
|
|
|
|
;; multibyte representation!
|
|
|
|
|
'(("em" "--" "\276" . t) ; 3/4 Em dash
|
|
|
|
|
("bu" "*" "\267" . t) ; bullet
|
|
|
|
|
("fm" "'") ; foot mark
|
|
|
|
|
("co" "(C)" "\251") ; copyright
|
|
|
|
|
|
|
|
|
|
("pl" "+" "+" . t) ; math plus
|
|
|
|
|
("mi" "-" "-" . t) ; math minus
|
|
|
|
|
("**" "*" "*" . t) ; math star
|
|
|
|
|
("aa" "'" "\242" . t) ; acute accent
|
|
|
|
|
("ul" "_") ; underrule
|
|
|
|
|
|
|
|
|
|
("*S" "Sigma" "S" . t) ; Sigma
|
|
|
|
|
|
|
|
|
|
(">=" ">=" "\263" . t) ; >=
|
|
|
|
|
("<=" "<=" "\243" . t) ; <=
|
|
|
|
|
("->" "->" "\256" . t) ; right arrow
|
|
|
|
|
("<-" "<-" "\254" . t) ; left arrow
|
|
|
|
|
("mu" " x " "\264" . t) ; multiply
|
|
|
|
|
("+-" "+/-" "\261" . t) ; plus-minus
|
|
|
|
|
("bv" "|") ; bold vertical
|
|
|
|
|
|
|
|
|
|
;; groff etc. extensions:
|
2011-09-09 06:32:08 +00:00
|
|
|
|
;; List these via eg man -Tdvi groff_char > groff_char.dvi.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
("lq" "\"")
|
|
|
|
|
("rq" "\"")
|
|
|
|
|
("aq" "'")
|
|
|
|
|
("ha" "^")
|
|
|
|
|
("ti" "~")
|
2011-09-09 06:32:08 +00:00
|
|
|
|
("oq" "‘") ; u2018
|
|
|
|
|
("cq" "’") ; u2019
|
2011-09-09 06:34:59 +00:00
|
|
|
|
("hy" "‐") ; u2010
|
2000-05-08 14:32:17 +00:00
|
|
|
|
)
|
|
|
|
|
"Alist of special character codes with ASCII and extended-font equivalents.
|
|
|
|
|
Each alist elements has the form
|
|
|
|
|
(input-string ascii-string extended-font-string . use-symbol-font)
|
|
|
|
|
where
|
|
|
|
|
* `\\(input-string' is the ?roff encoding,
|
|
|
|
|
* `ascii-string' is the (multi-character) ASCII simulation,
|
|
|
|
|
* `extended-font-string' is the single-character string representing
|
|
|
|
|
the character position in the extended 256-character font, and
|
|
|
|
|
* `use-symbol-font' is t to indicate use of the symbol font or nil,
|
|
|
|
|
i.e. omitted, to indicate use of the default font.
|
|
|
|
|
Any element may be nil. Avoid control character codes (0 to \\37, \\180
|
|
|
|
|
to \\237) in `extended-font-string' for now, since they can be
|
|
|
|
|
displayed only with a modified display table.
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Use the WoMan command `woman-display-extended-fonts' or a character
|
2000-05-08 14:32:17 +00:00
|
|
|
|
map accessory to help construct this alist.")
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(defsubst woman-replace-match (newtext &optional face)
|
|
|
|
|
"Replace text matched by last search with NEWTEXT and return t.
|
|
|
|
|
Set NEWTEXT in face FACE if specified."
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(insert-before-markers newtext)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(if face (put-text-property (1- (point)) (point) 'face 'woman-symbol))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
t)
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman-special-characters (to)
|
2002-10-23 09:08:20 +00:00
|
|
|
|
"Process special character escapes \\(xx, \\[xxx] up to buffer position TO.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
\(This must be done AFTER translation, which may use special characters.)"
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(while (re-search-forward "\\\\\\(?:(\\(..\\)\\|\\[\\([[^]]+\\)\\]\\)" to t)
|
|
|
|
|
(let* ((name (or (match-string-no-properties 1)
|
|
|
|
|
(match-string-no-properties 2)))
|
|
|
|
|
(replacement (assoc name woman-special-characters)))
|
|
|
|
|
(unless
|
|
|
|
|
(and
|
2000-05-08 14:32:17 +00:00
|
|
|
|
replacement
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(cond ((and (cddr replacement)
|
|
|
|
|
(if (nthcdr 3 replacement)
|
|
|
|
|
;; Need symbol font:
|
|
|
|
|
(if woman-use-symbol-font
|
|
|
|
|
(woman-replace-match (nth 2 replacement)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
'woman-symbol))
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Need extended font:
|
|
|
|
|
(if woman-use-extended-font
|
|
|
|
|
(woman-replace-match (nth 2 replacement))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
((cadr replacement) ; Use ASCII simulation
|
2000-05-22 07:01:17 +00:00
|
|
|
|
(woman-replace-match (cadr replacement)))))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(WoMan-warn (concat "Special character "
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(if (match-beginning 1) "\\(%s" "\\[%s]")
|
2002-10-23 09:08:20 +00:00
|
|
|
|
" not interpolated!") name)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(if woman-ignore (woman-delete-match 0))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-display-extended-fonts ()
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Display table of glyphs of graphic characters and their octal codes.
|
|
|
|
|
All the octal codes in the ranges [32..127] and [160..255] are displayed
|
2000-05-08 14:32:17 +00:00
|
|
|
|
together with the corresponding glyphs from the default and symbol fonts.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Useful for constructing the alist variable `woman-special-characters'."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(with-output-to-temp-buffer "*WoMan Extended Font Map*"
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(with-current-buffer standard-output
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let ((i 32))
|
|
|
|
|
(while (< i 256)
|
|
|
|
|
(insert (format "\\%03o " i) (string i) " " (string i))
|
|
|
|
|
(put-text-property (1- (point)) (point)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
'face 'woman-symbol)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(insert " ")
|
|
|
|
|
(setq i (1+ i))
|
|
|
|
|
(when (= i 128) (setq i 160) (insert "\n"))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(if (zerop (% i 8)) (insert "\n")))))
|
2009-08-21 07:24:26 +00:00
|
|
|
|
(help-print-return-message)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Formatting macros that do not cause a break:
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; Bound locally by woman[012]-roff-buffer, and also, annoyingly and
|
|
|
|
|
;; confusingly, as a function argument. Use dynamically in
|
|
|
|
|
;; woman-unquote and woman-forward-arg.
|
|
|
|
|
(defvar woman-request)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-unquote (to)
|
|
|
|
|
"Delete any double-quote characters between point and TO.
|
|
|
|
|
Leave point at TO (which should be a marker)."
|
|
|
|
|
(let (in-quote)
|
|
|
|
|
(while (search-forward "\"" to 1)
|
|
|
|
|
(if (and in-quote (looking-at "\""))
|
|
|
|
|
;; Repeated double-quote represents single double-quote
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(if (or in-quote (looking-at ".*\"")) ; paired
|
|
|
|
|
(delete-char -1))
|
|
|
|
|
(setq in-quote (not in-quote))
|
|
|
|
|
))
|
|
|
|
|
(if in-quote
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(WoMan-warn "Unpaired \" in .%s arguments." woman-request))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defsubst woman-unquote-args ()
|
|
|
|
|
"Delete any double-quote characters up to the end of the line."
|
|
|
|
|
(woman-unquote (save-excursion (end-of-line) (point-marker))))
|
|
|
|
|
|
|
|
|
|
(defun woman1-roff-buffer ()
|
|
|
|
|
"Process non-breaking requests."
|
|
|
|
|
(let ((case-fold-search t)
|
2010-11-05 08:16:55 +00:00
|
|
|
|
woman-request fn woman1-unquote)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(while
|
|
|
|
|
;; Find next control line:
|
|
|
|
|
(re-search-forward woman-request-regexp nil t)
|
|
|
|
|
(cond
|
|
|
|
|
;; Construct woman function to call:
|
|
|
|
|
((setq fn (intern-soft
|
|
|
|
|
(concat "woman1-"
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(setq woman-request (match-string 1)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (get fn 'notfont) ; not a font-change request
|
|
|
|
|
(funcall fn)
|
|
|
|
|
;; Delete request or macro name:
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
;; If no args then apply to next line else unquote args
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; (woman1-unquote is used by called function):
|
|
|
|
|
(setq woman1-unquote (not (eolp)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eolp) (delete-char 1))
|
|
|
|
|
; ;; Hide leading control character in unquoted argument:
|
|
|
|
|
; (cond ((memq (following-char) '(?. ?'))
|
|
|
|
|
; (insert "\\&")
|
|
|
|
|
; (beginning-of-line)))
|
|
|
|
|
;; Call the appropriate function:
|
|
|
|
|
(funcall fn)
|
|
|
|
|
;; Hide leading control character in quoted argument (only):
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(if (and woman1-unquote (memq (following-char) '(?. ?')))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(insert "\\&"))))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;; Font-changing macros:
|
|
|
|
|
|
|
|
|
|
(defun woman1-B ()
|
|
|
|
|
".B -- Set words of current line in bold font."
|
|
|
|
|
(woman1-B-or-I ".ft B\n"))
|
|
|
|
|
|
|
|
|
|
(defun woman1-I ()
|
|
|
|
|
".I -- Set words of current line in italic font."
|
|
|
|
|
(woman1-B-or-I ".ft I\n"))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(defvar woman1-unquote) ; bound locally by woman1-roff-buffer
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun woman1-B-or-I (B-or-I)
|
|
|
|
|
".B/I -- Set words of current line in bold/italic font.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
B-OR-I is the appropriate complete control line."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Should NOT concatenate the arguments!
|
|
|
|
|
(insert B-or-I) ; because it might be a control line
|
|
|
|
|
;; Return to bol to process .SM/.B, .B/.if etc.
|
|
|
|
|
;; or start of first arg to hide leading control char.
|
|
|
|
|
(save-excursion
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(if woman1-unquote
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-unquote-args)
|
|
|
|
|
(while (looking-at "^[.']") (forward-line))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(delete-horizontal-space))
|
|
|
|
|
(insert "\\fR")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-SM ()
|
|
|
|
|
".SM -- Set the current line in small font, i.e. IGNORE!"
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defalias 'woman1-SB 'woman1-B)
|
|
|
|
|
;; .SB -- Set the current line in small bold font, i.e. just embolden!
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; (This is what /usr/local/share/groff/tmac/tmac.an does. The
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Linux man.7 is wrong about this!)
|
|
|
|
|
|
|
|
|
|
(defun woman1-BI ()
|
|
|
|
|
".BI -- Join words of current line alternating bold and italic fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fB" "\\fI")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-BR ()
|
|
|
|
|
".BR -- Join words of current line alternating bold and Roman fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fB" "\\fR")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-IB ()
|
|
|
|
|
".IB -- Join words of current line alternating italic and bold fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fI" "\\fB")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-IR ()
|
|
|
|
|
".IR -- Join words of current line alternating italic and Roman fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fI" "\\fR")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-RB ()
|
|
|
|
|
".RB -- Join words of current line alternating Roman and bold fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fR" "\\fB")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-RI ()
|
|
|
|
|
".RI -- Join words of current line alternating Roman and italic fonts."
|
|
|
|
|
(woman1-alt-fonts (list "\\fR" "\\fI")))
|
|
|
|
|
|
|
|
|
|
(defun woman1-alt-fonts (fonts)
|
|
|
|
|
"Join words using alternating fonts in FONTS, which MUST be a dynamic list."
|
|
|
|
|
(nconc fonts fonts) ; circular list!
|
|
|
|
|
(insert (car fonts))
|
|
|
|
|
;; Return to start of first arg to hide leading control char:
|
|
|
|
|
(save-excursion
|
|
|
|
|
(setq fonts (cdr fonts))
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; woman1-unquote is bound in woman1-roff-buffer.
|
|
|
|
|
(woman-forward-arg woman1-unquote 'concat)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(while (not (eolp))
|
|
|
|
|
(insert (car fonts))
|
|
|
|
|
(setq fonts (cdr fonts))
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(woman-forward-arg woman1-unquote 'concat))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(insert "\\fR")))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-forward-arg (&optional unquote concat)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Move forward over one ?roff argument, optionally unquoting and/or joining.
|
|
|
|
|
If optional arg UNQUOTE is non-nil then delete any argument quotes.
|
|
|
|
|
If optional arg CONCAT is non-nil then join arguments."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eq (following-char) ?\")
|
|
|
|
|
(progn
|
|
|
|
|
(if unquote (delete-char 1) (forward-char))
|
|
|
|
|
(re-search-forward "\"\\|$")
|
|
|
|
|
;; Repeated double-quote represents single double-quote
|
|
|
|
|
(while (eq (following-char) ?\") ; paired
|
|
|
|
|
(if unquote (delete-char 1) (forward-char))
|
|
|
|
|
(re-search-forward "\"\\|$"))
|
|
|
|
|
(if (eq (preceding-char) ?\")
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
|
(if unquote (delete-char -1))
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(WoMan-warn "Unpaired \" in .%s arguments." woman-request)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; (re-search-forward "[^\\\n] \\|$") ; inconsistent
|
|
|
|
|
(skip-syntax-forward "^ "))
|
|
|
|
|
(cond ((null concat) (skip-chars-forward " \t")) ; don't skip eol!
|
|
|
|
|
((eq concat 'noskip)) ; do not skip following whitespace
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(t (woman-delete-following-space))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; The following requests are not explicit font-change requests and
|
|
|
|
|
;; so are flagged `notfont' to turn off automatic request deletion
|
|
|
|
|
;; and further processing.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(put 'woman1-TP 'notfont t)
|
|
|
|
|
(defun woman1-TP ()
|
|
|
|
|
".TP -- After tag line, reset font to Roman for paragraph body."
|
|
|
|
|
;; Same for .IP, but forward only 1 line?
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; May be an `irrelevant' control line in the way, so ...
|
|
|
|
|
(forward-line)
|
|
|
|
|
(forward-line (if (looking-at "\\.\\S-+[ \t]*$") 2 1))
|
|
|
|
|
;; May be looking at control line, so ...
|
|
|
|
|
(insert ".ft R\n")))
|
|
|
|
|
|
|
|
|
|
(put 'woman1-ul 'notfont t)
|
|
|
|
|
(defun woman1-ul ()
|
|
|
|
|
".ul N -- Underline (italicize) the next N input lines, default N = 1."
|
|
|
|
|
(let ((N (if (eolp) 1 (woman-parse-numeric-arg)))) ; woman-get-numeric-arg ?
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
(insert ".ft I\n")
|
|
|
|
|
(forward-line N)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(insert ".ft R\n")))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;;; Other non-breaking requests:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; Hyphenation
|
|
|
|
|
;; Warnings commented out.
|
|
|
|
|
|
|
|
|
|
(put 'woman1-nh 'notfont t)
|
|
|
|
|
(defun woman1-nh ()
|
|
|
|
|
".nh -- No hyphenation, i.e. IGNORE!"
|
|
|
|
|
;; Must be handled here to avoid breaking!
|
|
|
|
|
;; (WoMan-log-1 ".nh request ignored -- hyphenation not supported!")
|
|
|
|
|
(woman-delete-whole-line))
|
|
|
|
|
|
|
|
|
|
(put 'woman1-hy 'notfont t)
|
|
|
|
|
(defun woman1-hy ()
|
|
|
|
|
".hy N -- Set hyphenation mode to N, i.e. IGNORE!"
|
|
|
|
|
;; (WoMan-log-1 ".hy request ignored -- hyphenation not supported!")
|
|
|
|
|
(woman-delete-whole-line))
|
|
|
|
|
|
|
|
|
|
(put 'woman1-hc 'notfont t)
|
|
|
|
|
(defun woman1-hc ()
|
|
|
|
|
".hc c -- Set hyphenation character to c, i.e. delete it!"
|
|
|
|
|
(let ((c (char-to-string (following-char))))
|
|
|
|
|
;; (WoMan-log
|
|
|
|
|
;; "Hyphenation character %s deleted -- hyphenation not supported!" c)
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
(setq c (concat "\\(" c "\\)\\|^[.'][ \t]*hc"))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (and (re-search-forward c nil t)
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(match-beginning 1))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(delete-char -1)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(put 'woman1-hw 'notfont t)
|
|
|
|
|
(defun woman1-hw ()
|
|
|
|
|
".hw words -- Set hyphenation exception words, i.e. IGNORE!"
|
|
|
|
|
;; (WoMan-log-1 ".hw request ignored -- hyphenation not supported!")
|
|
|
|
|
(woman-delete-whole-line))
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;;; Other non-breaking requests correctly ignored by nroff:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(put 'woman1-ps 'notfont t)
|
|
|
|
|
(defalias 'woman1-ps 'woman-delete-whole-line)
|
|
|
|
|
;; .ps -- Point size -- IGNORE!
|
|
|
|
|
|
|
|
|
|
(put 'woman1-ss 'notfont t)
|
|
|
|
|
(defalias 'woman1-ss 'woman-delete-whole-line)
|
|
|
|
|
;; .ss -- Space-character size -- IGNORE!
|
|
|
|
|
|
|
|
|
|
(put 'woman1-cs 'notfont t)
|
|
|
|
|
(defalias 'woman1-cs 'woman-delete-whole-line)
|
|
|
|
|
;; .cs -- Constant character space (width) mode -- IGNORE!
|
|
|
|
|
|
|
|
|
|
(put 'woman1-ne 'notfont t)
|
|
|
|
|
(defalias 'woman1-ne 'woman-delete-whole-line)
|
|
|
|
|
;; .ne -- Need vertical space -- IGNORE!
|
|
|
|
|
|
|
|
|
|
(put 'woman1-vs 'notfont t)
|
|
|
|
|
(defalias 'woman1-vs 'woman-delete-whole-line)
|
|
|
|
|
;; .vs -- Vertical base line spacing -- IGNORE!
|
|
|
|
|
|
|
|
|
|
(put 'woman1-bd 'notfont t)
|
|
|
|
|
(defalias 'woman1-bd 'woman-delete-whole-line)
|
|
|
|
|
;; .bd -- Embolden font -- IGNORE!
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;;; Non-breaking SunOS-specific macros:
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman1-TX ()
|
|
|
|
|
".TX t p -- Resolve SunOS abbrev t and join to p (usually punctuation)."
|
|
|
|
|
(insert "SunOS ")
|
|
|
|
|
(woman-forward-arg 'unquote 'concat))
|
|
|
|
|
|
|
|
|
|
(put 'woman1-IX 'notfont t)
|
|
|
|
|
(defalias 'woman1-IX 'woman-delete-whole-line)
|
|
|
|
|
;; .IX -- Index macro, for Sun internal use -- IGNORE!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Direct font selection:
|
|
|
|
|
|
|
|
|
|
(defconst woman-font-alist
|
|
|
|
|
'(("R" . default)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
("I" . woman-italic)
|
|
|
|
|
("B" . woman-bold)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
("P" . previous)
|
|
|
|
|
("1" . default)
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
("2" . woman-italic)
|
|
|
|
|
("3" . woman-bold) ; used in bash.1
|
2000-05-08 14:32:17 +00:00
|
|
|
|
)
|
|
|
|
|
"Alist of ?roff font indicators and woman font variables and names.")
|
|
|
|
|
|
|
|
|
|
(defun woman-change-fonts ()
|
|
|
|
|
"Process font changes."
|
|
|
|
|
;; ***** NEEDS REVISING IF IT WORKS OK *****
|
|
|
|
|
;; Paragraph .LP/PP/HP/IP/TP and font .B/.BI etc. macros reset font.
|
|
|
|
|
;; Should .SH/.SS reset font?
|
|
|
|
|
;; Font size setting macros (?) should reset font.
|
2004-03-27 12:07:09 +00:00
|
|
|
|
(let ((font-alist woman-font-alist) ; for local updating
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(previous-pos (point))
|
|
|
|
|
(previous-font 'default)
|
|
|
|
|
(current-font 'default))
|
|
|
|
|
(while
|
|
|
|
|
;; Find font requests, paragraph macros and font escapes:
|
|
|
|
|
(re-search-forward
|
|
|
|
|
"^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
|
2007-03-10 04:12:44 +00:00
|
|
|
|
(let (font beg notfont fescape)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Match font indicator and leave point at end of sequence:
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(cond ((match-beginning 2)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; .ft request found
|
|
|
|
|
(setq beg (match-beginning 0))
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(if (eolp) ; default is previous font
|
|
|
|
|
(setq font previous-font)
|
|
|
|
|
(looking-at "[^ \t\n]+"))
|
|
|
|
|
(forward-line)) ; end of control line and \n
|
2007-09-30 19:10:44 +00:00
|
|
|
|
((match-beginning 3)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Macro that resets font found
|
|
|
|
|
(setq font 'default))
|
2007-09-30 19:10:44 +00:00
|
|
|
|
((match-beginning 4)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; \f escape found
|
2007-03-10 04:12:44 +00:00
|
|
|
|
(setq beg (match-beginning 0)
|
|
|
|
|
fescape t)
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(woman-match-name))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(t (setq notfont t)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(unless notfont
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Get font name:
|
|
|
|
|
(or font
|
|
|
|
|
(let ((fontstring (match-string 0)))
|
2004-03-27 12:07:09 +00:00
|
|
|
|
(setq font (assoc fontstring font-alist)
|
|
|
|
|
;; NB: font-alist contains VARIABLE NAMES.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
font (if font
|
|
|
|
|
(cdr font)
|
|
|
|
|
(WoMan-warn "Unknown font %s." fontstring)
|
|
|
|
|
;; Output this message once only per call ...
|
2004-03-27 12:07:09 +00:00
|
|
|
|
(setq font-alist
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
(cons (cons fontstring 'woman-unknown)
|
2004-03-27 12:07:09 +00:00
|
|
|
|
font-alist))
|
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370
Remove "-face" suffix from woman faces
2005-06-10 Miles Bader <miles@gnu.org>
* lisp/woman.el (woman-italic, woman-bold, woman-unknown)
(woman-addition, woman-symbol-face):
Remove "-face" suffix from face names.
(woman-italic-face, woman-bold-face, woman-unknown-face)
(woman-addition-face):
New backward-compatibility aliases for renamed faces.
(woman-default-faces, woman-monochrome-faces, woman-man-buffer)
(woman-decode-region, woman-replace-match)
(woman-display-extended-fonts, woman-special-characters)
(woman-font-alist, woman-change-fonts, woman2-TH, woman2-SH):
Use renamed woman faces.
2005-06-10 08:07:29 +00:00
|
|
|
|
'woman-unknown)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
)))
|
|
|
|
|
;; Delete font control line or escape sequence:
|
|
|
|
|
(cond (beg (delete-region beg (point))
|
|
|
|
|
(if (eq font 'previous) (setq font previous-font))))
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; Deal with things like \fB.cvsrc\fR at the start of a line.
|
|
|
|
|
;; After removing the font control codes, this would
|
|
|
|
|
;; otherwise match woman-request-regexp. The "\\&" which is
|
|
|
|
|
;; inserted to prevent this is removed by woman2-process-escapes.
|
|
|
|
|
(and fescape
|
2007-03-17 17:57:38 +00:00
|
|
|
|
(looking-at woman-request-regexp)
|
2007-03-10 04:12:44 +00:00
|
|
|
|
(insert "\\&"))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-set-face previous-pos (point) current-font)
|
|
|
|
|
(if beg
|
|
|
|
|
;; Explicit font control
|
|
|
|
|
(setq previous-pos (point)
|
|
|
|
|
previous-font current-font)
|
|
|
|
|
;; Macro that resets font
|
|
|
|
|
;; (forward-line) ; DOES NOT WORK! but unnecessary?
|
|
|
|
|
;; Must process font changes in any paragraph tag!
|
|
|
|
|
(setq previous-pos (point)
|
|
|
|
|
previous-font 'default))
|
|
|
|
|
(setq current-font font)
|
|
|
|
|
)))
|
|
|
|
|
;; Set font after last request up to eob:
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-set-face previous-pos (point) current-font)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-set-face (from to face)
|
|
|
|
|
"Set the face of the text from FROM to TO to face FACE.
|
|
|
|
|
Ignore the default face and underline only word characters."
|
|
|
|
|
(or (eq face 'default) ; ignore
|
|
|
|
|
(not woman-fontify)
|
|
|
|
|
(if (face-underline-p face)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((face-no-ul (intern (concat (symbol-name face) "-no-ul"))))
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(while (< (point) to)
|
|
|
|
|
(skip-syntax-forward "w" to)
|
|
|
|
|
(put-text-property from (point) 'face face)
|
|
|
|
|
(setq from (point))
|
|
|
|
|
(skip-syntax-forward "^w" to)
|
|
|
|
|
(put-text-property from (point) 'face face-no-ul)
|
|
|
|
|
(setq from (point))
|
|
|
|
|
)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(put-text-property from to 'face face))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Output translation:
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; This is only set by woman2-tr. It is bound locally in woman2-roff-buffer.
|
|
|
|
|
;; It is also used by woman-translate. woman-translate may be called
|
|
|
|
|
;; outside the scope of woman2-roff-buffer (by experiment). Therefore
|
|
|
|
|
;; this used to be globally bound to nil, to avoid an error. Instead
|
|
|
|
|
;; we can use bound-and-true-p in woman-translate.
|
|
|
|
|
(defvar woman-translations)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
;; A list of the form (\"[ace]\" (a . b) (c . d) (e . ?\s)) or nil.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-get-next-char ()
|
|
|
|
|
"Return and delete next char in buffer, including special chars."
|
|
|
|
|
(if ;;(looking-at "\\\\(\\(..\\)")
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Match special \(xx and strings \*[xxx], \*(xx, \*x:
|
|
|
|
|
(looking-at "\\\\\\((..\\|\\*\\(\\[[^]]+\\]\\|(..\\|.\\)\\)")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(prog1 (match-string 0)
|
|
|
|
|
(woman-delete-match 0))
|
|
|
|
|
(prog1 (char-to-string (following-char))
|
|
|
|
|
(delete-char 1))))
|
|
|
|
|
|
|
|
|
|
(defun woman2-tr (to)
|
|
|
|
|
".tr abcde -- Translate a -> b, c -> d, ..., e -> space.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Format paragraphs upto TO. Supports special chars.
|
|
|
|
|
\(Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; This should be an update, but consing onto the front of the alist
|
|
|
|
|
;; has the same effect and match duplicates should not matter.
|
|
|
|
|
;; Initialize translation data structures:
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(let ((matches (car woman-translations))
|
|
|
|
|
(alist (cdr woman-translations))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
a b)
|
|
|
|
|
;; `matches' must be a string:
|
|
|
|
|
(setq matches
|
|
|
|
|
(concat (if matches (substring matches 1 -1)) "]"))
|
|
|
|
|
;; Process .tr arguments:
|
|
|
|
|
(while (not (eolp)) ; (looking-at "[ \t]*$") ???
|
|
|
|
|
(setq a (woman-get-next-char))
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(setq b " ")
|
|
|
|
|
(setq b (woman-get-next-char)))
|
|
|
|
|
(setq matches
|
|
|
|
|
(if (= (length a) 1)
|
|
|
|
|
(concat a matches)
|
|
|
|
|
(concat matches "\\|\\" a))
|
|
|
|
|
alist (cons (cons a b) alist)))
|
|
|
|
|
(delete-char 1) ; no blank line
|
|
|
|
|
;; Rebuild translations list:
|
|
|
|
|
(setq matches
|
|
|
|
|
(if (= (string-to-char matches) ?\])
|
|
|
|
|
(substring matches 3)
|
|
|
|
|
(concat "[" matches))
|
2010-11-05 08:16:55 +00:00
|
|
|
|
woman-translations (cons matches alist))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Format any following text:
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman2-format-paragraphs to)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defsubst woman-translate (to)
|
|
|
|
|
"Translate up to marker TO. Do this last of all transformations."
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(if (bound-and-true-p woman-translations)
|
|
|
|
|
(let ((matches (car woman-translations))
|
|
|
|
|
(alist (cdr woman-translations))
|
2010-08-18 02:33:13 +00:00
|
|
|
|
;; Translations are case-sensitive, eg ".tr ab" does not
|
|
|
|
|
;; affect "A" (bug#6849).
|
|
|
|
|
(case-fold-search nil))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(while (re-search-forward matches to t)
|
|
|
|
|
;; Done like this to retain text properties and
|
|
|
|
|
;; support translation of special characters:
|
|
|
|
|
(insert-before-markers-and-inherit
|
|
|
|
|
(cdr (assoc
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(match-beginning 0) (match-end 0))
|
|
|
|
|
alist)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-delete-match 0)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Registers:
|
|
|
|
|
|
|
|
|
|
(defvar woman-registers ; these are all read-only
|
|
|
|
|
'((".H" 24) (".V" 48) ; resolution in basic units
|
|
|
|
|
(".g" 0) ; not groff
|
|
|
|
|
;; (Iff emulating groff need to implement groff italic correction
|
|
|
|
|
;; \/, e.g. for pic.1)
|
|
|
|
|
(".i" left-margin) ; current indent
|
|
|
|
|
(".j" woman-adjust) ; current adjustment
|
|
|
|
|
(".l" fill-column) ; current line length
|
|
|
|
|
(".s" 12) ; current point size
|
|
|
|
|
(".u" (if woman-nofill 0 1)) ; 1/0 in fill/nofill mode
|
|
|
|
|
(".v" 48) ; current vertical line spacing
|
|
|
|
|
)
|
|
|
|
|
"Register alist: the key is the register name as a string.
|
|
|
|
|
Each element has the form (KEY VALUE . INC) -- inc may be nil.
|
|
|
|
|
Also bound locally in `woman2-roff-buffer'.")
|
|
|
|
|
|
|
|
|
|
(defun woman-mark-horizonal-position ()
|
|
|
|
|
"\\kx -- Store current horizontal position in INPUT LINE in register x."
|
|
|
|
|
(while (re-search-forward "\\\\k\\(.\\)" nil t)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(setq woman-registers
|
|
|
|
|
(cons (list (match-string 1) (current-column))
|
|
|
|
|
woman-registers))
|
|
|
|
|
(woman-delete-match 0)))
|
|
|
|
|
|
|
|
|
|
(defsubst woman2-process-escapes-to-eol (&optional numeric)
|
|
|
|
|
"Process remaining escape sequences up to eol.
|
|
|
|
|
Handle numeric arguments specially if optional argument NUMERIC is non-nil."
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(woman2-process-escapes (copy-marker (line-end-position) t) numeric))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-nr (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".nr R +/-N M -- Assign +/-N (wrt to previous value, if any) to register R.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
The increment for auto-incrementing is set to M.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Format paragraphs upto TO. (Breaks, but should not!)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let* ((name (buffer-substring
|
|
|
|
|
(point)
|
|
|
|
|
(progn (skip-syntax-forward "^ ") (point))))
|
|
|
|
|
(pm (progn ; increment
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(when (memq (char-after) '(?+ ?-))
|
|
|
|
|
(forward-char) (char-before))))
|
|
|
|
|
(value (if (eolp) ; no value
|
|
|
|
|
nil ; to be interpreted as zero
|
|
|
|
|
(woman2-process-escapes-to-eol 'numeric)
|
|
|
|
|
(woman-parse-numeric-arg)))
|
|
|
|
|
(inc (progn ; auto-increment
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(if (eolp) ; no value
|
|
|
|
|
nil ; to be interpreted as zero ???
|
|
|
|
|
(woman-parse-numeric-arg))))
|
|
|
|
|
(oldvalue (assoc name woman-registers)))
|
|
|
|
|
(when oldvalue
|
|
|
|
|
(setq oldvalue (cdr oldvalue)) ; (value . inc)
|
|
|
|
|
(unless inc (setq inc (cdr oldvalue))))
|
|
|
|
|
(cond ((null value)
|
|
|
|
|
(setq value 0) ; correct?
|
|
|
|
|
(WoMan-warn "nr %s -- null value assigned as zero!" name))
|
|
|
|
|
((symbolp value)
|
|
|
|
|
(setq value (list 'quote value))))
|
|
|
|
|
(if pm ; increment old value
|
|
|
|
|
(setq oldvalue (if oldvalue (car oldvalue) 0)
|
|
|
|
|
value (if (eq pm ?+)
|
|
|
|
|
(+ oldvalue value)
|
|
|
|
|
(- oldvalue value))))
|
|
|
|
|
(setq woman-registers
|
|
|
|
|
(cons (cons name (cons value inc)) woman-registers))
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
(woman2-format-paragraphs to)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Numeric (and "non-text") request arguments:
|
|
|
|
|
|
|
|
|
|
(defsubst woman-get-numeric-arg ()
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Get the value of a numeric argument at or after point.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
The argument can include the width function and scale indicators.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Assumes 10 characters per inch. Does not move point."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman2-process-escapes-to-eol 'numeric)
|
|
|
|
|
(save-excursion (woman-parse-numeric-arg)))
|
|
|
|
|
|
|
|
|
|
(defun woman-parse-numeric-arg ()
|
|
|
|
|
"Get the value of a numeric expression at or after point.
|
|
|
|
|
Unlike `woman-get-numeric-arg', leaves point after the argument.
|
|
|
|
|
The expression may be an argument in quotes."
|
|
|
|
|
(if (= (following-char) ?\") (forward-char))
|
|
|
|
|
;; Allow leading +/-:
|
|
|
|
|
(let ((value (if (looking-at "[+-]") 0 (woman-parse-numeric-value)))
|
|
|
|
|
op)
|
|
|
|
|
(while (cond
|
|
|
|
|
((looking-at "[+-/*%]") ; arithmetic operators
|
|
|
|
|
(forward-char)
|
|
|
|
|
(setq op (intern-soft (match-string 0)))
|
|
|
|
|
(setq value (funcall op value (woman-parse-numeric-value))))
|
|
|
|
|
((looking-at "[<=>]=?") ; relational operators
|
|
|
|
|
(goto-char (match-end 0))
|
2008-01-12 23:21:25 +00:00
|
|
|
|
(setq op (intern-soft
|
|
|
|
|
(if (string-equal (match-string 0) "==")
|
|
|
|
|
"="
|
|
|
|
|
(match-string 0))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq value (if (funcall op value (woman-parse-numeric-value))
|
|
|
|
|
1 0)))
|
|
|
|
|
((memq (setq op (following-char)) '(?& ?:)) ; Boolean and / or
|
|
|
|
|
(forward-char)
|
|
|
|
|
(setq value
|
|
|
|
|
;; and / or are special forms, not functions, in ELisp
|
|
|
|
|
(if (eq op ?&)
|
|
|
|
|
;; and
|
|
|
|
|
(if (> value 0)
|
|
|
|
|
(if (> (woman-parse-numeric-value) 0) 1 0)
|
|
|
|
|
;; skip second operand
|
|
|
|
|
(prog1 0 (woman-parse-numeric-value)))
|
|
|
|
|
;; or
|
|
|
|
|
(if (> value 0)
|
|
|
|
|
;; skip second operand
|
|
|
|
|
(prog1 1 (woman-parse-numeric-value))
|
|
|
|
|
(if (> (woman-parse-numeric-value) 0) 1 0))
|
|
|
|
|
)))
|
|
|
|
|
))
|
|
|
|
|
; (if (looking-at "[ \t\nRC\)\"]") ; R, C are tab types
|
|
|
|
|
; ()
|
|
|
|
|
; (WoMan-warn "Unimplemented numerical operator `%c' in %s"
|
|
|
|
|
; (following-char)
|
|
|
|
|
; (buffer-substring
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
; (line-beginning-position)
|
|
|
|
|
; (line-end-position)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
; (skip-syntax-forward "^ "))
|
|
|
|
|
value
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(defun woman-parse-numeric-value ()
|
|
|
|
|
"Get a single numeric value at or after point.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
The value can be a number register or width function (which assumes 10
|
|
|
|
|
characters per inch) and can include scale indicators. It may be an
|
|
|
|
|
expression in parentheses. Leaves point after the value."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Must replace every \' by some different single character first
|
|
|
|
|
;; before calling this function by calling
|
|
|
|
|
;; (woman2-process-escapes-to-eol 'numeric)
|
|
|
|
|
(if (eq (following-char) ?\()
|
|
|
|
|
;; Treat parenthesized expression as a single value.
|
|
|
|
|
(let (n)
|
|
|
|
|
(forward-char)
|
|
|
|
|
(setq n (woman-parse-numeric-arg))
|
2012-08-07 03:57:05 +00:00
|
|
|
|
(skip-syntax-forward " " (line-end-position))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eq (following-char) ?\))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(WoMan-warn "Parenthesis confusion in numeric expression!"))
|
|
|
|
|
n)
|
|
|
|
|
(let ((n (cond ((looking-at "[-+]?[.0-9]+") ; single number
|
|
|
|
|
;; currently needed to set match-end, even though
|
|
|
|
|
;; string-to-number returns 0 if number not parsed.
|
|
|
|
|
(string-to-number (match-string 0)))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
((looking-at "\\\\n\\([-+]\\)?\\(?:\
|
|
|
|
|
\\[\\([^]]+\\)\\]\\|\(\\(..\\)\\|\\(.\\)\\)")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; interpolate number register, maybe auto-incremented
|
|
|
|
|
(let* ((pm (match-string-no-properties 1))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(name (or (match-string-no-properties 2)
|
|
|
|
|
(match-string-no-properties 3)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(match-string-no-properties 4)))
|
|
|
|
|
(value (assoc name woman-registers)))
|
|
|
|
|
(if value
|
|
|
|
|
(let (inc)
|
|
|
|
|
(setq value (cdr value) ; (value . inc)
|
|
|
|
|
inc (cdr value)
|
|
|
|
|
;; eval internal (.X) registers
|
|
|
|
|
;; stored as lisp variable names:
|
|
|
|
|
value (eval (car value)))
|
|
|
|
|
(if (and pm inc) ; auto-increment
|
|
|
|
|
(setq value
|
|
|
|
|
(funcall (intern-soft pm) value inc)
|
|
|
|
|
woman-registers
|
|
|
|
|
(cons (cons name (cons value inc))
|
|
|
|
|
woman-registers)))
|
|
|
|
|
value)
|
|
|
|
|
(WoMan-warn "Undefined register %s defaulted to 0."
|
|
|
|
|
name)
|
|
|
|
|
0) ; default to zero
|
|
|
|
|
))
|
|
|
|
|
((re-search-forward
|
2002-10-23 09:08:20 +00:00
|
|
|
|
;; Delimiter can be special char escape \[xxx],
|
|
|
|
|
;; \(xx or single normal char (usually '):
|
|
|
|
|
"\\=\\\\w\\(\\\\\\[[^]]+\\]\\|\\\\(..\\|.\\)" nil t)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let ((from (match-end 0))
|
|
|
|
|
(delim (regexp-quote (match-string 1))))
|
|
|
|
|
(if (re-search-forward delim nil t)
|
|
|
|
|
;; Return width of string:
|
|
|
|
|
(- (match-beginning 0) from)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(WoMan-warn "Width escape delimiter error!")))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (null n)
|
|
|
|
|
;; ERROR -- should handle this better!
|
|
|
|
|
(progn
|
|
|
|
|
(WoMan-warn "Numeric/register argument error: %s"
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(point)
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(line-end-position)))
|
2012-08-07 03:57:05 +00:00
|
|
|
|
(skip-syntax-forward "^ " (line-end-position))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
0)
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
;; Check for scale factor:
|
|
|
|
|
(if
|
|
|
|
|
(cond
|
|
|
|
|
((looking-at "\\s ") nil) ; stay put!
|
|
|
|
|
((looking-at "[mnuv]")) ; ignore for now
|
|
|
|
|
((looking-at "i") (setq n (* n 10))) ; inch
|
|
|
|
|
((looking-at "c") (setq n (* n 3.9))) ; cm
|
2012-10-29 10:30:11 +00:00
|
|
|
|
((let ((case-fold-search nil))
|
|
|
|
|
(looking-at "P"))
|
|
|
|
|
(setq n (* n 1.7))) ; Pica
|
2000-05-08 14:32:17 +00:00
|
|
|
|
((looking-at "p") (setq n (* n 0.14))) ; point
|
|
|
|
|
;; NB: May be immediately followed by + or -, etc.,
|
|
|
|
|
;; in which case do nothing and return nil.
|
|
|
|
|
)
|
|
|
|
|
(goto-char (match-end 0)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(if (numberp n) (round n) n)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; VERTICAL FORMATTING -- Formatting macros that cause a break:
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; Vertical spacing philosophy:
|
|
|
|
|
;; Delete all vertical space as it is encountered. Then insert
|
|
|
|
|
;; vertical space only before text, as required.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-roff-buffer ()
|
|
|
|
|
"Process breaks. Format paragraphs and headings."
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(to (make-marker))
|
|
|
|
|
(canonically-space-region
|
|
|
|
|
(symbol-function 'canonically-space-region))
|
|
|
|
|
(insert-and-inherit (symbol-function 'insert-and-inherit))
|
|
|
|
|
(set-text-properties (symbol-function 'set-text-properties))
|
|
|
|
|
(woman-registers woman-registers)
|
2010-11-05 08:16:55 +00:00
|
|
|
|
fn woman-request woman-translations
|
2000-05-08 14:32:17 +00:00
|
|
|
|
tab-stop-list)
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(set-marker-insertion-type to t)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; ?roff does not squeeze multiple spaces, but does fill, so...
|
|
|
|
|
(fset 'canonically-space-region 'ignore)
|
|
|
|
|
;; Try to avoid spaces inheriting underlines from preceding text!
|
|
|
|
|
(fset 'insert-and-inherit (symbol-function 'insert))
|
|
|
|
|
(fset 'set-text-properties 'ignore)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(while
|
|
|
|
|
;; Find next control line:
|
2007-03-10 04:12:44 +00:00
|
|
|
|
(re-search-forward woman-request-regexp nil t)
|
|
|
|
|
(cond
|
|
|
|
|
;; Construct woman function to call:
|
|
|
|
|
((setq fn (intern-soft
|
|
|
|
|
(concat "woman2-"
|
2010-11-05 08:16:55 +00:00
|
|
|
|
(setq woman-request (match-string 1)))))
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; Delete request or macro name:
|
|
|
|
|
(woman-delete-match 0))
|
2011-11-20 02:29:42 +00:00
|
|
|
|
;; Unrecognized request:
|
2007-03-10 04:12:44 +00:00
|
|
|
|
((prog1 nil
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; (WoMan-warn ".%s request ignored!" woman-request)
|
|
|
|
|
(WoMan-warn-ignored woman-request "ignored!")
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; (setq fn 'woman2-LP)
|
|
|
|
|
;; AVOID LEAVING A BLANK LINE!
|
|
|
|
|
;; (setq fn 'woman2-format-paragraphs)
|
|
|
|
|
))
|
|
|
|
|
;; .LP assumes it is at eol and leaves a (blank) line,
|
|
|
|
|
;; so leave point at end of line before paragraph:
|
|
|
|
|
((or (looking-at "[ \t]*$") ; no argument
|
|
|
|
|
woman-ignore) ; ignore all
|
|
|
|
|
;; (beginning-of-line) (kill-line)
|
|
|
|
|
;; AVOID LEAVING A BLANK LINE!
|
|
|
|
|
(beginning-of-line) (woman-delete-line 1))
|
|
|
|
|
(t (end-of-line) (insert ?\n))
|
|
|
|
|
)
|
|
|
|
|
(if (not (or fn
|
|
|
|
|
(and (not (memq (following-char) '(?. ?')))
|
|
|
|
|
(setq fn 'woman2-format-paragraphs))))
|
|
|
|
|
()
|
|
|
|
|
;; Find next control line:
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(if (equal woman-request "TS")
|
|
|
|
|
(set-marker to (woman-find-next-control-line "TE"))
|
|
|
|
|
(set-marker to (woman-find-next-control-line)))
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; Call the appropriate function:
|
|
|
|
|
(funcall fn to)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (not (eobp)) ; This should not happen, but ...
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(woman2-format-paragraphs (copy-marker (point-max) t)
|
|
|
|
|
woman-left-margin))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(fset 'canonically-space-region canonically-space-region)
|
|
|
|
|
(fset 'set-text-properties set-text-properties)
|
|
|
|
|
(fset 'insert-and-inherit insert-and-inherit)
|
|
|
|
|
(set-marker to nil))))
|
|
|
|
|
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(defun woman-find-next-control-line (&optional pat)
|
|
|
|
|
"Find and return start of next control line.
|
|
|
|
|
PAT, if non-nil, specifies an additional component of the control
|
|
|
|
|
line regexp to search for, which is appended to the default
|
|
|
|
|
regexp, \"\\(\\\\c\\)?\\n[.']\"."
|
|
|
|
|
(let ((pattern (concat "\\(\\\\c\\)?\n[.']" pat))
|
|
|
|
|
to)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
;; Must handle
|
|
|
|
|
;; ...\c
|
|
|
|
|
;; .br (and other requests?)
|
|
|
|
|
;; by deleting both the \c and the following request.
|
|
|
|
|
;; BEWARE THAT THIS CODE MAY BE UNRELIABLE!!!!!
|
|
|
|
|
(while
|
|
|
|
|
(and
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(setq to (re-search-forward pattern nil t))
|
2007-09-30 19:10:44 +00:00
|
|
|
|
(match-beginning 1)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(looking-at "br"))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(woman-delete-line 2)))
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(if to
|
|
|
|
|
(- to (+ 1 (length pat)))
|
|
|
|
|
(point-max))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-PD (to)
|
|
|
|
|
".PD d -- Set the interparagraph distance to d.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Round to whole lines, default 1 line. Format paragraphs upto TO.
|
2002-10-23 09:08:20 +00:00
|
|
|
|
\(Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; .ie \\n[.$] .nr PD (v;\\$1)
|
|
|
|
|
;; .el .nr PD .4v>?\n[.V]
|
|
|
|
|
(woman-set-interparagraph-distance)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman-set-interparagraph-distance ()
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Set the interparagraph distance from a .PD request at point."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq woman-interparagraph-distance
|
|
|
|
|
(if (eolp) 1 (woman-get-numeric-arg)))
|
|
|
|
|
;; Should allow .PD 0 to set zero line spacing
|
|
|
|
|
(woman-delete-line 1)) ; ignore remaining args
|
|
|
|
|
|
|
|
|
|
(defsubst woman-interparagraph-space ()
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Set variable `woman-leave-blank-lines' from `woman-interparagraph-distance'."
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setq woman-leave-blank-lines woman-interparagraph-distance))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-TH (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".TH n c x v m -- Begin a man page. Format paragraphs upto TO.
|
|
|
|
|
n is the name of the page in chapter c\; x is extra commentary\;
|
|
|
|
|
v alters page foot left; m alters page head center.
|
|
|
|
|
\(Should set prevailing indent and tabs to 5.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-forward-arg 'unquote 'concat)
|
|
|
|
|
(insert ?\()
|
|
|
|
|
(woman-forward-arg 'unquote 'concat)
|
|
|
|
|
(insert ?\))
|
|
|
|
|
(let ((start (point)) here)
|
|
|
|
|
(while (not (eolp))
|
|
|
|
|
(cond ((looking-at "\"\"[ \t]")
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(delete-char 2)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(setq here (point))
|
|
|
|
|
(insert " -- ")
|
|
|
|
|
(woman-forward-arg 'unquote 'concat)
|
|
|
|
|
;; Delete repeated arguments:
|
2008-04-11 02:30:24 +00:00
|
|
|
|
(if (string-equal (buffer-substring here (point))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(buffer-substring start here))
|
2008-04-11 02:24:15 +00:00
|
|
|
|
(delete-region here (point)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Embolden heading (point is at end of heading):
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(woman-set-face (line-beginning-position) (point) 'woman-bold)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(forward-line)
|
|
|
|
|
(delete-blank-lines)
|
|
|
|
|
(setq woman-left-margin woman-default-indent)
|
|
|
|
|
(setq woman-prevailing-indent woman-default-indent)
|
|
|
|
|
(woman2-format-paragraphs to woman-left-margin))
|
|
|
|
|
|
|
|
|
|
(defun woman2-SH (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".SH -- Sub-head. Leave blank line and subhead.
|
|
|
|
|
Format paragraphs upto TO. Set prevailing indent to 5."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eolp) ; If no args then
|
|
|
|
|
(delete-char 1) ; apply to next line
|
|
|
|
|
(woman-unquote-args) ; else unquote to end of heading
|
|
|
|
|
(beginning-of-line))
|
|
|
|
|
(woman2-process-escapes-to-eol)
|
|
|
|
|
(woman-leave-blank-lines woman-interparagraph-distance)
|
|
|
|
|
(setq woman-leave-blank-lines nil)
|
|
|
|
|
;; Optionally embolden heading (point is at beginning of heading):
|
|
|
|
|
(if woman-bold-headings
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(woman-set-face (point) (line-end-position) 'woman-bold))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(forward-line)
|
|
|
|
|
(setq woman-left-margin woman-default-indent
|
|
|
|
|
woman-nofill nil) ; fill output lines
|
|
|
|
|
(setq woman-prevailing-indent woman-default-indent)
|
|
|
|
|
(woman2-format-paragraphs to woman-left-margin))
|
|
|
|
|
|
|
|
|
|
(defun woman2-SS (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".SS -- Sub-sub-head. Like .SH but indent heading 3 spaces.
|
|
|
|
|
Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eolp) ; If no args then
|
|
|
|
|
(delete-char 1)) ; apply to next line.
|
|
|
|
|
(insert " ")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman2-SH to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-LP (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".LP,.PP -- Begin paragraph. Set prevailing indent to 5.
|
|
|
|
|
Leave 1 blank line. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman-interparagraph-space)
|
|
|
|
|
(setq woman-prevailing-indent woman-default-indent)
|
|
|
|
|
(woman2-format-paragraphs to woman-left-margin))
|
|
|
|
|
|
|
|
|
|
(defalias 'woman2-PP 'woman2-LP)
|
|
|
|
|
(defalias 'woman2-P 'woman2-LP)
|
|
|
|
|
|
|
|
|
|
(defun woman2-ns (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".ns -- Turn on no-space mode. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Should not cause a break!
|
|
|
|
|
(woman-delete-line 1) ; ignore argument(s)
|
|
|
|
|
(setq woman-nospace t)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-rs (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".rs -- Turn off no-space mode. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Should not cause a break!
|
|
|
|
|
(woman-delete-line 1) ; ignore argument(s)
|
|
|
|
|
(setq woman-nospace nil)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-sp (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".sp N -- If N > 0 then leave 1 blank line. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let ((N (if (eolp) 1 (woman-get-numeric-arg))))
|
|
|
|
|
(if (>= N 0)
|
|
|
|
|
(woman-delete-line 1) ; ignore argument(s)
|
|
|
|
|
(setq woman-negative-vertical-space t)
|
|
|
|
|
(insert ".sp ")
|
|
|
|
|
(forward-line))
|
|
|
|
|
(setq woman-leave-blank-lines N)
|
|
|
|
|
(woman2-format-paragraphs to)))
|
|
|
|
|
|
|
|
|
|
(defun woman-negative-vertical-space (from)
|
|
|
|
|
".sp N with N < 0 => overlap following with preceding lines at FROM."
|
|
|
|
|
;; Run by woman-decode-region if necessary -- not usually required.
|
|
|
|
|
(WoMan-warn "Negative vertical spacing support is experimental!")
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(while
|
|
|
|
|
;; Find next control line:
|
|
|
|
|
(re-search-forward "^\\.sp " nil t)
|
|
|
|
|
(let ((N (woman-get-numeric-arg))
|
|
|
|
|
overlap overwritten)
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
(setq from (point)
|
|
|
|
|
overlap (buffer-substring from
|
|
|
|
|
(progn (forward-line (- N)) (point))))
|
|
|
|
|
(delete-region from (point))
|
|
|
|
|
(forward-line N)
|
|
|
|
|
(let ((imax (length overlap))
|
|
|
|
|
(i 0) c)
|
|
|
|
|
(while (< i imax)
|
|
|
|
|
(setq c (aref overlap i))
|
|
|
|
|
(cond ((eq c ?\n) ; skip
|
|
|
|
|
(forward-line))
|
|
|
|
|
((eolp) ; extend line
|
|
|
|
|
;; Insert character INCLUDING TEXT PROPERTIES:
|
|
|
|
|
;; (insert (substring overlap i (1+ i)))
|
|
|
|
|
(let ((eol (string-match "\n" overlap i)))
|
|
|
|
|
(insert (substring overlap i eol))
|
|
|
|
|
(setq i (or eol imax)))
|
|
|
|
|
)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
((eq c ?\s) ; skip
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(forward-char))
|
|
|
|
|
((eq c ?\t) ; skip
|
|
|
|
|
(if (eq (following-char) ?\t)
|
|
|
|
|
(forward-char) ; both tabs, just skip
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(dotimes (i woman-tab-width)
|
|
|
|
|
(if (eolp)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(insert ?\s) ; extend line
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(forward-char)) ; skip
|
2000-05-08 14:32:17 +00:00
|
|
|
|
)))
|
|
|
|
|
(t
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(if (or (eq (following-char) ?\s) ; overwrite OK
|
2000-05-08 14:32:17 +00:00
|
|
|
|
overwritten) ; warning only once per ".sp -"
|
|
|
|
|
()
|
|
|
|
|
(setq overwritten t)
|
|
|
|
|
(WoMan-warn
|
|
|
|
|
"Character(s) overwritten by negative vertical spacing in line %d"
|
|
|
|
|
(count-lines 1 (point))))
|
|
|
|
|
(delete-char 1) (insert (substring overlap i (1+ i)))))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setq i (1+ i)))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; The following function should probably do ALL width and number
|
|
|
|
|
;; register interpolation.
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
(defun woman2-process-escapes (to &optional numeric)
|
|
|
|
|
"Process remaining escape sequences up to marker TO, preserving point.
|
|
|
|
|
Optional argument NUMERIC, if non-nil, means the argument is numeric."
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 23:13:41 +00:00
|
|
|
|
(cl-assert (and (markerp to) (marker-insertion-type to)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; The first two cases below could be merged (maybe)!
|
|
|
|
|
(let ((from (point)))
|
|
|
|
|
;; Discard zero width filler character used to hide leading dots
|
2010-03-16 17:24:44 +00:00
|
|
|
|
;; and zero width characters.
|
|
|
|
|
(while (re-search-forward "\\\\[&|^]" to t)
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
;; If on a line by itself, consume newline as well (Bug#3651).
|
2012-07-07 10:10:47 +00:00
|
|
|
|
;; But not in a .nf region, preserve all newlines in that case.
|
|
|
|
|
(and (not woman-nofill)
|
|
|
|
|
(eq (char-before (match-beginning 0)) ?\n)
|
2010-03-16 17:24:44 +00:00
|
|
|
|
(eq (char-after (match-beginning 0)) ?\n)
|
|
|
|
|
(delete-char 1)))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char from)
|
|
|
|
|
;; Interrupt text processing -- CONTINUE current text with the
|
|
|
|
|
;; next text line (after any control lines, unless processing to
|
|
|
|
|
;; eol):
|
|
|
|
|
(while (re-search-forward "\\\\c.*\n?" to t)
|
|
|
|
|
(woman-delete-match 0))
|
|
|
|
|
;; but do not delete the final newline ...
|
|
|
|
|
(if (and (or (eobp) (= (point) to)) (not (bolp)))
|
|
|
|
|
(insert-before-markers ?\n))
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman-translate to)
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(woman-special-characters to)
|
|
|
|
|
(goto-char from)
|
|
|
|
|
;; Printable version of the current escape character, ASSUMED to be `\'
|
|
|
|
|
;; This must be done LAST of all escape processing!
|
|
|
|
|
;; Done like this to preserve any text properties of the `\'
|
|
|
|
|
(while (search-forward "\\" to t)
|
|
|
|
|
(let ((c (following-char)))
|
2011-09-18 16:03:48 +00:00
|
|
|
|
;; Some other escapes, such as \f, are handled in
|
|
|
|
|
;; `woman0-process-escapes'.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(cond ((eq c ?') ; \' -> '
|
|
|
|
|
(delete-char -1)
|
|
|
|
|
(cond (numeric ; except in numeric args, \' -> `
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(insert ?`))))
|
|
|
|
|
((eq c ?\( )) ; uninterpreted special character
|
2009-07-06 02:17:31 +00:00
|
|
|
|
; \(.. -- do nothing
|
2000-05-08 14:32:17 +00:00
|
|
|
|
((eq c ?t) ; non-interpreted tab \t
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(delete-char -1)
|
|
|
|
|
(insert "\t"))
|
|
|
|
|
((and numeric
|
|
|
|
|
(memq c '(?w ?n ?h)))) ; leave \w, \n, \h (?????)
|
2011-09-18 16:03:48 +00:00
|
|
|
|
((eq c ?l) (woman-horizontal-line)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char from)
|
|
|
|
|
;; Process non-default tab settings:
|
|
|
|
|
(cond (tab-stop-list
|
|
|
|
|
(while (search-forward "\t" to t)
|
|
|
|
|
(woman-tab-to-tab-stop))
|
|
|
|
|
(goto-char from)))
|
|
|
|
|
|
|
|
|
|
;; Must replace \' by something before processing \w, done above.
|
|
|
|
|
|
|
|
|
|
;; Replace all `\w' and `\n' escapes:
|
|
|
|
|
;; (This may be a bit too recursive!)
|
|
|
|
|
(while (re-search-forward "\\\\[nw]" to t)
|
|
|
|
|
(let ((from (match-beginning 0)) N)
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(setq N (woman-parse-numeric-value))
|
|
|
|
|
(delete-region from (point))
|
|
|
|
|
;; Interpolate value:
|
|
|
|
|
(insert-before-markers (number-to-string N))))
|
|
|
|
|
(goto-char from)))
|
|
|
|
|
|
|
|
|
|
(defun woman-horizontal-line ()
|
|
|
|
|
"\\l'Nc' -- Draw a horizontal line of length N using character c, default _."
|
|
|
|
|
(delete-char -1)
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(looking-at "\\(.\\)\\(.*\\)\\1")
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(forward-char 1)
|
2006-09-22 21:35:30 +00:00
|
|
|
|
(let* ((to (match-end 2))
|
2006-09-22 19:09:45 +00:00
|
|
|
|
(from (match-beginning 0))
|
|
|
|
|
(N (woman-parse-numeric-arg))
|
|
|
|
|
(c (if (< (point) to) (following-char) ?_)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(delete-region from to)
|
|
|
|
|
(delete-char 1)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(insert (make-string N c))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;; 4. Text Filling, Adjusting, and Centering
|
|
|
|
|
|
|
|
|
|
(defun woman2-br (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".br -- Break. Leave no blank line. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-fi (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".fi -- Fill subsequent output lines. Leave no blank line.
|
|
|
|
|
Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq woman-nofill nil)
|
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
;; Preserve any final blank line in the nofill region:
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(if (looking-at "[ \t]*$") (setq woman-leave-blank-lines 1)))
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-nf (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".nf -- Nofill. Subsequent lines are neither filled nor adjusted.
|
|
|
|
|
Input text lines are copied directly to output lines without regard
|
2009-07-06 02:17:31 +00:00
|
|
|
|
for the current line length. Format paragraphs up to TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq woman-nofill t)
|
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-ad (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".ad c -- Line adjustment is begun (once fill mode is on).
|
|
|
|
|
Set justification mode to c if specified.
|
|
|
|
|
Format paragraphs upto TO. (Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; c = l -- left, r -- right, c -- center, b or n -- both,
|
|
|
|
|
;; absent -- unchanged. Initial mode adj,both.
|
|
|
|
|
(setq woman-adjust
|
|
|
|
|
(cond ((eolp) woman-adjust-previous)
|
|
|
|
|
((eq (following-char) ?l) woman-adjust-left)
|
|
|
|
|
((eq (following-char) ?r) woman-adjust-right)
|
|
|
|
|
((eq (following-char) ?c) woman-adjust-center)
|
|
|
|
|
((memq (following-char) '(?b ?n)) woman-adjust-both)
|
|
|
|
|
(t (woman-get-numeric-arg))
|
|
|
|
|
)
|
|
|
|
|
woman-justify (nth woman-adjust woman-justify-list))
|
|
|
|
|
(woman-delete-line 1) ; ignore any remaining arguments
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-na (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".na -- No adjusting. Format paragraphs upto TO.
|
2002-10-23 09:08:20 +00:00
|
|
|
|
\(Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq woman-adjust-previous woman-adjust
|
|
|
|
|
woman-justify-previous woman-justify
|
|
|
|
|
woman-adjust woman-adjust-left ; fill but do not adjust
|
|
|
|
|
woman-justify (nth woman-adjust woman-justify-list))
|
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
;;; The main formatting functions:
|
|
|
|
|
|
|
|
|
|
(defun woman-leave-blank-lines (&optional leave)
|
|
|
|
|
"Delete all blank lines around point.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
Leave one blank line if optional argument LEAVE is non-nil and
|
|
|
|
|
non-zero, or if LEAVE is nil and variable `woman-leave-blank-lines' is
|
|
|
|
|
non-nil and non-zero."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; ***** It may suffice to delete only lines ABOVE point! *****
|
|
|
|
|
;; NOTE: Function arguments are evaluated left to right
|
|
|
|
|
;; (*note (elisp)Function Forms::.).
|
|
|
|
|
(delete-region
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (not (eq (skip-syntax-backward " ") 0))
|
|
|
|
|
(forward-line)) ; forward-char ?
|
|
|
|
|
(point))
|
|
|
|
|
(progn (skip-syntax-forward " ")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(point)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(unless woman-nospace
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (or (null leave) (eq leave 0))
|
|
|
|
|
;; output any `pending' vertical space ...
|
|
|
|
|
(setq leave woman-leave-blank-lines))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(if (and leave (> leave 0)) (insert-before-markers ?\n)))
|
|
|
|
|
(setq woman-leave-blank-lines nil))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;; `fill-region-as-paragraph' in `fill.el' appears to be the principal
|
|
|
|
|
;; text filling function, so that is what I use here.
|
|
|
|
|
|
|
|
|
|
(defvar woman-temp-indent nil)
|
|
|
|
|
|
|
|
|
|
(defun woman2-format-paragraphs (to &optional new-left)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Indent, fill and adjust paragraphs upto TO to current left margin.
|
|
|
|
|
If optional arg NEW-LEFT is non-nil then reset current left margin.
|
|
|
|
|
If `woman-nofill' is non-nil then indent without filling or adjusting."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Blank space should only ever be output before text.
|
|
|
|
|
(if new-left (setq left-margin new-left))
|
|
|
|
|
(if (looking-at "^\\s *$")
|
|
|
|
|
;; A blank line should leave a space like .sp 1 (p. 14).
|
|
|
|
|
(setq woman-leave-blank-lines 1))
|
|
|
|
|
(skip-syntax-forward " ")
|
|
|
|
|
;; Successive control lines are sufficiently common to be worth a
|
|
|
|
|
;; special case (maybe):
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(unless (>= (point) to)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-reset-nospace)
|
|
|
|
|
(woman2-process-escapes to 'numeric)
|
|
|
|
|
(if woman-nofill
|
|
|
|
|
;; Indent without filling or adjusting ...
|
|
|
|
|
(progn
|
|
|
|
|
(woman-leave-blank-lines)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(when woman-temp-indent
|
|
|
|
|
(indent-to woman-temp-indent)
|
|
|
|
|
(forward-line))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(indent-rigidly (point) to left-margin)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman-horizontal-escapes to))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Fill and justify ...
|
|
|
|
|
;; Blank lines and initial spaces cause a break.
|
|
|
|
|
(while (< (point) to)
|
|
|
|
|
(woman-leave-blank-lines)
|
|
|
|
|
(let ((from (point)))
|
|
|
|
|
;; Indent first lin of paragraph:
|
|
|
|
|
(indent-to (or woman-temp-indent left-margin))
|
|
|
|
|
(woman-horizontal-escapes to) ; 7 October 1999
|
|
|
|
|
;; Find the beginning of the next paragraph:
|
|
|
|
|
(forward-line)
|
|
|
|
|
(and (re-search-forward "\\(^\\s *$\\)\\|\\(^\\s +\\)" to 1)
|
|
|
|
|
;; A blank line should leave a space like .sp 1 (p. 14).
|
|
|
|
|
(eolp)
|
|
|
|
|
(skip-syntax-forward " ")
|
|
|
|
|
(setq woman-leave-blank-lines 1))
|
2006-10-15 19:13:44 +00:00
|
|
|
|
;; This shouldn't happen, but in case it does (e.g. for
|
|
|
|
|
;; badly-formatted manfiles with no terminating newline),
|
|
|
|
|
;; avoid an infinite loop.
|
|
|
|
|
(unless (and (eolp) (eobp))
|
|
|
|
|
(beginning-of-line))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; If a single short line then just leave it.
|
|
|
|
|
;; This is necessary to preserve some table layouts.
|
|
|
|
|
;; PROBABLY NOT NECESSARY WITH SQUEEZE MODIFICATION !!!!!
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(when (or (> (count-lines from (point)) 1)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-char)
|
|
|
|
|
(> (current-column) fill-column)))
|
|
|
|
|
;; NOSQUEEZE has no effect if JUSTIFY is full, so redefine
|
|
|
|
|
;; canonically-space-region, see above.
|
|
|
|
|
(if (and woman-temp-indent (< woman-temp-indent left-margin))
|
|
|
|
|
(let ((left-margin woman-temp-indent))
|
|
|
|
|
(fill-region-as-paragraph from (point) woman-justify)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(save-excursion
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(goto-char from)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(setq from (point)))))
|
|
|
|
|
(fill-region-as-paragraph from (point) woman-justify)))))
|
|
|
|
|
(setq woman-temp-indent nil)))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Tagged, indented and hanging paragraphs:
|
|
|
|
|
|
|
|
|
|
(defun woman2-TP (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".TP i -- Set prevailing indent to i. Format paragraphs upto TO.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Begin indented paragraph with hanging tag given by next text line.
|
|
|
|
|
If tag doesn't fit, place it on a separate line."
|
|
|
|
|
(let ((i (woman2-get-prevailing-indent)))
|
|
|
|
|
(woman-leave-blank-lines woman-interparagraph-distance)
|
|
|
|
|
(woman2-tagged-paragraph to i)))
|
|
|
|
|
|
|
|
|
|
(defun woman2-IP (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".IP x i -- Same as .TP with tag x. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-interparagraph-space)
|
|
|
|
|
(if (eolp) ; no args
|
|
|
|
|
;; Like LP without resetting prevailing indent
|
|
|
|
|
(woman2-format-paragraphs to (+ woman-left-margin
|
|
|
|
|
woman-prevailing-indent))
|
|
|
|
|
(woman-forward-arg 'unquote)
|
|
|
|
|
(let ((i (woman2-get-prevailing-indent 'leave-eol)))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(woman-leave-blank-lines) ; must be here,
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;;
|
|
|
|
|
;; The cvs.1 manpage contains some (possibly buggy) syntax that
|
|
|
|
|
;; confuses woman, although the man program displays it ok.
|
|
|
|
|
;; Most problems are caused by IP followed by another request on
|
|
|
|
|
;; the next line. Without the following hack, the second request
|
|
|
|
|
;; gets displayed raw in the output. Note that
|
|
|
|
|
;; woman2-tagged-paragraph also contains a hack for similar
|
|
|
|
|
;; issues (eg IP followed by SP).
|
|
|
|
|
;;
|
|
|
|
|
;; i) For IP followed by one or more IPs, we ignore all but the
|
|
|
|
|
;; last (mimic man). The hack in w-t-p would only work for two
|
|
|
|
|
;; consecutive IPs, and would use the first.
|
|
|
|
|
;; ii) For IP followed by SP followed by one or more requests,
|
|
|
|
|
;; do nothing. At least in cvs.1, there is usually another IP in
|
|
|
|
|
;; there somewhere.
|
|
|
|
|
(unless (or (looking-at "^\\.IP")
|
|
|
|
|
(and (looking-at "^\\.sp")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(and (zerop (forward-line 1))
|
|
|
|
|
(looking-at woman-request-regexp)))))
|
|
|
|
|
(woman2-tagged-paragraph to i)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-find-next-control-line-carefully ()
|
|
|
|
|
"Find and return start of next control line, even if already there!"
|
|
|
|
|
(if (looking-at "^[.']")
|
|
|
|
|
(point)
|
|
|
|
|
(woman-find-next-control-line)))
|
|
|
|
|
|
|
|
|
|
(defun woman2-tagged-paragraph (to i)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Begin indented paragraph with hanging tag given by current text line.
|
|
|
|
|
If tag doesn't fit, leave it on separate line.
|
|
|
|
|
Format paragraphs upto TO. Set prevailing indent to I."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (not (looking-at "\\s *$")) ; non-empty tag
|
|
|
|
|
(setq woman-leave-blank-lines nil))
|
|
|
|
|
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; Temporary hack for bash.1, cvs.1 and groff_mmse.7 until code is revised
|
|
|
|
|
;; to process all requests uniformly.
|
|
|
|
|
;; This hack deals with IP requests followed by other requests (eg
|
|
|
|
|
;; SP) on the very next line. We skip over the SP, otherwise it gets
|
|
|
|
|
;; inserted raw in the rendered output.
|
|
|
|
|
(cond ((and (= (point) to)
|
|
|
|
|
(looking-at "^[.'][ \t]*\\(PD\\|br\\|ta\\|sp\\) *"))
|
|
|
|
|
(if (member (match-string 1) '("br" "sp"))
|
|
|
|
|
(woman-delete-line 1)
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(if (string= (match-string 1) "ta") ; for GetInt.3
|
|
|
|
|
(woman2-ta to)
|
|
|
|
|
(woman-set-interparagraph-distance)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(set-marker to (woman-find-next-control-line-carefully))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(let ((tag (point)))
|
|
|
|
|
(woman-reset-nospace)
|
|
|
|
|
;; Format the tag:
|
|
|
|
|
(woman2-process-escapes-to-eol)
|
|
|
|
|
;; TIDY UP THE FOLLOWING CODE
|
|
|
|
|
;; (indent-to woman-left-margin)
|
|
|
|
|
(setq left-margin woman-left-margin)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(fill-region-as-paragraph (save-excursion (forward-line -1) (point))
|
|
|
|
|
(point) woman-justify)
|
|
|
|
|
|
|
|
|
|
;; Temporary hack for bash.1 until all requests processed uniformly:
|
|
|
|
|
(cond ((and (= (point) to) (looking-at "^[.'][ \t]*PD *"))
|
|
|
|
|
(woman-delete-match 0)
|
|
|
|
|
(woman-set-interparagraph-distance)
|
|
|
|
|
(set-marker to (woman-find-next-control-line-carefully))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; Format the paragraph body, if there is one! Set indented left
|
|
|
|
|
;; margin anyway, because the paragraph body may begin with a
|
|
|
|
|
;; control line:
|
|
|
|
|
(setq left-margin (+ woman-left-margin i))
|
|
|
|
|
(cond ((< (point) to)
|
|
|
|
|
(woman2-format-paragraphs to)
|
|
|
|
|
(goto-char tag) (end-of-line)
|
|
|
|
|
(cond ((> (setq i (- left-margin (current-column))) 0)
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
;; Necessary to avoid spaces inheriting underlines.
|
|
|
|
|
;; Cannot simply delete (current-column) whitespace
|
|
|
|
|
;; characters because some may be tabs!
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(insert-char ?\s i)))
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(goto-char to)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-HP (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".HP i -- Set prevailing indent to i. Format paragraphs upto TO.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Begin paragraph with hanging indent."
|
|
|
|
|
(let ((i (woman2-get-prevailing-indent)))
|
|
|
|
|
(woman-interparagraph-space)
|
|
|
|
|
(setq woman-temp-indent woman-left-margin)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(woman2-format-paragraphs to (+ woman-left-margin i))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-get-prevailing-indent (&optional leave-eol)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Set prevailing indent to integer argument at point, and return it.
|
|
|
|
|
If no argument then return the existing prevailing indent.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Delete line from point and eol unless LEAVE-EOL is non-nil."
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(or leave-eol (delete-char 1))
|
|
|
|
|
(let ((i (woman-get-numeric-arg)))
|
|
|
|
|
(woman-delete-line) (or leave-eol (delete-char 1))
|
|
|
|
|
;; i = 0 if the argument was not a number
|
2007-03-10 04:12:44 +00:00
|
|
|
|
;; FIXME should this be >= 0? How else to reset to 0 indent?
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (> i 0) (setq woman-prevailing-indent i))))
|
|
|
|
|
woman-prevailing-indent)
|
|
|
|
|
|
|
|
|
|
(defmacro woman-push (value stack)
|
|
|
|
|
"Push VALUE onto STACK."
|
|
|
|
|
`(setq ,stack (cons ,value ,stack)))
|
|
|
|
|
|
|
|
|
|
(defmacro woman-pop (variable stack)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Pop into VARIABLE the value at the top of STACK.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Allow for mismatched requests!"
|
|
|
|
|
`(if ,stack
|
|
|
|
|
(setq ,variable (car ,stack)
|
|
|
|
|
,stack (cdr ,stack))))
|
|
|
|
|
|
|
|
|
|
(defun woman2-RS (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".RS i -- Start relative indent, move left margin in distance i.
|
|
|
|
|
Set prevailing indent to 5 for nested indents. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-push woman-left-margin woman-RS-left-margin)
|
|
|
|
|
(woman-push woman-prevailing-indent woman-RS-prevailing-indent)
|
|
|
|
|
(setq woman-left-margin (+ woman-left-margin
|
|
|
|
|
(woman2-get-prevailing-indent))
|
|
|
|
|
woman-prevailing-indent woman-default-indent)
|
|
|
|
|
(woman2-format-paragraphs to woman-left-margin))
|
|
|
|
|
|
|
|
|
|
(defun woman2-RE (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".RE -- End of relative indent. Format paragraphs upto TO.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
Set prevailing indent to amount of starting .RS."
|
|
|
|
|
(woman-pop woman-left-margin woman-RS-left-margin)
|
|
|
|
|
(woman-pop woman-prevailing-indent woman-RS-prevailing-indent)
|
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman2-format-paragraphs to woman-left-margin))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Line Length and Indenting:
|
|
|
|
|
|
|
|
|
|
(defun woman-set-arg (arg &optional previous)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
"Reset, increment or decrement argument ARG, which must be quoted.
|
|
|
|
|
If no argument then use value of optional arg PREVIOUS if non-nil,
|
|
|
|
|
otherwise set PREVIOUS. Delete the whole remaining control line."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (eolp) ; space already skipped
|
|
|
|
|
(set arg (if previous (eval previous) 0))
|
|
|
|
|
(if previous (set previous (eval arg)))
|
|
|
|
|
(woman2-process-escapes-to-eol 'numeric)
|
|
|
|
|
(let ((pm (if (looking-at "[+-]")
|
|
|
|
|
(prog1 (following-char)
|
|
|
|
|
(forward-char 1))))
|
|
|
|
|
(i (woman-parse-numeric-arg)))
|
|
|
|
|
(cond ((null pm) (set arg i))
|
|
|
|
|
((= pm ?+) (set arg (+ (eval arg) i)))
|
|
|
|
|
((= pm ?-) (set arg (- (eval arg) i)))
|
|
|
|
|
))
|
|
|
|
|
(beginning-of-line))
|
|
|
|
|
(woman-delete-line 1)) ; ignore any remaining arguments
|
|
|
|
|
|
|
|
|
|
;; NEED TO RATIONALIZE NAMES FOR PREVIOUS VALUES!
|
|
|
|
|
(defvar woman-ll-fill-column woman-fill-column)
|
|
|
|
|
(defvar woman-in-left-margin woman-left-margin)
|
|
|
|
|
|
|
|
|
|
(defun woman2-ll (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".ll +/-N -- Set, increment or decrement line length.
|
|
|
|
|
Format paragraphs upto TO. (Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-set-arg 'fill-column 'woman-ll-fill-column)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-in (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".in +/-N -- Set, increment or decrement the indent.
|
|
|
|
|
Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman-set-arg 'left-margin 'woman-in-left-margin)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-ti (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".ti +/-N -- Temporary indent. Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Ignore if no argument.
|
|
|
|
|
;; Indent next output line only wrt current indent.
|
|
|
|
|
;; Current indent is not changed.
|
|
|
|
|
(setq woman-temp-indent left-margin)
|
|
|
|
|
(woman-set-arg 'woman-temp-indent)
|
|
|
|
|
(woman2-format-paragraphs to nil))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Tabs, Leaders, and Fields:
|
|
|
|
|
|
|
|
|
|
(defun woman2-ta (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".ta Nt ... -- Set tabs, left type, unless t=R(right), C(centered).
|
|
|
|
|
\(Breaks, but should not.) The tab stops are separated by spaces\;
|
|
|
|
|
a value preceded by + represents an increment to the previous stop value.
|
|
|
|
|
Format paragraphs upto TO."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq tab-stop-list nil)
|
|
|
|
|
(woman2-process-escapes-to-eol 'numeric)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((tab-stop 0))
|
|
|
|
|
(while (not (eolp))
|
|
|
|
|
(let ((plus (cond ((eq (following-char) ?+) (forward-char 1) t)))
|
|
|
|
|
(i (woman-parse-numeric-arg)))
|
|
|
|
|
(setq tab-stop (if plus (+ tab-stop i) i)))
|
|
|
|
|
(if (memq (following-char) '(?R ?C))
|
|
|
|
|
(setq tab-stop (cons tab-stop (following-char))))
|
|
|
|
|
(setq tab-stop-list (cons tab-stop tab-stop-list))
|
|
|
|
|
(skip-syntax-forward "^ ") ; skip following R, C, `;', etc.
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
)))
|
|
|
|
|
(woman-delete-line 1) ; ignore any remaining arguments
|
|
|
|
|
(setq tab-stop-list (reverse tab-stop-list))
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defsubst woman-get-tab-stop (tab-stops)
|
|
|
|
|
"If TAB-STOPS is a cons, return its car, else return TAB-STOPS."
|
|
|
|
|
(if (consp tab-stops) (car tab-stops) tab-stops))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-tab-to-tab-stop ()
|
|
|
|
|
"Insert spaces to next defined tab-stop column.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
The variable `tab-stop-list' is a list whose elements are either left
|
|
|
|
|
tab stop columns or pairs (COLUMN . TYPE) where TYPE is R or C."
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Based on tab-to-tab-stop in indent.el.
|
|
|
|
|
;; R & C tabs probably not quite right!
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
|
(delete-char -1)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(let ((tabs tab-stop-list))
|
|
|
|
|
(while (and tabs (>= (current-column)
|
|
|
|
|
(woman-get-tab-stop (car tabs))))
|
|
|
|
|
(setq tabs (cdr tabs)))
|
|
|
|
|
(if tabs
|
|
|
|
|
(let* ((tab (car tabs))
|
|
|
|
|
(type (and (consp tab) (cdr tab)))
|
|
|
|
|
eol n)
|
|
|
|
|
(if type
|
|
|
|
|
(setq tab (woman-get-tab-stop tab)
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
eol (line-end-position)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
n (save-excursion
|
|
|
|
|
(search-forward "\t" eol t))
|
|
|
|
|
n (- (if n (1- n) eol) (point))
|
|
|
|
|
tab (- tab (if (eq type ?C) (/ n 2) n))) )
|
|
|
|
|
(setq n (- tab (current-column)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(insert-char ?\s n))
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(insert ?\s))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun woman2-DT (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".DT -- Restore default tabs. Format paragraphs upto TO.
|
|
|
|
|
\(Breaks, but should not.)"
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;; Currently just terminates special tab processing.
|
|
|
|
|
(setq tab-stop-list nil)
|
|
|
|
|
(woman-delete-line 1) ; ignore any arguments
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defun woman2-fc (to)
|
2000-05-22 07:01:17 +00:00
|
|
|
|
".fc a b -- Set field delimiter a and pad character b.
|
|
|
|
|
Format paragraphs upto TO.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
A VERY FIRST ATTEMPT to make fields at least readable!
|
|
|
|
|
Needs doing properly!"
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(woman-delete-whole-line) ; ignore!
|
|
|
|
|
(let ((delim (following-char))
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(pad ?\s) end) ; pad defaults to space
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(forward-char)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(or (eolp) (setq pad (following-char)))
|
|
|
|
|
(woman-delete-whole-line)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (re-search-forward "^[.'][ \t]*fc\\s " nil t)
|
|
|
|
|
(setq end (match-beginning 0))))
|
|
|
|
|
;; A field is contained between a pair of field delimiter
|
|
|
|
|
;; characters and consists of sub-strings separated by padding
|
|
|
|
|
;; indicator characters:
|
|
|
|
|
(setq delim (string delim ?[ ?^ delim ?] ?* delim))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (re-search-forward delim end t)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(insert woman-unpadded-space-char)
|
|
|
|
|
(goto-char (match-end 0))
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
|
(delete-char -1)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(insert-before-markers woman-unpadded-space-char)
|
|
|
|
|
(subst-char-in-region
|
|
|
|
|
(match-beginning 0) (match-end 0)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
pad woman-unpadded-space-char t)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
2002-10-23 09:08:20 +00:00
|
|
|
|
|
|
|
|
|
;;; Preliminary table support (.TS/.TE)
|
|
|
|
|
|
|
|
|
|
(defun woman2-TS (to)
|
|
|
|
|
".TS -- Start of table code for the tbl processor.
|
|
|
|
|
Format paragraphs upto TO."
|
|
|
|
|
(when woman-emulate-tbl
|
|
|
|
|
;; Assumes column separator is \t and intercolumn spacing is 3.
|
|
|
|
|
;; The first line may optionally be a list of options terminated by
|
|
|
|
|
;; a semicolon. Currently, just delete it:
|
|
|
|
|
(if (looking-at ".*;[ \t]*$") (woman-delete-line 1)) ;
|
|
|
|
|
;; The following lines must specify the format of each line of the
|
|
|
|
|
;; table and end with a period. Currently, just delete them:
|
|
|
|
|
(while (not (looking-at ".*\\.[ \t]*$")) (woman-delete-line 1))
|
|
|
|
|
(woman-delete-line 1)
|
|
|
|
|
;; For each column, find its width and align it:
|
|
|
|
|
(let ((start (point)) (col 1))
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(WoMan-log "%s" (buffer-substring start (+ start 40)))
|
|
|
|
|
;; change T{ T} to tabs
|
|
|
|
|
(while (search-forward "T{\n" to t)
|
|
|
|
|
(replace-match "")
|
|
|
|
|
(catch 'end
|
|
|
|
|
(while (search-forward "\n" to t)
|
|
|
|
|
(replace-match " ")
|
|
|
|
|
(if (looking-at "T}")
|
|
|
|
|
(progn
|
|
|
|
|
(delete-char 2)
|
|
|
|
|
(throw 'end t))))))
|
|
|
|
|
(goto-char start)
|
|
|
|
|
;; strip space and headers
|
|
|
|
|
(while (re-search-forward "^\\.TH\\|\\.sp" to t)
|
|
|
|
|
(woman-delete-whole-line))
|
|
|
|
|
(goto-char start)
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(while (prog1 (search-forward "\t" to t) (goto-char start))
|
|
|
|
|
;; Find current column width:
|
|
|
|
|
(while (< (point) to)
|
|
|
|
|
(when (search-forward "\t" to t)
|
|
|
|
|
(backward-char)
|
|
|
|
|
(if (> (current-column) col) (setq col (current-column))))
|
|
|
|
|
(forward-line))
|
|
|
|
|
;; Align current column:
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(setq col (+ col 3)) ; intercolumn space
|
|
|
|
|
(while (< (point) to)
|
|
|
|
|
(when (search-forward "\t" to t)
|
|
|
|
|
(delete-char -1)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(insert-char ?\s (- col (current-column))))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(forward-line))
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(goto-char start))
|
|
|
|
|
;; find maximum width
|
|
|
|
|
(let ((max-col 0))
|
|
|
|
|
(while (search-forward "\n" to t)
|
|
|
|
|
(backward-char)
|
|
|
|
|
(if (> (current-column) max-col)
|
|
|
|
|
(setq max-col (current-column)))
|
|
|
|
|
(forward-char))
|
|
|
|
|
(goto-char start)
|
|
|
|
|
;; break lines if they are too long
|
|
|
|
|
(when (and (> max-col woman-fill-column)
|
|
|
|
|
(> woman-fill-column col))
|
|
|
|
|
(setq max-col woman-fill-column)
|
|
|
|
|
(woman-break-table col to start)
|
|
|
|
|
(goto-char start))
|
|
|
|
|
(while (re-search-forward "^_$" to t)
|
|
|
|
|
(replace-match (make-string max-col ?_)))
|
2002-10-23 09:08:20 +00:00
|
|
|
|
(goto-char start))))
|
|
|
|
|
;; Format table with no filling or adjusting (cf. woman2-nf):
|
|
|
|
|
(setq woman-nofill t)
|
|
|
|
|
(woman2-format-paragraphs to))
|
|
|
|
|
|
|
|
|
|
(defalias 'woman2-TE 'woman2-fi)
|
|
|
|
|
;; ".TE -- End of table code for the tbl processor."
|
|
|
|
|
;; Turn filling and adjusting back on.
|
|
|
|
|
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(defun woman-break-table (start-column to start)
|
|
|
|
|
(while (< (point) to)
|
|
|
|
|
(move-to-column woman-fill-column)
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(if (and (search-backward " " start t)
|
|
|
|
|
(> (current-column) start-column))
|
|
|
|
|
(progn
|
|
|
|
|
(insert-char ?\n 1)
|
|
|
|
|
(insert-char ?\s (- start-column 5)))
|
|
|
|
|
(forward-line)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
;;; WoMan message logging:
|
|
|
|
|
|
2000-05-22 07:01:17 +00:00
|
|
|
|
;; The basis for this logging code was shamelessly pirated from bytecomp.el
|
|
|
|
|
;; by Jamie Zawinski <jwz@lucid.com> & Hallvard Furuseth <hbf@ulrik.uio.no>
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun WoMan-log-begin ()
|
|
|
|
|
"Log the beginning of formatting in *WoMan-Log*."
|
|
|
|
|
(let ((WoMan-current-buffer (buffer-name)))
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create "*WoMan-Log*")
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(or (eq major-mode 'view-mode) (view-mode 1))
|
|
|
|
|
(setq buffer-read-only nil)
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert "\n\^L\nFormatting "
|
|
|
|
|
(if (stringp WoMan-current-file)
|
|
|
|
|
(concat "file " WoMan-current-file)
|
|
|
|
|
(concat "buffer " WoMan-current-buffer))
|
|
|
|
|
" at " (current-time-string) "\n")
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(setq WoMan-Log-header-point-max (point-max)))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun WoMan-log (format &rest args)
|
|
|
|
|
"Log a message out of FORMAT control string and optional ARGS."
|
|
|
|
|
(WoMan-log-1 (apply 'format format args)))
|
|
|
|
|
|
|
|
|
|
(defun WoMan-warn (format &rest args)
|
|
|
|
|
"Log a warning message out of FORMAT control string and optional ARGS."
|
|
|
|
|
(setq format (apply 'format format args))
|
|
|
|
|
(WoMan-log-1 (concat "** " format)))
|
|
|
|
|
|
2010-11-05 08:16:55 +00:00
|
|
|
|
;; request is not used dynamically by any callees.
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(defun WoMan-warn-ignored (request ignored)
|
|
|
|
|
"Log a warning message about ignored directive REQUEST.
|
|
|
|
|
IGNORED is a string appended to the log message."
|
|
|
|
|
(let ((tail
|
|
|
|
|
(buffer-substring (point)
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(line-end-position))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(if (and (> (length tail) 0)
|
2012-04-21 05:54:39 +00:00
|
|
|
|
(/= (string-to-char tail) ?\s))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(setq tail (concat " " tail)))
|
|
|
|
|
(WoMan-log-1
|
|
|
|
|
(concat "** " request tail " request " ignored))))
|
|
|
|
|
|
|
|
|
|
(defun WoMan-log-end (time)
|
|
|
|
|
"Log the end of formatting in *WoMan-Log*.
|
|
|
|
|
TIME specifies the time it took to format the man page, to be printed
|
|
|
|
|
with the message."
|
2011-07-01 04:52:27 +00:00
|
|
|
|
(WoMan-log-1 (format "Formatting time %g seconds." time) 'end))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
|
|
|
|
|
(defun WoMan-log-1 (string &optional end)
|
|
|
|
|
"Log a message STRING in *WoMan-Log*.
|
2000-05-22 07:01:17 +00:00
|
|
|
|
If optional argument END is non-nil then make buffer read-only after
|
|
|
|
|
logging the message."
|
2007-09-07 02:45:28 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create "*WoMan-Log*")
|
2001-01-29 16:24:49 +00:00
|
|
|
|
(setq buffer-read-only nil)
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(or end (insert " ")) (insert string "\n")
|
|
|
|
|
(if end
|
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
|
(if woman-show-log
|
|
|
|
|
(select-window ; to return to
|
|
|
|
|
(prog1 (selected-window) ; WoMan window
|
|
|
|
|
(select-window (display-buffer (current-buffer)))
|
|
|
|
|
(cond (WoMan-Log-header-point-max
|
|
|
|
|
(goto-char WoMan-Log-header-point-max)
|
|
|
|
|
(forward-line -1)
|
2009-07-06 02:17:31 +00:00
|
|
|
|
(recenter 0))))))))
|
2000-05-08 14:32:17 +00:00
|
|
|
|
nil) ; for woman-file-readable-p etc.
|
|
|
|
|
|
2010-04-12 15:17:29 +00:00
|
|
|
|
;;; Bookmark Woman support.
|
2010-07-14 15:57:54 +00:00
|
|
|
|
(declare-function bookmark-make-record-default
|
|
|
|
|
"bookmark" (&optional no-file no-context posn))
|
2010-04-12 16:09:47 +00:00
|
|
|
|
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
|
|
|
|
|
(declare-function bookmark-default-handler "bookmark" (bmk))
|
|
|
|
|
(declare-function bookmark-get-bookmark-record "bookmark" (bmk))
|
|
|
|
|
|
|
|
|
|
;; FIXME: woman.el and man.el should be better integrated so, for
|
|
|
|
|
;; example, bookmarks of one can be used with the other.
|
2010-04-12 15:17:29 +00:00
|
|
|
|
|
|
|
|
|
(defun woman-bookmark-make-record ()
|
|
|
|
|
"Make a bookmark entry for a Woman buffer."
|
2010-04-12 16:09:47 +00:00
|
|
|
|
`(,(Man-default-bookmark-title)
|
2010-07-14 15:57:54 +00:00
|
|
|
|
,@(bookmark-make-record-default 'no-file)
|
2010-04-14 15:07:53 +00:00
|
|
|
|
(location . ,(concat "woman " woman-last-file-name))
|
2010-04-12 16:09:47 +00:00
|
|
|
|
;; Use the same form as man's bookmarks, as much as possible.
|
|
|
|
|
(man-args . ,woman-last-file-name)
|
|
|
|
|
(handler . woman-bookmark-jump)))
|
2010-04-12 15:17:29 +00:00
|
|
|
|
|
2010-04-12 16:09:47 +00:00
|
|
|
|
;;;###autoload
|
2010-04-12 15:17:29 +00:00
|
|
|
|
(defun woman-bookmark-jump (bookmark)
|
|
|
|
|
"Default bookmark handler for Woman buffers."
|
2010-04-12 16:09:47 +00:00
|
|
|
|
(let* ((file (bookmark-prop-get bookmark 'man-args))
|
|
|
|
|
;; FIXME: we need woman-find-file-noselect, since
|
|
|
|
|
;; save-window-excursion can't protect us from the case where
|
|
|
|
|
;; woman-find-file creates a new frame.
|
2010-04-12 15:17:29 +00:00
|
|
|
|
(buf (save-window-excursion
|
|
|
|
|
(woman-find-file file) (current-buffer))))
|
|
|
|
|
(bookmark-default-handler
|
|
|
|
|
`("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
(provide 'woman)
|
|
|
|
|
|
2011-09-09 06:32:08 +00:00
|
|
|
|
|
|
|
|
|
;; Local Variables:
|
|
|
|
|
;; coding: utf-8
|
|
|
|
|
;; End:
|
|
|
|
|
|
2000-05-08 14:32:17 +00:00
|
|
|
|
;;; woman.el ends here
|