• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +defs:buffer +defs:file +defs:format

13 ;; This file is part of GNU Emacs.
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
33 ;; `man' (or `manual-entry') command to format a UN*X manual `page'
54 ;; are available in the file woman.status.
58 ;; need to adjust the user option `woman-file-compression-regexp'.
78 ;; (autoload 'woman-find-file "woman"
79 ;; "Find, decode and browse a specific UN*X man-page file." t)
89 ;; cursor in the current buffer as the topic.
91 ;; Or (2): Execute the extended command `woman-find-file' and enter a
97 ;; (autoload 'woman-dired-find-file "woman"
98 ;; "In dired, run the WoMan man-page browser on this file." t)
101 ;; (define-key dired-mode-map "W" 'woman-dired-find-file)))
102 ;; and open the directory containing the man page file using dired,
103 ;; put the cursor on the file, and press `W'.
105 ;; In each case, the result should (!) be a buffer in Man mode showing
128 ;; If you use Microsoft COMMAND.COM then you can create a file called
144 ;; buffer as the default topic to look up if it matches the name of a
173 ;; WoMan currently runs two hooks: `woman-pre-format-hook' immediately
174 ;; before formatting a buffer and `woman-post-format-hook' immediately
175 ;; after formatting a buffer. These hooks can be used for special
179 ;; hooks. `woman-pre-format-hook' might be appropriate for face
180 ;; customization, whereas `woman-post-format-hook' might be
195 ;; buffer. For further documentation of the use of imenu, such as
196 ;; menu sorting, see the source file imenu.el, which is distributed
221 ;; The number of consecutive blank lines in the formatted buffer
236 ;; The *WoMan-Log* buffer
241 ;; writes a warning to this buffer. If the variable `woman-show-log'
243 ;; displays this buffer. Many WoMan warnings can be completely
252 ;; formatted buffer to indicate precisely where they occur by
261 ;; set-visited-file-name is to avoid font-locking triggered by
266 ;; (setq format-alist
268 ;; '(man "UN*X man-page source format" "\\.\\(TH\\|ig\\) "
271 ;; set-visited-file-name
272 ;; (file-name-sans-extension buffer-file-name)))))
273 ;; format-alist))
279 ;; If WoMan fails completely, or formats a file incorrectly
286 ;; (b) check that the problem is not already described in the file
290 ;; the *WoMan-Log* buffer relating to the problem file, together with
292 ;; the source file from, but do not send it to me unless I ask you to!
301 ;; file pathnames only when it seems appropriate. MS-Windows users
303 ;; `w32-downcase-file-names' to `t' and use all lower case when
304 ;; setting WoMan file paths.
322 ;; are changed then WoMan will automatically update its cache file on
332 ;; Reconsider case sensitivity of file names.
348 ;; Optionally save large files in enriched format?
367 ;; and format.el.
488 (defun woman-Cyg-to-Win (file)
492 (if (consp file)
493 file
495 (if (eq (aref file 0) ?/)
498 (with-temp-buffer
499 ;; cygpath -m file
500 (call-process "cygpath" nil t nil "-m" file)
501 (buffer-substring 1 (buffer-size)))
505 (when (string-match "\\`\\(/cygdrive\\|/\\)?/./" file)
507 (setq file (substring file (match-end 1))))
508 (aset file 0 (aref file 1)) ; /x/ -> xx/
509 (aset file 1 ?:)) ; xx/ -> x:/
510 file))
511 file)))
525 "*If non-nil then show the *WoMan-Log* buffer if appropriate.
530 (defcustom woman-pre-format-hook nil
531 "*Hook run by WoMan immediately before formatting a buffer.
536 (defcustom woman-post-format-hook nil
537 "*Hook run by WoMan immediately after formatting a buffer.
556 "*List of dirs to search and/or files to try for man config file.
560 with \".conf\". If MANPATH is not set but a config file is found
567 "Parse if possible configuration file for man command.
570 Concatenate data from all lines in the config file of the form
580 file manpath)
584 (file-readable-p (setq file (car path)))
585 ;; If not a file then find the file:
586 (or (not (file-directory-p file))
588 (setq file
589 (directory-files file t "\\`man.*\\.conf[a-z]*\\'" t))
590 (file-readable-p (setq file (car file)))))
591 ;; Parse the file -- if no MANPATH data ignore it:
592 (with-temp-buffer
593 (insert-file-contents file)
625 consulting the man configuration file if found, which is determined by
693 file `woman-cache-filename' for a change to take effect.
701 "*The full pathname of the WoMan directory and topic cache file.
709 file)
713 "*List of `dired' mode keys to define to run WoMan on current file.
746 ;; `woman-file-name' sets it to this value if it is unbound.
760 (defvar woman-file-regexp nil
764 `woman-uncompressed-file-regexp' and `woman-file-compression-regexp'.")
766 (defvar woman-uncompressed-file-regexp) ; for the compiler
767 (defvar woman-file-compression-regexp) ; for the compiler
769 (defun set-woman-file-regexp (symbol value)
770 "Bind SYMBOL to VALUE and set `woman-file-regexp' as per user customizations.
772 `woman-uncompressed-file-regexp' and `woman-file-compression-regexp'."
774 (and (boundp 'woman-uncompressed-file-regexp)
775 (boundp 'woman-file-compression-regexp)
776 (setq woman-file-regexp
777 (concat woman-uncompressed-file-regexp
779 (substring woman-file-compression-regexp 0 -2)
782 (defcustom woman-uncompressed-file-regexp
794 :set 'set-woman-file-regexp
797 (defcustom woman-file-compression-regexp
800 Regexp used to match compressed man file extensions for which
805 ;; `jka-compr-file-name-handler-entry', but that is unduly
809 :set 'set-woman-file-regexp
855 the buffer, which may aid debugging."
860 "*If non-nil, preserve ASCII characters in the WoMan buffer.
864 respectively) so that the buffer content is strictly wrong even though
866 buffer text is searched, copied or saved to a file."
1073 (make-variable-buffer-local 'woman-imenu-done)
1075 ;; From imenu.el -- needed when reformatting a file in its old buffer.
1076 ;; The latest buffer index used to update the menu bar menu.
1079 (make-variable-buffer-local 'imenu--last-menubar-index-alist)
1081 (defvar woman-buffer-alist nil
1085 (defvar woman-buffer-number 0
1086 "Ordinal number of current buffer entry in `woman-buffer-alist'.
1112 (signal 'end-of-buffer nil))
1129 "Delete subexpression SUBEXP of buffer text matched by last search."
1162 (let ((file-name (woman-file-name topic re-cache)))
1163 (if file-name
1164 (woman-find-file file-name)
1194 (when dir (add-to-list 'lst (substitute-in-file-name dir)))))
1195 (mapcar 'substitute-in-file-name woman-path)))
1199 It is loaded from the file named by the variable `woman-cache-filename'.
1200 Return t if the file exists, nil otherwise."
1203 (load woman-cache-filename t nil t) ; file exists
1208 It is saved to the file named by the variable `woman-cache-filename'."
1210 (save-excursion ; to restore current buffer
1211 ;; Make a temporary buffer; name starting with space "hides" it.
1213 (set-buffer (generate-new-buffer "WoMan tmp buffer")))
1215 ;; (switch-to-buffer standard-output t) ; only for debugging
1216 (buffer-disable-undo standard-output)
1228 (write-file woman-cache-filename) ; write CURRENT buffer
1229 (kill-buffer standard-output)
1233 (defvar woman-file-history nil "File-name read history.")
1235 (defun woman-file-name (topic &optional re-cache)
1236 "Get the name of the UN*X man-page file describing a chosen TOPIC.
1239 `woman-use-topic-at-point' is non-nil. Return nil if no file can
1264 ;; Was let-bound when file loaded, so ...
1277 (format "Manual entry (default %s): " default)
1285 nil ; no topic, so no file!
1287 ((setq files (woman-file-name-all-completions topic)))
1293 (setq files (woman-file-name-all-completions (car files)))))
1295 ((null files) nil) ; no file found for topic.
1296 ((null (cdr files)) (car (car files))) ; only 1 file for topic.
1303 (completing-read "Manual file: " files nil 1
1304 (try-completion "" files) 'woman-file-history))))))
1326 (defun woman-file-readable-p (dir)
1328 (or (file-readable-p dir)
1337 (or head (directory-file-name default-directory)) ; was "."
1339 (file-name-nondirectory dir))
1342 (defun woman-file-accessible-directory-p (dir)
1344 (or (file-accessible-directory-p dir)
1364 (if (and dir (woman-file-readable-p dir))
1377 head (file-name-directory dir)))
1378 (woman-file-readable-p head))
1382 (cons (directory-file-name default-directory) dirs))
1385 (woman-select 'woman-file-accessible-directory-p dirs)))
1390 (setq dir (expand-file-name (substitute-in-file-name dir)))
1396 ;; Match capitalization used by `file-name-directory':
1397 (setq dir (concat (file-name-directory dir)
1398 (file-name-nondirectory dir))))
1432 ;; This function used to check that each file in the directory was
1434 ;; unnecessary. So let us assume that `woman-file-regexp' will
1439 (let (newlst (lst (directory-files dir nil woman-file-regexp t))
1441 ;; compression extension: file-name-sans-extension is a
1443 (ext (format "\\(\\.[^.\\/]*\\)?\\(%s\\)?\\'"
1444 woman-file-compression-regexp)))
1447 (dolist (file lst newlst)
1450 (if (string-match ext file)
1451 (substring file 0 (match-beginning 0))
1452 file)
1457 (list file)))))
1486 (defun woman-file-name-all-completions (topic)
1499 woman-file-regexp)) ; extension
1512 ;; Find the actual file name:
1533 "Bind the argument KEY to the command `woman-dired-find-file'."
1534 (define-key dired-mode-map key 'woman-dired-find-file))
1537 "If KEY is undefined in Dired, bind it to command `woman-dired-find-file'."
1550 [woman] '("Read Man Page (WoMan)" . woman-dired-find-file) 'view))
1557 (defun woman-dired-find-file ()
1558 "In dired, run the WoMan man-page browser on this file."
1561 (woman-find-file (dired-get-filename)))
1566 (defun woman-tar-extract-file ()
1567 "In tar mode, run the WoMan man-page browser on this file."
1570 (error "`woman-tar-extract-file' can be used only in `tar-mode'"))
1571 (buffer-disable-undo)
1574 (let ((WoMan-current-file buffer-file-name)) ; used for message logging
1575 (rename-buffer
1576 (woman-make-bufname (file-name-nondirectory buffer-file-name)))
1577 (woman-process-buffer)
1583 (define-key tar-mode-map "w" 'woman-tar-extract-file)
1585 [woman] '("Read Man Page (WoMan)" . woman-tar-extract-file) 'view)))
1588 (defvar woman-last-file-name nil
1589 "The full pathname of the last file formatted by WoMan.")
1591 (defun woman-reformat-last-file ()
1592 "Reformat last file, e.g. after changing fill column."
1594 (if woman-last-file-name
1595 (woman-find-file woman-last-file-name t)
1596 (call-interactively 'woman-find-file)))
1599 (defun woman-find-file (file-name &optional reformat)
1600 "Find, decode and browse a specific UN*X man-page source file FILE-NAME.
1601 Use existing buffer if possible; reformat only if prefix arg given.
1603 of an existing WoMan buffer formatted earlier.
1605 decompress the file if appropriate. See the documentation for the
1607 (interactive "fBrowse UN*X manual file: \nP")
1608 (setq woman-last-file-name
1609 (setq file-name (expand-file-name file-name))) ; to canonicalize
1610 (let ((alist-tail woman-buffer-alist) exists)
1611 (setq woman-buffer-number 0)
1612 (while (and alist-tail (not (string= file-name (car (car alist-tail)))))
1614 woman-buffer-number (1+ woman-buffer-number)))
1616 (and alist-tail (WoMan-find-buffer))) ; buffer exists
1618 ;; Format new buffer or reformat current buffer:
1619 (let* ((bufname (file-name-nondirectory file-name))
1622 (not (not (string-match woman-file-compression-regexp bufname)))))
1624 (setq bufname (file-name-sans-extension bufname)))
1626 (buffer-name)
1628 (woman-really-find-file file-name compressed bufname)
1630 (setq woman-buffer-alist
1631 (cons (cons file-name bufname) woman-buffer-alist)
1632 woman-buffer-number 0))
1639 "Create an unambiguous buffer name from BUFNAME."
1644 (generate-new-buffer-name ; ensure uniqueness
1650 (defun woman-really-find-file (filename compressed bufname)
1653 the file if necessary. Set buffer name BUFNAME and major mode.
1655 (let ((WoMan-current-file filename)) ; used for message logging
1660 (switch-to-buffer (get-buffer-create bufname))
1661 (buffer-disable-undo)
1662 (setq buffer-read-only nil)
1663 (erase-buffer) ; NEEDED for reformat
1664 (woman-insert-file-contents filename compressed)
1665 ;; Set buffer's default directory to that of the file.
1666 (setq default-directory (file-name-directory filename))
1668 (set-visited-file-name "")
1669 (woman-process-buffer)))
1671 (defun woman-process-buffer ()
1672 "The second half of `woman-really-find-file'!"
1675 ;; man-page source format, assuming we are at point-min:
1678 (woman-decode-buffer)
1680 "File appears to be pre-formatted -- using source file may be better.")
1681 (woman-man-buffer))
1684 (defun woman-man-buffer ()
1685 "Post-process an nroff-preformatted man buffer."
1710 (if (< (buffer-size) (position-bytes (point-max)))
1735 ;; Leave any other uninterpreted ^H's in the buffer for now! (They
1749 (defun woman-insert-file-contents (filename compressed)
1750 "Insert file FILENAME into the current buffer.
1752 then turn on auto-compression mode to decompress the file.
1761 (string-match woman-file-compression-regexp filename))
1763 (not (rassq 'jka-compr-handler file-name-handler-alist)) )
1764 ;; (error "Compressed file requires Auto File Decompression turned on")
1768 (insert-file-contents filename nil)
1769 (file-error
1770 ;; Run find-file-not-found-hooks until one returns non-nil.
1771 ;; (run-hook-with-args-until-success 'find-file-not-found-hooks)
1786 (define-key woman-mode-map "R" 'woman-reformat-last-file)
1797 "Get a Un*x manual page of the item under point and put it in a buffer."
1837 ["Reformat Last Man Page" woman-reformat-last-file t]
1849 ["View Source" (view-file woman-last-file-name) woman-last-file-name]
1850 ["Show Log" (switch-to-buffer-other-window "*WoMan-Log*" t) t]
1873 (woman-reformat-last-file))
1879 (woman-reformat-last-file))
1885 (woman-reformat-last-file))
1890 "Turn on (most of) Man mode to browse a buffer formatted by WoMan.
1916 (kill-local-variable 'mode-line-buffer-identification)
1924 ;; necessary when reformatting a file in its old buffer:
1929 (let (buffer-read-only)
1931 (set-buffer-modified-p nil)
1941 ;; in the same buffer.
1956 "Display WoMan commands and user options in an `apropos' buffer."
1961 (let ((standard-output (get-buffer-create "*Apropos*")))
2005 ;; Both advices are disabled because "a file in Emacs should not put
2015 ;; "Use WoMan unless invoked outside a WoMan buffer or invoked explicitly.
2038 "Find the previous WoMan buffer."
2039 ;; Assumes currently in a WoMan buffer!
2041 (WoMan-find-buffer) ; find current existing buffer
2042 (if (null (cdr woman-buffer-alist))
2043 (error "No previous WoMan buffer"))
2044 (if (>= (setq woman-buffer-number (1+ woman-buffer-number))
2045 (length woman-buffer-alist))
2046 (setq woman-buffer-number 0))
2047 (if (WoMan-find-buffer)
2049 (if (< (setq woman-buffer-number (1- woman-buffer-number)) 0)
2050 (setq woman-buffer-number (1- (length woman-buffer-alist))))
2054 "Find the next WoMan buffer."
2055 ;; Assumes currently in a WoMan buffer!
2057 (WoMan-find-buffer) ; find current existing buffer
2058 (if (null (cdr woman-buffer-alist))
2059 (error "No next WoMan buffer"))
2060 (if (< (setq woman-buffer-number (1- woman-buffer-number)) 0)
2061 (setq woman-buffer-number (1- (length woman-buffer-alist))))
2062 (if (WoMan-find-buffer)
2066 (defun WoMan-find-buffer ()
2067 "Switch to buffer corresponding to `woman-buffer-number' and return it.
2068 If such a buffer does not exist then remove its association from the
2069 alist in `woman-buffer-alist' and return nil."
2070 (if (zerop woman-buffer-number)
2071 (let ((buffer (get-buffer (cdr (car woman-buffer-alist)))))
2072 (if buffer
2073 (switch-to-buffer buffer)
2075 (setq woman-buffer-alist (cdr woman-buffer-alist))
2077 (let* ((prev-ptr (nthcdr (1- woman-buffer-number) woman-buffer-alist))
2078 (buffer (get-buffer (cdr (car (cdr prev-ptr))))))
2079 (if buffer
2080 (switch-to-buffer buffer)
2083 (if (>= woman-buffer-number (length woman-buffer-alist))
2084 (setq woman-buffer-number 0))
2117 (defun woman-set-buffer-display-table ()
2118 "Set up a display table for a WoMan buffer.
2122 (setq buffer-display-table
2132 (aset buffer-display-table woman-unpadded-space-char [?\ ])
2133 (aset buffer-display-table woman-escaped-escape-char [?\\]))
2141 (defun woman-decode-buffer ()
2142 "Decode a buffer in UN*X man-page source format.
2146 (run-hooks 'woman-pre-format-hook)
2151 (message "WoMan formatting buffer...")
2154 ; ((re-search-forward "^\\.[ \t]*TH" nil t) ; wrong format if not found?
2157 ; (t (message "WARNING: .TH request not found -- not man-page format?")))
2162 (message "WoMan formatting buffer...done in %d seconds" time)
2164 (run-hooks 'woman-post-format-hook))
2179 To be called on original buffer and any .so insertions."
2223 ;; not set then the initial line of the nroff file is parsed for a
2240 Currently set only from '\" t in the first line of the source file.")
2243 "Decode the region between FROM and TO in UN*X man-page source format."
2244 ;; Suitable for use in format-alist.
2246 ;; Must return the new end of file. See format.el for details.
2278 (woman-set-buffer-display-table)
2300 (woman0-roff-buffer from)
2312 (error "WoMan can only format man pages written with the usual `-man' macros")))
2318 ;; Set buffer-local variables:
2344 (woman1-roff-buffer)
2399 ; ;; Warn but leave escape in buffer unprocessed:
2402 ; (buffer-substring from (1+ (point)))) ; point at end of arg
2405 ; msg (buffer-substring from to))
2428 (woman2-roff-buffer)
2437 ;; properties. This is not necessary, UNLESS the buffer is to
2448 ;; Must return the new end of file if used in format-alist.
2470 ;; Warn but leave escape in buffer unprocessed:
2473 (buffer-substring from (1+ (point)))) ; point at end of arg
2476 msg (buffer-substring from to))
2505 (defvar woman0-if-to) ; marker bound in woman0-roff-buffer
2506 (defvar woman0-macro-alist) ; bound in woman0-roff-buffer
2507 (defvar woman0-search-regex) ; bound in woman0-roff-buffer
2508 (defvar woman0-search-regex-start ; bound in woman0-roff-buffer
2514 (defvar woman0-rename-alist) ; bound in woman0-roff-buffer
2516 (defun woman0-roff-buffer (from)
2540 ;; Should now re-run `woman0-roff-buffer' if any renaming was
2606 (setq c (string= (buffer-substring (point) end1)
2607 (buffer-substring end1 woman0-if-to)))
2675 (t ; Ignore -- leave in buffer
2686 ;; Ignore -- leave in buffer
2693 ".so filename -- Switch source file. `.so' requests may be nested."
2698 (name (buffer-substring beg end))
2700 ;; If the specified file does not exist in this ...
2701 (or (file-exists-p filename)
2703 (file-exists-p
2707 (woman-file-name
2708 (file-name-sans-extension
2709 (file-name-nondirectory name))))
2710 ;; Cannot find the file, so ...
2711 (kill-buffer (current-buffer))
2716 (length (woman-insert-file-contents filename 0))
2735 (old (buffer-substring beg end))
2741 new (buffer-substring beg end)
2801 (let ((body (woman-unescape (buffer-substring from (point)))))
2829 "Interpolate (.de) or append (.am) expansion of MACRO into the buffer."
2840 (setq argno-string (format "%d" argno))
2844 (setq actual-arg (buffer-substring from (point)))
2887 "Process ?roff string requests and escape sequences up to buffer position TO.
3003 "Process special character escapes \\(xx, \\[xxx] up to buffer position TO.
3035 (with-output-to-temp-buffer "*WoMan Extended Font Map*"
3037 (set-buffer standard-output)
3040 (insert (format "\\%03o " i) (string i) " " (string i))
3054 (defvar request) ; Bound locally by woman1-roff-buffer
3055 (defvar unquote) ; Bound locally by woman1-roff-buffer
3077 (defun woman1-roff-buffer ()
3420 (defvar translations nil) ; Also bound locally by woman2-roff-buffer
3424 "Return and delete next char in buffer, including special chars."
3465 (woman2-format-paragraphs to)
3478 (buffer-substring-no-properties
3502 Also bound locally in `woman2-roff-buffer'.")
3522 (let* ((name (buffer-substring
3555 (woman2-format-paragraphs to)))
3608 ; (buffer-substring
3678 (buffer-substring
3708 (defun woman2-roff-buffer ()
3742 ;; (setq fn 'woman2-format-paragraphs)
3755 (setq fn 'woman2-format-paragraphs))))
3762 (woman2-format-paragraphs (copy-marker (point-max) t)
3797 (woman2-format-paragraphs to))
3834 (if (string-match (buffer-substring here (point))
3835 (buffer-substring start here))
3845 (woman2-format-paragraphs to woman-left-margin))
3865 (woman2-format-paragraphs to woman-left-margin))
3882 (woman2-format-paragraphs to woman-left-margin))
3892 (woman2-format-paragraphs to))
3899 (woman2-format-paragraphs to))
3910 (woman2-format-paragraphs to)))
3924 overlap (buffer-substring from
4061 (woman2-format-paragraphs to))
4072 (woman2-format-paragraphs to))
4080 (woman2-format-paragraphs to))
4098 (woman2-format-paragraphs to))
4108 (woman2-format-paragraphs to))
4143 (defun woman2-format-paragraphs (to &optional new-left)
4252 (woman2-format-paragraphs to (+ woman-left-margin
4332 (woman2-format-paragraphs to)
4351 (woman2-format-paragraphs to (+ woman-left-margin i))
4386 (woman2-format-paragraphs to woman-left-margin))
4394 (woman2-format-paragraphs to woman-left-margin))
4427 (woman2-format-paragraphs to))
4433 (woman2-format-paragraphs to))
4442 (woman2-format-paragraphs to nil))
4469 (woman2-format-paragraphs to))
4509 (woman2-format-paragraphs to))
4544 (woman2-format-paragraphs to))
4560 ;; The following lines must specify the format of each line of the
4584 (woman2-format-paragraphs to))
4597 (defvar WoMan-current-file nil) ; bound in woman-really-find-file
4602 (let ((WoMan-current-buffer (buffer-name)))
4604 (set-buffer (get-buffer-create "*WoMan-Log*"))
4606 (setq buffer-read-only nil)
4609 (if (stringp WoMan-current-file)
4610 (concat "file " WoMan-current-file)
4611 (concat "buffer " WoMan-current-buffer))
4616 (defun WoMan-log (format &rest args)
4618 (WoMan-log-1 (apply 'format format args)))
4620 (defun WoMan-warn (format &rest args)
4622 (setq format (apply 'format format args))
4623 (WoMan-log-1 (concat "** " format)))
4629 (buffer-substring (point)
4639 TIME specifies the time it took to format the man page, to be printed
4641 (WoMan-log-1 (format "Formatting time %d seconds." time) 'end))
4645 If optional argument END is non-nil then make buffer read-only after
4648 (set-buffer (get-buffer-create "*WoMan-Log*"))
4649 (setq buffer-read-only nil)
4653 (setq buffer-read-only t)
4657 (select-window (display-buffer (current-buffer)))
4663 nil) ; for woman-file-readable-p etc.