GNU Emacs / XEmacs tip #(incf emacsen-tip-number)
I just did an "apt-get source" in the course of gathering mise en
place to study OpenLDAP, and needed a quick way to review the man
pages for all of the Build-Depends libraries, etc. Here's my
five minute solution.
First, I visited "debian/control", and used "C-space C-e M-w"[1] to
grab a copy of the Build-Depends line. Here's what it looks like:
Build-Depends: libdb3-dev, libwrap0-dev, debhelper (>= 2.0.54), libiodbc2-dev, patch, libsasl-dev, dpkg-dev (>= 1.7.1), libncurses5-dev
I then did "M-x shell", then "C-y" to grab that into a shell prompt,
after a quick "cd" to a more convienient location than the "debian/"
directory of OpenLDAP 2. I editted it, removing the header, the
commas, and the version numbers, leaving just a space separated list,
and then stuck it in a shell variable for easy access.
% export pkgs="libdb3-dev libwrap0-dev debhelper libiodbc2-dev patch libsasl-dev dpkg-dev libncurses5-dev"
I made sure those packages were all installed with a quick[2]:
% sudo apt-get -q install $pkgs
... and then:
% for pkg in $pkgs; do egrep '/man/' /var/lib/dpkg/info/$pkg.list >> manlist.txt; done
After that, I did "C-x C-f manlist.txt", and wrote the following lisp
function, which is now in my `user-init-file'[3]:
(require 'thingatpt)
(defun man-locally-at-point ()
(interactive)
(let ((manpage (thing-at-point 'filename)))
(if (= 1 (function-max-args #'manual-entry))
(manual-entry (concat manpage " -l"))
(manual-entry manpage "-l"))))
With my cursor on an interesting line in that "manlist.txt" file now,
I can type "M-x man-locally-at-point", and instantly have the man
page in view.
For browsing man pages that are part of a source package, here's what
I do:
(defun dired-man-locally ()
(interactive)
(if (= 1 (function-max-args #'manual-entry))
(manual-entry (concat (dired-get-filename) " -l"))
(manual-entry (dired-get-filename) "-l")))
(add-hook 'dired-setup-keys-hook
#'(lambda ()
(define-key dired-mode-map [(?l)] #'dired-man-locally)))
Now the "l" key in dired mode invokes `dired-man-locally'.
Footnotes:
[1] If you don't know what that did, here's a hint. "F1-k" invokes
`describe-key-binding', "F1-f" invokes `describe-function', and
"F1-a" invokes `apropos'.
[2] The "-q" here is for "quiet", not "quick". It suppresses the
spinners and updating percentage transfered, which doesn't work
right in the emacs shell mode. I don't know why "apt-get"
doesn't just check the term settings to see if it can do that.
[3] This is compatible with both GNU Emacs and XEmacs.
Reply to: