diff options
| author | Juri Linkov | 2013-12-19 23:02:46 +0200 |
|---|---|---|
| committer | Juri Linkov | 2013-12-19 23:02:46 +0200 |
| commit | b41594fd4d77194a6781ee5a84e01142ad1b72e7 (patch) | |
| tree | 84cb4eb66d7dea9cee8708a53a3d2160dd80b4d8 | |
| parent | 459457271091c8bb0b6734fe9bd709e86a8c66c1 (diff) | |
| download | emacs-b41594fd4d77194a6781ee5a84e01142ad1b72e7.tar.gz emacs-b41594fd4d77194a6781ee5a84e01142ad1b72e7.zip | |
* lisp/simple.el (eval-expression-print-format): Don't check for
command names and the last command. Always display additional
formats of the integer result in the echo area, and insert them
to the current buffer only with a zero prefix arg.
Display character when char-displayable-p is non-nil.
(eval-expression): With a zero prefix arg, set `print-length' and
`print-level' to nil, and insert the integer values from
`eval-expression-print-format' at the end. Doc fix.
* lisp/emacs-lisp/lisp-mode.el (eval-print-last-sexp): Add arg
`eval-last-sexp-arg-internal'. Doc fix.
(eval-last-sexp-1): Pass arg `eval-last-sexp-arg-internal' to
`eval-last-sexp-print-value'. Doc fix.
(eval-last-sexp-print-value): Add arg `eval-last-sexp-arg-internal'.
Set `print-length' and `print-level' to nil when arg is zero.
(eval-last-sexp): Doc fix.
(eval-defun-2): Print the integer values from
`eval-expression-print-format' at the end.
* lisp/emacs-lisp/edebug.el (edebug-eval-defun): Print the integer
values from `eval-expression-print-format' at the end.
* lisp/ielm.el (ielm-eval-input): Print the integer
values from `eval-expression-print-format' at the end.
Fixes: debbugs:12985
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/ChangeLog | 27 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 33 | ||||
| -rw-r--r-- | lisp/ielm.el | 4 | ||||
| -rw-r--r-- | lisp/simple.el | 30 |
6 files changed, 83 insertions, 22 deletions
| @@ -119,6 +119,12 @@ non-nil, they output the same results. | |||
| 119 | ** `eval-defun' on an already defined defcustom calls the :set function, | 119 | ** `eval-defun' on an already defined defcustom calls the :set function, |
| 120 | if there is one. | 120 | if there is one. |
| 121 | 121 | ||
| 122 | ** A zero prefix arg of `eval-last-sexp' (`C-x C-e'), | ||
| 123 | `eval-expression' (`M-:') and `eval-print-last-sexp' (`C-j') inserts | ||
| 124 | a list with no limit on its length and level (by using nil values of | ||
| 125 | `print-length' and `print-level'), and inserts additional formats for | ||
| 126 | integers (octal, hexadecimal, and character). | ||
| 127 | |||
| 122 | ** If the new variable `enable-dir-local-variables' is nil, | 128 | ** If the new variable `enable-dir-local-variables' is nil, |
| 123 | directory local variables are ignored. May be useful for some modes | 129 | directory local variables are ignored. May be useful for some modes |
| 124 | that want to ignore directory-locals while still respecting file-locals. | 130 | that want to ignore directory-locals while still respecting file-locals. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 31a8cead95f..636617595cb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2013-12-19 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * simple.el (eval-expression-print-format): Don't check for | ||
| 4 | command names and the last command. Always display additional | ||
| 5 | formats of the integer result in the echo area, and insert them | ||
| 6 | to the current buffer only with a zero prefix arg. | ||
| 7 | Display character when char-displayable-p is non-nil. | ||
| 8 | (eval-expression): With a zero prefix arg, set `print-length' and | ||
| 9 | `print-level' to nil, and insert the integer values from | ||
| 10 | `eval-expression-print-format' at the end. Doc fix. (Bug#12985) | ||
| 11 | |||
| 12 | * emacs-lisp/lisp-mode.el (eval-print-last-sexp): Add arg | ||
| 13 | `eval-last-sexp-arg-internal'. Doc fix. | ||
| 14 | (eval-last-sexp-1): Pass arg `eval-last-sexp-arg-internal' to | ||
| 15 | `eval-last-sexp-print-value'. Doc fix. | ||
| 16 | (eval-last-sexp-print-value): Add arg `eval-last-sexp-arg-internal'. | ||
| 17 | Set `print-length' and `print-level' to nil when arg is zero. | ||
| 18 | (eval-last-sexp): Doc fix. | ||
| 19 | (eval-defun-2): Print the integer values from | ||
| 20 | `eval-expression-print-format' at the end. | ||
| 21 | |||
| 22 | * emacs-lisp/edebug.el (edebug-eval-defun): Print the integer | ||
| 23 | values from `eval-expression-print-format' at the end. | ||
| 24 | |||
| 25 | * ielm.el (ielm-eval-input): Print the integer | ||
| 26 | values from `eval-expression-print-format' at the end. | ||
| 27 | |||
| 1 | 2013-12-19 Teodor Zlatanov <tzz@lifelogs.com> | 28 | 2013-12-19 Teodor Zlatanov <tzz@lifelogs.com> |
| 2 | 29 | ||
| 3 | * net/eww.el (eww-exit, eww-close, eww-mode-map): Revert change of | 30 | * net/eww.el (eww-exit, eww-close, eww-mode-map): Revert change of |
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index ec343eab631..552ee696ef3 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -497,7 +497,10 @@ the minibuffer." | |||
| 497 | (put (nth 1 form) 'saved-face nil))))) | 497 | (put (nth 1 form) 'saved-face nil))))) |
| 498 | (setq edebug-result (eval (eval-sexp-add-defvars form) lexical-binding)) | 498 | (setq edebug-result (eval (eval-sexp-add-defvars form) lexical-binding)) |
| 499 | (if (not edebugging) | 499 | (if (not edebugging) |
| 500 | (princ edebug-result) | 500 | (prog1 |
| 501 | (princ edebug-result) | ||
| 502 | (let ((str (eval-expression-print-format edebug-result))) | ||
| 503 | (if str (princ str)))) | ||
| 501 | edebug-result))) | 504 | edebug-result))) |
| 502 | 505 | ||
| 503 | 506 | ||
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index f4e9b311acc..b7bd33f628f 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -858,7 +858,7 @@ Semicolons start comments. | |||
| 858 | \\{lisp-interaction-mode-map}" | 858 | \\{lisp-interaction-mode-map}" |
| 859 | :abbrev-table nil) | 859 | :abbrev-table nil) |
| 860 | 860 | ||
| 861 | (defun eval-print-last-sexp () | 861 | (defun eval-print-last-sexp (&optional eval-last-sexp-arg-internal) |
| 862 | "Evaluate sexp before point; print value into current buffer. | 862 | "Evaluate sexp before point; print value into current buffer. |
| 863 | 863 | ||
| 864 | If `eval-expression-debug-on-error' is non-nil, which is the default, | 864 | If `eval-expression-debug-on-error' is non-nil, which is the default, |
| @@ -866,11 +866,13 @@ this command arranges for all errors to enter the debugger. | |||
| 866 | 866 | ||
| 867 | Note that printing the result is controlled by the variables | 867 | Note that printing the result is controlled by the variables |
| 868 | `eval-expression-print-length' and `eval-expression-print-level', | 868 | `eval-expression-print-length' and `eval-expression-print-level', |
| 869 | which see." | 869 | which see. With a zero prefix arg, print output with no limit |
| 870 | (interactive) | 870 | on the length and level of lists, and include additional formats |
| 871 | for integers (octal, hexadecimal, and character)." | ||
| 872 | (interactive "P") | ||
| 871 | (let ((standard-output (current-buffer))) | 873 | (let ((standard-output (current-buffer))) |
| 872 | (terpri) | 874 | (terpri) |
| 873 | (eval-last-sexp t) | 875 | (eval-last-sexp (or eval-last-sexp-arg-internal t)) |
| 874 | (terpri))) | 876 | (terpri))) |
| 875 | 877 | ||
| 876 | 878 | ||
| @@ -1013,18 +1015,26 @@ If CHAR is not a character, return nil." | |||
| 1013 | 1015 | ||
| 1014 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) | 1016 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) |
| 1015 | "Evaluate sexp before point; print value in the echo area. | 1017 | "Evaluate sexp before point; print value in the echo area. |
| 1016 | With argument, print output into current buffer." | 1018 | With argument, print output into current buffer. |
| 1019 | With a zero prefix arg, print output with no limit on the length | ||
| 1020 | and level of lists, and include additional formats for integers | ||
| 1021 | \(octal, hexadecimal, and character)." | ||
| 1017 | (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) | 1022 | (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) |
| 1018 | ;; Setup the lexical environment if lexical-binding is enabled. | 1023 | ;; Setup the lexical environment if lexical-binding is enabled. |
| 1019 | (eval-last-sexp-print-value | 1024 | (eval-last-sexp-print-value |
| 1020 | (eval (eval-sexp-add-defvars (preceding-sexp)) lexical-binding)))) | 1025 | (eval (eval-sexp-add-defvars (preceding-sexp)) lexical-binding) |
| 1026 | eval-last-sexp-arg-internal))) | ||
| 1021 | 1027 | ||
| 1022 | 1028 | ||
| 1023 | (defun eval-last-sexp-print-value (value) | 1029 | (defun eval-last-sexp-print-value (value &optional eval-last-sexp-arg-internal) |
| 1024 | (let ((unabbreviated (let ((print-length nil) (print-level nil)) | 1030 | (let ((unabbreviated (let ((print-length nil) (print-level nil)) |
| 1025 | (prin1-to-string value))) | 1031 | (prin1-to-string value))) |
| 1026 | (print-length eval-expression-print-length) | 1032 | (print-length (and (not (zerop (prefix-numeric-value |
| 1027 | (print-level eval-expression-print-level) | 1033 | eval-last-sexp-arg-internal))) |
| 1034 | eval-expression-print-length)) | ||
| 1035 | (print-level (and (not (zerop (prefix-numeric-value | ||
| 1036 | eval-last-sexp-arg-internal))) | ||
| 1037 | eval-expression-print-level)) | ||
| 1028 | (beg (point)) | 1038 | (beg (point)) |
| 1029 | end) | 1039 | end) |
| 1030 | (prog1 | 1040 | (prog1 |
| @@ -1070,6 +1080,9 @@ POS specifies the starting position where EXP was found and defaults to point." | |||
| 1070 | Interactively, with prefix argument, print output into current buffer. | 1080 | Interactively, with prefix argument, print output into current buffer. |
| 1071 | Truncates long output according to the value of the variables | 1081 | Truncates long output according to the value of the variables |
| 1072 | `eval-expression-print-length' and `eval-expression-print-level'. | 1082 | `eval-expression-print-length' and `eval-expression-print-level'. |
| 1083 | With a zero prefix arg, print output with no limit on the length | ||
| 1084 | and level of lists, and include additional formats for integers | ||
| 1085 | \(octal, hexadecimal, and character). | ||
| 1073 | 1086 | ||
| 1074 | If `eval-expression-debug-on-error' is non-nil, which is the default, | 1087 | If `eval-expression-debug-on-error' is non-nil, which is the default, |
| 1075 | this command arranges for all errors to enter the debugger." | 1088 | this command arranges for all errors to enter the debugger." |
| @@ -1167,6 +1180,8 @@ Return the result of evaluation." | |||
| 1167 | ;; will make eval-region return. | 1180 | ;; will make eval-region return. |
| 1168 | (goto-char end) | 1181 | (goto-char end) |
| 1169 | form)))))) | 1182 | form)))))) |
| 1183 | (let ((str (eval-expression-print-format (car values)))) | ||
| 1184 | (if str (princ str))) | ||
| 1170 | ;; The result of evaluation has been put onto VALUES. So return it. | 1185 | ;; The result of evaluation has been put onto VALUES. So return it. |
| 1171 | (car values)) | 1186 | (car values)) |
| 1172 | 1187 | ||
diff --git a/lisp/ielm.el b/lisp/ielm.el index fb1f9774237..8176704e75f 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el | |||
| @@ -458,7 +458,9 @@ nonempty, then flushes the buffer." | |||
| 458 | ;; Self-referential objects cause loops in the printer, so | 458 | ;; Self-referential objects cause loops in the printer, so |
| 459 | ;; trap quits here. May as well do errors, too | 459 | ;; trap quits here. May as well do errors, too |
| 460 | (unless for-effect | 460 | (unless for-effect |
| 461 | (setq output (concat output (pp-to-string result)))) | 461 | (setq output (concat output (pp-to-string result) |
| 462 | (let ((str (eval-expression-print-format result))) | ||
| 463 | (if str (propertize str 'font-lock-face 'shadow)))))) | ||
| 462 | (error (setq error-type "IELM Error") | 464 | (error (setq error-type "IELM Error") |
| 463 | (setq result "Error during pretty-printing (bug in pp)")) | 465 | (setq result "Error during pretty-printing (bug in pp)")) |
| 464 | (quit (setq error-type "IELM Error") | 466 | (quit (setq error-type "IELM Error") |
diff --git a/lisp/simple.el b/lisp/simple.el index 61068efce59..5101bfb26f8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1365,13 +1365,12 @@ Return a formatted string which is displayed in the echo area | |||
| 1365 | in addition to the value printed by prin1 in functions which | 1365 | in addition to the value printed by prin1 in functions which |
| 1366 | display the result of expression evaluation." | 1366 | display the result of expression evaluation." |
| 1367 | (if (and (integerp value) | 1367 | (if (and (integerp value) |
| 1368 | (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp))) | 1368 | (or (eq standard-output t) |
| 1369 | (eq this-command last-command) | 1369 | (zerop (prefix-numeric-value current-prefix-arg)))) |
| 1370 | (if (boundp 'edebug-active) edebug-active))) | ||
| 1371 | (let ((char-string | 1370 | (let ((char-string |
| 1372 | (if (or (if (boundp 'edebug-active) edebug-active) | 1371 | (if (and (characterp value) |
| 1373 | (memq this-command '(eval-last-sexp eval-print-last-sexp))) | 1372 | (char-displayable-p value)) |
| 1374 | (prin1-char value)))) | 1373 | (prin1-char value)))) |
| 1375 | (if char-string | 1374 | (if char-string |
| 1376 | (format " (#o%o, #x%x, %s)" value value char-string) | 1375 | (format " (#o%o, #x%x, %s)" value value char-string) |
| 1377 | (format " (#o%o, #x%x)" value value))))) | 1376 | (format " (#o%o, #x%x)" value value))))) |
| @@ -1399,8 +1398,11 @@ evaluate it. | |||
| 1399 | Value is also consed on to front of the variable `values'. | 1398 | Value is also consed on to front of the variable `values'. |
| 1400 | Optional argument INSERT-VALUE non-nil (interactively, | 1399 | Optional argument INSERT-VALUE non-nil (interactively, |
| 1401 | with prefix argument) means insert the result into the current buffer | 1400 | with prefix argument) means insert the result into the current buffer |
| 1402 | instead of printing it in the echo area. Truncates long output | 1401 | instead of printing it in the echo area. With a zero prefix arg, |
| 1403 | according to the value of the variables `eval-expression-print-length' | 1402 | insert the result with no limit on the length and level of lists, |
| 1403 | and include additional formats for integers (octal, hexadecimal, | ||
| 1404 | and character). Truncates long output according to the value | ||
| 1405 | of the variables `eval-expression-print-length' | ||
| 1404 | and `eval-expression-print-level'. | 1406 | and `eval-expression-print-level'. |
| 1405 | 1407 | ||
| 1406 | If `eval-expression-debug-on-error' is non-nil, which is the default, | 1408 | If `eval-expression-debug-on-error' is non-nil, which is the default, |
| @@ -1422,13 +1424,19 @@ this command arranges for all errors to enter the debugger." | |||
| 1422 | (unless (eq old-value new-value) | 1424 | (unless (eq old-value new-value) |
| 1423 | (setq debug-on-error new-value)))) | 1425 | (setq debug-on-error new-value)))) |
| 1424 | 1426 | ||
| 1425 | (let ((print-length eval-expression-print-length) | 1427 | (let ((print-length (and (not (zerop (prefix-numeric-value insert-value))) |
| 1426 | (print-level eval-expression-print-level) | 1428 | eval-expression-print-length)) |
| 1429 | (print-level (and (not (zerop (prefix-numeric-value insert-value))) | ||
| 1430 | eval-expression-print-level)) | ||
| 1427 | (deactivate-mark)) | 1431 | (deactivate-mark)) |
| 1428 | (if insert-value | 1432 | (if insert-value |
| 1429 | (with-no-warnings | 1433 | (with-no-warnings |
| 1430 | (let ((standard-output (current-buffer))) | 1434 | (let ((standard-output (current-buffer))) |
| 1431 | (prin1 (car values)))) | 1435 | (prog1 |
| 1436 | (prin1 (car values)) | ||
| 1437 | (when (zerop (prefix-numeric-value insert-value)) | ||
| 1438 | (let ((str (eval-expression-print-format (car values)))) | ||
| 1439 | (if str (princ str))))))) | ||
| 1432 | (prog1 | 1440 | (prog1 |
| 1433 | (prin1 (car values) t) | 1441 | (prin1 (car values) t) |
| 1434 | (let ((str (eval-expression-print-format (car values)))) | 1442 | (let ((str (eval-expression-print-format (car values)))) |