home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / ilisp / popper.el < prev    next >
Encoding:
Text File  |  1992-06-29  |  20.5 KB  |  566 lines

  1. ;;; -*-Emacs-Lisp-*-
  2. ;;; %Header
  3. ;;; Shrink-wrapped temporary windows for GNU Emacs V2.11
  4. ;;; Copyright (C) 1990, 1991, 1992 Chris McConnell, ccm@cs.cmu.edu.
  5. ;;; Thanks to Ken Laprade for suggestions and patches.
  6. ;;; hacked for Emacs 19 and Lucid GNU Emacs
  7.  
  8. ;;; This file is part of GNU Emacs.
  9.  
  10. ;;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;;; but WITHOUT ANY WARRANTY.  No author or distributor
  12. ;;; accepts responsibility to anyone for the consequences of using it
  13. ;;; or for whether it serves any particular purpose or works at all,
  14. ;;; unless he says so in writing.  Refer to the GNU Emacs General Public
  15. ;;; License for full details.
  16.  
  17. ;;; Everyone is granted permission to copy, modify and redistribute
  18. ;;; GNU Emacs, but only under the conditions described in the
  19. ;;; GNU Emacs General Public License.   A copy of this license is
  20. ;;; supposed to have been given to you along with GNU Emacs so you
  21. ;;; can know your rights and responsibilities.  It should be in a
  22. ;;; file named COPYING.  Among other things, the copyright notice
  23. ;;; and this notice must be preserved on all copies.
  24.  
  25. ;;; DESCRIPTION: This module provides a single shrink-wrapped window
  26. ;;; for displaying temporary text called the popper window.  At any
  27. ;;; time there is only one popper window on the screen.  If there is
  28. ;;; an entry for the buffer being displayed on popper-min-heights, the
  29. ;;; size of the window will be from that entry.  If the buffer is
  30. ;;; empty, the size of the window will be popper-empty-min.  Otherwise
  31. ;;; its size will be the minimum of the number of lines of text being
  32. ;;; displayed and half the number of lines in the currently selected
  33. ;;; window when the popper window was created.  It will work with any
  34. ;;; function that uses temporary windows or that has been wrapped with
  35. ;;; popper-wrap.  The window can be scrolled or buried from any other
  36. ;;; window.
  37. ;;;
  38. ;;; When a buffer is displayed using the function
  39. ;;; with-output-to-temp-buffer, the text will be displayed in the
  40. ;;; popper window if the name of the buffer is in popper-pop-buffers
  41. ;;; or popper-pop-buffers is set to T and the name is not in
  42. ;;; popper-no-pop-buffers.  Many kinds of completion and help
  43. ;;; information are displayed this way.  In general any buffer with
  44. ;;; *'s around its name will be a temporary buffer.  Some commands
  45. ;;; like shell-command do not use with-output-to-temp-buffer even
  46. ;;; though you might like to have their output be temporary.  For
  47. ;;; commands like this, you can define a wrapper like this using the
  48. ;;; function popper-wrap.
  49. ;;;
  50. ;;; The default binding for C-x o is changed so that when a buffer is
  51. ;;; displayed in a popper window, it will be skipped if it is in
  52. ;;; popper-buffers-to-skip or popper-buffers-to-skip is T and it is
  53. ;;; not in popper-buffers-no-skip.
  54.  
  55. ;;; USAGE: Load this file, preferably after byte-compiling it.  If you
  56. ;;; do not define key bindings using popper-load-hook, the bindings
  57. ;;; will be:
  58. ;;; 
  59. ;;;  C-z 1   popper-bury-output
  60. ;;;  C-z v   popper-scroll-output
  61. ;;;  C-z g   popper-grow-output
  62. ;;;  C-z b   popper-switch
  63. ;;;  C-x o   popper-other-window (C-u to select popper window)
  64.  
  65. ;;; See %%User variables below for possible options.  Here is a sample
  66. ;;; load hook for your .emacs:
  67. ;;;
  68. ;;; (setq popper-load-hook 
  69. ;;;      '(lambda ()
  70. ;;;        ;; Define key bindings
  71. ;;;        (define-key global-map "\C-c1" 'popper-bury-output)
  72. ;;;        (define-key global-map "\C-cv" 'popper-scroll-output)
  73. ;;;        (define-key global-map "\C-cg" 'popper-grow-output)
  74. ;;;        (define-key global-map "\C-cb" 'popper-switch)
  75. ;;;        ;; Make *Manual windows default to 10 lines
  76. ;;;        (setq popper-min-heights
  77. ;;;              (cons (cons "^\\*Manual" 10) popper-min-heights)
  78. ;;;              ;; Don't skip over *Buffer List*
  79. ;;;              popper-buffers-no-skip (cons "*Buffer List*" 
  80. ;;;                                             popper-buffers-no-skip))))
  81. ;;; This is an example that will not work in your .emacs
  82. ;;;        ;; Make command's output buffer a popper window even though
  83. ;;;        ;; it does not use with-output-to-temp-buffer
  84. ;;;        (popper-wrap 'command "*Command Output*")))
  85. ;;; (require 'popper)
  86.  
  87. ;;; WARNING: This package redefines the function split-window and
  88. ;;; pop-to-buffer so that the popper window is buried before calling
  89. ;;; the old definition.
  90.  
  91. ;;;%Globals
  92. ;;;%%User variables
  93. (defvar popper-load-hook nil
  94.   "List of functions to run when the popper module is loaded.")
  95.  
  96. ;;;
  97. (defvar popper-pop-buffers t
  98.   "*List of buffers to put in the shrink-wrapped pop-up window.  
  99. If it is T, all temporary buffers will be put in the pop-up window.")
  100.  
  101. (defvar popper-no-pop-buffers nil
  102.   "*If popper-pop-buffers is T, these buffers will not be put into the
  103. pop-up window.")
  104.  
  105. (defvar popper-buffers-to-skip popper-pop-buffers
  106.   "*\\[popper-other-window] will skip over these buffers when they are
  107. used in a temporary window.  If it is T, all popper windows will be
  108. skipped except those in popper-buffers-no-skip.")
  109.  
  110. (defvar popper-buffers-no-skip nil
  111.   "*\\[popper-other-window] will not skip these buffers when they are
  112. used in a popper window if popper-buffers-to-skip is T.")
  113.  
  114. ;;; By default, this is set to 2 so that a window can be one line big.
  115. ;;; The number of lines in the popper window plus the mode line will
  116. ;;; never be less than this value.  (In fact no window will be less
  117. ;;; than this value.)
  118. (setq window-min-height 2)
  119.  
  120. ;;;
  121. (defvar popper-empty-min '(50) 
  122.   "*Minimum number of lines to display for an empty popper buffer.  If
  123. it is a list, it is an integer percentage 0-100 of the available space.")
  124.  
  125. ;;;
  126. (defvar popper-min-heights '(("^\\*compilation\\*" . (50)))
  127.   "*List of cons where each the car is a regular expression pattern to
  128. match a buffer name and the cdr is the minimum number of lines to
  129. allow when popping buffers that match the regular expression.  If the
  130. number is a list, it is interpreted as the percentage of available
  131. space 0-100 to use for the window.")
  132.  
  133. (defvar popper-mode-line-text nil
  134.   "*Minor mode text for mode line of popper buffers.  If nil, it will
  135. be set to a short help message on first use of popper.")
  136.  
  137. ;;;%%Internal variables
  138. (defvar popper-output-buffers nil
  139.   "LIFO list of buffers displayed in the popper window.")
  140. (defvar popper-last-output-window nil
  141.   "The window that last popped up an output window.")
  142.  
  143. (defvar popper-buffer nil
  144.   "Indicates buffer is a popper for minor-mode-alist.")
  145. (make-variable-buffer-local 'popper-buffer)
  146. (or (assq 'popper-buffer minor-mode-alist)
  147.     (setq minor-mode-alist
  148.       (cons '(popper-buffer popper-mode-line-text) minor-mode-alist)))
  149.  
  150. ;;;%Utils
  151. ;;; This should be in emacs, but it isn't.
  152. (defun popper-mem (item list &optional elt=)
  153.   "Test to see if ITEM is equal to an item in LIST.
  154. Option comparison function ELT= defaults to equal."
  155.   (let ((elt= (or elt= (function equal)))
  156.     (done nil))
  157.     (while (and list (not done))
  158.       (if (funcall elt= item (car list))
  159.       (setq done list)
  160.       (setq list (cdr list))))
  161.     done))
  162.  
  163. ;;;
  164. (defun popper-select (&optional window)
  165.   "Select WINDOW and its buffer.  WINDOW defaults to selected-window."
  166.   (setq window (or window (selected-window)))
  167.   (select-window window)
  168.   (set-buffer (window-buffer window)))
  169.  
  170. ;;;
  171. (defun popper-first-buffer ()
  172.   "Remove killed buffers and return the first buffer on
  173. popper-output-buffers."
  174.   (while (and popper-output-buffers
  175.           (null (buffer-name (car popper-output-buffers))))
  176.     (setq popper-output-buffers (cdr popper-output-buffers)))
  177.    (let ((buffers popper-output-buffers))
  178.      (while (cdr buffers)
  179.        (if (buffer-name (car (cdr buffers)))
  180.        (setq buffers (cdr buffers))
  181.        (rplacd buffers (cdr (cdr buffers))))))
  182.    (car popper-output-buffers))
  183.  
  184. ;;;
  185. (defun popper-output-buffer ()
  186.   "Return the buffer being displayed in the popper window."
  187.   (popper-first-buffer)
  188.   (if (not (eq (selected-window) (next-window)))
  189.       (let ((buffers popper-output-buffers)
  190.         (done nil))
  191.     (while (and buffers (not done))
  192.       (let* ((buffer (car buffers))
  193.          (window (if (buffer-name buffer) (get-buffer-window buffer))))
  194.         (if window 
  195.         (setq done buffer)
  196.         (save-excursion
  197.           (set-buffer (car buffers)) (setq popper-buffer nil))
  198.         (setq buffers (cdr buffers)))))
  199.     (if done (setq popper-output-buffers buffers))
  200.     done)))
  201.  
  202. ;;;
  203. (defun popper-parent ()
  204.   "Return the parent of the popper window."
  205.   (let ((output (popper-output-buffer)))
  206.     (if output (next-window (get-buffer-window output) 'no))))
  207.  
  208. ;;;
  209. (defun popper-window-heights (window)
  210.   "Return a list of the heights of all of the windows following WINDOW."
  211.   (let ((heights nil))
  212.     (select-window window)
  213.     (while (progn 
  214.          (select-window (next-window (selected-window) 'no))
  215.          (not (eq (selected-window) window)))
  216.       (setq heights (cons (window-height (selected-window)) heights)))
  217.     (reverse heights)))
  218.  
  219. ;;;
  220. (defun popper-min-height ()
  221.   "Return the minimum height to use for the buffer in the current
  222. window.  This is either an entry from popper-min-heights,
  223. popper-empty-min if the buffer is empty or window-min-height."
  224.   (let ((buffer (buffer-name))
  225.     (pat popper-min-heights)
  226.     min)
  227.     (while pat
  228.       (if (string-match (car (car pat)) buffer)
  229.       (setq min (cdr (car pat))
  230.         pat nil)
  231.     (setq pat (cdr pat))))
  232.     (if (not min)
  233.     (setq min
  234.           (if (= (point-min) (point-max))
  235.           popper-empty-min
  236.           window-min-height)))
  237.     (if (consp min)
  238.     ;; Floating percentage
  239.     (/ (* (+ (window-height) (window-height (next-window)))
  240.           (car min))
  241.        100)
  242.     min)))
  243.  
  244. ;;;
  245. (defun popper-show-output (&optional buffer size)
  246.   "Bring the output window up showing optional BUFFER in window of
  247. SIZE.  If SIZE is not specified, then shrink the window.  Finally
  248. select the original window."
  249.   (let* ((window (selected-window))
  250.      (old-buffer (window-buffer window))
  251.      (buffer (get-buffer-create
  252.           (or buffer (popper-first-buffer) 
  253.               (error "No popper buffers"))))
  254.      start parent
  255.      (min-height (+ window-min-height (or size window-min-height))))
  256.     (setq popper-last-output-window window)
  257.     (if (eq buffer old-buffer)
  258.     (popper-shrink-window)
  259.     (if (eq window (minibuffer-window)) 
  260.         (let* ((parent (popper-parent)))
  261.           (popper-bury-output t)
  262.           (select-window (setq window (or parent (previous-window)))))
  263.         (if (not (eq old-buffer (popper-output-buffer)))
  264.         (popper-bury-output t)))
  265.     (if (< (window-height window) min-height)
  266.         (enlarge-window (- min-height (window-height window))))
  267.     (setq start (window-start window))
  268.     (split-window nil size)
  269.     (set-window-buffer window buffer)
  270.     (set-buffer buffer)
  271.     (setq popper-buffer t)
  272.     (or popper-mode-line-text
  273.         (setq popper-mode-line-text
  274.           (list (format " %s bury, %s scroll"
  275.                 ;; what where-is-internal returns isn't a
  276.                 ;; string in Lucid GNU Emacs
  277.                 (key-description
  278.                  (where-is-internal 'popper-bury-output nil t))
  279.                 (key-description
  280.                  (where-is-internal 'popper-scroll-output nil t))))))
  281.     (setq popper-output-buffers
  282.           (cons buffer (delq buffer popper-output-buffers)))
  283.     (if (not size) (popper-shrink-window))
  284.     (setq parent (next-window window 'no))
  285.     (popper-select parent)
  286.     ;; Move the window so that top lines get covered unless it would
  287.     ;; cover point in which case point is at top of window
  288.     (save-excursion
  289.       (set-window-start parent start)
  290.       (move-to-window-line (window-height window))
  291.       (set-window-start parent (point)))
  292.     (let ((point (save-excursion (beginning-of-line) (point))))
  293.       (if (not (pos-visible-in-window-p point))
  294.           (set-window-start (selected-window) point)))
  295.     (if (eq popper-last-output-window (minibuffer-window))
  296.         (select-window (minibuffer-window)))
  297.     (set-buffer old-buffer))))
  298.  
  299. ;;;
  300. (defun popper-shrink-window ()
  301.   "Shrink the current window if larger than its buffer unless it has
  302. an entry in popper-min-heights or it is empty in which case
  303. popper-empty-min is used."
  304.   (let* ((window (selected-window))
  305.      (window-lines (1- (window-height window))))
  306.     (set-buffer (window-buffer window))
  307.     (let ((buffer-read-only nil)
  308.       (buffer-modified-p (buffer-modified-p)))
  309.       (save-excursion
  310.     ;; Delete trailing blank lines
  311.     (goto-char (point-max))
  312.     (skip-chars-backward "\n")
  313.     (if (< (point) (point-max)) (delete-region (1+ (point)) (point-max)))
  314.     (goto-char (point-min))
  315.     ;; Delete leading blank lines
  316.     (if (looking-at "\n+") (replace-match ""))
  317.     (set-buffer-modified-p buffer-modified-p)))
  318.     (enlarge-window (- (max (1+ (save-excursion 
  319.                   (goto-char (point-min))
  320.                   (vertical-motion window-lines)))
  321.                 (1- (popper-min-height)))
  322.                window-lines))))
  323.  
  324. ;;;
  325. (defun popper-show (buffer)
  326.   "Function to display BUFFER in a popper window if it is in
  327. popper-pop-buffers or popper-pop-buffers is T and it is not in
  328. popper-no-pop-buffers."
  329.   (let ((name (if (bufferp buffer) (buffer-name buffer) buffer)))
  330.     (if (eq popper-pop-buffers t)
  331.     (if (not (popper-mem name popper-no-pop-buffers))
  332.         (popper-show-output buffer)
  333.         (display-buffer buffer))
  334.     (if (popper-mem name popper-pop-buffers)
  335.         (popper-show-output buffer)
  336.         (display-buffer buffer))))
  337.   (setq minibuffer-scroll-window (get-buffer-window buffer)))
  338.  
  339. ;;;%Commands
  340. (defun popper-bury-output (&optional no-error)
  341.   "Bury the popper output signalling an error if not there unless
  342. optional NO-ERROR is T."
  343.   (interactive)
  344.   (let ((buffer (popper-output-buffer)))
  345.     (if buffer
  346.     (let* ((old (current-buffer))
  347.            (old-window (selected-window))
  348.            (output (get-buffer-window buffer))
  349.            (start (window-height output))
  350.            (parent (next-window output 'no))
  351.            (height (window-height output))
  352.            (heights (popper-window-heights output)))
  353.       (bury-buffer buffer)
  354.       (delete-window output)
  355.       (popper-select parent)
  356.       (while heights
  357.         (enlarge-window (- (+ height (car heights)) (window-height)))
  358.         (if start
  359.         (condition-case () (scroll-down start) (error nil)))
  360.         (select-window (next-window (selected-window) 'no))
  361.         (setq height 0 start nil)
  362.         (setq heights (cdr heights)))
  363.       (set-buffer old)
  364.       (if (not (eq old-window output))
  365.           (select-window old-window)))
  366.     (if (not no-error) (popper-show-output)))))
  367.  
  368. ;;;
  369. (defun popper-scroll-output (&optional n)
  370.   "Scroll text of the popper window upward ARG lines ; or near full
  371. screen if no ARG.  When calling from a program, supply a number as
  372. argument or nil.  If the output window is not being displayed, it will
  373. be brought up."
  374.   (interactive "P")
  375.   (let ((buffer (popper-output-buffer)))
  376.     (if buffer
  377.     (let ((window (selected-window)))
  378.       (unwind-protect
  379.            (progn (select-window (get-buffer-window buffer))
  380.               (condition-case ()
  381.               (scroll-up n)
  382.             (error
  383.              (if (or (null n) (and (numberp n) (> n 0)))
  384.                  (goto-char (point-min))
  385.                  (goto-char (point-max))))))
  386.         (select-window window)))
  387.     (popper-show-output))))
  388.  
  389. ;;;
  390. (defun popper-grow-output (&optional n)
  391.   "Grow the popper window by ARG (default 1) lines.  If the popper
  392. window is not being shown, it will be brought up."
  393.   (interactive "p")
  394.   (let ((buffer (popper-output-buffer)))
  395.     (if buffer
  396.     (let ((old-buffer (current-buffer))
  397.           (window (selected-window)))
  398.       (select-window (get-buffer-window buffer))
  399.       (enlarge-window n)
  400.       (popper-select (next-window (selected-window) 'no))
  401.       (save-excursion
  402.         (if (< n 0)
  403.         (condition-case () (scroll-up n) (error nil))
  404.         (move-to-window-line n)
  405.         (set-window-start (selected-window) (point))))
  406.       (select-window window)
  407.       (set-buffer old-buffer))
  408.     (popper-show-output))))
  409.  
  410. ;;;
  411. (defun popper-switch (buffer)
  412.   "Switch the popper window to BUFFER."
  413.   (interactive
  414.    (list (read-buffer
  415.       "Popper buffer " 
  416.       (car (if (popper-output-buffer)
  417.            (cdr popper-output-buffers)
  418.            popper-output-buffers))
  419.       t)))
  420.   (if buffer (popper-show buffer)))
  421.      
  422. ;;;%Redefinitions
  423. ;;;***Redefine split-window to bury popper window first***
  424. (defvar popper-split-window (symbol-function 'split-window) 
  425.   "Original definition of split-window.")
  426. (defun split-window (&optional window size hor-flag)
  427.   "Split WINDOW, putting SIZE lines in the first of the pair.
  428. WINDOW defaults to selected one and SIZE to half its size.
  429. If optional third arg HOR-FLAG is non-nil, split side by side
  430. and put SIZE columns in the first of the pair."
  431.   (let ((parent (popper-parent)))
  432.     (if (eq parent (selected-window))
  433.     (let* ((pop-size (window-height
  434.               (get-buffer-window (popper-output-buffer))))
  435.            (size (if size (+ size pop-size))))
  436.       (popper-bury-output)
  437.       (prog1
  438.           (funcall popper-split-window window size hor-flag)
  439.         (popper-show-output nil pop-size)))
  440.     (funcall popper-split-window window size hor-flag))))
  441.  
  442. ;;; ***Redefine pop-to-buffer to skip output windows***
  443. (defvar popper-pop-to-buffer (symbol-function 'pop-to-buffer)
  444.   "Original pop to buffer function.")
  445. (defun pop-to-buffer (buffer &optional other-window)
  446.   "Select buffer BUFFER in some window, preferably a different one.
  447. If pop-up-windows is non-nil, windows can be split to do this.
  448. If second arg OTHER-WINDOW is non-nil, insist on finding another
  449. window even if BUFFER is already visible in the selected window."
  450.   (let ((parent (popper-parent)))
  451.     (if (and parent 
  452.          (not (eq (get-buffer buffer) (popper-output-buffer))))
  453.     (progn
  454.       (popper-bury-output)
  455.       (funcall popper-pop-to-buffer buffer other-window)
  456.       (select-window parent)
  457.       (popper-show-output)
  458.       (sit-for 0)            ;Allow display update
  459.       (funcall popper-pop-to-buffer buffer))
  460.     (funcall popper-pop-to-buffer buffer other-window))))
  461.  
  462. ;;;***Redefine other-window to skip popper buffers***
  463. (defun popper-other-window (arg)
  464.   "Select the arg'th other window.  If arg is a C-u prefix, the popper
  465. window will be selected.  Otherwise, windows that contain buffers in
  466. popper-buffers-to-skip will be skipped or if popper-buffers-to-skip is
  467. T those that are not in popper-buffers-no-skip."
  468.   (interactive "P")
  469.   (if (consp arg) 
  470.       (let* ((buffer (popper-output-buffer))
  471.          (window (and buffer (get-buffer-window buffer))))
  472.     (if window (select-window window)))
  473.       (setq arg (if (eq arg '-) -1 (or arg 1)))
  474.       (other-window arg)
  475.       (if (eq popper-buffers-to-skip t)
  476.       (if (and (not (popper-mem (buffer-name (current-buffer))
  477.                     popper-buffers-no-skip))
  478.            (eq (popper-output-buffer) (current-buffer)))
  479.           (other-window arg))
  480.       (if (popper-mem (buffer-name (current-buffer))
  481.               popper-buffers-to-skip)
  482.           (other-window arg)))))
  483. (define-key ctl-x-map "o" 'popper-other-window)
  484.  
  485. ;;; %Wrappers
  486. (defun popper-unwrap (function)
  487.   "Remove the popper wrapper for NAME."
  488.   (let ((var (car (read-from-string (format "popper-%s" function)))))
  489.     (if (boundp var)
  490.     (progn (fset function (symbol-value var))
  491.            (makunbound var)))))
  492.  
  493. ;;;
  494. (defun popper-wrap (function buffer)
  495.   "Define a wrapper on FUNCTION so that BUFFER will be a pop up window."
  496.   (popper-unwrap function)
  497.   (let* ((var (car (read-from-string (format "popper-%s" function))))
  498.      (defn (symbol-function function))
  499.      arg-spec doc int)
  500.     (set var defn)
  501.     (if (consp defn)
  502.     (setq arg-spec (elt defn 1)
  503.           doc (elt defn 2)
  504.           int (elt defn 3))
  505.     (setq arg-spec (aref defn 0)
  506.           doc (and (> (length defn) 4) (aref defn 4))
  507.           int (and (> (length defn) 5) (list 'interactive (aref defn 5)))))
  508.     (fset function 
  509.       (append 
  510.        (list 'lambda arg-spec)
  511.        (if (numberp doc) (list (documentation function)))
  512.        (if (stringp doc) (list doc))
  513.        (if (eq (car int) 'interactive) (list int))
  514.        (list 
  515.         (list
  516.          'let '((shown nil))
  517.          (list 'save-window-excursion 
  518.            (cons 'funcall 
  519.              (cons 
  520.               var
  521.               (let ((args nil))
  522.                 (while arg-spec
  523.                   (if (not (eq (car arg-spec) '&optional))
  524.                   (setq args (cons (car arg-spec)
  525.                            args)))
  526.                   (setq arg-spec (cdr arg-spec)))
  527.                 (reverse args))))
  528.            (list 'setq 'shown (list 'get-buffer-window buffer)))
  529.          (list 'if 'shown
  530.            (list 'funcall
  531.              '(if (string-match "^19\\." emacs-version)
  532.                   temp-buffer-show-function
  533.                 temp-buffer-show-hook)
  534.              buffer))))))
  535.     (if (not (eq popper-pop-buffers t))
  536.     (let ((elt popper-pop-buffers))
  537.       (while (consp elt)
  538.         (if (string= (car elt) buffer) 
  539.         (setq elt t)
  540.         (setq elt (cdr elt))))
  541.       (if (not elt)
  542.           (setq popper-pop-buffers (cons buffer popper-pop-buffers)))))))
  543.  
  544. ;;; 
  545. (popper-wrap 'shell-command "*Shell Command Output*")
  546. (popper-wrap 'shell-command-on-region "*Shell Command Output*")
  547.  
  548. ;;;
  549. (if (string-match "^19\\." emacs-version)
  550.     (setq temp-buffer-show-function 'popper-show)
  551.   (setq temp-buffer-show-hook 'popper-show))
  552.   
  553. (run-hooks 'popper-load-hook)
  554.  
  555. ;;; Default key bindings
  556. (if (not (where-is-internal 'popper-bury-output nil t))
  557.     (progn
  558.       (if (not (keymapp (lookup-key global-map "\C-z")))
  559.       (define-key global-map "\C-z" (make-keymap)))
  560.       (define-key global-map "\C-z1" 'popper-bury-output)
  561.       (define-key global-map "\C-zv" 'popper-scroll-output)
  562.       (define-key global-map "\C-zg" 'popper-grow-output)
  563.       (define-key global-map "\C-zb" 'popper-switch)))
  564.  
  565. (provide 'popper)
  566.