Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

for questions about Emacs Lisp as a Lisp dialect, that is, questions *about the language* itself. DO NOT USE it for questions about customization or how to write an application. Emacs Lisp is the scripting and programming language that the Emacs editor is built on.

4
votes
2answers
78 views

Displaying buffer modification before end of function

I notice that Emacs waits for the end of a function to actually display the buffer modifications the function has produced. For instance, if a function looks like this: (defun foo () (interactive) ...
1
vote
1answer
36 views

\\{ in a doc string: what does it mean/do?

What does this backslash syntax mean? (defun elfeed-search-mode () "Major mode for listing elfeed feed entries. \\{elfeed-search-mode-map}" (interactive)
1
vote
1answer
57 views

how to call a c++ function from elisp

initially, i'am new to emacs. So I have little expierience with emacs. In past I used Visual Basic or VBA to work with the Output from some .dll. Now I'am working a little with emacs/elisp. My ...
0
votes
1answer
58 views

Return Value of apply-partially

I'm playing around with apply-partially and I'm confused about what gets returned when calling this function. The documentation states that apply-partially returns a function, but then I'd expect to ...
10
votes
3answers
93 views

Why does defvar scoping work differently without an initvalue?

Suppose I have a file named elisp-defvar-test.el containing: ;;; elisp-defvar-test.el --- -*- lexical-binding: t -*- (defvar my-dynamic-var) (defun f1 (x) "Should return X." (let ((my-dynamic-...
1
vote
0answers
80 views

Learning (Emacs) Lisp coming from languages like C, PHP [closed]

Not knowing (Emacs) Lisp has become a hindrance for configuring Emacs to my liking. And I'm also fascinating by this so-different-from-others language, so I really want to dive down into it and need ...
1
vote
1answer
206 views

What paradigm shift of my thinking must happen to understand the essence of Emacs/Emacs Lisp? [closed]

I've always had "AHA!"-moments when encountering new concepts or ideas in programming. That's when things start clicking for me. And I think I haven't yet had that moment with Emacs/Emacs Lisp yet. ...
0
votes
0answers
19 views

cl-loop for loop variable outside of scope [duplicate]

I wrote the code below to set the right font for my emacs based on the fonts that exist already. (cl-loop with preferred-fonts = (list "Noto Mono" "Source Code Pro" ...
1
vote
1answer
76 views

Kill initial buffers

I want to kill some buffers created by default, such as the GNU Emacs, but putting: (kill-buffer "*GNU Emacs*") On the .emacs doesn't work. I guess this code is called before the initial buffers are ...
1
vote
1answer
39 views

is there a function that can partially apply arguments on a function with order?

apply-partially cannot specify the order. Is there one from the default emacs installation that can specify order?
4
votes
2answers
69 views

How can I define new places for setf?

Q: how do I teach setf about new places it can set? In common lisp, one uses the macro defsetf to tell setf about new places it can set. In elisp, that macro exists in in the cl library, but, as far ...
2
votes
1answer
159 views

Call a function and insert text in minibuffer prompt

I'd like to define a key binding that calls a function and inserts some default input in the function's minibuffer prompt. For example, I'd like to call the command ivy-switch-buffer and automatically ...
4
votes
0answers
136 views

Is there an ELISP decompiler?

I'm thinking of writing one so that when I get those horrible tracebacks from bytecode files, I can better see where I was at. Is there one already? Are there any other tools for showing an error ...
4
votes
3answers
263 views

Is there an equivalent for defparameter on emacs-lisp?

I know we have defvar and setq. defvar has a special meaning on defining global variables because the assignment only happens once. So I was thinking about use setq to get the desired behavior of ...
2
votes
2answers
595 views

How to wrap a single string literal across multiple lines?

Is it possible to write a single line for an Elisp string: "hello world" As: "hello world" Without inserting a newline character? (wrapping a string literal). I read that adding a tilde at the ...
2
votes
1answer
128 views

How to use custom macro indentation in elisp?

This blog post shows that its possible to indent like this: (lispy-dotimes arg (when (= (point) (point-max)) (error "Reached end of buffer")) (forward-list)) Instead of this: (lispy-dotimes ...
2
votes
1answer
121 views

orgmode - babel language elisp vs. emacs-lisp

I am not sure what's the difference between elisp and emacs-lisp. In my environment, both work for elisp code but I did not found elisp from the load language list: #+BEGIN_SRC elisp :results output (...
1
vote
1answer
35 views

practical relevance of storing value and function into one symbol

With Emacs Lisp it is possible to store a value and a function within the same symbol. (setq foo 6) (defun foo () (message "blah %d" foo))) Then you can do: (symbol-function 'foo) which returns the ...
1
vote
1answer
44 views

How to print a quoted sexp using '… (reader syntax) instead of using (quote …)?

The result of (print 'foo) is (quote foo). Is there a similar function whose result is 'foo, which is what people generally write?
4
votes
1answer
90 views

Elisp backtrace print garbage messages

I'm using emacs 25.2 on osx 10.12 and following elisp intro to produce some error message intentionally. (This is a list) After I run C-x C-e on this line. A backtrace buffer appeared as supposed ...
1
vote
0answers
28 views

How to de-instrument elisp function? [duplicate]

To instrument an elisp function means to set up Emacs in such a way that whenever the function gets executed, debug mode is entered so the function can be executed stepwise. To instrument a function, ...
0
votes
0answers
40 views

Byte Compiling Functions Using `defalias` for `progn`

The following code: (defalias 'new-progn 'progn) (defun foo () (new-progn "foo")) (byte-compile 'foo) (foo) gives this error: Debugger entered--Lisp error: (invalid-function #<subr progn>) ...
5
votes
0answers
84 views

Structure-preserving copying of sequences

The form (cl-copy-tree TREE t) returns a deep-copy of a sequence TREE. The the Common Lisp Hyper Spec explains that copy-tree does not preserve circularities and sharing of substructures. I.e., even ...
1
vote
2answers
107 views

Wrapper objects / types for Emacs Lisp primitives?

I'm curious if there's any precedent for wrapper objects or types in Emacs Lisp. Javascript notably has built-in types that wrap built-in literal types and those objects can largely be used in the ...
1
vote
1answer
45 views

File mode name with -mode suffix or not?

I am not sure when I should name file x-mode.el and when x.el. Note that because of established practice mode writer should put (provide 'x) or (provide x-mode) to the end of file and end-users load ...
5
votes
1answer
253 views

The default value of buffer-local variable not set until first `setq`

Say I define a buffer-local variable foo, and its default value is "a": (defvar foo "a") (make-variable-buffer-local 'foo) (default-value 'foo) ;; => "a" Immediately after this I run the ...
1
vote
1answer
248 views

Passing a symbol as an argument to a function

I'm trying to understand why this doesn't work, and how to make it work: (defvar test/var-1 nil) (defvar test/var-2 nil) (defun make-setter (var-to-set) (lambda (val-to-set) (setq var-to-set ...
0
votes
2answers
266 views

how to correctly pass around function as parameters?

I have a working snippet that advices both kill-buffer and kill-this-buffer to not kill the scratch buffer: (defun ninrod/scratch-bodyguard (buffer-assassin &rest arguments) (let ((buffer-...
0
votes
0answers
32 views

alist error when value created using (concat string1 string2) [duplicate]

I'm really confused with what's happening here. In my config for backups I've the line (setq backup-directory-alist '(("" . "~/.emacs.d/backup/per-save"))) and I've a defined a variable in my init....
0
votes
2answers
79 views

Warning assigning variables

I'm rebuilding my emacs configuration, and trying to compile without warnings. I'm using also cask. I have this case: (require 'magit) ;; Enable a right limit of 70 chars for git logs (add-hook '...
5
votes
2answers
144 views

Reflection on function argument signatures

Is there anything built into elisp for reflection on function argument signatures? I have used (length (cadr (symbol-function #'my/function))), but this notably fails on built-in C functions. I'm ...
4
votes
2answers
105 views

Calling a function with a shorter but unknown argument signature length

Is there a terse idiomatic way of calling a function in the manner of funcall (dereferencing function symbols) when that function may have a variably shorter function signature? Say for example: a ...
0
votes
1answer
73 views

converting xemacs lisp to run in emacs [closed]

I have used xemacs for years and have a lot of lisp code I have written. Now I want to switch to emacs and convert all the lisp code over to work in emacs. This is on an winXP machine. I'm sure I am ...
3
votes
2answers
179 views

An efficient set data structure in elisp

Does elisp provide a builtin efficient set data structure, similar to set in Python and std::set in C++?
3
votes
2answers
161 views

How to evaluate a symbol in a lambda function when defining it?

For example, (lambda () (message "%s" x))) But I would like x to be evaluated -- the lambda function should always use that value, instead of the current value of x. How should I do it? Preferably ...
1
vote
1answer
64 views

When is it not possible to quote nil? [duplicate]

I've never quoted nil before, as I can't see any sense in doing that, but I just played around with some code and it seems that in most cases it is possible to quote nil without any effect. However ...
12
votes
1answer
1k views

Meaning of period in (. 123)

I learnt . /path/to/file in bash is used to execute a file. Just out of curiosity, I eval something like the following in Emacs (. 123) ⇒ 123 (read "(. 123)") ⇒ 123 It looks like Emacs ...
2
votes
3answers
141 views

Bringing a function into a lexical environment

I'm using a closure to keep track of some stuff to do with state; I want to be able to ‘include’ a function into that closure, so it can access the state. The only way this is possible is by creating ...
1
vote
1answer
94 views

Why is org-table-calc-current-TBLFM throwing Wrong type argument: integer-or-marker-p Error?

Why does my code generate the error when used with org-table? No error message when code used outside of org-table #+NAME: get-country-or-area-name #+HEADER: :var iso-alpha2-code="ca" #+HEADER: :...
0
votes
1answer
128 views

Define key inside dolist

I am trying to avoid duplicating code and also trying to avoid introducing unnecessary global symbols. So I tried to use let, dolist and lambda when defining the same keys in two different keymaps: (...
2
votes
2answers
152 views

apply partially last arg

Is there something like apply-partially (apply-partially FUN &rest ARGS) Return a function that is a partial application of FUN to ARGS. ARGS is a list of the first N arguments to pass to FUN. ...
4
votes
2answers
145 views

Elisp backquote comma eval puts a space in between

Here's an example: (defmacro test (arg) `(message foo-,arg)) (defmacro test-with-space (arg) `(message foo- ,arg)) (macroexpand-1 '(test-with-space bar)) (macroexpand-1 '(test bar)) Both eval ...
15
votes
1answer
395 views

Why do setq and set quote act differently on let-bound variables with lexical scope?

I had a bug in one of my extensions that eventually turned out to be caused by set not working as I expected: ;; -*- lexical-binding: t -*- (let ((a nil)) (setq a t) (print a)) (let ((a nil)) ...
1
vote
1answer
218 views

Pass function symbol as argument via function or single quote?

Are 'function-name and (function function-name) completely equivalent, or are there conditions under which I must use the more verbose (function function-name)? (apply 'message ( list "call func via ...
5
votes
1answer
555 views

How to make local function binding for closure?

For example, when defining the natural number sequence stream, I can use ;; -*- lexical-binding: t; -*- (defun nats (n) (cons n (lambda () (nats (1+ n))))) (nats 0) => (0 closure ((n . 0) ...
3
votes
2answers
124 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 (...
4
votes
2answers
145 views

One-time advice

I've been trying to a macro to put one-time advice on a function. What I mean by one-time advice is advice which removes itself after it is called – so that when you add the advice and run the ...
2
votes
2answers
163 views

Is there a way to comment within a line in elisp?

Is it possible to comment the string "emacs" below while keeping this code one line? If so, how? (message "hi") "emacs" (message "hi!")
1
vote
2answers
215 views

How to get an insert-text-button 'action property accessing a dynamically-bound buffer-local variable

In realgud I have a text button that needs access to a dynamically-bound buffer-local variable. The situation occurs like this. Inside one buffer that has the buffer local variable, there is a ...
5
votes
2answers
128 views

Finding the source of a function after macro expansion?

(I'm a rookie and I use Spacemacs) I'm trying to find the source of a certain function*. I can find the .el file in which it's defined by using find-function, however the defun is created ...