aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasatake YAMATO2005-11-06 18:01:34 +0000
committerMasatake YAMATO2005-11-06 18:01:34 +0000
commit30abc4f43e8696fc0e6696acd372187139e6a596 (patch)
treee3528b0b3f9374cef25b699ac66d3a00542df454
parent21c172a36f17aa9143052f49c4d065b2b6793f86 (diff)
downloademacs-30abc4f43e8696fc0e6696acd372187139e6a596.tar.gz
emacs-30abc4f43e8696fc0e6696acd372187139e6a596.zip
Improve man -k support.
(Man-reference-regexp): Accpet spaces between `Man-name-regexp' and `Man-section-regexp'. (Man-apropos-regexp): New variable. (Man-abstract-xref-man-page): Use value for `Man-target-string' if available. (Man-highlight-references, Man-highlight-references0): Handle the case when `Man-arguments' includes "-k". (Man-highlight-references0): Rename the argument `TARGET-POS' to `TARGET'. `TARGET' can be a number, function or nil.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/man.el51
2 files changed, 50 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2dafec8dcd6..6c36e3ae86b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12005-11-07 Masatake YAMATO <jet@gyve.org>
2
3 * man.el (Man-reference-regexp): Accpet spaces between
4 `Man-name-regexp' and `Man-section-regexp'.
5 (Man-apropos-regexp): New variable.
6 (Man-abstract-xref-man-page): Use value for `Man-target-string'
7 if available.
8 (Man-highlight-references, Man-highlight-references0): Handle
9 the case when `Man-arguments' includes "-k".
10 (Man-highlight-references0): Rename the argument `TARGET-POS' to
11 `TARGET'. `TARGET' can be a number, function or nil.
12
12005-11-06 Nick Roberts <nickrob@snap.net.nz> 132005-11-06 Nick Roberts <nickrob@snap.net.nz>
2 14
3 * progmodes/gdb-ui.el (gdb-var-create-handler, gdb-var-delete) 15 * progmodes/gdb-ui.el (gdb-var-create-handler, gdb-var-delete)
diff --git a/lisp/man.el b/lisp/man.el
index c54a00d3663..30ab44efad0 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -286,9 +286,13 @@ This regexp should not start with a `^' character.")
286This regular expression should start with a `^' character.") 286This regular expression should start with a `^' character.")
287 287
288(defvar Man-reference-regexp 288(defvar Man-reference-regexp
289 (concat "\\(" Man-name-regexp "\\)(\\(" Man-section-regexp "\\))") 289 (concat "\\(" Man-name-regexp "\\)[ \t]*(\\(" Man-section-regexp "\\))")
290 "Regular expression describing a reference to another manpage.") 290 "Regular expression describing a reference to another manpage.")
291 291
292(defvar Man-apropos-regexp
293 (concat "\\\[\\(" Man-name-regexp "\\)\\\][ \t]*(\\(" Man-section-regexp "\\))")
294 "Regular expression describing a reference to manpages in \"man -k output\".")
295
292(defvar Man-synopsis-regexp "SYNOPSIS" 296(defvar Man-synopsis-regexp "SYNOPSIS"
293 "Regular expression for SYNOPSIS heading (or your equivalent). 297 "Regular expression for SYNOPSIS heading (or your equivalent).
294This regexp should not start with a `^' character.") 298This regexp should not start with a `^' character.")
@@ -421,7 +425,8 @@ Otherwise, the value is whatever the function
421 'func nil 425 'func nil
422 'action (lambda (button) (funcall 426 'action (lambda (button) (funcall
423 (button-get button 'func) 427 (button-get button 'func)
424 (button-label button)))) 428 (or (button-get button 'Man-target-string)
429 (button-label button)))))
425 430
426(define-button-type 'Man-xref-man-page 431(define-button-type 'Man-xref-man-page
427 :supertype 'Man-abstract-xref-man-page 432 :supertype 'Man-abstract-xref-man-page
@@ -918,9 +923,20 @@ header file (#include <foo.h>) and files in FILES.
918If XREF-MAN-TYPE is used as the button type for items 923If XREF-MAN-TYPE is used as the button type for items
919in SEE ALSO section. If it is nil, default type, 924in SEE ALSO section. If it is nil, default type,
920`Man-xref-man-page' is used." 925`Man-xref-man-page' is used."
921 (let ((dummy 0)) 926 (if (string-match "-k " Man-arguments)
927 (progn
928 (Man-highlight-references0
929 nil Man-reference-regexp 1 nil
930 (or xref-man-type 'Man-xref-man-page))
931 (Man-highlight-references0
932 nil Man-apropos-regexp 1 (lambda ()
933 (format "%s(%s)"
934 (match-string 1)
935 (match-string 2)))
936 (or xref-man-type 'Man-xref-man-page))
937 )
922 (Man-highlight-references0 938 (Man-highlight-references0
923 Man-see-also-regexp Man-reference-regexp 1 dummy 939 Man-see-also-regexp Man-reference-regexp 1 nil
924 (or xref-man-type 'Man-xref-man-page)) 940 (or xref-man-type 'Man-xref-man-page))
925 (Man-highlight-references0 941 (Man-highlight-references0
926 Man-synopsis-regexp Man-header-regexp 0 2 942 Man-synopsis-regexp Man-header-regexp 0 2
@@ -929,21 +945,30 @@ in SEE ALSO section. If it is nil, default type,
929 Man-files-regexp Man-normal-file-regexp 0 0 945 Man-files-regexp Man-normal-file-regexp 0 0
930 'Man-xref-normal-file))) 946 'Man-xref-normal-file)))
931 947
932(defun Man-highlight-references0 (start-section regexp button-pos target-pos type) 948(defun Man-highlight-references0 (start-section regexp button-pos target type)
933 ;; Based on `Man-build-references-alist' 949 ;; Based on `Man-build-references-alist'
934 (when (Man-find-section start-section) 950 (when (or (null start-section)
935 (forward-line 1) 951 (Man-find-section start-section))
936 (let ((end (save-excursion 952 (let ((end (if start-section
937 (Man-next-section 1) 953 (progn
938 (point)))) 954 (forward-line 1)
939 (back-to-indentation) 955 (back-to-indentation)
956 (save-excursion
957 (Man-next-section 1)
958 (point)))
959 (goto-char (point-min))
960 (point-max))))
940 (while (re-search-forward regexp end t) 961 (while (re-search-forward regexp end t)
941 (make-text-button 962 (make-text-button
942 (match-beginning button-pos) 963 (match-beginning button-pos)
943 (match-end button-pos) 964 (match-end button-pos)
944 'type type 965 'type type
945 'Man-target-string (match-string target-pos) 966 'Man-target-string (cond
946 ))))) 967 ((numberp target)
968 (match-string target))
969 ((functionp target)
970 (funcall target))
971 (t nil)))))))
947 972
948(defun Man-cleanup-manpage (&optional interactive) 973(defun Man-cleanup-manpage (&optional interactive)
949 "Remove overstriking and underlining from the current buffer. 974 "Remove overstriking and underlining from the current buffer.