Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [eval]

The tag has no usage guidance.

5
votes
0answers
54 views

Evaluate some arguments to macro immediately

I am trying to call a macro (defined somewhere else; I can't change it), but I want to evaluate some of the arguments before the macro is expanded. Is this possible? For example: (defmacro foo (&...
4
votes
2answers
78 views

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

When I do bulk calculations in a scratch buffer, it is annoying to have to delete the actual expressions after they are evaluated (I want them to be deleted on evaluation). Example: (+ 2 2) ...
1
vote
1answer
112 views

evaluating fn in dir-locals.el

I realize there are a number of questions surrounding this topic, but I'm trying use a global function that I've written inside a project .dir-locals.el. Specifically, I wrote a function to add a ...
2
votes
2answers
100 views

Does `car` on an non-lazy function generated list evals the whole list?

I want to get in a huge directory the first file which satisfies some condition, something like (require 'seq) (require 'f) (defun lazy-filter-file (pred path) (car (seq-filter pred (f--files path ...
0
votes
1answer
34 views

Duplicate output from princ / pp?

So I'm trying to figure out why the following produces unexpected output: (setq var 1) (pp var) (princ var) Put the cursor just after the closing ) in the expression (setq var 1) and then press C-xC-...
1
vote
0answers
41 views

How do I stop evaluating an expression in Lisp Interaction mode?

So I made a loop that prints out numbers from 0 - 100,000,000 and it's still going. How do I force stop it? I have a feeling that something like this is going to happen again one day..
1
vote
1answer
85 views

How to evaluate a defun with square brackets in column 0 of its docstring?

I have problems running eval-defun for a defun when there is a square bracket [ in column 0 of its doc string. For example: (defun test () "Test function. [Some text]" (message "Hello")) When I ...
1
vote
1answer
202 views

How do you recompile an .el source file and make it active in my current session

I have been writing some elisp code, current i have to open the file edit quit and reload emacs seems there must be a better way ? I know i can recompile the current file but that does not seem to ...
2
votes
1answer
132 views

elisp - print result not found after eval-buffer

Create a test.el file as below: (print "hello world!") Then run M-x eval-buffer. No output can be seen even in *Messages* buffer. where is the print output for this case?
1
vote
0answers
97 views

Sending an s-expression to another buffer

I'm currently working in Clojure with Arcadia, which is requiring me to use a REPL that doesn't have support with Cider. This has been giving me some trouble given how I usually code, so I'd like to ...
2
votes
2answers
153 views

Set an Elisp var on the command line and read it in the init file

I'm trying to set a variable at load-time: # emacs --eval '(defvar myvar t)' Now, in this session, if I C-h v myvar RET I get a nice t. But if I put (message "MYVAR: %s" myvar) in my init file, I ...
1
vote
1answer
71 views

deactivate active region after `eval-region`

I do the following to activate the region and evaluate it M-x spc to begin mark C-n C-n C-n M-x eval-region The region is still active (highlighted) after the eval-region is performed. I would ...
0
votes
0answers
66 views

How to re-evaluate cl-defstruct during same Emacs session

I am putting together a modification of a library that contains an existing cl-defstruct definition, and I am having problems redefining it after its initial evaluation. Q:  How can I replace the old ...
1
vote
2answers
209 views

emacs lisp execute random command

I want to change my colour scheme to a random color scheme. Consider this elisp function: (defun random-colour-theme () ;; written 2017-04-02 "Pick a random colour theme." (interactive) (setq ...
1
vote
1answer
61 views

Is there a way to evaluate from top of buffer to point?

While doing statistical work in ESS, I often want to evaluate everything from the top of buffer to point. This is to make sure that my analysis is reproducible (i.e. script can be run from top to ...
0
votes
1answer
68 views

elisp - simplify a stranger data structure [duplicate]

I wish to define a variable to replace the hardcode string below: (setq org-publish-project-alist '( ("blog" :components ("org-blog-docs" "org-blog-static")) ("org-blog-docs" ...
1
vote
1answer
139 views

eval-when-compile: Is my understanding correct?

I want to build a ring of symbols in my init.el for the purpose of rotating themes. I could do it like this: (let* ((themes '(doom-one zenburn leuven)) (ring (make-ring (length themes)))) (...
4
votes
2answers
358 views

How to re-load a package?

The situation I have is this. First, I run (require 'prolog) ...which loads the system's default version of prolog.el, and makes the variable prolog-mode-version available. It has value "1.22". ...
1
vote
1answer
645 views

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

Suppose I already opened a emacs but its in the background. So, is there an emacsclient eval option that I can type in the shell like: emacsclient --eval "(bring-existing-emacs-window-to-front)" To ...
0
votes
1answer
95 views

vdiff-refine-all-hunks/ediff-update-diffs in startup eval

I'm having a problem with putting vdiff-refine-all-hunks or ediff-update-diffs into --eval for startup. Take vdiff as example, I'm calling it using: emacs --eval "(progn (vdiff-files file1 file2) (...
5
votes
1answer
1k views

emacs --eval of multiple functions on command line

How do I evaluate multiple functions simultaneously using emacs --eval on command line? For example I want to combine the followings in a single command: emacs --eval "(toggle-frame-maximized)" emacs ...
45
votes
6answers
9k views

Org-mode 9: unable to eval code-blocks

My Emacs config lives inside of a .org file from which I tangle source blocks to a .el file. I could evaluate source blocks with C-c C-c Today I updated to org-mode version 9 from org elpa and now ...
3
votes
2answers
158 views

Deep eager macroexpansion

This works: (require 'clojure-mode) (when (member 'clojure-mode my-packages) (define-clojure-indent (-> 1) (->> 1))) This gives the error Wrong type argument: listp, 1: (when (...
5
votes
1answer
288 views

Is there any difference between \` and backquote?

I was surprised to find that if I use M-x ielm, I get a literal backquote: ELISP> (read "`foo") `foo However, if I use M-: (read "`foo") then *Messages* and the minibuffer show (\` foo). Are ...
2
votes
1answer
300 views

How to handle end of file during parsing errors while reading a string?

I was trying to read and eval Lisp forms from a string using a loop, instead of just putting the string into a buffer and using eval-buffer to load everything in the string. That method was mentioned ...
0
votes
1answer
369 views

Can I eval a value in quote? [duplicate]

I have a variable say some-var, its value is a string. I want to use its value in a quote expression. '(some-var "some string") The function who is using the above expression reports error because ...
1
vote
1answer
42 views

Comparison of quoted symbols fails using equal

I'm trying to compare (quote foo) with 'foo using equal, but the equality is failing. Here is a trace of what is happening with my code. I don't understand why the comparison fails -- does it have ...
0
votes
0answers
105 views

Recommendations for eval on save workflow for projects?

I've started to write a package and excessive use of the interactive eval-* functions has become a pain point for me. After I make a change re-evaluating entire file or package is almost always ...
21
votes
2answers
2k views

How to evaluate Elisp code contained in a string?

The question pretty much says it all: I have a string containing the source code for a valid Elisp expression, and I would like to evaluate it. (In Python, for example, the expression eval("1 - 2 + 3"...
5
votes
1answer
370 views

How to set a key binding conditional to evaluate a Lisp expression

I am thinking of binding C-x C-e to a single command, which does eval-last-sexp if there is no selection or eval-region if there is a selection. This is what I have tried: (defun my/eval() (...