Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [defun]

The tag has no usage guidance.

4
votes
2answers
69 views

defun in defun is not local?

I am reading SICP to learn Lisp, the book uses Scheme dialect. I want accommodate it to emacs lisp, I find something weird in 3.1.1 and cannot figure it out, say I have a test.el file: (defun make-...
0
votes
1answer
35 views

defun removes function in spacemacs config

I re-defined the function org-archive-subtree to call another function as described in the function below. I did this in spacemacs/user-config, now I can't call org-archive-subtree and C-h v (describe ...
1
vote
1answer
141 views

Make a variable visible to some functions only

Consider the following metacode: ;;; -*- lexical-binding: t -*- (defvar var1 ...) (defvar var2 ...) (defun main () "Main entry point" ...) (defun func1 ...) (defun func2 ...) ... (defun funcn ...)...
0
votes
1answer
49 views

Trying to copy everything between double quotes, and then make a list of everything that was copied

So I have a defun that I made that is supposed to copy every thing that is between double quotes and then make a list of everything that was copied. I don't know what the problem is, but it doesn't ...
0
votes
2answers
49 views

How to create a function which calls edit-indirect-region and then changes the mode in the buffer?

I'm beginner user of Emacs and I found trouble while trying to bind a custom function to a key. I successfully bind some keys to edit-indirect-region using following code: (global-set-key (kbd "C-c ...
0
votes
0answers
104 views

How to enable minimap when X and disable it when noX?

I want to disable minimap when nox system. (defun my:minimap-only-x() (when (eq window-system 'x) (add-hook 'prog-mode-hook 'minimap-mode))) (add-hook 'prog-mode-hook 'my:...
4
votes
2answers
50 views

How to define a bundle of variable-and-function pairs?

I want to define a bundle of variable-and-function pairs, e.g.: vl/path-doc points to my often used path, and vl/open-path-doc is used for open it in dired-mode. I tried this piece of code: (setq ...
2
votes
0answers
141 views

Interactive lambda functions

How do I create interactive lambda functions? (use-package general :ensure t :config (general-evil-setup t) ;;(setq general-default-keymaps 'evil-normal-state-map) (general-define-key :...
0
votes
1answer
25 views

How do I update this defun to select region

I wrote this function which takes a string and writes out self.var for each entry in the string. This helps me create python classes faster. (defun elf-python-self (str) "Parse the arguemnts in STR ...
1
vote
1answer
57 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 ...
0
votes
2answers
83 views

Play chess, login on a FICS server

I wish to play chess with chess.el on a FICS server using M-x chess-ics but using that logs me as a guest player. How can I login with my registered user/password? EDIT I've come with a way to login....
0
votes
1answer
58 views

Adding to kill-buffer-hook results in “setq: Wrong type argument”

Subtract a buffer's (the file's) size from a variable before killing it. Emacs 26. (defvar cumulative-open-bytes '0 ) (defun buffer-settings-calc-bytes () (interactive) (let ((current-open-file-...
13
votes
3answers
202 views

Defun inside let with lexical binding gives byte-compile warning “the function is not known to be defined”

I want to get the effect of a static variable by using defun inside of let with lexical binding to create a closure. However, when byte-compiling the file, I get a warning. Am I doing something wrong, ...
6
votes
1answer
711 views

How to make local function binding for closure?

For example, when defining the natural number sequence stream, I can use ;; -*- lexical-binding: t; -*- (defun nats (n) (cons n (lambda () (nats (1+ n))))) (nats 0) => (0 closure ((n . 0) ...
0
votes
1answer
26 views

eval-last-sexp produces unnecessary void-variable error when using a macro containing eval

Suppose I have defined the following macro: (defmacro mymacro (a) "" (eval a)) If I then use eval-last-sexp (i.e. C-x C-e) to evaluate the following, (defun somefcn (b) "" (mymacro b)) I get the ...
0
votes
0answers
81 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. ...
2
votes
0answers
73 views

Optional docstring in defun

After taking a look at the definition of defun in byte-run.el, it seems that the macro does some very interesting things regarding checking for the existence of a docstring. First, it uses a declare ...