X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/bf120ed1b9f1fa5a2422465e7ca825080b7b0c65..2b4e72e1d5ccecf590125c022a78a88755c779e5:/lisp/man.el diff --git a/lisp/man.el b/lisp/man.el index 67d745347c..3aadfa2d5e 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1,7 +1,7 @@ ;;; man.el --- browse UNIX manual pages -*- coding: iso-8859-1 -*- ;; Copyright (C) 1993, 1994, 1996, 1997, 2001, 2002, 2003, -;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. ;; Author: Barry A. Warsaw ;; Maintainer: FSF @@ -10,10 +10,10 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,9 +21,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -76,7 +74,7 @@ ;; ============= TODO =========== ;; - Add a command for printing. -;; - The awk script deletes multiple blank lines. This behaviour does +;; - The awk script deletes multiple blank lines. This behavior does ;; not allow to understand if there was indeed a blank line at the ;; end or beginning of a page (after the header, or before the ;; footer). A different algorithm should be used. It is easy to @@ -110,7 +108,7 @@ (defvar Man-notify) (defcustom Man-filter-list nil - "*Manpage cleaning filter command phrases. + "Manpage cleaning filter command phrases. This variable contains a list of the following form: '((command-string phrase-string*)*) @@ -427,9 +425,9 @@ Otherwise, the value is whatever the function 'func nil 'action #'Man-xref-button-action) -(defun Man-xref-button-action (button) +(defun Man-xref-button-action (button) (let ((target (button-get button 'Man-target-string))) - (funcall + (funcall (button-get button 'func) (cond ((null target) (button-label button)) @@ -437,7 +435,7 @@ Otherwise, the value is whatever the function (funcall target (button-start button))) (t target))))) -(define-button-type 'Man-xref-man-page +(define-button-type 'Man-xref-man-page :supertype 'Man-abstract-xref-man-page 'func 'man-follow) @@ -488,36 +486,51 @@ This is necessary if one wants to dump man.el with Emacs." (apply 'list (cons Man-sed-command - (list - (if Man-sed-script - (concat "-e '" Man-sed-script "'") - "") - "-e '/^[\001-\032][\001-\032]*$/d'" - "-e '/\e[789]/s///g'" - "-e '/Reformatting page. Wait/d'" - "-e '/Reformatting entry. Wait/d'" - "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" - "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" - "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" - "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" - "-e '/^Printed[ \t][0-9].*[0-9]$/d'" - "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" - "-e '/^[A-Za-z].*Last[ \t]change:/d'" - "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" - "-e '/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d'" - "-e '/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d'" - )) - (cons - Man-awk-command - (list - "'\n" - "BEGIN { blankline=0; anonblank=0; }\n" - "/^$/ { if (anonblank==0) next; }\n" - "{ anonblank=1; }\n" - "/^$/ { blankline++; next; }\n" - "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" - "'" - )) + (if (eq system-type 'windows-nt) + ;; Windows needs ".." quoting, not '..'. + (list + "-e \"/Reformatting page. Wait/d\"" + "-e \"/Reformatting entry. Wait/d\"" + "-e \"/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d\"" + "-e \"/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d\"" + "-e \"/^Printed[ \t][0-9].*[0-9]$/d\"" + "-e \"/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d\"" + "-e \"/^[A-Za-z].*Last[ \t]change:/d\"" + "-e \"/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d\"" + "-e \"/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d\"") + (list + (if Man-sed-script + (concat "-e '" Man-sed-script "'") + "") + "-e '/^[\001-\032][\001-\032]*$/d'" + "-e '/\e[789]/s///g'" + "-e '/Reformatting page. Wait/d'" + "-e '/Reformatting entry. Wait/d'" + "-e '/^[ \t]*Hewlett-Packard[ \t]Company[ \t]*-[ \t][0-9]*[ \t]-/d'" + "-e '/^[ \t]*Hewlett-Packard[ \t]*-[ \t][0-9]*[ \t]-.*$/d'" + "-e '/^[ \t][ \t]*-[ \t][0-9]*[ \t]-[ \t]*Formatted:.*[0-9]$/d'" + "-e '/^[ \t]*Page[ \t][0-9]*.*(printed[ \t][0-9\\/]*)$/d'" + "-e '/^Printed[ \t][0-9].*[0-9]$/d'" + "-e '/^[ \t]*X[ \t]Version[ \t]1[01].*Release[ \t][0-9]/d'" + "-e '/^[A-Za-z].*Last[ \t]change:/d'" + "-e '/^Sun[ \t]Release[ \t][0-9].*[0-9]$/d'" + "-e '/[ \t]*Copyright [0-9]* UNIX System Laboratories, Inc.$/d'" + "-e '/^[ \t]*Rev\\..*Page [0-9][0-9]*$/d'" + ))) + ;; Windows doesn't support multi-line commands, so don't + ;; invoke Awk there. + (unless (eq system-type 'windows-nt) + (cons + Man-awk-command + (list + "'\n" + "BEGIN { blankline=0; anonblank=0; }\n" + "/^$/ { if (anonblank==0) next; }\n" + "{ anonblank=1; }\n" + "/^$/ { blankline++; next; }\n" + "{ if (blankline>0) { print \"\"; blankline=0; } print $0; }\n" + "'" + ))) (if (not Man-uses-untabify-flag) ;; The outer list will be stripped off by apply. (list (cons @@ -831,6 +844,10 @@ all sections related to a subject, put something appropriate into the (Man-width (frame-width)) ((window-width)))))) (setenv "GROFF_NO_SGR" "1") + ;; Since man-db 2.4.3-1, man writes plain text with no escape + ;; sequences when stdout is not a tty. In 2.5.0, the following + ;; env-var was added to allow control of this (see Debian Bug#340673). + (setenv "MAN_KEEP_FORMATTING" "1") (if (fboundp 'start-process) (set-process-sentinel (start-process manual-program buffer @@ -1009,7 +1026,7 @@ default type, `Man-xref-man-page' is used for the buttons." (Man-highlight-references0 nil Man-apropos-regexp 1 'Man-default-man-entry (or xref-man-type 'Man-xref-man-page))) - (Man-highlight-references0 Man-see-also-regexp Man-reference-regexp 1 + (Man-highlight-references0 Man-see-also-regexp Man-reference-regexp 1 'Man-default-man-entry (or xref-man-type 'Man-xref-man-page)) (Man-highlight-references0 Man-synopsis-regexp Man-header-regexp 0 2 @@ -1036,7 +1053,7 @@ default type, `Man-xref-man-page' is used for the buttons." (match-end button-pos) 'type type 'Man-target-string (cond - ((numberp target) + ((numberp target) (match-string target)) ((functionp target) target)