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.
241
questions
1
vote
2
answers
109
views
Defining functions as other functions
I'm writing a package that provides a new shortcut layout for Emacs. Among other things, I'd like to replace y-n-queries with queries using a and t. I know there is a map for most such queries, but a ...
0
votes
1
answer
38
views
Help understanding elisp debugger error
I am writing a function to set a BLOCKER property on tasks under certain conditions. The logic is working fine, but I am getting an error I cannot make sense of.
When executing the function on a org ...
3
votes
1
answer
44
views
After refactoring elisp code, is there some help in finding unused code, mostly functions and variables?
Dealing with a one-file elisp package, I wonder if there is a nice way to see unused functions and variables after some major refactoring. I can go through the code and do xref-find-references. But ...
1
vote
2
answers
52
views
How to create an independent copy of a function's definition?
I want to create a modified copy of re-search-forward and advise this copy to be sensitive to isearch-filter-predicate. I tried:
(defun make-search-sensitive-to-ifpmod-advice (orig-fun &rest args)
...
0
votes
1
answer
55
views
"Suffixed" version of a function without define it
In reference to my previous question Unwanted Focus Shift when Clicking Menu Functions in Emacs Mode Line, I have found a possible solution:
(defmacro with-ignore-mouse-events (&rest body)
"...
0
votes
1
answer
22
views
Why does my function not accept a keymap when called as a variable?
I have to remap a lot of keys in existing maps while still remembering the old value of the map. To do that, I wrote some functions that go through lists of keys and lists of keymaps:
(defun Daselt/...
0
votes
1
answer
22
views
Why can a function change behavior after instrumenting edebug on it 1 time?
I have a function that's broken until debugging: it returns nil which it shouldn't. After I flag it for debug and unflag it, it works correctly from then on.
Why?
1
vote
1
answer
40
views
Return a list of functions with a given property or creating a group of functions
I am a copy editor and I make an intensive use of custom "predicates" when I perform replacements in LaTeX code.
I use, among others, this technique:
;; predicate
(defun omit-comments (beg ...
0
votes
1
answer
56
views
Define command that executes several functions
I apologize for this question, for which I know an elementary answer exists that I can't find for the life of me. I would simply like to define a command that executes several functions sequentially. ...
3
votes
2
answers
388
views
Where to find all elisp functions?
I’m working on this tutorial and it uses functions such as,
search-forward, goto-char, save-excursion etc.
Is there a place where all functions are listed?
If I search for search-forward I find this ...
0
votes
1
answer
102
views
Command that does absolutely nothing
Is there an Emacs command that does absolutely nothing ?
6
votes
2
answers
239
views
Call function without calling advice defined on it
I sometimes want to bypass the advice I have defined on some function. Something like:
(call-without-advice #'fn ...)
0
votes
1
answer
30
views
Using a function with a different name [closed]
I want to call tematika-activate using hooks to minor mode. But I want to call the function called tematika-activate rather than tematika-enable which does the same thing, enabling tematika-minor-...
0
votes
2
answers
51
views
kill-buffer ERROR: wrong-type-argument - can't programatically kill buffers
I'm trying to kill buffers after selecting them from buffer-list:
(kill-buffer
(cl-remove-if-not (lambda (b)
(and
(string-match-p "ein" (buffer-...
1
vote
1
answer
67
views
Some functions/commands appear to be missing
I cannot call emacs-lisp-docstring-fill-column mentioned here or url-link mentioned here. Neither using M-x nor in code. I use Emacs 28.2. Are these commands provided by a package ? As far as I read, ...
1
vote
2
answers
273
views
How can I make Org-mode's code-block output into another code-block in a different language?
I'm using a Python code-block (the middle part of the code below) to convert the table (top part) into an Emacs Lisp code-block (the bottom part).
#+NAME: tmp_table
| key | trans | description ...
1
vote
2
answers
121
views
How to implement a function in `quail-define-rules` (for `set-input-method`)?
I'm checking out quail (set-input-method) to write some LaTeX snippets (I felt it had some advantages over the others snippet options such as yas-snippets).
According to the manual:
quail-define-...
1
vote
1
answer
44
views
Write a function that prompts for a file from within a list
As a starting point, this:
(defvar myfoo "~/org/test-file-1.org" "myfoo") ; C-x C-e
(defun mybar()
(newline-and-indent)
(insert-file-contents myfoo)) ; C-x C-e
(mybar) ; C-x C-e
...
0
votes
1
answer
87
views
How do I put a function into a cons with dotted pair?
I want to send keybindings to meow-leader-define-key but it only takes them in dotted pair notation, which is a string followed by a function, but I can't figure out how to convert a string and a ...
4
votes
2
answers
663
views
Is there any function that allows me to execute code on the run?
I'm a Vim user who is trying to migrate to emacs. On Vim, I've been using the following vimscript function to execute code:
function! ExecuteOnTerminal(type) range
if (&ft=='bash' || &ft=='...
1
vote
1
answer
110
views
GNU emacs lisp: string match (how to pass emacs-version correctly)
I'm newbie with Emacs and I'm experimenting with Lisp on GNU Emacs-26.1. Can't understand why the following simple piece of Elisp code does not work:
(string-match "^GNU Emacs" emacs-...
0
votes
1
answer
114
views
Changing value of a function argument
Have been playing with the following function
(defun ignition (featr actm)
"TODO."
(when (eq 'sweep featr) (setq featr 'icomplt))
(message "%S" featr))
Calling the ...
11
votes
1
answer
2k
views
Warning: quoted with ' rather than with #'
After switching from Emacs 25 to Emacs 28 I started to get this warning message during the loading of my custom settings
.emacs.d/init.el: Warning: (lambda nil \.\.\.) quoted with ' rather than with #'...
1
vote
2
answers
131
views
How to find Emacs Lisp Org Mode functions
How can I find Org Mode emacs lisp functions like org-current-level which is used in the answer for Org subtree from yasnippet?
I looked for the command in the Org Mode Manual but didn't find it there....
9
votes
6
answers
1k
views
When is the first element in the argument list regarded as a function symbol and when not?
I'm learning elisp, and I just learned that the first element of a list is interpreted as a function symbol. I then learned how to define a function with defun. Here's the example from An Introduction ...
-1
votes
1
answer
53
views
Passing and testing symbol in a function [closed]
Would like to pass a symbol to a function that tests for the symbol before executing certain tools.
Let there be a function named (highlight-mode-line) such that when it is called with (highlight-mode-...
0
votes
1
answer
81
views
Org export "invalid function" error
This is my export.el:
(require 'ox-publish)
(setq org-publish-project-alist
'(
("org-notes"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory ...
-1
votes
1
answer
32
views
Using symbols to set options [closed]
I would like to use a symbol to set an option. I am currently using a variable cune-launch to determine when to execute cune-tools.
(defvar cune-launch t)
(defun cune ()
"Loads cune and ...
1
vote
2
answers
385
views
Why can't I compose commands `mark-whole-buffer` and `copy-region-as-kill` in Elisp code?
I am trying to write a small code snippet in Elisp.
Basically, I want to create a function so that the content of the whole buffer is copied and, then, copied to the kill ring.
I can achieve this by ...
0
votes
1
answer
116
views
Let a function do a keystroke
Often there is a function which then asks for another keystroke to determine how to act. Examples for this are the cdlatex functions cdlatex-math-modify, cdlatex-environment, or the reftex function ...
1
vote
1
answer
189
views
How do write a function/macro to wrap arbitrary interactive function?
I'm trying to write a function/macro to wrap arbitrary interactive function with some pre- and post- processing. Those processing does not involve the arguments of the interactive function.
For ...
0
votes
1
answer
236
views
:documentation void-function error
The following backtrace problem in being produced but cannot identify the problem correctly.
Debugger entered--Lisp error: (void-function :documentation)
(:documentation (concat "Version and ...
0
votes
1
answer
25
views
Setting of face using funcall
I am using funcall to set a typeface by calling a function select-typeface. I would like to remove select-typeface, calling (face (funcall level-typeface depth match).
Cannot simply do
(let ( (face (...
1
vote
1
answer
143
views
Function that determines and returns the programming language of a given file
I'm working on some compiler shortcuts:
I want to write a function (cmp FILE-NAME &optional args) that will use FILE-NAME and args to construct the appropriate COMMAND to call (compile COMMAND) ...
0
votes
1
answer
118
views
How to add spacemacs/evil functions to pulsar-pulse-functions?
I'm using emacs 28.1 with Spacemacs and after installing pulsar I'm wondering how to add the pulse functionality on certain events, such as, when going through search matches, scrolling up, down, etc.
...
0
votes
3
answers
59
views
Problems using a function reference from a plist
I'm trying to (funcall) a function reference I have in a plist.
(defun helper-get-filename ()
"Argument Helper to get a filename."
(read-file-name "-l <filename>: " "...
3
votes
1
answer
413
views
How can I create an alias for a function name?
Does Elisp allow the equivalent of an alias for a function name?
1
vote
1
answer
122
views
Is there some way to have a local defalias?
I have some very long function names I want to use short forms for in particular files, eg
(defalias-local avlfn a-very-long-function-name)
Is that possible, or is that something I may have to write ...
1
vote
1
answer
99
views
What makes an elisp function available with M-x [duplicate]
Why some functions in simple.el are invokable with M-x and some others aren't?
For example I can do M-x what-line but I can't do M-x line-number-at-pos.
1
vote
1
answer
56
views
Extract org heading title without task count e. g. [0/0]
I would like to extract just the plain name of an org heading:
I tried with (nth 4 (org-heading-components))
Example:
* Some Heading Title [0/1] ;; cursor in this line when executing
** ...
0
votes
1
answer
47
views
Function to clone and rename buffer and narrow to subtree
This is a continuation of another question of mine which stated:
I would like to go to an org heading * [A] HeadingTitle :sometag:, then clone a buffer, rename it to "HeadingTitle" and ...
0
votes
1
answer
50
views
Function to clone buffer, narrow it and rename it to the name of the current heading
I would like to go to an org heading * [A] HeadingTitle :sometag:, then clone a buffer, rename it to "HeadingTitle" and narrow it to this heading - all in one function.
I know how to add the ...
4
votes
1
answer
474
views
Why do people add their initials to the names of tailor-made functions added to their config file?
Is it a namespace trick to prevent future problems?
I noticed a pattern in the Emacs community. When people create some tailor made function and insert it on their init files, they use a convention on ...
1
vote
1
answer
100
views
Lisp function to parse shebang line?
Before I probably re-invent the wheel, has anyone written a function (or perhaps there's one somewhere in Emacs already) to parse the shebang line of the current buffer (or some specified buffer). For ...
1
vote
1
answer
281
views
How do I call a function within a lambda?
I would like to define a function that generates lambdas, as such:
(defun my-func (FUNCTION)
(lambda ()
(FUNCTION)))
But when I evaluate the following
(defun my-func1 ()
(message &...
5
votes
2
answers
396
views
Create a function that returns a new function definition
I'm creating a modular system for my use of Emacs, so I can call modules on the fly, as I need them. Just like a lazy call, but I must explicitly call them.
Anyways, I found this riddle, I want a ...
1
vote
2
answers
113
views
How can a function be used as an alist value but be evaluated before its value is used?
I am using Chemacs2 and I want to set an environment variable in the .emacs-profiles.el, eg
To clarify the problem .emacs-profiles.el is not executed it is read and I have updated the post with a ...
2
votes
1
answer
281
views
Validating Arguments to a Function
I would like to validate the argument to a function before its action is executed. The main concern is the passing of a void variable. How can I trap this?
(defun is-it-bound(item)
(if (boundp 'item)...
2
votes
1
answer
301
views
redefine a function as wrapper for the old definition
I am trying to modify a package by redefining a function in it. However, I would like to call the original definition in the new definition. (kind of like extending a constructor in a subclass now ...
3
votes
1
answer
46
views
command print no results with (interactive "r")
Consider this test function (tested in emacs -q):
(defun foo (start end)
"for testing purposes"
(interactive "r")
(when (region-active-p)
(cons start end)))
...