unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: <John.Basrai@ngc.com>
Subject: Suggestion to integrating emacs man pages with imenu.
Date: Tue, 14 Oct 2003 15:11:18 -0700	[thread overview]
Message-ID: <AC3BC8D4E568BC4A8E8F04531F721EFBE18451@mclca-xmb01> (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
 

                 reply	other threads:[~2003-10-14 22:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AC3BC8D4E568BC4A8E8F04531F721EFBE18451@mclca-xmb01 \
    --to=john.basrai@ngc.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).