use this tag for Elisp functions
for their usage, definitions, re-definitions, defining aliases, and other standard features of function execution fundamental to Lisp programming languages. Add additional Elisp tags when the functions are about specific Emacs features.
Questions tagged [functions]
238 questions
24
votes
1 answer
Curiosity: What does progn stands for?
According to Emacs documentation:
progn is a special form in `C source code'.
(progn BODY...)
Eval BODY forms sequentially and return value of last one.
What does progn stands for (or its origin)?
Useage: Is it equivalent to Clojure's -> macro?

Nick
- 4,473
- 4
- 26
- 44
9
votes
2 answers
How do I invoke a non-interactive lisp function interactively?
This is dim, but I've forgotten how to do this, and I can't work it out, sorry:
I'm in python mode with elpy, and I want to run the function
python-nav-beginning-of-defun
in a python buffer, to see what it does
M-x python-nav-beginning-of-defun…

John Lawrence Aspden
- 265
- 1
- 6
8
votes
3 answers
Is everything in Emacs made of functions?
Being more used to Vim, I know that it was correct to think "everything in Vim is a macro" but what about Emacs?
Is it fine/correct to think that everything is a function in Emacs?

Nordine Lotfi
- 357
- 2
- 13
8
votes
2 answers
How to delete a function?
For what I do I tend to define a lot of functions that I use temporarily. Life span is usually about 1-2 weeks - and then I define a new set of functions.
I was not able to find where these definitions actually are, nor how to delete them just by…

A_P
- 672
- 4
- 21
7
votes
3 answers
#'and is an invalid function?
I'm trying to see if all the values in a list are truthy. For some reason, (apply #'and lst) errors with:
Invalid function: and
This also happens when I try (cl-reduce #'and lst).
However, (apply #'max lst) seems to work fine.
Right now, I'm using…

PythonNut
- 10,363
- 2
- 30
- 76
6
votes
2 answers
Does Emacs Lisp functions return objects by reference or by value?
I tried to determine if Emacs returned object by reference or value, but could not find a clear answer (searching google and Emacs Lisp manual). I guess it must be "by reference", and I just overlooked it somewhere..
For example:
(defun my-get-hash…

Håkon Hægland
- 3,648
- 1
- 22
- 51
5
votes
1 answer
What is identity doing?
I've seen this sort of thing a few times:
(mapconcat 'identity '("" "home" "alex " "elisp" "erc") "/")
=> "/home/alex /elisp/erc"
which means mapconcatwants a function in the second position, hence just shove it the "identity" function if you…

147pm
- 2,959
- 1
- 18
- 42
3
votes
2 answers
Function for compressing a number range
I'm working with TeX-Files which are converted from other formats. One thing that pops up in these are vertical lines in tables like the following:
\cline{1-1}\cline{2-2}...\cline{n-n}
This can be expressed in a compressed fashion…

Shylock
- 309
- 2
- 6
3
votes
2 answers
Can I define a function/macro in emacs named .?
I would like to define this function:
(defun . (object method &rest args)
(apply (plist-get object method) args))
But, not surprisingly I get: if: Dot in wrong context
Not surprising because it looks like a cons cell and isn't. I can use some…

John Kitchin
- 11,891
- 1
- 20
- 42
3
votes
1 answer
Command for inserting for-statement skeleton
How would one write a function that one could bind to, say, SUPER-f, which inserts the code:
for () {
}
in the buffer with my cursor being moved into the () parens for filling out the loop guard?

eof
- 91
- 1
3
votes
2 answers
How interpret the Lisp way to include arguments in functions?
I have some difficulties to understand how Lisp wanted to receive the arguments. When I look into the documentation about arguments in functions, I need to name the arguments exactly as in the source code, when calling the same function.
When I…

ReneFroger
- 3,850
- 23
- 66
2
votes
1 answer
built-in function to return the argument itself
The line below shows the first element which is not nil.
(message "%s" (cl-some #'(lambda (x) x) '(nil nil "hello" nil)))
;; Output: hello
Is there a built-in function which is equivalent to (lambda (x) x)?

Zheng Qu
- 123
- 5
2
votes
1 answer
Disable minor modes like flycheck-mode and flymake-mode by default
I disable the following the modes in init.el
;;flycheck-mode
;;flymake-mode …

Alice
- 219
- 1
- 8
2
votes
2 answers
How to save all modified buffers and kill emacs
I use the well known key-binding C-x C-c to quit emacs. However this command asks y/n confirmation to save modified buffers and if there are process buffers (eg. Shell) it also asks for yes/no confirmation before to exit.
I'd like a command that…

PinkCollins
- 191
- 9
2
votes
2 answers
Why use `defsubst` in `man.el`?
I recently noticed an issue in man.el, in which sections in Man--sections are listed backwards. That is, the value is is something like:
(#("SEE ALSO" 0 8
(face Man-overstrike))
#("COPYRIGHT" 0 9
(face Man-overstrike))
#("REPORTING BUGS" 0…

Tianxiang Xiong
- 3,878
- 18
- 28