11

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 you requested). It executes one command after another.


8

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 Emacs does these things by looking in the manual, or asking Emacs itself. To see what a particular keybinding does, you can use C-h k (describe-key). You were ...


8

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 interactively, read an Emacs Lisp expression and evaluate it. Value is also consed on to front of the variable ‘values’. If the resulting value is ...


8

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 char ?\C-d yields 4. edit: FWIW, this behaviour seems to be a bug and should be fixed on master (and hopefully become part of the upcoming 25.1 release).


6

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 to do likewise for any other variable, by adding it to savehist-additional-variables: (eval-after-load "savehist" '(add-to-list 'savehist-additional-variables ...


6

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


5

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 use the whole package you can just take this function. (defun crux-eval-and-replace () "Replace the preceding sexp with its value." (interactive) (let ((...


5

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-region (save-excursion (backward-sexp) (point)) (point)) (insert result)))


4

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 override it temporarily.


4

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


4

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 *scratch*, kill it and yank into minibuffer of eval-expression or use C-q C-j to insert new lines in minibuffer.


3

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. This blog has (defun eval-and-replace (value) "Evaluate the sexp at point and replace it with its value" (interactive (list (eval-last-sexp nil))) (kill-...


3

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-b (ielm-change-working-buffer). To learn more info about IELM, type C-h m (describe-mode) as usual.


3

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 multiple lines — that would work just fine — but that the Lisp code consists of multiple expressions that need to be executed in sequence. M-x eval-expression ...


3

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-expression-print-format (orig-fun value) (if mute-eval-expression-print-format "" (funcall orig-fun value))) (advice-add 'eval-expression-print-format ...


2

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-buffer removes the selected buffer from the history, if you need to get it out of your way.


2

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 done its work by the time a character is inserted into a buffer, such that (using your example) typing q would result in (insert "a"), not (insert "q"). insert ...


2

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.


2

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 (selected-frame)))' But, if you only want to open a file, don't use --eval: emacsclient -c file.txt


2

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. Otherwise mark it and type C-0 C-x * e (Update: thanks to Dodgie, forgot to mention that) When you are finished with your mathematical manipulations type C-x * e ...


1

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 buffer can grow too quickly. Instead of changing helm-debug directly, according to helm's own help (you can get it by type C-h m within any helm session, I have ...


1

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

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 Stack Exchange. User there uses emacsclient -a '' ... which incidentally solves the issue. I guess it allows emacsclient to assume that callee is a real ...


1

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: (defun delete-comments () (interactive) (save-excursion (goto-char (point-min)) (let (kill-ring) (comment-kill (count-lines (point-min) (...


1

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 sequences that are normally bound to `eval-expression` or `pp-eval-expression` to `icicle-pp-eval-expression`. If you do not want this remapping, then ...


1

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: (eval '(:m (8))) which obviously implies a call to the function 8. With the extra quote in the definition of x, it would try this instead: (eval '(:m '(8))) ...


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