diff options
| author | Juri Linkov | 2004-05-28 21:09:05 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-05-28 21:09:05 +0000 |
| commit | 889bfc7d448e69692bc42a42a4a591b11059129d (patch) | |
| tree | 468dc8f71868e4dfa22d5258881067c2b417d53f | |
| parent | f833e227cbcf652b20b52c15be9e7bf04af54f97 (diff) | |
| download | emacs-889bfc7d448e69692bc42a42a4a591b11059129d.tar.gz emacs-889bfc7d448e69692bc42a42a4a591b11059129d.zip | |
* emacs-lisp/lisp-mode.el (indent-pp-sexp): New fun.
(emacs-lisp-mode-map, lisp-interaction-mode-map):
Bind C-M-q to `indent-pp-sexp'.
(eval-last-sexp-print-value): Print additionally the value returned by
`eval-expression-print-format'.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index fcc6517b747..1f53d9e630f 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -239,6 +239,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") | |||
| 239 | (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map) | 239 | (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map) |
| 240 | (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol) | 240 | (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol) |
| 241 | (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun) | 241 | (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun) |
| 242 | (define-key emacs-lisp-mode-map "\e\C-q" 'indent-pp-sexp) | ||
| 242 | (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap)) | 243 | (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap)) |
| 243 | (define-key emacs-lisp-mode-map [menu-bar emacs-lisp] | 244 | (define-key emacs-lisp-mode-map [menu-bar emacs-lisp] |
| 244 | (cons "Emacs-Lisp" map)) | 245 | (cons "Emacs-Lisp" map)) |
| @@ -377,6 +378,7 @@ if that value is non-nil." | |||
| 377 | (let ((map (make-sparse-keymap))) | 378 | (let ((map (make-sparse-keymap))) |
| 378 | (set-keymap-parent map lisp-mode-shared-map) | 379 | (set-keymap-parent map lisp-mode-shared-map) |
| 379 | (define-key map "\e\C-x" 'eval-defun) | 380 | (define-key map "\e\C-x" 'eval-defun) |
| 381 | (define-key map "\e\C-q" 'indent-pp-sexp) | ||
| 380 | (define-key map "\e\t" 'lisp-complete-symbol) | 382 | (define-key map "\e\t" 'lisp-complete-symbol) |
| 381 | (define-key map "\n" 'eval-print-last-sexp) | 383 | (define-key map "\n" 'eval-print-last-sexp) |
| 382 | map) | 384 | map) |
| @@ -532,13 +534,13 @@ With argument, print output into current buffer." | |||
| 532 | (prin1-to-string value))) | 534 | (prin1-to-string value))) |
| 533 | (print-length eval-expression-print-length) | 535 | (print-length eval-expression-print-length) |
| 534 | (print-level eval-expression-print-level) | 536 | (print-level eval-expression-print-level) |
| 535 | (char-string (prin1-char value)) | ||
| 536 | (beg (point)) | 537 | (beg (point)) |
| 537 | end) | 538 | end) |
| 538 | (prog1 | 539 | (prog1 |
| 539 | (prin1 value) | 540 | (prin1 value) |
| 540 | (if (and (eq standard-output t) char-string) | 541 | (if (eq standard-output t) |
| 541 | (princ (concat " = " char-string))) | 542 | (let ((str (eval-expression-print-format value))) |
| 543 | (if str (princ str)))) | ||
| 542 | (setq end (point)) | 544 | (setq end (point)) |
| 543 | (when (and (bufferp standard-output) | 545 | (when (and (bufferp standard-output) |
| 544 | (or (not (null print-length)) | 546 | (or (not (null print-length)) |
| @@ -1092,6 +1094,19 @@ ENDPOS is encountered." | |||
| 1092 | (indent-sexp endmark) | 1094 | (indent-sexp endmark) |
| 1093 | (set-marker endmark nil)))) | 1095 | (set-marker endmark nil)))) |
| 1094 | 1096 | ||
| 1097 | (defun indent-pp-sexp (&optional arg) | ||
| 1098 | "Indent each line of the list or, with prefix ARG, pretty-printify the list." | ||
| 1099 | (interactive "P") | ||
| 1100 | (if arg | ||
| 1101 | (save-excursion | ||
| 1102 | (save-restriction | ||
| 1103 | (narrow-to-region (point) (progn (forward-sexp 1) (point))) | ||
| 1104 | (pp-buffer) | ||
| 1105 | (goto-char (point-max)) | ||
| 1106 | (if (eq (char-before) ?\n) | ||
| 1107 | (delete-char -1))))) | ||
| 1108 | (indent-sexp)) | ||
| 1109 | |||
| 1095 | ;;;; Lisp paragraph filling commands. | 1110 | ;;;; Lisp paragraph filling commands. |
| 1096 | 1111 | ||
| 1097 | (defcustom emacs-lisp-docstring-fill-column 65 | 1112 | (defcustom emacs-lisp-docstring-fill-column 65 |