* header files in woman.el @ 2003-03-30 11:45 Masatake YAMATO 2003-03-31 8:37 ` Richard Stallman 0 siblings, 1 reply; 9+ messages in thread From: Masatake YAMATO @ 2003-03-30 11:45 UTC (permalink / raw) Cc: emacs-devel Hi, I've added buttons for header files(e.g. #include <foo.h>) and files in FILES section to woman.el. So a user can jump to the files with mouse-2 or return key. Could you approve this function? I'm using woman.el in CVS version of GNU Emacs. (defvar woman-version "0.551 (beta)" "WoMan version information.") Masatake YAMATO Index: lisp/woman.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/woman.el,v retrieving revision 1.15 diff -u -r1.15 woman.el --- lisp/woman.el 31 Jan 2003 15:18:38 -0000 1.15 +++ lisp/woman.el 30 Mar 2003 11:51:14 -0000 @@ -792,6 +792,24 @@ :type 'boolean :group 'woman-interface) +(defcustom woman-synopsis-regexp "SYNOPSIS" + "Regular expression for SYNOPSIS heading (or your equivalent). +This regexp should not start with a `^' character." + :type 'regexp + :group 'woman-interface) + +(defcustom woman-files-regexp "FILES" + "Regular expression for FILES heading (or your equivalent). +This regexp should not start with a `^' character." + :type 'regexp + :group 'woman-interface) + +(defcustom woman-header-file-path + '("/usr/include" "/usr/local/include") + "C Header file search path used in WoMan." + :type '(repeat string) + :group 'woman-interface) + \f ;; Formatting options @@ -1058,13 +1076,51 @@ Should include ?e, ?o (page even/odd) and either ?n (nroff) or ?t (troff). Default is '(?n ?e ?o). Set via `woman-emulation'.") +(defvar woman-include-regexp "#[ \t]*include[ \t]*" + "Regular expression describing the #include (directive of cpp).") + +(defvar woman-file-name-regexp "[^<>\" \t\n]+" + "Regular expression describing <> in #include line (directive of cpp).") + +(defvar woman-normal-file-prefix-regexp "[/~$]" + "Regular expression describing a file path appeared in FILES section.") + +(defvar woman-header-regexp + (concat "\\(" woman-include-regexp "\\)" + "[<\"]" + "\\(" woman-file-name-regexp "\\)" + "[>\"]") + "Regular expression describing references to header files.") + +(defvar woman-normal-file-regexp + (concat woman-normal-file-prefix-regexp woman-file-name-regexp) + "Regular expression describing references to normal files.") + \f ;;; Button types: -(define-button-type 'woman-xref +(define-button-type 'woman-xref-man-page 'action (lambda (button) (woman (button-label button))) 'help-echo "RET, mouse-2: display this man page") + +(define-button-type 'woman-xref-header-file + 'action (lambda (button) + (unless (woman-view-header-file (button-get button 'woman-target-string)) + (error "Cannot find header file: %s" w))) + 'help-echo "mouse-2: display this header file") + +(define-button-type 'woman-xref-normal-file + 'action (lambda (button) + (let ((f (substitute-in-file-name + (button-get button 'woman-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") + \f ;;; Specialized utility functions: @@ -1964,20 +2020,38 @@ (- (cadr time) (cadr WoMan-Man-start-time))))) (message "Man formatting done in %d seconds" time))) -(defun WoMan-highlight-references () - "Highlight the references (in the SEE ALSO section) on mouse-over." +(defun WoMan-highlight-references0 (start-section regexp button-pos target-pos type) ;; Based on `Man-build-references-alist' in `man'. - (when (Man-find-section Man-see-also-regexp) + (when (Man-find-section start-section) (forward-line 1) (let ((end (save-excursion - (Man-next-section 1) - (point)))) + (Man-next-section 1) + (point)))) (back-to-indentation) - (while (re-search-forward Man-reference-regexp end t) + (while (re-search-forward regexp end t) ;; Highlight reference when mouse is over it. ;; (NB: WoMan does not hyphenate!) - (make-text-button (match-beginning 1) (match-end 1) - 'type 'woman-xref))))) + (make-text-button + (match-beginning button-pos) + (match-end button-pos) + 'type type + 'woman-target-string (match-string target-pos) + ))))) + +(defun WoMan-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 ((just-dummy 0)) + (WoMan-highlight-references0 + Man-see-also-regexp Man-reference-regexp 1 just-dummy + 'woman-xref-man-page) + (WoMan-highlight-references0 + woman-synopsis-regexp woman-header-regexp 0 2 + 'woman-xref-header-file) + (WoMan-highlight-references0 + woman-files-regexp woman-normal-file-regexp 0 0 + 'woman-xref-normal-file))) \f ;;; Buffer handling: @@ -4548,4 +4622,18 @@ (provide 'woman) +\f +;; Header file support +(defun woman-view-header-file (file) + "View a header file specified by FILE from `woman-header-file-path'." + (let ((path woman-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)) ;;; woman.el ends here ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-03-30 11:45 header files in woman.el Masatake YAMATO @ 2003-03-31 8:37 ` Richard Stallman 2003-03-31 15:43 ` Masatake YAMATO 0 siblings, 1 reply; 9+ messages in thread From: Richard Stallman @ 2003-03-31 8:37 UTC (permalink / raw) Cc: emacs-devel woman.el uses Man mode in the buffer, once it has set up the buffer contents. So I think the right place to implement this feature is in man.el. If you implement this feature in man.el, it will work for woman.el too; it will work on all platforms. But if you implement it in woman.el, it will not work in systems that use the man program. Could you reimplememt this inside of Man-follow? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-03-31 8:37 ` Richard Stallman @ 2003-03-31 15:43 ` Masatake YAMATO 2003-03-31 16:35 ` Dr Francis J. Wright 2003-04-01 9:37 ` Richard Stallman 0 siblings, 2 replies; 9+ messages in thread From: Masatake YAMATO @ 2003-03-31 15:43 UTC (permalink / raw) Cc: emacs-devel woman.el uses Man mode in the buffer, once it has set up the buffer contents. So I think the right place to implement this feature is in man.el. If you implement this feature in man.el, it will work for woman.el too; it will work on all platforms. But if you implement it in woman.el, it will not work in systems that use the man program. Could you reimplememt this inside of Man-follow? I've tried. I've moved all woman.el's BUTTON related code to man.el; and I've used man.el's code in woman.el. Masatake YAMATO 2003-04-01 Masatake YAMATO <jet@gyve.org> * woman.el (woman-xref): removed. (woman-mode): Use `Man-highlight-references' instead of `WoMan-highlight-references'. (WoMan-highlight-references): removed. * man.el (toplevel): require button. (Man-header-file-path): New option. (Man-synopsis-regexp, Man-files-regexp, Man-include-regexp) (Man-file-name-regexp, Man-normal-file-prefix-regexp) (Man-header-regexp, Man-normal-file-regexp): New variables. (Man-mode-map): inherited from `button-buffer-map'. (Man-mode-map): don't define "\r" and mouse-2 directly. These key are defined in `button-buffer-map'. (Man-xref-man-page, Man-xref-header-file, Man-xref-normal-file): New buttons. `Man-xref-man-page' comes from woman.el. (man-follow-mouse): removed. (Man-fontify-manpage): use `Man-highlight-references' instead of calling `add-text-properties' directly. (Man-highlight-references, Man-highlight-references0): New functions. (Man-view-header-file): New function. Index: woman.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/woman.el,v retrieving revision 1.15 diff -u -r1.15 woman.el --- woman.el 31 Jan 2003 15:18:38 -0000 1.15 +++ woman.el 31 Mar 2003 15:50:29 -0000 @@ -1059,13 +1059,6 @@ Default is '(?n ?e ?o). Set via `woman-emulation'.") \f -;;; Button types: - -(define-button-type 'woman-xref - 'action (lambda (button) (woman (button-label button))) - 'help-echo "RET, mouse-2: display this man page") - -\f ;;; Specialized utility functions: ;;; Fast deletion without saving on the kill ring (cf. simple.el): @@ -1869,7 +1862,7 @@ (setq woman-imenu-done nil) (if woman-imenu (woman-imenu)) (setq buffer-read-only nil) - (WoMan-highlight-references) + (Man-highlight-references) (setq buffer-read-only t) (set-buffer-modified-p nil))) @@ -1963,21 +1956,6 @@ (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536) (- (cadr time) (cadr WoMan-Man-start-time))))) (message "Man formatting done in %d seconds" time))) - -(defun WoMan-highlight-references () - "Highlight the references (in the SEE ALSO section) on mouse-over." - ;; Based on `Man-build-references-alist' in `man'. - (when (Man-find-section Man-see-also-regexp) - (forward-line 1) - (let ((end (save-excursion - (Man-next-section 1) - (point)))) - (back-to-indentation) - (while (re-search-forward Man-reference-regexp end t) - ;; Highlight reference when mouse is over it. - ;; (NB: WoMan does not hyphenate!) - (make-text-button (match-beginning 1) (match-end 1) - 'type 'woman-xref))))) \f ;;; Buffer handling: Index: man.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/man.el,v retrieving revision 1.117 diff -u -r1.117 man.el --- man.el 9 Mar 2003 14:05:25 -0000 1.117 +++ man.el 31 Mar 2003 15:55:32 -0000 @@ -95,6 +95,7 @@ ;;; Code: (require 'assoc) +(require 'button) ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ;; empty defvars (keep the compiler quiet) @@ -210,6 +211,12 @@ (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,6 +271,34 @@ (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,7 +368,7 @@ (if Man-mode-map nil - (setq Man-mode-map (make-keymap)) + (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,11 +385,31 @@ (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) ) +;; 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") + \f ;; ====================================================================== ;; utilities @@ -562,13 +617,6 @@ (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) @@ -737,12 +785,41 @@ (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-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,6 +1270,20 @@ (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)) \f ;; Init the man package variables, if not already done. (Man-init-defvars) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-03-31 15:43 ` Masatake YAMATO @ 2003-03-31 16:35 ` Dr Francis J. Wright 2003-04-01 9:38 ` Richard Stallman 2003-04-01 9:37 ` Richard Stallman 1 sibling, 1 reply; 9+ messages in thread From: Dr Francis J. Wright @ 2003-03-31 16:35 UTC (permalink / raw) Cc: emacs-devel From: "Masatake YAMATO" <jet@gyve.org> To: <rms@gnu.org> Cc: <emacs-devel@gnu.org>; <F.J.Wright@qmul.ac.uk> Sent: Monday, March 31, 2003 4:43 PM Subject: Re: header files in woman.el > woman.el uses Man mode in the buffer, once it has set up the buffer > contents. So I think the right place to implement this feature > is in man.el. If you implement this feature in man.el, it will > work for woman.el too; it will work on all platforms. But if you > implement it in woman.el, it will not work in systems that use the > man program. > > Could you reimplememt this inside of Man-follow? > > I've tried. I've moved all woman.el's BUTTON related code to man.el; > and I've used man.el's code in woman.el. > > Masatake YAMATO Thanks. That's more or less what I was going to suggest doing. But until NT Emacs supports buttons, I can't easily test your code myself. Best wishes, Francis ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-03-31 16:35 ` Dr Francis J. Wright @ 2003-04-01 9:38 ` Richard Stallman 2003-04-01 10:03 ` Dr Francis J. Wright 0 siblings, 1 reply; 9+ messages in thread From: Richard Stallman @ 2003-04-01 9:38 UTC (permalink / raw) Cc: emacs-devel Thanks. That's more or less what I was going to suggest doing. But until NT Emacs supports buttons, I can't easily test your code myself. Buttons in Emacs are implemented in terms of mouse clicks and faces. If mouse clicks and faces work on Windows, why don't buttons work? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-04-01 9:38 ` Richard Stallman @ 2003-04-01 10:03 ` Dr Francis J. Wright 0 siblings, 0 replies; 9+ messages in thread From: Dr Francis J. Wright @ 2003-04-01 10:03 UTC (permalink / raw) Cc: emacs-devel From: "Richard Stallman" <rms@gnu.org> To: "Dr Francis J. Wright" <F.J.Wright@qmul.ac.uk> Cc: <jet@gyve.org>; <emacs-devel@gnu.org> Sent: Tuesday, April 01, 2003 10:38 AM Subject: Re: header files in woman.el > Thanks. That's more or less what I was going to suggest doing. But until > NT Emacs supports buttons, I can't easily test your code myself. > > Buttons in Emacs are implemented in terms of mouse clicks and faces. > If mouse clicks and faces work on Windows, why don't buttons work? I assumed "buttons" meant toolbar buttons, which don't work in NT Emacs because (as I understand it) the general image support does not yet work. Buttons in customization buttons etc. work fine. (Toolbars might work in other Windows ports of Emacs, such as Cygwin, but currently I use only NT Emacs.) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-03-31 15:43 ` Masatake YAMATO 2003-03-31 16:35 ` Dr Francis J. Wright @ 2003-04-01 9:37 ` Richard Stallman 2003-04-01 9:44 ` Masatake YAMATO 1 sibling, 1 reply; 9+ messages in thread From: Richard Stallman @ 2003-04-01 9:37 UTC (permalink / raw) Cc: emacs-devel I've tried. I've moved all woman.el's BUTTON related code to man.el; and I've used man.el's code in woman.el. Thanks. Does the result work well? The diff that you sent seems to start from your previous version. Can you send a diff and change log suitable to install into the current Emacs sources? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-04-01 9:37 ` Richard Stallman @ 2003-04-01 9:44 ` Masatake YAMATO 2003-04-02 9:19 ` Richard Stallman 0 siblings, 1 reply; 9+ messages in thread From: Masatake YAMATO @ 2003-04-01 9:44 UTC (permalink / raw) Cc: emacs-devel The diff that you sent seems to start from your previous version. Can you send a diff and change log suitable to install into the current Emacs sources? I sent the diff for the current Emacs sources in the CVS repository. However, I sent again. 2003-04-01 Masatake YAMATO <jet@gyve.org> * woman.el (woman-xref): removed. (woman-mode): Use `Man-highlight-references' instead of `WoMan-highlight-references'. (WoMan-highlight-references): removed. * man.el (toplevel): require button. (Man-header-file-path): New option. (Man-synopsis-regexp, Man-files-regexp, Man-include-regexp) (Man-file-name-regexp, Man-normal-file-prefix-regexp) (Man-header-regexp, Man-normal-file-regexp): New variables. (Man-mode-map): inherited from `button-buffer-map'. (Man-mode-map): don't define "\r" and mouse-2 directly. These key are defined in `button-buffer-map'. (Man-xref-man-page, Man-xref-header-file, Man-xref-normal-file): New buttons. `Man-xref-man-page' comes from woman.el. (man-follow-mouse): removed. (Man-fontify-manpage): use `Man-highlight-references' instead of calling `add-text-properties' directly. (Man-highlight-references, Man-highlight-references0): New functions. (Man-view-header-file): New function. Index: lisp/woman.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/woman.el,v retrieving revision 1.15 diff -u -r1.15 woman.el --- lisp/woman.el 31 Jan 2003 15:18:38 -0000 1.15 +++ lisp/woman.el 1 Apr 2003 10:12:12 -0000 @@ -1059,13 +1059,6 @@ Default is '(?n ?e ?o). Set via `woman-emulation'.") \f -;;; Button types: - -(define-button-type 'woman-xref - 'action (lambda (button) (woman (button-label button))) - 'help-echo "RET, mouse-2: display this man page") - -\f ;;; Specialized utility functions: ;;; Fast deletion without saving on the kill ring (cf. simple.el): @@ -1869,7 +1862,7 @@ (setq woman-imenu-done nil) (if woman-imenu (woman-imenu)) (setq buffer-read-only nil) - (WoMan-highlight-references) + (Man-highlight-references) (setq buffer-read-only t) (set-buffer-modified-p nil))) @@ -1963,21 +1956,6 @@ (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536) (- (cadr time) (cadr WoMan-Man-start-time))))) (message "Man formatting done in %d seconds" time))) - -(defun WoMan-highlight-references () - "Highlight the references (in the SEE ALSO section) on mouse-over." - ;; Based on `Man-build-references-alist' in `man'. - (when (Man-find-section Man-see-also-regexp) - (forward-line 1) - (let ((end (save-excursion - (Man-next-section 1) - (point)))) - (back-to-indentation) - (while (re-search-forward Man-reference-regexp end t) - ;; Highlight reference when mouse is over it. - ;; (NB: WoMan does not hyphenate!) - (make-text-button (match-beginning 1) (match-end 1) - 'type 'woman-xref))))) \f ;;; Buffer handling: Index: lisp/man.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/man.el,v retrieving revision 1.117 diff -u -r1.117 man.el --- lisp/man.el 9 Mar 2003 14:05:25 -0000 1.117 +++ lisp/man.el 1 Apr 2003 10:12:13 -0000 @@ -95,6 +95,7 @@ ;;; Code: (require 'assoc) +(require 'button) ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ;; empty defvars (keep the compiler quiet) @@ -210,6 +211,12 @@ (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,6 +271,34 @@ (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,7 +368,7 @@ (if Man-mode-map nil - (setq Man-mode-map (make-keymap)) + (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,11 +385,31 @@ (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) ) +;; 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") + \f ;; ====================================================================== ;; utilities @@ -562,13 +617,6 @@ (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) @@ -737,12 +785,41 @@ (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-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,6 +1270,20 @@ (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)) \f ;; Init the man package variables, if not already done. (Man-init-defvars) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: header files in woman.el 2003-04-01 9:44 ` Masatake YAMATO @ 2003-04-02 9:19 ` Richard Stallman 0 siblings, 0 replies; 9+ messages in thread From: Richard Stallman @ 2003-04-02 9:19 UTC (permalink / raw) Cc: emacs-devel I sent the diff for the current Emacs sources in the CVS repository. However, I sent again. Thanks. I will get that installed. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-04-02 9:19 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-03-30 11:45 header files in woman.el Masatake YAMATO 2003-03-31 8:37 ` Richard Stallman 2003-03-31 15:43 ` Masatake YAMATO 2003-03-31 16:35 ` Dr Francis J. Wright 2003-04-01 9:38 ` Richard Stallman 2003-04-01 10:03 ` Dr Francis J. Wright 2003-04-01 9:37 ` Richard Stallman 2003-04-01 9:44 ` Masatake YAMATO 2003-04-02 9:19 ` Richard Stallman
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.