bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: M-x man when cursor on top of hyphenated reference


From: Kevin Rodgers
Subject: Re: M-x man when cursor on top of hyphenated reference
Date: Mon, 23 Jun 2003 12:34:08 -0600

Richard Stallman writes:
>     > Hovever, the m command, which usually knows what is under the cursor,
>     > doesn't know about maildropex when on top of it
> 
>     Here's a hack for you to try.  If it works, I can try to implement it as
>     a proper patch to man.el:
> 
> If you would like to do that, please do.

This also does a slightly better job with simple references like cat(1),
which currently doesn't include the "(1)" in the return value if point
is between the command name and the parenthesized section number.


2003-06-23  Kevin Rodgers <ihs_4664@yahoo.com>

        * man.el (Man-default-man-entry): Handle hypenated references
        via a recursive call (flagged by new optional HYPHENATED arg)
        or a check by Man-possibly-hyphenated-word.


*** emacs-21.3/lisp/man.el.orig Fri Oct 18 19:21:09 2002
--- emacs-21.3/lisp/man.el      Mon Jun 23 11:58:58 2003
***************
*** 499,524 ****
  ;; ======================================================================
  ;; default man entry: get word under point
  
! (defsubst Man-default-man-entry ()
    "Make a guess at a default manual entry.
  This guess is based on the text surrounding the cursor."
!   (let (word)
      (save-excursion
!       ;; Default man entry title is any word the cursor is on, or if
!       ;; cursor not on a word, then nearest preceding word.
!       (setq word (current-word))
!       (if (string-match "[._]+$" word)
!         (setq word (substring word 0 (match-beginning 0))))
        ;; If looking at something like ioctl(2) or brc(1M), include the
!       ;; section number in the returned value.  Remove text properties.
!       (forward-word 1)
!       ;; Use `format' here to clear any text props from `word'.
!       (format "%s%s"
!             word
!             (if (looking-at
!                  (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
!                 (format "(%s)" (Man-match-substring 1))
!               "")))))
  
  
  ;; ======================================================================
--- 499,534 ----
  ;; ======================================================================
  ;; default man entry: get word under point
  
! (defsubst Man-default-man-entry (&optional hyphenated)
    "Make a guess at a default manual entry.
! This guess is based on the text surrounding point."
!   (let ((word (current-word)))                ; matches \(\sw\|\s_\)+
!     ;; Default man entry title is any word the cursor is on, or if
!     ;; cursor not on a word, then nearest preceding word.
!     (if (string-match "[._]+\\'" word)
!       (setq word (substring word 0 (match-beginning 0))))
      (save-excursion
!       (or hyphenated                  ; i.e. recursive call
!         (if (string-match "-\\'" word)
!             ;; word is the prefix of a hyphenated entry:
!             (setq word (concat (substring word 0 (match-beginning 0))
!                                (progn
!                                  (forward-line 1)
!                                  (Man-default-man-entry t))))
!           (let ((prefix (Man-possibly-hyphenated-word)))
!             (if (string-match "-\\'" prefix)
!                 ;; word is the suffix of a hyphenated entry:
!                 (setq word (concat (substring prefix 0 (match-beginning 0))
!                                    word))))))
        ;; If looking at something like ioctl(2) or brc(1M), include the
!       ;; section number in the returned value.
!       (if (looking-at (format "%s\\(\\sw\\|\\s_\\)*[ \t]*([ \t]*\\(%s\\)[ 
\t]*)"
!                             (if hyphenated
!                                 ""
!                               "[ \t]*")
!                             Man-section-regexp))
!         (format "%s(%s)" word (match-string 2))
!       word))))
  
  
  ;; ======================================================================


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]