[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Suggestion to integrating emacs man pages with imenu.
From: |
John.Basrai |
Subject: |
Suggestion to integrating emacs man pages with imenu. |
Date: |
Tue, 14 Oct 2003 15:11:18 -0700 |
I like to use imenu to jump around the man page so I have a small
man-page-hook that adds the needed call-backs for imenu.el to work.
Also not sure if I'm handling buffer-read-only correctly.
It could be incorporated directly into man.el at the appropriate place.
I think just after the call to run-hooks.
(defun Man-prev-index-position ()
"Search for the previous procedure or function.
Return nil if not found. For use with imenu.el."
(save-match-data
(cond
((re-search-backward Man-heading-regexp -1 t))
(t nil))))
(defun Man-section-name ()
"Return the section name.
Assumes that point is at the beginning of the section as found by
`Man-heading-regexp'."
(let ((begin (point)))
(end-of-line 1)
(downcase
(if (fboundp 'buffer-substring-no-properties)
(buffer-substring-no-properties begin (point))
(buffer-substring begin (point))))))
(defun Man-mode-hook()
(save-excursion
(widen)
(setq buffer-read-only nil)
(goto-char (point-min))
;;bold the section headings.
;; My man program doesn't seem to overstrike the section heads
;; so they don't come out build when man page is done.
;; This will force them to be bold.
(while (re-search-forward Man-heading-regexp (point-max) t)
(progn
(put-text-property (point)
(progn
(beginning-of-line 1) (point))
'face Man-overstrike-face)
(beginning-of-line 2)))
(setq buffer-read-only t))
;; Arrange for imenu to work by indexing the section heads.
(set (make-local-variable 'imenu-prev-index-position-function)
'Man-prev-index-position)
(set (make-local-variable 'imenu-extract-index-name-function)
'Man-section-name)
)
(add-hook 'Man-mode-hook 'Man-mode-hook)
-John Basrai
Software Engineer
John.Basrai@ngc.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Suggestion to integrating emacs man pages with imenu.,
John.Basrai <=