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
1
vote
1answer
444 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 ...
1
vote
2answers
34 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)
1
vote
1answer
98 views

Deleting duplicates in an org-table column

I wanted to preserve the first row value while deleting all subsequent repeated values in the sequence column ($5) as in the MWE below: | ID | M | D | P | sequence | item | |----+---+---+--...
1
vote
2answers
132 views

Getting latest command from function, but function exceeds “max-lisp-eval-depth”

This defines the Helm-source for Emacs commands history. (defvar helm-source-emacs-commands-history (helm-build-sync-source "Emacs commands history" :candidates (lambda () ...
1
vote
1answer
52 views

Problem with file-exists-p function on Linux running as VirtualBox guest

Until this morning, my emacs setup (running on Arch Linux as a VirtualBox guest) was working absolutely fine. Then for no obvious reason I started experiencing the following issue: If I opened an ...
1
vote
1answer
100 views

Call emacs function from terminal and obtain the same behaviour

I have this simple function that opens an external shell (st) in the same directory of the current buffer: (defun external-shell-in-dir () (interactive) (start-process "st" nil "st")) However, ...
1
vote
1answer
84 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?
1
vote
1answer
88 views

How to evaluate a defun with square brackets in column 0 of its docstring?

I have problems running eval-defun for a defun when there is a square bracket [ in column 0 of its doc string. For example: (defun test () "Test function. [Some text]" (message "Hello")) When I ...
1
vote
1answer
439 views

auto kill a shell buffer when command finishes

i have this function you guys helped me write (defun z/dired-shell-other-window-beets () (interactive) (let ((command (concat "beet import " (format "%S" (dired-get-filename))))) (switch-...
1
vote
1answer
71 views

help with writing a dired function to convert md to org with pandoc CLI..started but stuck

im trying to write a function that will be used in dired where i would launch it on the file at point and it will convert it using pandoc. i have the following code chunk (warning: my coding skills ...
1
vote
1answer
51 views

Expression as var

Is it possible for a variable to be set to an expression that will be evaluated each time that variable is accessed? The idea would be that a user could then set the variable to be either a string or ...
1
vote
1answer
239 views

How to break out of function indirection loop

I have a problem that I suspect is a general Emacs problem. If I run a certain package, simple-rtm, and then try and use M-x to run any command, I get the error in the bottom line of the screen: ...
1
vote
1answer
70 views

How to create named functions for dynamic key bindings?

I am creating a keymap based on a configuration file. The resulting keys all call the same function but with different arguments. Here is the code I am using for a single key: (defun add-do-my-stuff-...
1
vote
2answers
50 views

`ibuffer-switch-to-saved-filter-groups' is not known to be defined

I have this line in my .emacs file. (add-hook 'ibuffer-mode-hook #'(lambda () (ibuffer-switch-to-saved-filter-groups "default"))) The settings work fine for me. But flycheck ...
1
vote
0answers
52 views

What is confusing about upcase-region?

Using upcase-region gives the message about it being disabled because new users find it confusing; but it seems very straightforward—replace every character with its upper-case version, if there is ...
1
vote
1answer
27 views

Read-string does not always return a value

I have written a small function to search MDN docs and display them on the browser. However, sometimes the function does not work and an empty query is made. My code is as follows: (defun search-...
1
vote
0answers
56 views

How to trigger function on particularly named buffer creation?

How does one trigger a function to run when a buffer of a particular name is created? My use case is connecting to freenode with ERC for Emacs related channels. I manually call a function to create a ...
1
vote
0answers
132 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 ....
0
votes
2answers
359 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
1answer
44 views

Disable minor modes like flycheck-mode and flymake-mode by default

I disable the following the modes in init.el ;;flycheck-mode ;;flymake-mode ...
0
votes
1answer
38 views

Apply of a logic function over a list

I'm trying to apply a logic function over a list, but: e.g.(apply 'and some_list) give me Invalid function: and. There is a way to apply a logical function to a list?
0
votes
2answers
132 views

Automatically break long function signatures, calls, etc

void parse(std::vector<float>& io_vertices, std::vector<unsigned>& io_indices) {} Oftentimes when we code we need to break lines repeatedly as new expressions and statements enter ...
0
votes
1answer
39 views

Why doesn't generate-new-buffer work in M-x?

According to the documentation generate-new-buffer "buffername" creates a new empty buffer with the given name, yet when I try it in M-x the prompt refuses the name and replaces it with "No match". ...
0
votes
1answer
51 views

If a function is passed as an argument to another function, is the first function's name accessible?

I have some code that takes as an argument a function: (defun message-name (fn) ) I would like to be able to, if the function has a name, message it. For example, if called this way: (message-...
0
votes
1answer
644 views

Symbol's function definition is void on built-in variables?

For some reason I am getting errors for built-in variables that are available in the documentation. For instance, evaluating in the scratch buffer the following all return: Symbol's function ...
0
votes
1answer
92 views

a function to clear out particular words/characters via regex

I have a specific request to all you regex wizards :) I want to create a simple function that deletes or cleans out several parts of a text file based on predefined keywords (such as single capital ...
0
votes
1answer
64 views

How call a function, when the user confirms the question?

I'm trying to write some Emacs Lisp. But I stumble on one thing. The code is structured as following: (defun foo () (interactive) (if (yes-or-no-p "Do you want to call the function bar?") ...
0
votes
1answer
139 views

How to run an executable from within emacs on windows

I have a program, say myprogram.exe, and I want to run it from within Emacs by using a key binding. I can run the program in the shell, but don't know how to write a function that calls this function ...
0
votes
1answer
190 views

evil quit-window and evil-record-macro integration

I am trying to replicate emacs standard behavior when it comes to 'q', i.e. when in a buffer where insert mode does not make sense 'q' closes it. So I defined the following function (defun evil-new-...
0
votes
1answer
77 views

Using result of an Elisp function as input to replace-regexp in interactive mode

I am using replace-regexp interactively. Can I programmatically refer to a match or otherwise interpolate values in the replacement string? In Ruby, for example, it is easily done, by using the #{ <...
0
votes
1answer
86 views

function that takes a function as argument and returns a new function

I'd like to write an elisp-function that has a function as argument and returns a new function. Let's say the new function double-the-function should write the returned value of the argument-function ...
0
votes
2answers
53 views

Changing default output of a function

When I run (+ 1 1) using eval-print-last-sexp in a buffer, this function inserts a newline and outputs 2. I'd rather its output were just ' 2' (space and 2). How can I change this?
0
votes
1answer
77 views

My emacs doesn't contain a function in the online emacs manual

Command comment-line is not recognized by my version of emacs. How can I install this function? UPDATE: It may be relevant that my system shows at least two emacs, at /usr/local/bin/emacs; and at /...
0
votes
1answer
160 views

Create a sub-mode of an existing mode which overrides certain functions?

I want to make a few customizations to cmake-model.el. The big-picture view of this lisp file is as follows: ... ;; This function I want to modify (defun cmake-indent () ... ) ... ;; Mode ...
0
votes
1answer
49 views

Reacting to custom key press

My goal was to improve the php mode. Very often I have to define an array element. And the possible code is this: $array['key'] $array[$key] So, I wanted to create Emacs function, reacting upon ...
0
votes
2answers
47 views

windmove: write a function to move two times (e.g. down and right)?

I'm using the windmove package to move my cursor between windows. In addition, I want to define a function to move twice, e.g. down first and right second. The following function only do the "down" ...
0
votes
1answer
34 views

How can I get git-gutter:next-hunk to NOT loop around at buffer bottom?

As per the title, I would like to stop processing at the end of a buffer and not loop around to the top. I find it easier to keep track of what I am doing that way. TIA.
0
votes
1answer
47 views

use a function to get file in compilation-error-regexp-alist

I have used compilation-error-regexp-alist a lot so I am familiar with the syntax. However for this particular error I need to use a function to get the file because I need wildcards. Here is the ...
0
votes
0answers
104 views

Custom functions in emacs?

I'm finding I run C-x C-f and then: /ssh:$user@$host|sudo:$host:/ Where $host is a device IP. I'm relatively new to emacs, I want to create a custom function that accepts values for $host and $user....
0
votes
1answer
295 views

*** Eval error *** Invalid function:

Step 1 make-toggle-func returns a anonymous function ... (defun make-toggle-func (book-name repl-name code-file) `(function (lambda (x) (interactive) (setq book-name ,book-...
0
votes
3answers
131 views

run emacs function in the shell with parameter

Since there is parameter I need to use, so I will not use single quote as the question's answer First, I try emacsclient -q --eval (progn (find-file "ORG/${UN}.org") (org-latex-export-to-pdf)) ...
0
votes
1answer
130 views

Custom search function for dictionary lookup

I have a plain text dictionary in which each headword is matched by ^# \(† \)?headword, How can I make a custom search function that relieves me of typing the whole regex every time I want to look ...
0
votes
0answers
109 views

Sublime Text like Ctrl-Delete/Backspace

Is there any easy way (or maybe a package) which provides Ctrl-Del/Backspace behavior like in Sublime? The default rule of sublime is delete-to-next-word-boundary. I did not find similar options. ...
-1
votes
1answer
75 views

Emacs Lisp Error when called as command but works well when called as function

https://github.com/Cheatinikle/Spacemacs-settings/blob/master/emacs-package/preetest-mode.el This is my full source code, and 'just-utils package is also included in the repository. The problem is, ...