annotate lisp/emacs-lisp/pp.el @ 83004:7900111db01c

Converted display hooks to be display-local. Plus many bugfixes. lib-src/emacsclient.c (window_change_signal): Renamed to pass_signal_to_emacs. (init_signal): Pass SIGINT and SIGQUIT to the emacs process. lisp/faces.el (face-valid-attribute-values): Use the window-system function, not the variable. (read-face-attribute, face-spec-set-match-display, frame-set-background-mode) (face-set-after-frame-default): Ditto. lisp/frame.el (make-frame-on-tty): Added interactive declaration (suggested by Robert J. Chassell). Use tty-create-frame-with-faces, not make-terminal-frame. src/termhooks.h (struct display_method): Renamed to display for brevity. (struct display): Added all display hook variables as members of this structure. Added next_display, reference_count, type and display_info components. (FRAME_MUST_WRITE_SPACES, FRAME_FAST_CLEAR_END_OF_LINE, FRAME_LINE_INS_DEL_OK) (FRAME_CHAR_INS_DEL_OK, FRAME_SCROLL_REGION_OK, FRAME_SCROLL_REGION_COST) (FRAME_MEMORY_BELOW_FRAME, FRAME_RIF): Updated for struct display. (FRAME_DISPLAY): New macro. (create_display, delete_display): New prototypes. src/frame.h (struct frame): Added `display' member, removed display_method. (FRAME_LIVE_P): Look at f->display, not f->output_data. src/termchar.h (struct tty_display_info): Removed display_method component. (FRAME_TTY): Use the display structure, not output_data. src/term.c (display_list): New variable. (cursor_to_hook, raw_cursor_to_hook, clear_to_end_hook, clear_frame_hook) (clear_end_of_line_hook, ins_del_lines_hook, delete_glyphs_hook) (ring_bell_hook, reset_terminal_modes_hook, set_terminal_modes_hook) (update_begin_hook, update_end_hook, set_terminal_window_hook) (insert_glyphs_hook, write_glyphs_hook, delete_glyphs_hoo, read_socket_hook) (frame_up_to_date_hook, mouse_position_hook, frame_rehighlight_hook) (frame_raise_lower_hook, set_vertical_scroll_bar_hook, condemn_scroll_bars_hook) (redeem_scroll_bar_hook, judge_scroll_bars_hook): Moved to struct display. (tty_display_method_template): Removed. (syms_of_term): Don't initialize tty_display_method_template. (ring_bell, set_terminal_modes, reset_terminal_modes, update_begin) (update_end, set_terminal_window, cursor_to, raw_cursor_to, clear_to_end) (clear_frame, clear_end_of_line, write_glyphs, insert_glyphs) (delete_glyphs, ins_del_lines): Access display hooks through the frame pointer. (Ftty_display_color_p): Use the frame given as a parameter, or else return nil. (Ftty_display_color_cells): Ditto. (get_named_tty): Renamed to get_named_tty_display, changed return type to struct display. (term_dummy_init): Renamed to initial_term_init. Create and return an initial display. (term_init): Initialize a new struct display and return a pointer to it instead of tty_display_info. Removed frame initialization kludge. (Fdelete_tty): Updated for struct display. (delete_tty): The parameter type is now struct display, not tty_display_info. Delete the display, too. (create_tty_output): New function for creating tty_output structures. (delete_tty_output): New function for deleting tty_output structures. (create_display): New function for creating and registering display structures. (delete_display): New function for deleting and unregistering display structures. src/dispextern.h: Updated prototypes. src/dispnew.c: Include frame.h before termhooks.h. (init_display): Updated term_init call to new signature. src/emacs.c: Include frame.h (for termhooks.h). src/keymap.c: Ditto. src/lread.c: Ditto. src/xsmfns.c: Ditto. src/process.c: Include frame.h before termhooks.h. src/frame.c (Fwindow_system): New function. (syms_of_frame): Initialize it. (make_terminal_frame): Open the terminal device before creating the new frame. Disable scrollbars here, term_init cannot do that anymore. (Fdelete_frame): Use the new delete_frame_hook, don't do display-specific frame deletion here. Ditto for delete_display_hook. (Fmouse_position, Fmouse_pixel_position, Fraise_frame, Flower_frame) (Fredirect_frame_focus): Access display hooks through the frame pointer. src/keyboard.c: Include frame.h before termhooks.h. (start_polling, input_polling_used, stop_polling, gobble_input): Ignore read_socket_hook. (kbd_buffer_get_event, Fset_input_mode): Access display hooks through the frame pointer. (read_avail_input): Loop through all display devices for and call all read_socket_hook functions. Check ttys even if read_socket_hook returned an error. src/sysdep.c (discard_tty_input): Ignore read_socket_hook. (stuff_char): Don't do anything if the current frame is not on a termcap display. (request_sigio, unrequest_sigio): Ignore read_socket_hook. (init_sys_modes): Always call narrow_foreground_group. Set up terminal modes and sigio even under X. src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal) (set_vertical_scroll_bar, redisplay_window): Access display hooks through the frame pointer. (echo_area_display): Don't be afraid of termcap frames during an X+tty combo session. src/xfaces.c: Include termhooks.h. (Ftty_supports_face_attributes_p): Use the given frame, not selected_frame. src/xfns.c (x_set_scroll_bar_foreground, x_set_scroll_bar_background): Access display hooks through the frame pointer. (Fx_create_frame, x_create_tip_frame): Initialize the frame's display structure. src/xmenu.c: Include termhooks.h after frame.h. src/xselect.c (x_own_selection, some_frame_on_display, x_get_foreign_selection) (Fx_disown_selection_internal, Fx_get_cut_buffer_internal) (Fx_store_cut_buffer_internal, Fx_rotate_cut_buffers_internal): Don't do anything if the selected frame is not an X frame. src/xterm.c (x_display_method): Removed. (x_create_frame_display, x_delete_frame_display): New functions for handling struct display objects. (x_term_init): Set up a new struct display object, too. (x_delete_display): Delete the struct display corresponding to the X display. (x_initialize): Moved hook initialization to x_create_frame_display. src/xterm.h (x_display_method): Removed. (struct x_display_info): Added frame_display component. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-44
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 05 Jan 2004 05:54:35 +0000
parents 695cf19ef79e
children a8550ca246eb 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 11730
diff changeset
1 ;;; pp.el --- pretty printer for Emacs Lisp
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
2
39117
abd085bfec0c Add Keywords header.
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
3 ;; Copyright (C) 1989, 1993, 2001 Free Software Foundation, Inc.
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
14224
e47d5fcad4be Comment change.
Erik Naggum <erik@naggum.no>
parents: 14169
diff changeset
5 ;; Author: Randal Schwartz <merlyn@stonehenge.com>
39117
abd085bfec0c Add Keywords header.
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
6 ;; Keywords: lisp
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
23 ;; Boston, MA 02111-1307, USA.
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23244
diff changeset
25 ;;; Commentary:
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23244
diff changeset
26
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Code:
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23244
diff changeset
28
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
29 (defgroup pp nil
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
30 "Pretty printer for Emacs Lisp."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
31 :prefix "pp-"
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
32 :group 'lisp)
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43295
diff changeset
34 (defcustom pp-escape-newlines t
21365
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
35 "*Value of `print-escape-newlines' used by pp-* functions."
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
36 :type 'boolean
db005054f15d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20598
diff changeset
37 :group 'pp)
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
43295
ce2590f06ba0 2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 39117
diff changeset
39 ;;;###autoload
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defun pp-to-string (object)
23244
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
41 "Return a string containing the pretty-printed representation of OBJECT.
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
42 OBJECT can be any Lisp object. Quoting characters are used as needed
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
43 to make output that `read' can handle, whenever this is possible."
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (save-excursion
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (set-buffer (generate-new-buffer " pp-to-string"))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (unwind-protect
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (progn
19147
ec57f19bc39c (pp-to-string): Use emacs-lisp-mode-sytax-table.
Richard M. Stallman <rms@gnu.org>
parents: 16171
diff changeset
48 (lisp-mode-variables nil)
ec57f19bc39c (pp-to-string): Use emacs-lisp-mode-sytax-table.
Richard M. Stallman <rms@gnu.org>
parents: 16171
diff changeset
49 (set-syntax-table emacs-lisp-mode-syntax-table)
20598
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
50 (let ((print-escape-newlines pp-escape-newlines)
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
51 (print-quoted t))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (prin1 object (current-buffer)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (goto-char (point-min))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (while (not (eobp))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; (message "%06d" (- (point-max) (point)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (cond
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ((condition-case err-var
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (prog1 t (down-list 1))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (error nil))
20598
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
60 (save-excursion
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
61 (backward-char 1)
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
62 (skip-chars-backward "'`#^")
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
63 (when (and (not (bobp)) (= ?\ (char-before)))
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
64 (delete-char -1)
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
65 (insert "\n"))))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ((condition-case err-var
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (prog1 t (up-list 1))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (error nil))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (while (looking-at "\\s)")
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (forward-char 1))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (delete-region
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (point)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (progn (skip-chars-forward " \t") (point)))
20598
a61e2395961f (pp-to-string): Greatly simplify by letting the
Andreas Schwab <schwab@suse.de>
parents: 19147
diff changeset
74 (insert ?\n))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (t (goto-char (point-max)))))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (goto-char (point-min))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (indent-sexp)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (buffer-string))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (kill-buffer (current-buffer)))))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
10329
aa393c4b380c Add autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 8544
diff changeset
81 ;;;###autoload
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (defun pp (object &optional stream)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 "Output the pretty-printed representation of OBJECT, any Lisp object.
23244
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
84 Quoting characters are printed as needed to make output that `read'
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 can handle, whenever this is possible.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 Output stream is STREAM, or value of `standard-output' (which see)."
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (princ (pp-to-string object) (or stream standard-output)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
10329
aa393c4b380c Add autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 8544
diff changeset
89 ;;;###autoload
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (defun pp-eval-expression (expression)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 "Evaluate EXPRESSION and pretty-print value into a new display buffer.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 If the pretty-printed value fits on one line, the message line is used
23244
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
93 instead. The value is also consed onto the front of the list
67e80974136e Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 21365
diff changeset
94 in the variable `values'."
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (interactive "xPp-eval: ")
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (setq values (cons (eval expression) values))
11730
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
97 (let* ((old-show-function temp-buffer-show-function)
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
98 ;; Use this function to display the buffer.
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
99 ;; This function either decides not to display it at all
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
100 ;; or displays it in the usual way.
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
101 (temp-buffer-show-function
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (function
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (lambda (buf)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (save-excursion
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (set-buffer buf)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (goto-char (point-min))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (end-of-line 1)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (if (or (< (1+ (point)) (point-max))
14225
ec298b8bee29 (pp-eval-expression): Use `frame-width' instead of `screen-width'.
Erik Naggum <erik@naggum.no>
parents: 14224
diff changeset
109 (>= (- (point) (point-min)) (frame-width)))
11730
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
110 (let ((temp-buffer-show-function old-show-function)
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
111 (old-selected (selected-window))
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
112 (window (display-buffer buf)))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (goto-char (point-min)) ; expected by some hooks ...
11730
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
114 (make-frame-visible (window-frame window))
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
115 (unwind-protect
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
116 (progn
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
117 (select-window window)
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
118 (run-hooks 'temp-buffer-show-hook))
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
119 (select-window old-selected)))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (message "%s" (buffer-substring (point-min) (point)))
11730
084c36d46615 (pp-eval-expression): Update use of temp-buffer-show-function.
Richard M. Stallman <rms@gnu.org>
parents: 10732
diff changeset
121 ))))))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (with-output-to-temp-buffer "*Pp Eval Output*"
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (pp (car values)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (save-excursion
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (set-buffer "*Pp Eval Output*")
16171
919ed1778c0b (pp-eval-expression): Set font-lock-default locally to nil.
Richard M. Stallman <rms@gnu.org>
parents: 15446
diff changeset
126 (emacs-lisp-mode)
919ed1778c0b (pp-eval-expression): Set font-lock-default locally to nil.
Richard M. Stallman <rms@gnu.org>
parents: 15446
diff changeset
127 (make-local-variable 'font-lock-verbose)
919ed1778c0b (pp-eval-expression): Set font-lock-default locally to nil.
Richard M. Stallman <rms@gnu.org>
parents: 15446
diff changeset
128 (setq font-lock-verbose nil))))
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
10329
aa393c4b380c Add autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 8544
diff changeset
130 ;;;###autoload
8544
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (defun pp-eval-last-sexp (arg)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "Run `pp-eval-expression' on sexp before point (which see).
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 With argument, pretty-print output into current buffer.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 Ignores leading comment characters."
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (interactive "P")
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (let ((stab (syntax-table)) (pt (point)) start exp)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (set-syntax-table emacs-lisp-mode-syntax-table)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (save-excursion
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (forward-sexp -1)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; If first line is commented, ignore all leading comments:
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (if (save-excursion (beginning-of-line) (looking-at "[ \t]*;"))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (progn
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (setq exp (buffer-substring (point) pt))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (while (string-match "\n[ \t]*;+" exp start)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (setq start (1+ (match-beginning 0))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 exp (concat (substring exp 0 start)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (substring exp (match-end 0)))))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (setq exp (read exp)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (setq exp (read (current-buffer)))))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (set-syntax-table stab)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (if arg
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (insert (pp-to-string (eval exp)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (pp-eval-expression exp))))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;;; Test cases for quote
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; (pp-eval-expression ''(quote quote))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; (pp-eval-expression ''((quote a) (quote b)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; (pp-eval-expression ''('a 'b)) ; same as above
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;; (pp-eval-expression ''((quote (quote quote)) (quote quote)))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ;; These do not satisfy the quote test.
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; (pp-eval-expression ''quote)
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; (pp-eval-expression ''(quote))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; (pp-eval-expression ''(quote . quote))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; (pp-eval-expression ''(quote a b))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;; (pp-eval-expression ''(quotefoo))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;; (pp-eval-expression ''(a b))
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (provide 'pp) ; so (require 'pp) works
dc4a53a05b98 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
170 ;;; arch-tag: b0f7c65b-02c7-42bb-9ee3-508a59b8fbb9
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23244
diff changeset
171 ;;; pp.el ends here