[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/man.el
From: |
Juanma Barranquero |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/man.el |
Date: |
Wed, 02 Apr 2003 16:22:39 -0500 |
Index: emacs/lisp/man.el
diff -c emacs/lisp/man.el:1.117 emacs/lisp/man.el:1.118
*** emacs/lisp/man.el:1.117 Sun Mar 9 09:05:25 2003
--- emacs/lisp/man.el Wed Apr 2 16:22:38 2003
***************
*** 95,100 ****
--- 95,101 ----
;;; Code:
(require 'assoc)
+ (require 'button)
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
;; empty defvars (keep the compiler quiet)
***************
*** 210,215 ****
--- 211,222 ----
(string :tag "Real Section")))
:group 'man)
+ (defcustom Man-header-file-path
+ '("/usr/include" "/usr/local/include")
+ "C Header file search path used in Man."
+ :type '(repeat string)
+ :group 'man)
+
(defvar manual-program "man"
"The name of the program that produces man pages.")
***************
*** 264,269 ****
--- 271,304 ----
(concat "\\(" Man-name-regexp "\\)(\\(" Man-section-regexp "\\))")
"Regular expression describing a reference to another manpage.")
+ (defvar Man-synopsis-regexp "SYNOPSIS"
+ "Regular expression for SYNOPSIS heading (or your equivalent).
+ This regexp should not start with a `^' character.")
+
+ (defvar Man-files-regexp "FILES"
+ "Regular expression for FILES heading (or your equivalent).
+ This regexp should not start with a `^' character.")
+
+ (defvar Man-include-regexp "#[ \t]*include[ \t]*"
+ "Regular expression describing the #include (directive of cpp).")
+
+ (defvar Man-file-name-regexp "[^<>\" \t\n]+"
+ "Regular expression describing <> in #include line (directive of cpp).")
+
+ (defvar Man-normal-file-prefix-regexp "[/~$]"
+ "Regular expression describing a file path appeared in FILES section.")
+
+ (defvar Man-header-regexp
+ (concat "\\(" Man-include-regexp "\\)"
+ "[<\"]"
+ "\\(" Man-file-name-regexp "\\)"
+ "[>\"]")
+ "Regular expression describing references to header files.")
+
+ (defvar Man-normal-file-regexp
+ (concat Man-normal-file-prefix-regexp Man-file-name-regexp)
+ "Regular expression describing references to normal files.")
+
;; This includes the section as an optional part to catch hyphenated
;; refernces to manpages.
(defvar Man-hyphenated-reference-regexp
***************
*** 333,339 ****
(if Man-mode-map
nil
! (setq Man-mode-map (make-keymap))
(suppress-keymap Man-mode-map)
(define-key Man-mode-map " " 'scroll-up)
(define-key Man-mode-map "\177" 'scroll-down)
--- 368,374 ----
(if Man-mode-map
nil
! (setq Man-mode-map (copy-keymap button-buffer-map))
(suppress-keymap Man-mode-map)
(define-key Man-mode-map " " 'scroll-up)
(define-key Man-mode-map "\177" 'scroll-down)
***************
*** 350,360 ****
(define-key Man-mode-map "k" 'Man-kill)
(define-key Man-mode-map "q" 'Man-quit)
(define-key Man-mode-map "m" 'man)
- (define-key Man-mode-map "\r" 'man-follow)
- (define-key Man-mode-map [mouse-2] 'man-follow-mouse)
(define-key Man-mode-map "?" 'describe-mode)
)
;; ======================================================================
;; utilities
--- 385,415 ----
(define-key Man-mode-map "k" 'Man-kill)
(define-key Man-mode-map "q" 'Man-quit)
(define-key Man-mode-map "m" 'man)
(define-key Man-mode-map "?" 'describe-mode)
)
+ ;; buttons
+ (define-button-type 'Man-xref-man-page
+ 'action (lambda (button) (man-follow (button-label button)))
+ 'help-echo "RET, mouse-2: display this man page")
+
+ (define-button-type 'Man-xref-header-file
+ 'action (lambda (button)
+ (unless (Man-view-header-file (button-get button
'Man-target-string))
+ (error "Cannot find header file: %s" w)))
+ 'help-echo "mouse-2: display this header file")
+
+ (define-button-type 'Man-xref-normal-file
+ 'action (lambda (button)
+ (let ((f (substitute-in-file-name
+ (button-get button 'Man-target-string))))
+ (if (file-exists-p f)
+ (if (file-readable-p f)
+ (view-file f)
+ (error "Cannot read a file: %s" f))
+ (error "Cannot find a file: %s" f))))
+ 'help-echo "mouse-2: mouse-2: display this file")
+
;; ======================================================================
;; utilities
***************
*** 562,574 ****
(error "No item under point")
(man man-args)))
- (defun man-follow-mouse (e)
- "Get a Un*x manual page of the item under the mouse and put it in a buffer."
- (interactive "e")
- (save-excursion
- (mouse-set-point e)
- (call-interactively 'man-follow)))
-
(defun Man-getpage-in-background (topic)
"Use TOPIC to build and fire off the manpage and cleaning command."
(let* ((man-args topic)
--- 617,622 ----
***************
*** 737,748 ****
(put-text-property (1- (point)) (point) 'face 'bold))
(goto-char (point-min))
;; Try to recognize common forms of cross references.
! (while (re-search-forward "\\w+([0-9].?)" nil t)
! (put-text-property (match-beginning 0) (match-end 0)
! 'mouse-face 'highlight))
(Man-softhyphen-to-minus)
(message "%s man page made up" Man-arguments))
(defun Man-cleanup-manpage ()
"Remove overstriking and underlining from the current buffer."
(interactive)
--- 785,825 ----
(put-text-property (1- (point)) (point) 'face 'bold))
(goto-char (point-min))
;; Try to recognize common forms of cross references.
! (Man-highlight-references)
(Man-softhyphen-to-minus)
(message "%s man page made up" Man-arguments))
+ (defun Man-highlight-references ()
+ "Highlight the references on mouse-over.
+ references include items in the SEE ALSO section,
+ header file(#include <foo.h>) and files in FILES"
+ (let ((dummy 0))
+ (Man-highlight-references0
+ Man-see-also-regexp Man-reference-regexp 1 dummy
+ 'Man-xref-man-page)
+ (Man-highlight-references0
+ Man-synopsis-regexp Man-header-regexp 0 2
+ 'Man-xref-header-file)
+ (Man-highlight-references0
+ Man-files-regexp Man-normal-file-regexp 0 0
+ 'Man-xref-normal-file)))
+
+ (defun Man-highlight-references0 (start-section regexp button-pos target-pos
type)
+ ;; Based on `Man-build-references-alist'
+ (when (Man-find-section start-section)
+ (forward-line 1)
+ (let ((end (save-excursion
+ (Man-next-section 1)
+ (point))))
+ (back-to-indentation)
+ (while (re-search-forward regexp end t)
+ (make-text-button
+ (match-beginning button-pos)
+ (match-end button-pos)
+ 'type type
+ 'Man-target-string (match-string target-pos)
+ )))))
+
(defun Man-cleanup-manpage ()
"Remove overstriking and underlining from the current buffer."
(interactive)
***************
*** 1193,1198 ****
--- 1270,1289 ----
(if Man-circular-pages-flag
(Man-goto-page (length Man-page-list))
(error "You're looking at the first manpage in the buffer"))))
+
+ ;; Header file support
+ (defun Man-view-header-file (file)
+ "View a header file specified by FILE from `Man-header-file-path'."
+ (let ((path Man-header-file-path)
+ complete-path)
+ (while path
+ (setq complete-path (concat (car path) "/" file)
+ path (cdr path))
+ (if (file-readable-p complete-path)
+ (progn (view-file complete-path)
+ (setq path nil))
+ (setq complete-path nil)))
+ complete-path))
;; Init the man package variables, if not already done.
(Man-init-defvars)
- [Emacs-diffs] Changes to emacs/lisp/man.el,
Juanma Barranquero <=
- [Emacs-diffs] Changes to emacs/lisp/man.el, Juanma Barranquero, 2003/04/03
- [Emacs-diffs] Changes to emacs/lisp/man.el, Miles Bader, 2003/04/04
- [Emacs-diffs] Changes to emacs/lisp/man.el, Kai Großjohann, 2003/04/07
- [Emacs-diffs] Changes to emacs/lisp/man.el, Thien-Thi Nguyen, 2003/04/09
- [Emacs-diffs] Changes to emacs/lisp/man.el, Richard M. Stallman, 2003/04/16