Questions tagged [elisp]

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.

Filter by
Sorted by
Tagged with
0
votes
1answer
23 views

Elisp review, guidance and help [on hold]

I'm new at customizing Emacs, and I need guidance and help on a little something I'm trying to achieve. The plan is to have the possibility to enter in a custom "writting mode" from any org file. If I ...
2
votes
0answers
34 views

Follow mode for describe-function/describe-variable

When learning elisp by reading source code (on a large screen) it would be nice to have something like a "follow mode", which automaticaly displays the output of describe-variable or describe-function ...
0
votes
0answers
21 views

How can I modify zone's putz-with-case to print random letters instead?

(I will bold the actual questions.) So here is an old version of the offical zone code that randomly chooses letters and randomly makes them uppercase or lowercase. I did not modify this, and it ...
2
votes
3answers
166 views

Are local nested functions possible in elisp?

It it possible to declare functions whose names are only available in the scope of another function, similar to let? e.g.: (defun my-fn (x y) (let ((my-local-fn (lambda (a b) (message "%S" (- a b)...
1
vote
0answers
26 views

Has elisp some object inspector? [closed]

Do you know about some elisp object inspector? I want object tree view similar to ones in javascript consoles in browsers. Object: (list (list "foo" "bar" "baz") "some" "thing") Inspector: list | ...
1
vote
2answers
35 views

' versus #' what are the differences and when should I choose one over the other? [duplicate]

Both seem to work equally well when mapping a function over a list, for example. (mapcar #'1+ (list 1 2 3)) ;; => (2 3 4) (mapcar '1+ (list 1 2 3)) ;; => (2 3 4)
2
votes
1answer
78 views

Is there a timsort implementation in Emacs Lisp?

Timsort is the default sort algo of Python and Java and it performs better than mergesort on roughly sorted lists. I could not find any implementation of this in Elisp. How can I find out whether ...
2
votes
1answer
48 views

what does grave accent ` and aposrophe ' do in elisp regular expression?

I use C-h v to check the doc about this variable org-agenda-file-regexp. It says it is a variable defined in ‘org.el’. Its value is "\\`[^.].*\\.org\\'" What is the meaning of grave accent ` and ...
1
vote
1answer
47 views

How to match an expression under the cursor?

I'm trying to match an expression under the cursor. In this case it happens to be reStructuredText, however I don't think that's such an important detail. :role:`Some Content` While this works, it ...
1
vote
1answer
53 views

Updating code from lexical-let to lexical-binding: t

This code shows an elisp function (third example) using lexical-let, which is now passe as I understand. How would it be written today with lexical scope now being a quasi-built-in feature of elisp? ...
6
votes
1answer
137 views

Shortening trees list with (setcdr (nthcdr 2 trees) nil)

I am starting to learn elisp and working through this tutorial https://www.gnu.org/software/emacs/manual/html_node/eintr/kill_002dnew-function.html and I do not understand this basic example: (setq ...
3
votes
1answer
140 views

How remove lines which are not equal in two buffers?

Consider the following buffers buffer_1: 11111111 22222222 33333333 44444444 buffer_2: 55555555 66666666 22222222 44444444 I need to remove all lines which are not equal in buffer_1 and buffer_2. ...
1
vote
1answer
28 views

How to define a function that calls two commands where the first one requires an arguments

I use emms to play music in emacs and I have this function to add a music directory and shuffle it. (defun my-emms-command() "Run `emms-add-directory' and `emms-...
0
votes
1answer
100 views

How to execute elisp commands

Related Question Hi, I want to give an elisp command which extracts the words between two arbitrary symbols. I searched google for elisp and the first item was emacs lisp, which I guess it means a ...
2
votes
1answer
78 views

How to write a list literal with conditional items? [duplicate]

Given a list literal '(1 2 3) is it possible to conditionally include parts of the list? eg: '(1 2 3 (when thing-is-true '(10 11 12))) 4 5 6) Which would result in '(1 2 3 4 5 6) or '(1 2 3 ...
0
votes
1answer
42 views

how to generate dynamic json data with emacs (macros)?

I was in a meeting yesterday where I was presenting a program that referenced a certain json file with data like this: [ { id: 1, text: '...', ... }, { id: 2, text: '...', ... } ] In ...
0
votes
1answer
52 views

(interactive “r”) can't be used directly after Emacs startup

The proper way to deal with region is using (interactive "r"). But in my case, (interactive "r") always complaints 'The mark is not set now, so there is no region' after fresh Emacs startup. This ...
0
votes
1answer
96 views

How to prevent “the function ‘->’ is not known to be defined.” warning

How do I prevent flycheck from triggering a warning for the following code: (defun file-path-last-segment () "Get last segment of file path for use in snippets." (-> default-directory (...
37
votes
9answers
4k views

How can I start learning Emacs Lisp?

Background: I'm mostly a vi user and am converting to Emacs. Past the basics and now use it for writing code in C and some Python with plans to do an R conversion too. I wrote (Common) LISP for ...
0
votes
0answers
30 views

Is #'(lambda …) historical legacy? [duplicate]

(elisp) Anonymous Functions says The following forms are all equivalent: (lambda (x) (* x x)) (function (lambda (x) (* x x))) #'(lambda (x) (* x x)) Because (lambda ...) is the most concise, I ...
3
votes
1answer
96 views

About closure creation

After reading this article about readable closures, I check that: Since closures are byte-code function objects, they print readably. You can capture an environment in a closure, serialize it, ...
0
votes
0answers
62 views

Slime inspector for emacs lisp

I want to know, if there is some possibility of inspecting an object as slime inspector does. For example, using libyaml I get the following result, it worked well: ELISP> (yaml-read-from-string ...
3
votes
3answers
250 views

Automatically installing the available version of org

Based on this reply, my code has the following function that installs its dependencies: (defun literef-install-packages() "Install any missing packages. The code is taken from `https://...
2
votes
2answers
121 views

Evaluating symbol in function arguments affected by destructive operations?

While evaluating a function call, the arguments is from left to right. For example, (let ((x '(1 2 3))) (list (nreverse x) x)) ;; => ((3 2 1) (1)) The first argument (nreverse x) evaluates to (...
0
votes
1answer
91 views

Access document title, author, date with elisp

The beginning of my document looks like this #+TITLE: this is the document title #+AUTHOR: R. Wiggum #+DATE: 2018-09-12 How can I access these properties with LISP?
1
vote
1answer
90 views

are braces `{` and `}` used at all in elisp?

What is the convention for using { and } characters in Emacs Lisp if they are used at all? Do macros make use of them?
3
votes
1answer
50 views

formatting of elisp file is different in emacs and other text editor

I'm having an issue with formatting in that when I'm in emacs, the formatting looks fine: but when the file is viewed with a different text editor, the spaces are different. this only occurs in the ...
1
vote
1answer
40 views

oddp vs cl-oddp in elisp script

I am trying to write a short script file with elisp for the first time which will serve me to install all the required packages that I use. Thus when I change from one computer to another, I can get ...
4
votes
4answers
260 views

Write `var0, var1, var2, …, var10` in a buffer

Most of the times there is no need to write manually many variables with the same name and a different index, like var0, var1, var2, var3, ..., var9 because one can use arrays, vectors or whatever ...
4
votes
2answers
95 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
64 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
227 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 ...
1
vote
1answer
104 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
155 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
1answer
262 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. ...
1
vote
1answer
230 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
93 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
90 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 ...
4
votes
1answer
422 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 ...
9
votes
2answers
403 views

When should sharp quotes be used?

I see sharp quotes being used in other people's eLisp code, and I use them myself, but I'm not completely clear on when they are appropriate and when not. Could anyone clarify on exactly when it's ...
4
votes
0answers
168 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
466 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 ...
6
votes
3answers
2k 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
246 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
303 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
53 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
67 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
126 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
33 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
56 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>) ...