Mercurial > emacs
comparison lisp/man.el @ 90072:cb67264d6096
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-2
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-83
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-84
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-3
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-4
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-5
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-6
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-11
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-12
Remove "-face" suffix from lazy-highlight face name
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-13
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-16
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-17
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-18
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-21
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-22
<no summary provided>
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-23
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-39
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Fix regressions from latest reftex update
* miles@gnu.org--gnu-2005/gnus--rel--5.10--base-0
tag of miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-1
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-2
Merge from miles@gnu.org--gnu-2004
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-3
Merge from emacs--cvs-trunk--0
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 16 Jan 2005 03:40:12 +0000 |
parents | f2ebccfa87d4 c47c12607f08 |
children | fa9654493afb |
comparison
equal
deleted
inserted
replaced
90071:f6b4d0ebf147 | 90072:cb67264d6096 |
---|---|
413 ) | 413 ) |
414 | 414 |
415 ;; buttons | 415 ;; buttons |
416 (define-button-type 'Man-xref-man-page | 416 (define-button-type 'Man-xref-man-page |
417 'action (lambda (button) (man-follow (button-label button))) | 417 'action (lambda (button) (man-follow (button-label button))) |
418 'help-echo "RET, mouse-2: display this man page") | 418 'follow-link t |
419 'help-echo "mouse-2, RET: display this man page") | |
419 | 420 |
420 (define-button-type 'Man-xref-header-file | 421 (define-button-type 'Man-xref-header-file |
421 'action (lambda (button) | 422 'action (lambda (button) |
422 (let ((w (button-get button 'Man-target-string))) | 423 (let ((w (button-get button 'Man-target-string))) |
423 (unless (Man-view-header-file w) | 424 (unless (Man-view-header-file w) |
424 (error "Cannot find header file: %s" w)))) | 425 (error "Cannot find header file: %s" w)))) |
426 'follow-link t | |
425 'help-echo "mouse-2: display this header file") | 427 'help-echo "mouse-2: display this header file") |
426 | 428 |
427 (define-button-type 'Man-xref-normal-file | 429 (define-button-type 'Man-xref-normal-file |
428 'action (lambda (button) | 430 'action (lambda (button) |
429 (let ((f (substitute-in-file-name | 431 (let ((f (substitute-in-file-name |
431 (if (file-exists-p f) | 433 (if (file-exists-p f) |
432 (if (file-readable-p f) | 434 (if (file-readable-p f) |
433 (view-file f) | 435 (view-file f) |
434 (error "Cannot read a file: %s" f)) | 436 (error "Cannot read a file: %s" f)) |
435 (error "Cannot find a file: %s" f)))) | 437 (error "Cannot find a file: %s" f)))) |
438 'follow-link t | |
436 'help-echo "mouse-2: display this file") | 439 'help-echo "mouse-2: display this file") |
437 | 440 |
438 | 441 |
439 ;; ====================================================================== | 442 ;; ====================================================================== |
440 ;; utilities | 443 ;; utilities |
820 (interactive) | 823 (interactive) |
821 (message "Please wait: formatting the %s man page..." Man-arguments) | 824 (message "Please wait: formatting the %s man page..." Man-arguments) |
822 (goto-char (point-min)) | 825 (goto-char (point-min)) |
823 ;; Fontify ANSI escapes. | 826 ;; Fontify ANSI escapes. |
824 (let ((faces nil) | 827 (let ((faces nil) |
828 (buffer-undo-list t) | |
825 (start (point))) | 829 (start (point))) |
826 ;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html | 830 ;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html |
827 ;; suggests many codes, but we only handle: | 831 ;; suggests many codes, but we only handle: |
828 ;; ESC [ 00 m reset to normal display | 832 ;; ESC [ 00 m reset to normal display |
829 ;; ESC [ 01 m bold | 833 ;; ESC [ 01 m bold |
851 (?7 Man-reverse-face)) | 855 (?7 Man-reverse-face)) |
852 faces)))) | 856 faces)))) |
853 (delete-region (match-beginning 0) (match-end 0)) | 857 (delete-region (match-beginning 0) (match-end 0)) |
854 (setq start (point)))) | 858 (setq start (point)))) |
855 ;; Other highlighting. | 859 ;; Other highlighting. |
856 (if (< (buffer-size) (position-bytes (point-max))) | 860 (let ((buffer-undo-list t)) |
857 ;; Multibyte characters exist. | 861 (if (< (buffer-size) (position-bytes (point-max))) |
858 (progn | 862 ;; Multibyte characters exist. |
859 (goto-char (point-min)) | 863 (progn |
860 (while (search-forward "__\b\b" nil t) | 864 (goto-char (point-min)) |
861 (backward-delete-char 4) | 865 (while (search-forward "__\b\b" nil t) |
862 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) | 866 (backward-delete-char 4) |
863 (goto-char (point-min)) | 867 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
864 (while (search-forward "\b\b__" nil t) | 868 (goto-char (point-min)) |
865 (backward-delete-char 4) | 869 (while (search-forward "\b\b__" nil t) |
866 (put-text-property (1- (point)) (point) 'face Man-underline-face)))) | 870 (backward-delete-char 4) |
867 (goto-char (point-min)) | 871 (put-text-property (1- (point)) (point) 'face Man-underline-face)))) |
868 (while (search-forward "_\b" nil t) | 872 (goto-char (point-min)) |
869 (backward-delete-char 2) | 873 (while (search-forward "_\b" nil t) |
870 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) | 874 (backward-delete-char 2) |
871 (goto-char (point-min)) | 875 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
872 (while (search-forward "\b_" nil t) | 876 (goto-char (point-min)) |
873 (backward-delete-char 2) | 877 (while (search-forward "\b_" nil t) |
874 (put-text-property (1- (point)) (point) 'face Man-underline-face)) | 878 (backward-delete-char 2) |
875 (goto-char (point-min)) | 879 (put-text-property (1- (point)) (point) 'face Man-underline-face)) |
876 (while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) | 880 (goto-char (point-min)) |
877 (replace-match "\\1") | 881 (while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) |
878 (put-text-property (1- (point)) (point) 'face Man-overstrike-face)) | 882 (replace-match "\\1") |
879 (goto-char (point-min)) | 883 (put-text-property (1- (point)) (point) 'face Man-overstrike-face)) |
880 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) | 884 (goto-char (point-min)) |
881 (replace-match "o") | 885 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) |
882 (put-text-property (1- (point)) (point) 'face 'bold)) | 886 (replace-match "o") |
883 (goto-char (point-min)) | 887 (put-text-property (1- (point)) (point) 'face 'bold)) |
884 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) | 888 (goto-char (point-min)) |
885 (replace-match "+") | 889 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) |
886 (put-text-property (1- (point)) (point) 'face 'bold)) | 890 (replace-match "+") |
887 (goto-char (point-min)) | 891 (put-text-property (1- (point)) (point) 'face 'bold)) |
888 ;; Try to recognize common forms of cross references. | 892 (goto-char (point-min)) |
889 (Man-highlight-references) | 893 ;; Try to recognize common forms of cross references. |
890 (Man-softhyphen-to-minus) | 894 (Man-highlight-references) |
891 (goto-char (point-min)) | 895 (Man-softhyphen-to-minus) |
892 (while (re-search-forward Man-heading-regexp nil t) | 896 (goto-char (point-min)) |
893 (put-text-property (match-beginning 0) | 897 (while (re-search-forward Man-heading-regexp nil t) |
894 (match-end 0) | 898 (put-text-property (match-beginning 0) |
895 'face Man-overstrike-face)) | 899 (match-end 0) |
900 'face Man-overstrike-face))) | |
896 (message "%s man page formatted" Man-arguments)) | 901 (message "%s man page formatted" Man-arguments)) |
897 | 902 |
898 (defun Man-highlight-references () | 903 (defun Man-highlight-references () |
899 "Highlight the references on mouse-over. | 904 "Highlight the references on mouse-over. |
900 references include items in the SEE ALSO section, | 905 references include items in the SEE ALSO section, |