aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2001-11-30 09:13:21 +0000
committerStefan Monnier2001-11-30 09:13:21 +0000
commit72397ff1a9b0d94ccf77c9bda86bd37657d21ffc (patch)
tree8f431eb573d3928baddf4b66b4a4757d197acbf5
parentedd7d3beb4e886caeba20af16cf7f5ce7f38336d (diff)
downloademacs-72397ff1a9b0d94ccf77c9bda86bd37657d21ffc.tar.gz
emacs-72397ff1a9b0d94ccf77c9bda86bd37657d21ffc.zip
(man-follow-mouse): New function.
(Man-mode-map): Bind mouse-2 to it. (Man-match-substring): Remove. Replace with `match-string'. (man): Use the `default-value' argument to `read-string'. (Man-fontify-manpage): Add mouse-face to cross references.
-rw-r--r--lisp/man.el46
1 files changed, 24 insertions, 22 deletions
diff --git a/lisp/man.el b/lisp/man.el
index 550d1c5f040..c9d175466f7 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -81,7 +81,7 @@
81;; footer). A different algorithm should be used. It is easy to 81;; footer). A different algorithm should be used. It is easy to
82;; compute how many blank lines there are before and after the page 82;; compute how many blank lines there are before and after the page
83;; headers, and after the page footer. But it is possible to compute 83;; headers, and after the page footer. But it is possible to compute
84;; the number of blank lines before the page footer by euristhics 84;; the number of blank lines before the page footer by heuristics
85;; only. Is it worth doing? 85;; only. Is it worth doing?
86;; - Allow a user option to mean that all the manpages should go in 86;; - Allow a user option to mean that all the manpages should go in
87;; the same buffer, where they can be browsed with M-n and M-p. 87;; the same buffer, where they can be browsed with M-n and M-p.
@@ -351,6 +351,7 @@ make -a one of the switches, if your `man' program supports it.")
351 (define-key Man-mode-map "q" 'Man-quit) 351 (define-key Man-mode-map "q" 'Man-quit)
352 (define-key Man-mode-map "m" 'man) 352 (define-key Man-mode-map "m" 'man)
353 (define-key Man-mode-map "\r" 'man-follow) 353 (define-key Man-mode-map "\r" 'man-follow)
354 (define-key Man-mode-map [mouse-2] 'man-follow-mouse)
354 (define-key Man-mode-map "?" 'describe-mode) 355 (define-key Man-mode-map "?" 'describe-mode)
355 ) 356 )
356 357
@@ -418,16 +419,6 @@ This is necessary if one wants to dump man.el with Emacs."
418 ))) 419 )))
419) 420)
420 421
421(defsubst Man-match-substring (&optional n string)
422 "Return the substring matched by the last search.
423Optional arg N means return the substring matched by the Nth paren
424grouping. Optional second arg STRING means return a substring from
425that string instead of from the current buffer."
426 (if (null n) (setq n 0))
427 (if string
428 (substring string (match-beginning n) (match-end n))
429 (buffer-substring (match-beginning n) (match-end n))))
430
431(defsubst Man-make-page-mode-string () 422(defsubst Man-make-page-mode-string ()
432 "Formats part of the mode line for Man mode." 423 "Formats part of the mode line for Man mode."
433 (format "%s page %d of %d" 424 (format "%s page %d of %d"
@@ -471,13 +462,13 @@ and the Man-section-translations-alist variables)."
471 (cond 462 (cond
472 ;; "chmod(2V)" case ? 463 ;; "chmod(2V)" case ?
473 ((string-match (concat "^" Man-reference-regexp "$") ref) 464 ((string-match (concat "^" Man-reference-regexp "$") ref)
474 (setq name (Man-match-substring 1 ref) 465 (setq name (match-string 1 ref)
475 section (Man-match-substring 2 ref))) 466 section (match-string 2 ref)))
476 ;; "2v chmod" case ? 467 ;; "2v chmod" case ?
477 ((string-match (concat "^\\(" Man-section-regexp 468 ((string-match (concat "^\\(" Man-section-regexp
478 "\\) +\\(" Man-name-regexp "\\)$") ref) 469 "\\) +\\(" Man-name-regexp "\\)$") ref)
479 (setq name (Man-match-substring 2 ref) 470 (setq name (match-string 2 ref)
480 section (Man-match-substring 1 ref)))) 471 section (match-string 1 ref))))
481 (if (string= name "") 472 (if (string= name "")
482 ref ; Return the reference as is 473 ref ; Return the reference as is
483 (if Man-downcase-section-letters-flag 474 (if Man-downcase-section-letters-flag
@@ -517,7 +508,7 @@ This guess is based on the text surrounding the cursor."
517 word 508 word
518 (if (looking-at 509 (if (looking-at
519 (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)")) 510 (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
520 (format "(%s)" (Man-match-substring 1)) 511 (format "(%s)" (match-string 1))
521 ""))))) 512 "")))))
522 513
523 514
@@ -547,11 +538,10 @@ all sections related to a subject, put something appropriate into the
547 (format "Manual entry%s: " 538 (format "Manual entry%s: "
548 (if (string= default-entry "") 539 (if (string= default-entry "")
549 "" 540 ""
550 (format " (default %s)" default-entry)))))) 541 (format " (default %s)" default-entry)))
542 nil nil default-entry)))
551 (if (string= input "") 543 (if (string= input "")
552 (if (string= default-entry "") 544 (error "No man args given")
553 (error "No man args given")
554 default-entry)
555 input)))) 545 input))))
556 546
557 ;; Possibly translate the "subject(section)" syntax into the 547 ;; Possibly translate the "subject(section)" syntax into the
@@ -569,6 +559,13 @@ all sections related to a subject, put something appropriate into the
569 (error "No item under point") 559 (error "No item under point")
570 (man man-args))) 560 (man man-args)))
571 561
562(defun man-follow-mouse (e)
563 "Get a Un*x manual page of the item under the mouse and put it in a buffer."
564 (interactive "e")
565 (save-excursion
566 (mouse-set-point e)
567 (call-interactively 'man-follow)))
568
572(defun Man-getpage-in-background (topic) 569(defun Man-getpage-in-background (topic)
573 "Use TOPIC to build and fire off the manpage and cleaning command." 570 "Use TOPIC to build and fire off the manpage and cleaning command."
574 (let* ((man-args topic) 571 (let* ((man-args topic)
@@ -713,6 +710,11 @@ Same for the ANSI bold and normal escape sequences."
713 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) 710 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t)
714 (replace-match "+") 711 (replace-match "+")
715 (put-text-property (1- (point)) (point) 'face 'bold)) 712 (put-text-property (1- (point)) (point) 'face 'bold))
713 (goto-char (point-min))
714 ;; Try to recognize common forms of cross references.
715 (while (re-search-forward "\\w+([0-9].?)" nil t)
716 (put-text-property (match-beginning 0) (match-end 0)
717 'mouse-face 'highlight))
716 (Man-softhyphen-to-minus) 718 (Man-softhyphen-to-minus)
717 (message "%s man page made up" Man-arguments)) 719 (message "%s man page made up" Man-arguments))
718 720
@@ -886,7 +888,7 @@ The following key bindings are currently in effect in the buffer:
886 (while (and (not (eobp)) (/= (point) runningpoint)) 888 (while (and (not (eobp)) (/= (point) runningpoint))
887 (setq runningpoint (point)) 889 (setq runningpoint (point))
888 (if (re-search-forward Man-hyphenated-reference-regexp end t) 890 (if (re-search-forward Man-hyphenated-reference-regexp end t)
889 (let* ((word (Man-match-substring 0)) 891 (let* ((word (match-string 0))
890 (len (1- (length word)))) 892 (len (1- (length word))))
891 (if hyphenated 893 (if hyphenated
892 (setq word (concat hyphenated word) 894 (setq word (concat hyphenated word)
@@ -912,7 +914,7 @@ The following key bindings are currently in effect in the buffer:
912 (while (not (eobp)) 914 (while (not (eobp))
913 (setq header 915 (setq header
914 (if (looking-at Man-page-header-regexp) 916 (if (looking-at Man-page-header-regexp)
915 (Man-match-substring 1) 917 (match-string 1)
916 nil)) 918 nil))
917 ;; Go past both the current and the next Man-first-heading-regexp 919 ;; Go past both the current and the next Man-first-heading-regexp
918 (if (re-search-forward Man-first-heading-regexp nil 'move 2) 920 (if (re-search-forward Man-first-heading-regexp nil 'move 2)