all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* M-x man could better guess neighboring word
@ 2007-12-14  8:07 jidanni
  2007-12-14  9:40 ` martin rudalics
  0 siblings, 1 reply; 7+ messages in thread
From: jidanni @ 2007-12-14  8:07 UTC (permalink / raw)
  To: bug-gnu-emacs

My cursor is at "_":
jidanni@fartzwadd:~$ crontab _
and I do M-x man, and it doesn't prompt me with the default of
crontab, instead I have to move the cursor back a bit and try again.
emacs-version "22.1.1"




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-14  8:07 M-x man could better guess neighboring word jidanni
@ 2007-12-14  9:40 ` martin rudalics
  2007-12-15  1:33   ` jidanni
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-12-14  9:40 UTC (permalink / raw)
  To: jidanni; +Cc: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

> My cursor is at "_":
> jidanni@fartzwadd:~$ crontab _
> and I do M-x man, and it doesn't prompt me with the default of
> crontab, instead I have to move the cursor back a bit and try again.
> emacs-version "22.1.1"

Please try the attached patch.  Would you find it useful to
search previous lines, the remainder of the current line,
following lines?  Should we skip any non-whitespace chars?


[-- Attachment #2: man.patch --]
[-- Type: text/plain, Size: 457 bytes --]

*** man.el.~1.167.2.6.~	Thu Nov 29 19:51:20 2007
--- man.el	Fri Dec 14 10:22:56 2007
***************
*** 652,657 ****
--- 652,658 ----
        (if pos (goto-char pos))
        ;; Default man entry title is any word the cursor is on, or if
        ;; cursor not on a word, then nearest preceding word.
+       (skip-chars-backward " \t")
        (skip-chars-backward "-a-zA-Z0-9._+:")
        (let ((start (point)))
  	(skip-chars-forward "-a-zA-Z0-9._+:")


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-14  9:40 ` martin rudalics
@ 2007-12-15  1:33   ` jidanni
  2007-12-16 10:11     ` martin rudalics
  0 siblings, 1 reply; 7+ messages in thread
From: jidanni @ 2007-12-15  1:33 UTC (permalink / raw)
  To: bug-gnu-emacs

mr> Would you find it useful to search previous lines, the remainder
mr> of the current line, following lines? Should we skip any
mr> non-whitespace chars?

Principles: always offer at least two default choices, one
forwards/beneath, one backwards/beneath the cursor. The topmost of
which should be the closest to the cursor. Skip past punctuation at
the ends of sentences too...




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-15  1:33   ` jidanni
@ 2007-12-16 10:11     ` martin rudalics
  2007-12-17 13:38       ` jidanni
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-12-16 10:11 UTC (permalink / raw)
  To: jidanni; +Cc: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

> Principles: always offer at least two default choices, one
> forwards/beneath, one backwards/beneath the cursor. The topmost of
> which should be the closest to the cursor. Skip past punctuation at
> the ends of sentences too...

Does the attached patch obey these principles?  I'm not quite sure
which characters shall consitute punctuation.

[-- Attachment #2: man.patch --]
[-- Type: text/plain, Size: 3106 bytes --]

*** man.el.~1.175.~	Sat Dec  8 10:07:02 2007
--- man.el	Sun Dec 16 11:06:08 2007
***************
*** 647,672 ****
  (defsubst Man-default-man-entry (&optional pos)
    "Make a guess at a default manual entry based on the text at POS.
  If POS is nil, the current point is used."
!   (let (word)
      (save-excursion
        (if pos (goto-char pos))
        ;; Default man entry title is any word the cursor is on, or if
!       ;; cursor not on a word, then nearest preceding word.
!       (skip-chars-backward "-a-zA-Z0-9._+:")
!       (let ((start (point)))
! 	(skip-chars-forward "-a-zA-Z0-9._+:")
! 	;; If there is a continuation at the end of line, check the
! 	;; following line too, eg:
! 	;;     see this-
! 	;;     command-here(1)
! 	(setq word (buffer-substring-no-properties start (point)))
! 	(if (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
! 	    (setq word (concat word (match-string 1)))))
!       (if (string-match "[._]+$" word)
! 	  (setq word (substring word 0 (match-beginning 0))))
        ;; If looking at something like *strcat(... , remove the '*'
!       (if (string-match "^*" word)
! 	  (setq word (substring word 1)))
        ;; If looking at something like ioctl(2) or brc(1M), include the
        ;; section number in the returned value.  Remove text properties.
        (concat word
--- 647,685 ----
  (defsubst Man-default-man-entry (&optional pos)
    "Make a guess at a default manual entry based on the text at POS.
  If POS is nil, the current point is used."
!   (let (word start original-pos distance)
      (save-excursion
        (if pos (goto-char pos))
        ;; Default man entry title is any word the cursor is on, or if
!       ;; cursor not on a word, nearest preceding or next word on this
!       ;; line.
!       (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:")))
! 	  (setq start (point))
! 	(setq original-pos (point))
! 	(setq distance (abs (skip-chars-backward " \t")))
! 	(if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:")))
! 	    (progn
! 	      (setq start (point))
! 	      (goto-char original-pos)
! 	      (if (and (< (skip-chars-forward " \t") distance)
! 		       (looking-at "[-a-zA-Z0-9._+:]"))
! 		  (setq start (point))
! 		(goto-char start)))
! 	  (skip-chars-forward " \t")
! 	  (setq start (point))))
!       (skip-chars-forward "-a-zA-Z0-9._+:")
!       (setq word (buffer-substring-no-properties start (point)))
!       ;; If there is a continuation at the end of line, check the
!       ;; following line too, eg:
!       ;;     see this-
!       ;;     command-here(1)
!       (when (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
! 	(setq word (concat word (match-string-no-properties 1))))
!       (when (string-match "[._]+$" word)
! 	(setq word (substring word 0 (match-beginning 0))))
        ;; If looking at something like *strcat(... , remove the '*'
!       (when (string-match "^*" word)
! 	(setq word (substring word 1)))
        ;; If looking at something like ioctl(2) or brc(1M), include the
        ;; section number in the returned value.  Remove text properties.
        (concat word

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-16 10:11     ` martin rudalics
@ 2007-12-17 13:38       ` jidanni
  2007-12-17 22:19         ` martin rudalics
  0 siblings, 1 reply; 7+ messages in thread
From: jidanni @ 2007-12-17 13:38 UTC (permalink / raw)
  To: bug-gnu-emacs

mr> Does the attached patch obey these principles?  I'm not quite sure
mr> which characters shall consitute punctuation.
patching file man.el
Hunk #1 FAILED at 647.

Never mind, I trust you, and thanks for the effort. I'm a pure Debian
sid shop, not current fresh version, and... trust you thanks.

P.S., given a non-existent page,
(man "hahaha")
Loading man...done
Invoking man hahaha in the background
Please wait: formatting the hahaha man page...
hahaha man page formatted
error in process sentinel: Man-bgproc-sentinel: Can't find the hahaha manpage

Odd, it talks with so much confidence, but then it can't find the
meatloaf it says it just baked. I guess that's how asynchronous
messages work.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-17 13:38       ` jidanni
@ 2007-12-17 22:19         ` martin rudalics
  2007-12-18  1:53           ` jidanni
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-12-17 22:19 UTC (permalink / raw)
  To: jidanni; +Cc: bug-gnu-emacs

> mr> I'm not quite sure
> mr> which characters shall consitute punctuation.

You didn't state anything here.  Is ", \t" sufficient or shall I
skip something else?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: M-x man could better guess neighboring word
  2007-12-17 22:19         ` martin rudalics
@ 2007-12-18  1:53           ` jidanni
  0 siblings, 0 replies; 7+ messages in thread
From: jidanni @ 2007-12-18  1:53 UTC (permalink / raw)
  To: bug-gnu-emacs

r> which characters shall consitute punctuation.

r> You didn't state anything here.  Is ", \t" sufficient or shall I
r> skip something else?

Perhaps use some emacs syntax table definition of punctuation... or
OK, I mean anything that wouldn't be part of a man page name. Hmmm, I
recall I've never seen commas in man page names, but have seen lots of
: and - and _. Regarding ".", I've only seen it with a man page name,
not at the edges... Sorry I can't be more helpful. Hmmm,
$ apropos .
gives lots of man page names to test on.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-12-18  1:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14  8:07 M-x man could better guess neighboring word jidanni
2007-12-14  9:40 ` martin rudalics
2007-12-15  1:33   ` jidanni
2007-12-16 10:11     ` martin rudalics
2007-12-17 13:38       ` jidanni
2007-12-17 22:19         ` martin rudalics
2007-12-18  1:53           ` jidanni

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.