Hot answers tagged

44

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 sees the old macro instead of the new function. As others have pointed out uninstalling org-mode restarting Emacs (without loading org-mode) and reinstalling will ...


38

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.


26

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) "Evaluate elisp code stored in a string." (eval (car (read-from-string string)))) Now (my-eval-string "(+ 1 2)") evaluates to 3. Edit: As pointed out by ...


12

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.


9

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() (interactive) (if (region-active-p) (eval-region region-beginning region-end) (eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL))) (global-set-key (kbd "C-x C-e") 'my-...


8

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 example: `(,some-var "some-string")


7

(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 compilation time, then your code can't be compiled properly since the define-clojure-indent macro won't be known during compilation, leading to mis-compilation, ...


7

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") (unload-feature 'prolog) (load "/path/to/my/own/private/prolog.el")) Note that unload-feature is not a commonly used function, so it's possible you may hit some ...


5

1) 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 each of the sublists contains a tag (the first element) and a property list (the rest of it). But property lists consist of key-value pairs (pairs in a more ...


5

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 0) ret) (condition-case err (while t (setq ret (cons (funcall (lambda (ret) (setq next (cdr ...


5

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 prints is a Lisp representation of the value. If you instead use pp-eval-expression then you see `foo, which is the (same) value printed for humans. (This is ...


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 ((...


4

@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 its evaluation, using (eval-and-compile (require 'clojure-mode)). The fact that require is evaluated by the byte-compiler when it is at top level is pointed out ...


4

for me uninstalling the org-plus-contrib package and reinstalling it solved it.


4

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 type B (dired-do-byte-compile) to byte-compile all specified Elisp files. In all buffers, you can run the command M-xbyte-compile-fileRET to byte-compile an ...


4

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 init file to declare additional options. To run something before the init file, you can force a different load order: # emacs --no-init-file --eval '(defvar ...


4

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 returning the bound value (a list object that has been created earlier). However, by that point the huge list has already been generated. Evaluating it over and ...


3

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 (seq-random-elt theme-selection))) See also funcall and Sequence Functions. PS. Note that if you compile your function, you will get warnings about undeclared ...


3

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".


3

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 [RET] org-plus-contrib and reinstalling with M-x package-install [RET] org-plus-contrib DID fix it


3

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 (find-library-name "prolog")) (re-search-forward "(defvar prolog-mode-version \"\\([^\"]+\\)") (string-to-number (match-string ...


3

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 variable. Use comma (, to evaluate it. But then quote that evaluated result. You need to use kbd, or else you are trying to bind the key sequence C-x SPC k. You need ...


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

vdiff processes the output of diff asynchronously which takes a nonzero amount of time. Instead of guessing when to run vdiff-refine-all-hunks just set vdiff-auto-refine to t to let vdiff run it at the right time. If you're having a performance issue, first check how long diff takes on the command line, then see if refining all hunks is slow, and finally ...


2

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-errors.


2

It looks like you're comparing 'ctkb with '(quote ctkb) -- or (quote (quote ctkb)) if you prefer. e.g. Evaluating '(quote ctkb) returns the value (quote ctkb), exactly like your plist-get return value. (equal 'ctkb (quote ctkb)) is certainly true, but (equal 'ctkb '(quote ctkb)) isn't the same thing. I presume that (equal 'ctkb (cadr (plist-get (gethash "...


2

Moving the setq into the eval-when-compile means that the variable will be assigned during byte-compilation but not when you load init.elc, so it's probably not what you want. BTW, I'd recommend (dolist (x '(doom-one zenburn leuven)) (ring-insert ring x)) over using mapc, tho it's largely a question of taste.


2

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. ... PRINTFLAG controls printing of output by any output functions in the evaluated code, such as ‘print’, ‘princ’, and ‘prin1’: a value of nil ...


2

The Lisp interpreter always evaluates the arguments before it passes them to the function you're calling, so the answer is that yes, the entire list will be generated first, and then car will select the first element of it. This may or may not be a performance problem. If the test you're doing on each file name is expensive, then you might want to go to ...


2

Evaluating(princ 1) with C-x C-e (eval-last-sexp) displays the following in the echo area 11 (#o1 #x1 ?\C-a) because (princ 1) prints 1 and returns the integer 1. And (pp 1) is the same as (princ "1"), it prints 1 and returns the string "1". Try executing them in M-x ielm, it produces cleaner output. *** Welcome to IELM *** Type (describe-mode) for help....


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