[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[21.3] [patch] M-x man does not pick word 'snmpd.conf(5)'
From: |
Jari Aalto |
Subject: |
[21.3] [patch] M-x man does not pick word 'snmpd.conf(5)' |
Date: |
Sun, 21 Nov 2004 18:47:51 +0200 |
In GNU Emacs 21.3.1 (i386-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2004-10-16 on raven, modified by Debian
configured using `configure '--build=i386-linux' '--host=i386-linux'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes' '--with-x=yes'
'--with-x-toolkit=athena' 'CFLAGS=-DDEBIAN -g -O2' 'build_alias=i386-linux'
'host_alias=i386-linux''
Command M-x man and the call to (Man-default-man-entry) does not pick full
manual page reference like snmpd.conf(5).
Given cursor -!- positions:
sn-!-mpd.conf(5) => (Man-default-man-entry) => snmp
snmpd.c-!-onf(5) => (Man-default-man-entry) => conf(5)
Patch attached. Old defsubst was completely rewritten to take
use of the syntax table instead of relying forward-word etc.
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)'.
--- 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)
+ (modify-syntax-entry ?- "w" table) ;; invoke-rc.d(8)
+ (set-syntax-table table)
(setq word (current-word))
+ (set-syntax-table orig)
(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))
;; ======================================================================
- [21.3] [patch] M-x man does not pick word 'snmpd.conf(5)',
Jari Aalto <=