From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jari Aalto Newsgroups: gmane.emacs.bugs Subject: Re: [21.3] [patch] M-x man does not pick word 'snmpd.conf(5)' Date: Thu, 25 Nov 2004 18:27:09 +0200 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1101401641 24289 80.91.229.6 (25 Nov 2004 16:54:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2004 16:54:01 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 25 17:53:53 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CXMeO-0008FX-00 for ; Thu, 25 Nov 2004 17:39:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXMcU-0005Kp-KX for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Nov 2004 11:37:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CXMcQ-0005Kj-UM for bug-gnu-emacs@gnu.org; Thu, 25 Nov 2004 11:37:19 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CXMcQ-0005KX-Fa for bug-gnu-emacs@gnu.org; Thu, 25 Nov 2004 11:37:18 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXMcQ-0005KU-Dx for bug-gnu-emacs@gnu.org; Thu, 25 Nov 2004 11:37:18 -0500 Original-Received: from [193.229.0.32] (helo=fep30-app.kolumbus.fi) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CXMSx-0007YD-3L for bug-gnu-emacs@gnu.org; Thu, 25 Nov 2004 11:27:31 -0500 Original-Received: from cante.net ([81.197.3.110]) by fep30-app.kolumbus.fi with ESMTP id <20041125162729.VCLS19007.fep30-app.kolumbus.fi@cante.net> for ; Thu, 25 Nov 2004 18:27:29 +0200 Original-To: bug-gnu-emacs@gnu.org In-Reply-To: (Andreas Schwab's message of "Sun, 21 Nov 2004 21:06:38 +0100") User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (windows-nt) 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: main.gmane.org gmane.emacs.bugs:9810 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:9810 Andreas Schwab writes: | Jari Aalto writes: | | > --- man.el.orig 2004-11-21 18:05:53.000000000 +0200 | > +++ man.el 2004-11-21 18:45:26.000000000 +0200 | > @@ -502,23 +502,35 @@ | > (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. | > + ;; Use local syntax table to find correct word in cases like: | > + ;; ioctl(2) or brc(1M) | > + (let* (word | > + (ret "") | > + (table (syntax-table)) | > + (orig (copy-sequence table))) | > + (modify-syntax-entry ?\( "w" table) | > + (modify-syntax-entry ?\) "w" table) | > + (modify-syntax-entry ?. "w" table) ;; snmpd.conf(5)=20 | > + (modify-syntax-entry ?- "w" table) ;; invoke-rc.d(8) | > + (set-syntax-table table) | > (setq word (current-word)) | > + (set-syntax-table orig) | | That should use with-syntax-table to not lose the old syntax table in cas= | e | of errors or quit (even if it is rather unlikely to occur). Here. Jari 2004-11-21 Jari Aalto * man.el (Man-default-man-entry): Use local syntax table to get correct full word in cases like 'snmpd.conf(5)' and invoke-rc.d(8) --- man.el.orig 2004-11-21 18:05:53.000000000 +0200 +++ man.el 2004-11-25 18:16:41.000000000 +0200 @@ -502,23 +502,33 @@ (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. + ;; Use local syntax table to find correct word in cases like: + ;; ioctl(2) or brc(1M) + (let (word + (ret "") + (table (syntax-table))) + (with-syntax-table table + (modify-syntax-entry ?\( "w" table) + (modify-syntax-entry ?\) "w" table) + (modify-syntax-entry ?. "w" table) ;; snmpd.conf(5) + (modify-syntax-entry ?- "w" table) ;; invoke-rc.d(8) (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) + ;; Delete leading "-.()". + (if (string-match "[a-zA-Z].*$" word) + (setq word (match-string 0 word))) ;; 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)) - ""))))) + (cond + ((string-match (format "[^ \t\r\n]+(%s)" Man-section-regexp) word) + (setq ret (format "%s" (match-string 0 word)))) + ((string-match "[^ \t\r\n()]+" word) + (setq word (match-string 0 word)) + (if (> (length word) 1) + (setq ret (format "%s" word))))) + ret))) ;; ======================================================================