Questions tagged [functions]

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.

Filter by
Sorted by
Tagged with
3
votes
3answers
214 views

How to call another function, if one function gives an error message

Suppose I call a function which is named as foo. Sometimes that function foo will give a message such as "Example of error message". If that is the case, then something else should be executed. ...
4
votes
2answers
107 views

Understanding “It is bound to …” message in describe-function

If you ask for a function description, there is a line that starts: It is bound to <...> <...> <...> For example, for isearch it says: It is bound to <menu-bar> <search&...
2
votes
1answer
73 views

Where is this `make-magit-section` function defined?

I'm looking at the magit source code, and there's this make-magit-section function that doesn't seem to found anywhere in the project (grep doesn't return any results). describe-function says that ...
1
vote
0answers
138 views

My function seems to not know a variable has changed and gives the wrong output

I want to change the shebang string every time I create a new Python file, some projects use Python 2 and other use Python 3, so the shebang should change according to the value of a variable in the ....
5
votes
1answer
630 views

How kill all hidden (non-visible) buffers?

I looked around to be sure, that none had this issue earlier. Okay, sometimes I'm having too many buffers to manage. So I would like to kill all these buffers, except the buffers that are currently ...
9
votes
1answer
885 views

How to find out where a function is called from (backtrace/stacktrace)?

I've hit a problem that region is deactivated (in transient-mark-mode). The function deactivate-mark is called and I would like to find out where (and why) it is called from. I tried M-x debug-on-...
1
vote
1answer
264 views

Text is shown as bounding boxes when I switch to Arabic input method and use a certain font

I use this function in init.el file so that I can switch to Arabic language when writing code in Arabic and select an Arabic font for that: (defun arabic-input-font () "changes the set-input-method ...
25
votes
1answer
2k views

What is the difference between ' and #' in front of a symbol?

I'm a little new to Emacs. When looking at some of the configurations, I found there are two types command in "add-hook". (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode) and (add-hook 'LaTeX-mode-...
2
votes
1answer
179 views

buffer-file-name is a function, so why doesn't M-x buffer-file-name work? [duplicate]

When trying to run it I get M-x buffer-file-name [No match] But it has a function help entry via C-h f and I can evaluate it with M-: buffer-file-name. So why isn't it accessible via M-x?
2
votes
3answers
122 views

How to convert this add-to-list call into a function

I have a bunch of add-to-list calls that I'd like to shorten in my .emacs file. They all look like this: (add-to-list 'align-rules-list '(haskell-comment (regexp . "\\(\...
5
votes
1answer
376 views

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 ...
12
votes
2answers
5k views

How do you return from a function at an arbitrary point?

How do you return early from a function before it's ended? For example: (defun my-func () "for example." (unless something (return nil)) ; continue as usual... (+ 42 1))
6
votes
1answer
289 views

How to map a function over several values?

I have a function foo-function that takes the variable x and performs a specific action. The variable x comes before the definition of foo-function: (defvar x "value1") (defun foo-function () (...
5
votes
2answers
1k views

Partial function application

apply-partially lets you create a new function by fixing the first n arguments of an existing function. Is there any way to achieve unrestricted partial function application, i.e., the ability to fix ...
23
votes
1answer
3k views

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)? ...
30
votes
4answers
3k views

When to sharp-quote a lambda expression?

Q: When, if ever, is it useful to sharp-quote a lambda, and when, if ever, must we not sharp-quote a lambda? People use lambdas in three ways: plain: (lambda (x) x) quoted: '(lambda (x) x) sharp-...
36
votes
1answer
2k views

What is the difference between a function and a command?

When posting questions and answers here, people sometimes use the terms "function" and "command" interchangeably. In other cases, people only use one of the two terms to discuss specific pieces of ...
18
votes
2answers
3k views

Difference between load-file and load

I went through the documentation of both the function but they don't seem to shed much information. What is the actual difference between them apart from the fact that load is a built-in function in C ...
2
votes
1answer
375 views

Monkey patching a function

Some context: I'm doing some linux kernel development on a Debian VM so naturally I'm using tramp. I want to use semantic-symref, but the trouble is that: Semantic will eventually call cedet-gnu-...
5
votes
2answers
289 views

Define an emacs function to take arguments in the same way as something like M-x goto-line

I want to write an emacs function for debug purposes in c++ code. Basically I'm fed up typing the following: std::cout << "variable is: " << variable << std::endl; Instead I want ...
3
votes
1answer
327 views

function calls from command line, using emacsclient

I used to read my emails from command line with emacs -f gnus. To read my emails using emacsclient, I'm doing emacsclient -c --eval '(gnus)'. Just want to know, is there a simpler alternative to that? ...
5
votes
1answer
66 views

How can I create an function to build a table of contents at a marker?

I'm planning to move StackMode to a literate program once it matures, but until then I'm using the conventional ^L section markers. My files look like this: ;;; Code: ^L ;;; Section 1 Title (defun ...
2
votes
7answers
913 views

How to get the function help without typing?

I'm already used to press C-h f and type a function name to ask for help on that function. But if the function name is already under the cursor (e.g. while visiting the .emacs configuration file), is ...
26
votes
2answers
2k views

Can functions access their name?

In C there is the magic variable __func__ that holds the current function name. In Bash, there is an array FUNCNAME holding the names of all functions in the calling stack !!! Is there a similar ...
8
votes
2answers
258 views

Argspec or arity of a bytecode function in Emacs 24

I have code that tests the arity of a function. I use it to determine whether optional arguments added in recent versions of a package are present. It calls subr-arity for built-in functions and ...

1 2 3
4