Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 55805:a4c5317be59a
* 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'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 28 May 2004 21:09:05 +0000 |
parents | 6010b740e1d0 |
children | fcd2e17daffa |
comparison
equal
deleted
inserted
replaced
55804:9766648e58a2 | 55805:a4c5317be59a |
---|---|
237 (let ((map (make-sparse-keymap "Emacs-Lisp"))) | 237 (let ((map (make-sparse-keymap "Emacs-Lisp"))) |
238 (setq emacs-lisp-mode-map (make-sparse-keymap)) | 238 (setq emacs-lisp-mode-map (make-sparse-keymap)) |
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)) |
245 (define-key map [edebug-defun] | 246 (define-key map [edebug-defun] |
246 '("Instrument Function for Debugging" . edebug-defun)) | 247 '("Instrument Function for Debugging" . edebug-defun)) |
375 | 376 |
376 (defvar lisp-interaction-mode-map | 377 (defvar lisp-interaction-mode-map |
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) |
383 "Keymap for Lisp Interaction mode. | 385 "Keymap for Lisp Interaction mode. |
384 All commands in `lisp-mode-shared-map' are inherited by this map.") | 386 All commands in `lisp-mode-shared-map' are inherited by this map.") |
530 (defun eval-last-sexp-print-value (value) | 532 (defun eval-last-sexp-print-value (value) |
531 (let ((unabbreviated (let ((print-length nil) (print-level nil)) | 533 (let ((unabbreviated (let ((print-length nil) (print-level nil)) |
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)) |
545 (not (null print-level))) | 547 (not (null print-level))) |
546 (not (string= unabbreviated | 548 (not (string= unabbreviated |
1090 (and (bolp) (not (eolp)) | 1092 (and (bolp) (not (eolp)) |
1091 (lisp-indent-line)) | 1093 (lisp-indent-line)) |
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 |
1098 "Value of `fill-column' to use when filling a docstring. | 1113 "Value of `fill-column' to use when filling a docstring. |
1099 Any non-integer value means do not use a different value of | 1114 Any non-integer value means do not use a different value of |