gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pp+.el - extensions to GNU `pp.el'


From: Drew Adams
Subject: pp+.el - extensions to GNU `pp.el'
Date: Tue, 16 Jan 2001 21:35:20 -0500

;;; pp+.el --- Extensions to `pp.el'.
;; 
;; Emacs Lisp Archive Entry
;; Filename: pp+.el
;; Description: Extensions to `pp.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1999-2001, Drew Adams, all rights reserved.
;; Created: Fri Sep  3 13:45:40 1999
;; Version: $Id: pp+.el,v 1.4 2001/01/09 01:58:13 dadams Exp $
;; Last-Updated: Mon Jan  8 17:58:07 2001
;;           By: dadams
;;     Update #: 42
;; Keywords: lisp
;; Compatibility: GNU Emacs 20.x
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Commentary: 
;; 
;;    Extensions to `pp.el'.
;; 
;;
;;  ***** NOTE: The following function defined in `pp.el' has
;;              been REDEFINED HERE:
;;
;;  `pp-eval-expression'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Change log:
;; 
;; RCS $Log: pp+.el,v $
;; RCS Revision 1.4  2001/01/09 01:58:13  dadams
;; RCS Adapted file header for Emacs Lisp Archive.
;; RCS
;; RCS Revision 1.3  2001/01/03 17:44:08  dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.2  2001/01/03 01:02:32  dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.1  2000/09/14 17:23:35  dadams
;; RCS Initial revision
;; RCS
; Revision 1.1  1999/09/03  12:47:05  dadams
; Initial revision
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Code:

(require 'pp)

;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;; REPLACES ORIGINAL in `pp.el':
;;; 1. Uses no `emacs-lisp-mode-hook'.
;;; 2. Progress message added.
;;;###autoload
(defun pp-eval-expression (expression)
  "Evaluate EXPRESSION and pretty-print value into a new display buffer.
If the pretty-printed value fits on one line, the message line is used
instead.  Value is also consed onto front of global list `values'."
  (interactive "xPp-eval: ")
  (message "Evaluating...")
  (setq values (cons (eval expression) values))
  (let* ((old-show-function temp-buffer-show-function)
         ;; Use this function to display the buffer.
         ;; This function either decides not to display it at all
         ;; or displays it in the usual way.
         (temp-buffer-show-function
          (function
           (lambda (buf)
             (save-excursion
               (set-buffer buf)
               (goto-char (point-min))
               (end-of-line 1)
               (if (or (< (1+ (point)) (point-max))
                       (>= (- (point) (point-min)) (frame-width)))
                   (let ((temp-buffer-show-function old-show-function)
                         (old-selected (selected-window))
                         (window (display-buffer buf)))
                     (goto-char (point-min)) ; expected by some hooks ...
                     (make-frame-visible (window-frame window))
                     (unwind-protect
                         (progn
                           (select-window window)
                           (run-hooks 'temp-buffer-show-hook))
                       (select-window old-selected)
                       (message "Evaluating...done. See buffer *Pp Eval 
Output*.")))
                 (message "%s" (buffer-substring (point-min) (point)))
                 ))))))
    (with-output-to-temp-buffer "*Pp Eval Output*"
      (pp (car values)))
    (save-excursion
      (set-buffer "*Pp Eval Output*")
      (let ((emacs-lisp-mode-hook nil)
            (change-major-mode-hook nil))
        (emacs-lisp-mode))
      (make-local-variable 'font-lock-verbose)
      (setq font-lock-verbose nil))))
  
;;;;;;;;;;;;;;;;;;

(provide 'pp+)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `pp+.el' ends here



reply via email to

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