home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / dired-man.el < prev    next >
Encoding:
Text File  |  1991-06-03  |  3.9 KB  |  101 lines

  1. ; Path: dg-rtp!rock.concert.net!mcnc!stanford.edu!hsdndev!wuarchive!cs.utexas.edu!cse!evax!lindahl
  2. ; From: lindahl@arrisun3.uta.edu (Charlie S. Lindahl)
  3. ; Newsgroups: gnu.emacs.sources
  4. ; Subject: Revised DIRED-MAN.EL
  5. ; Date: 1 Jun 91 18:22:37 GMT
  6. ; Organization: Automation and Robotics Research Institute, U Texas @ Arlington
  7. ; All: 
  8. ; Here's a new version of DIRED-MAN.EL, a short function which adds
  9. ; the capability to invoke MAN on files from within DIRED. My original
  10. ; description appears below. 
  11. ; Thanx to Steinar Bang (steinarb@idt.unit.no) for noticing that I used a 
  12. ; function ("dired-run-shell-command") in the original version, which is
  13. ; only defined by the advanced DIRED I use (TREE-DIRED, in the archives). I 
  14. ; have called the standard "shell-run-command" function, instead. 
  15. ; Please send me EMAIL if you use this little utility; I am curious as 
  16. ; to how many other folks wanted/needed this functionality. 
  17. ; Charlie S. Lindahl
  18. ; Automation and Robotics Research Institute
  19. ; University of Texas at Arlington
  20. ; Internet EMAIL: lindahl@cse.uta.edu
  21. ; ------------------------------------------------------------------------
  22. ;; MAN command invocation from within DIRED
  23. ;; Copyright (C) 1989 Free Software Foundation, Inc.
  24.  
  25. ;; This file is not officially part of GNU Emacs, but is being donated
  26. ;; to the Free Software Foundation.
  27.  
  28. ;; GNU Emacs is distributed in the hope that it will be useful,
  29. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  30. ;; accepts responsibility to anyone for the consequences of using it
  31. ;; or for whether it serves any particular purpose or works at all,
  32. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  33. ;; License for full details.
  34.  
  35. ;; Everyone is granted permission to copy, modify and redistribute
  36. ;; GNU Emacs, but only under the conditions described in the
  37. ;; GNU Emacs General Public License.   A copy of this license is
  38. ;; supposed to have been given to you along with GNU Emacs so you
  39. ;; can know your rights and responsibilities.  It should be in a
  40. ;; file named COPYING.  Among other things, the copyright notice
  41. ;; and this notice must be preserved on all copies.
  42.  
  43. ;; Created by: Charlie Lindahl, lindahl@cse.uta.edu
  44. ;; Purpose: Add MAN invocation from within DIRED (particularly handy
  45. ;;          for X man pages!) when files have not yet been installed
  46. ;;          in the usual MAN places.
  47. ;;
  48. ;; Change log: 
  49. ;;    6/01/91 : Modified to use "shell-command" function (built-in
  50. ;;              GNU EMACS function) instead of "dired-run-shell-command"
  51. ;;          used in original version. Thanx to steinar@idt.unit.no
  52. ;;          for the suggestion/feedback (Steinar Bang)
  53. ;;     5/15/91 : Original 
  54. ;;
  55. ;;
  56.  
  57. ;; The idea for this function & binding came from the fact that I am
  58. ;; constantly downloading new X stuff (most of which contain a ".man"
  59. ;; file); I wanted to be able to look at the ".man" files without
  60. ;; explicitly having to copy them into /usr/man (or wherever your
  61. ;; man pages live). 
  62. ;;
  63. ;; Since the DIRED buffer is read-only, "CONTROL-M" was bound to 
  64. ;; "newline" but disabled due to the read-only status; therefore I felt
  65. ;; free to replace the binding.
  66. ;;
  67. (define-key dired-mode-map "\C-m" 'dired-do-man)
  68.  
  69. (defun dired-do-man (&optional arg)
  70.   (interactive "P")
  71.   (let* (buffer-read-only 
  72.      (from-file (dired-get-filename))
  73.      (nroff-command-to-run      
  74.       (concat "nroff" " -man " " -h " from-file)))
  75.     (message (format "Expanding MAN page for %s..." from-file))
  76.     (shell-command nroff-command-to-run)
  77.     (save-excursion 
  78.       (set-buffer "*Shell Command Output*")
  79.       (rename-buffer (format "*Manual Entry %s*" 
  80.                  (file-name-nondirectory from-file)))
  81.       (message 
  82.        (concat "Cleaning manual entry in buffer " (buffer-name)))
  83.     (nuke-nroff-bs)
  84.     (set-buffer-modified-p nil)
  85.     )
  86.     (message "")
  87.   ))
  88.  
  89. --
  90. Charlie S. Lindahl
  91. Automation and Robotics Research Institute
  92. University of Texas at Arlington
  93. Internet EMAIL: lindahl@cse.uta.edu
  94.  
  95. Standard disclaimer: Ain't no opinion but my own.
  96.