Hot answers tagged

47 votes
Accepted

Org-mode 9: unable to eval code-blocks

I think this problem is caused by the change of org-babel-check-confirm-evaluate from a macro to a function. If you have org-mode (and thus the old macro) loaded when you compile the new code, it ...
erikstokes's user avatar
  • 12.6k
38 votes

Org-mode 9: unable to eval code-blocks

To elaborate on @erikstokes: rm ~/.emacs.d/elpa/ORGDIRNAME/*.elc where ORGDIRNAME is the name of the core ogrmode directory. Restart emacs and you can now run org-babel code blocks.
בנימן הגלילי's user avatar
29 votes
Accepted

How to evaluate Elisp code contained in a string?

Evaluating a string of elisp code is a two-stage process: you need to parse the string using read-from-string and then evaluate the resulting Lisp expression with eval. (defun my-eval-string (string) ...
Constantine's user avatar
  • 9,042
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 ...
dmg's user avatar
  • 619
11 votes
Accepted

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

How do you recompile an .el source file [...] In Elisp file-visiting buffers, you can run the command M-xemacs-lisp-byte-compileRET to byte-compile the corresponding file. In Dired buffers, you can ...
Basil's user avatar
  • 11.9k
11 votes
Accepted

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

First of all, a few stylistic recommendations. (Style is important in programming :-D) In Lisps, we use dashes as separators, so your function is better called my-eval, not my/eval: (defun my-eval() (...
Mark Karpov's user avatar
  • 4,893
9 votes
Accepted

Can I eval a value in quote?

You have two options: 1) Don't use quotes at all, as in: (list some-var "some-string") 2) Use a backquote. They work like quotes, but part of an expression can be evaluated by using , and ,@. For ...
Lindydancer's user avatar
  • 6,065
8 votes

When is the first element in the argument list regarded as a function symbol and when not?

the first element of a list is interpreted as a function symbol That's the most common case, but it isn't an absolute rule. First, you need to know that every symbol can have both a function meaning (...
Gilles 'SO- stop being evil''s user avatar
7 votes

Deep eager macroexpansion

(require <foo>) is treated specially when it's at top-level (it causes the compiler to require the file also, rather than only do the require at run-time). If the require is not performed at ...
Stefan's user avatar
  • 26k
7 votes
Accepted

How to re-load a package?

You can unload the system prolog mode first, this unbinds all its variables, so that the new defvar init-forms will take effect: (require 'prolog) (when (version< prolog-mode-version "1.25") (...
npostavs's user avatar
  • 8,983
6 votes

How to evaluate Elisp code contained in a string?

The answer of Constantine is okay. Just to provide a slight modification: (defun my-eval-string (str) "Read and evaluate all forms in str. Return the results of all forms as a list." (let ((next ...
Tobias's user avatar
  • 32.1k
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 ...
andrej's user avatar
  • 983
5 votes
Accepted

elisp - simplify a stranger data structure

It's not an association list, strictly speaking, even though the name seems to say it is. An alist is a list of (key . value) dotted pairs. org-publish-project-alist is just a list of lists, where ...
NickD's user avatar
  • 25.9k
5 votes
Accepted

Is there any difference between \` and backquote?

The value returned by the sexp (read "`foo") is `foo. You are confused by the form of the printing of the read value by the command you are using (eval-expression, bound to M-: by default). What it ...
Drew's user avatar
  • 74.6k
4 votes
Accepted

Deep eager macroexpansion

@Stefan explained why you see what you see: Your require statement is not at top level of the file. A solution to the byte-compiler not evaluating your (non top-level) require statement is to force ...
Drew's user avatar
  • 74.6k
4 votes
Accepted

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

If you want evaluation to return nil when it would normally raise an error, wrap the sexp to be evaluated in ignore-errors: (ignore-errors (read-from-string contents pos)) See also with-demoted-...
Drew's user avatar
  • 74.6k
4 votes

Org-mode 9: unable to eval code-blocks

for me uninstalling the org-plus-contrib package and reinstalling it solved it.
zeltak's user avatar
  • 1,675
4 votes
Accepted

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

This doesn't work because command line options are processed after the init file. This allows the command line to refer to functions and variables defined or loaded in the init file, and allows the ...
xuchunyang's user avatar
  • 14.2k
4 votes
Accepted

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

The function you are looking for is ess-eval-buffer-from-beg-to-here (bound to C-c <C-up> by default). I found this using M-x apropos "ess eval".
ebpa's user avatar
  • 7,229
4 votes
Accepted

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

The question misses the point. Sure, suppose you do (car huge-list), the evaluator will eval huge-list by checking for its type, finding that it's a symbol, looking it up in the environment and ...
wasamasa's user avatar
  • 21.7k
4 votes

When is the first element in the argument list regarded as a function symbol and when not?

Lisp code and some Lisp data structures (lists, symbols, strings, vectors, etc.) can be the same thing. Lisp code is a Lisp data structure that's ready to be evaluated, that is, "run". Both ...
Drew's user avatar
  • 74.6k
4 votes

“A mutable object stops being mutable if it is part of an expression that is evaluated.”

The key to understanding this sentence in the manual, is the next sentence in the manual, and its footnote: If a program attempts to change objects that should not be changed, the resulting behavior ...
zwol's user avatar
  • 262
3 votes

elisp - print result not found after eval-buffer

Nowhere. See the docstring (C-h f eval-buffer): (eval-buffer &optional BUFFER PRINTFLAG FILENAME UNIBYTE DO-ALLOW-PRINT) Execute the accessible portion of current buffer as Lisp code. ...
JeanPierre's user avatar
  • 7,273
3 votes

emacs lisp execute random command

Use symbols instead of strings: (require 'seq) (defvar theme-selection '(color-theme-dark color-theme-light)) (defun random-theme () "Pick a random colour theme." (interactive) (funcall (...
sds's user avatar
  • 5,838
3 votes

Org-mode 9: unable to eval code-blocks

On Emacs 25.2 (9.0) and using org-plus-contrib: org-babel-execute-src-block gave me the same error as C-c C-c deleting the .emacs.d/elpa folder and reinstalling did not fix it but M-x package-delete [...
rdcdr's user avatar
  • 63
3 votes

How to re-load a package?

As an alternative to unload-feature, you could use this to check the version of the default package without actually loading the code: (let ((version (with-temp-buffer (insert-file (...
Tyler's user avatar
  • 21.4k
3 votes
Accepted

eval and quotes

There are several things wrong with the code: You need #', (or just ',) in front of func. Inside a backquote expression, just func would result in the literal symbol func, not its value as a ...
Drew's user avatar
  • 74.6k
3 votes
Accepted

Iterate only length times over a list

Welcome to SE Emacs. The nil you are seeing is not an extra iteration: it is simply the return value of the dolist or dotimes function.
Fran Burstall's user avatar
3 votes

When is the first element in the argument list regarded as a function symbol and when not?

Specifically responding to if I see the following code, (hoge (foo bar)) how do I know whether (foo bar) is evaluated by passing argument bar to function foo or it is treated as a list of two ...
zwol's user avatar
  • 262

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