all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Unsure of error in passing an anonymous function to another function
@ 2015-08-16  2:44 Grant Rettke
  2015-08-16  2:56 ` Ian Zimmerman
       [not found] ` <mailman.8406.1439693823.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Grant Rettke @ 2015-08-16  2:44 UTC (permalink / raw)
  To: Emacs Help

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-17 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16  2:44 Unsure of error in passing an anonymous function to another function Grant Rettke
2015-08-16  2:56 ` Ian Zimmerman
     [not found] ` <mailman.8406.1439693823.904.help-gnu-emacs@gnu.org>
2015-08-16  3:05   ` Rusi
2015-08-17  7:53   ` Joost Kremers
2015-08-17 17:41     ` Grant Rettke

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.