From: Jari Aalto <jari.aalto@cante.net>
Subject: Re: [21.3] [patch] M-x man does not pick word 'snmpd.conf(5)'
Date: Thu, 25 Nov 2004 18:27:09 +0200 [thread overview]
Message-ID: <u0rdx5b6.fsf@blue.sea.net> (raw)
In-Reply-To: <jek6sf7yr5.fsf@sykes.suse.de> (Andreas Schwab's message of "Sun, 21 Nov 2004 21:06:38 +0100")
Andreas Schwab <schwab@suse.de> writes:
| Jari Aalto <jari.aalto@cante.net> 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 <jari aalto A T cante net>
* 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)))
\f
;; ======================================================================
next prev parent reply other threads:[~2004-11-25 16:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-21 16:47 [21.3] [patch] M-x man does not pick word 'snmpd.conf(5)' Jari Aalto
2004-11-21 20:06 ` Andreas Schwab
2004-11-25 16:27 ` Jari Aalto [this message]
[not found] ` <mailman.1459.1101400640.27204.bug-gnu-emacs@gnu.org>
2004-11-25 19:27 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u0rdx5b6.fsf@blue.sea.net \
--to=jari.aalto@cante.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.