18 votes
Accepted

Result of arithmetic evaluation in buffer, not echo area

Short version: yes Instead of C-x C-e to evaluate the expression, give it a prefix argument. C-u C-x C-e will print the output to the buffer. How I found this information You can investigate how ...
  • 31.3k
14 votes
Accepted

emacs --eval of multiple functions on command line

Simply use (progn ). This should address your question: emacs --eval "(progn (toggle-frame-maximized) (sr-speedbar-toggle))" Please note that this does not execute the commands simultaneously (as ...
  • 609
9 votes
Accepted

Saving open file list and buffer command history in between sessions

The savehist library is the general option for persisting variable values across sessions. Simply enabling savehist-mode ensures that most minibuffer histories will persist, but you can also tell it ...
  • 44.2k
8 votes
Accepted

What does "(#o4, #x4, ?\C-d)" mean here?

These are alternative representations of an integer with their reader literals for octal, hexadecimal and char notation. In other words, evaluating the octal number #o4, hexadecimal number #x4 or ...
  • 21.2k
8 votes

Result of arithmetic evaluation in buffer, not echo area

Bind this to some key. (defun foo () "Replace sexp before point by result of its evaluation." (interactive) (let ((result (pp-to-string (eval (pp-last-sexp) lexical-binding)))) (delete-...
  • 70.9k
8 votes
Accepted

How to direct `M-:`'s value to the current buffer?

use C-u M-: insert the result into current buffer instead of printing it in the echo area. (eval-expression EXP &optional INSERT-VALUE) Evaluate EXP and print value in the echo area. When called ...
  • 206
8 votes

Quickly Evaluate Infix Math Expression?

You can use the built-in calc package to do so. Mark your expression, e.g. 3 * (1 + 1) Call calc-grab-region Call calc-dispatch (default C-x *), then hit g
7 votes
Accepted

Showing returned values in the same buffer

The emacs way is to ask emacs: C-h k C-x C-e C-x C-e runs the command eval-last-sexp (found in global-map), which is an interactive compiled Lisp function in `elisp-mode.el'. It is bound to C-x C-e. ...
  • 4,167
6 votes
Accepted

How to replace the expression with evaluation result using Elisp interpreter?

Two possibilities that I am aware of. In the package crux https://github.com/bbatsov/crux there is a function crux-eval-and-replace which does exactly what you are asking for. If you don't want to ...
  • 983
5 votes

Result of arithmetic evaluation in buffer, not echo area

If you want to do an arithmetic operation and insert the value into the buffer, but don't care where you do the operation, then you can also do C-u M-: and type the operation info the minibuffer. ...
  • 1,859
5 votes
Accepted

Insert a string from eval-expression without the quotes

Rather than ask M-: to insert the output of the Elisp code, just write the Elisp code that inserts the text you want: Try M-: (insert (format-time-string "%m/%d/%Y")) RET
  • 25.5k
4 votes

Is there a variable to toggle Emacs 24.4 elisp return "noise"?

You can override eval-expression-print-format to return "" or nil: (defun eval-expression-print-format (value) ; return an empty string "") See the answer by @Harald Hanche-Olsen for a way to ...
  • 9,002
4 votes

How do I eval a multiple line elisp expression inside the current buffer?

I guess you mean M-x eval-expression, because eval is not interactive function (command). You can either: define temporary function in *scratch* and then call it or write everything you need in *...
  • 4,813
3 votes
Accepted

How to enable a major + a minor mode on loading a file?

To use rainbow-mode in clojure-mode only under a certain directory, add a .dir-locals.el file to the directory, containing: ((clojure-mode . ((eval . (rainbow-mode 1))))) You can also use M-x add-dir-...
  • 44.2k
3 votes

Quickly Evaluate Infix Math Expression?

You might also use calc's embedded mode if you intent to replace an expression with its result in the current buffer. C-u C-x * e when your formula / expression is on it's own on a separate line. ...
3 votes
Accepted

Weird (point) and (point-max) values in IELM

IELM allows you to set another the current buffer, take a look at your Mode Line to see which buffer your IELM is running on, I guess you changed the current buffer. You can change it back with C-c C-...
  • 13.8k
3 votes
Accepted

How do I eval a multiple line elisp expression inside the current buffer?

I assume that the code you want to run is (goto-char (point-min)) (let (kill-ring) (comment-kill (count-lines (point-min) (point-max)))) Actually, the problem is not that the Lisp code contains ...
3 votes
Accepted

Is there a variable to toggle Emacs 24.4 elisp return "noise"?

If you don't want a permanent change, you can arrange things with a bit of advice: (defvar mute-eval-expression-print-format nil "Set to t to mute eval-expression-print-format") (defun mute-eval-...
2 votes

Saving open file list and buffer command history in between sessions

For file history, if you enable ido-mode and customize ido-use-virtual-buffers to t, even closed buffers remain in the ido history. This persists across desktop.el sessions. C-k during an ido-switch-...
2 votes
Accepted

Input-methods in the insert eval expressions

When you evaluate (insert "qwerty") the lisp reader creates a string object with the literal value "qwerty". No input method functionality is able to intervene there. The input method has already ...
  • 44.2k
2 votes

How do I eval a multiple line elisp expression inside the current buffer?

M-x eval-expression, aka M-: evaluates a multiline expression just fine. And besides pasting a multiline sexp into the minibuffer, you can insert a newline char there using C-q C-j.
  • 70.9k
2 votes
Accepted

emacsclient --eval command to bring a background emacs window to front

You can use select-frame-set-input-focus to give focus to a given frame: emacsclient --eval '(progn (find-file "file.txt") (select-frame-set-input-focus (...
  • 1,835
2 votes

How to replace the expression with evaluation result using Elisp interpreter?

Try writing the expression in the minibuffer instead. Using eval-expression with the universal prefix argument inserts the result: C-u M-: (+ 2 2) RET
  • 1,444
1 vote
Accepted

How to get the value of an evaluated function and nothing else?

It prints out that extra information as an aid to the user when you evaluate expressions interactively, but they’re not actually part of the return value of the expression itself. What are you ...
  • 12.6k
1 vote
Accepted

eval-expression on (setq helm-debug t) does not change describe-variable output

It seems it's intended: helm-internal calls helm-log-save-maybe calls (setq helm-debug nil) thus whenever a helm session ends, helm-debug will be reset to nil. I guess it's because the log ...
  • 13.8k
1 vote

Result of arithmetic evaluation in buffer, not echo area

I prefer to do (also complex) computations in Emacs' calc C-x * * and then copy its result in the buffer where my cursor was with y, q closes the calc buffers and I'm back at this location.
1 vote

From an external script, open file and run some simple expression whether emacs already running or not

Sort-of solution: emacsclient -a '' ... Looking at the automatic links appearing at the right of the question, I saw a question not seen before: emacsclient - Opening frames from emacs-daemon - Emacs ...
1 vote

How do I eval a multiple line elisp expression inside the current buffer?

I'm not sure if I understand your question correctly but if you just want to have a command to delete the comments you can take the code from your referenced answer and wrap it in a function like this:...
  • 3,281
1 vote
Accepted

How to make icicle-pp-eval-expression use eldoc like eval-expression?

I will take a look to see what, if anything, I think might be done as an improvement. C-h f icicle-pp-eval-expression tells you how to do without that function: By default, Icicle mode remaps all key ...
  • 70.9k
1 vote
Accepted

both keywordp and macrop then eval from a functionp

Try this for line 7: (defun x (y z) (eval `(,y ',z))) That is, ensure that the second argument is quoted in the expansion. When you call (x :m `(8)), in your version the body of x ends up as: (...
  • 5,924

Only top scored, non community-wiki answers of a minimum length are eligible