* Suggestion to integrating emacs man pages with imenu.
@ 2003-10-14 22:11 John.Basrai
0 siblings, 0 replies; only message in thread
From: John.Basrai @ 2003-10-14 22:11 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-10-14 22:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-14 22:11 Suggestion to integrating emacs man pages with imenu John.Basrai
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.