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

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

Re: M-x man bolder default looking


From: Kevin Rodgers
Subject: Re: M-x man bolder default looking
Date: Wed, 29 Nov 2006 11:09:46 -0700
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Dan Jacobson wrote:
One must have the cursor on top, or immediately after a word, for M-x
man to give a nice default at the minibuffer prompt.

It should be pepped up to look around more in the buffer for defaults,
if the cursor is on whitespace.

As you say, Man-default-man-entry does the right thing when point is
adjacent to a following or preceding topic character (hyphen, letter,
number, period, underscore, plus, or colon).

But the code does not agree with the second part of this comment, in
that it does not return the nearest preceding topic:

      ;; Default man entry title is any word the cursor is on, or if
      ;; cursor not on a word, then nearest preceding word.

Instead, when point is between 2 non-topic characters,
Man-default-man-entry returns "".  Here's a minimal patch to make the
code agree with the comment:

*** man.el.orig 2006-09-02 23:28:55 -0000
--- man.el      2006-11-29 10:48:27 -0700
***************
*** 643,648 ****
--- 643,651 ----
      (save-excursion
        ;; Default man entry title is any word the cursor is on, or if
        ;; cursor not on a word, then nearest preceding word.
+       (unless (or (looking-at "[-a-zA-Z0-9._+:]")
+                   (looking-back "[-a-zA-Z0-9._+:]" (1- (point))))
+         (skip-chars-backward "^-a-zA-Z0-9._+:"))
        (skip-chars-backward "-a-zA-Z0-9._+:")
        (let ((start (point)))
        (skip-chars-forward "-a-zA-Z0-9._+:")

It doesn't behave intuitively though, because it doesn't skip backward
over the period, plus, and colon characters (which may be part of a
topic, but which are more often used as punctuation).  You might want to
remove them from the skip-chars-backward argument.

You might also consider a slightly more complicated bit to find the
nearest topic:

      (unless (or (looking-at "[-a-zA-Z0-9._+:]")
                  (looking-back "[-a-zA-Z0-9._+:]" (1- (point))))
        ;; move to the nearest topic on this line:
        (let ((next (save-excursion
                      (skip-chars-forward "^-a-zA-Z0-9_"
                                          (line-end-position))))
              (prev (save-excursion
                      (skip-chars-backward "^-a-zA-Z0-9_"
                                           (line-beginning-position)))))
          (if (< next (abs prev))
              (forward-char next)
            (forward-char prev))))

--
Kevin





reply via email to

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