[Top][All Lists]

[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."
     ((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
  (let ((begin (point)))
    (end-of-line 1)
     (if (fboundp 'buffer-substring-no-properties)
         (buffer-substring-no-properties begin (point))
       (buffer-substring begin (point))))))

(defun Man-mode-hook()
    (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)
        (put-text-property (point)
                             (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)

  (set (make-local-variable 'imenu-extract-index-name-function)
(add-hook 'Man-mode-hook 'Man-mode-hook)

-John Basrai
Software Engineer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]