help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unsure of error in passing an anonymous function to another function


From: Grant Rettke
Subject: Unsure of error in passing an anonymous function to another function
Date: Sat, 15 Aug 2015 21:44:25 -0500

Good evening,

Emacs-Lisp question.

Emacs: 24.4.1.

Lexical binding: nil

Trying to refactor a function. Broke it down by my intention:

• Save excursion
• Go to start of buffer
• Do something (In this case just insert some text to see that is is working)

Expected result

• To see "XXX" at the start of the buffer

Actual result

• save-excursion: Symbol's function definition is void: fn
• the function `fn' is not known to be defined.

To address this I started by reading more on Emacs-Lisp and scoping and
function definitions.

What am I doing wrong?

┌────
│ (defun doer (fn)
│   (interactive)
│   (save-excursion
│     (goto-char (point-min))
│     (fn)))
│
│ (defun useit ()
│   (interactive)
│   (doer
│    (lambda ()
│      (insert "XXX"))))
│
│ (useit)
└────

Grant Rettke
--
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
“All creativity is an extended form of a joke.” --Kay
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]