From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: Re: M-x man could better guess neighboring word Date: Sun, 16 Dec 2007 11:11:17 +0100 Message-ID: <4764F9C5.6070706@gmx.at> References: <47624FA7.1030009@gmx.at> <87bq8slp16.fsf@jidanni.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060408020406040200010109" X-Trace: ger.gmane.org 1197799947 20105 80.91.229.12 (16 Dec 2007 10:12:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Dec 2007 10:12:27 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: jidanni@jidanni.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 16 11:12:39 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J3qU8-0003Zc-TE for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Dec 2007 11:12:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J3qTo-0002fE-Vx for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Dec 2007 05:12:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J3qTe-0002eO-0S for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2007 05:12:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J3qTa-0002d2-1m for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2007 05:12:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J3qTZ-0002cx-TW for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2007 05:12:01 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1J3qTZ-0002AB-3b for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2007 05:12:01 -0500 Original-Received: (qmail invoked by alias); 16 Dec 2007 10:11:56 -0000 Original-Received: from N775P021.adsl.highway.telekom.at (EHLO [62.47.40.213]) [62.47.40.213] by mail.gmx.net (mp041) with SMTP; 16 Dec 2007 11:11:56 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18u2ccquysuUWpM1bCVed/8zCtjvdECV0RZBFZPkQ rD+t0HXlJlYrFd User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: <87bq8slp16.fsf@jidanni.org> X-Y-GMX-Trusted: 0 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17172 Archived-At: This is a multi-part message in MIME format. --------------060408020406040200010109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > 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. --------------060408020406040200010109 Content-Type: text/plain; name="man.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="man.patch" *** 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 --------------060408020406040200010109--