* 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
* Re: Unsure of error in passing an anonymous function to another function
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>
1 sibling, 0 replies; 5+ messages in thread
From: Ian Zimmerman @ 2015-08-16 2:56 UTC (permalink / raw)
To: help-gnu-emacs
On 2015-08-15 21:44 -0500, Grant Rettke wrote:
> What am I doing wrong?
Elisp is not Scheme (sadly). Function bindings are separate from
variable bindings. To use the function binding you need funcall (which
see in the docs).
> (defun doer (fn)
> (interactive)
> (save-excursion
> (goto-char (point-min))
> (fn)))
(defun doer (fn)
(interactive)
(save-excursion
(goto-char (point-min))
(funcall fn)))
Btw, please don't use that "pretty" quoting, it just gets in the way.
--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unsure of error in passing an anonymous function to another function
[not found] ` <mailman.8406.1439693823.904.help-gnu-emacs@gnu.org>
@ 2015-08-16 3:05 ` Rusi
2015-08-17 7:53 ` Joost Kremers
1 sibling, 0 replies; 5+ messages in thread
From: Rusi @ 2015-08-16 3:05 UTC (permalink / raw)
To: help-gnu-emacs
On Sunday, August 16, 2015 at 8:27:04 AM UTC+5:30, Ian Zimmerman wrote:
> On 2015-08-15 21:44 -0500, Grant Rettke wrote:
>
> > What am I doing wrong?
>
> Elisp is not Scheme (sadly). Function bindings are separate from
> variable bindings. To use the function binding you need funcall (which
> see in the docs).
Funcall is the solution
The problem is elisp is a lisp-2; See
http://www.nhplace.com/kent/Papers/Technical-Issues.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unsure of error in passing an anonymous function to another function
[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
1 sibling, 1 reply; 5+ messages in thread
From: Joost Kremers @ 2015-08-17 7:53 UTC (permalink / raw)
To: help-gnu-emacs
Ian Zimmerman wrote:
> Elisp is not Scheme (sadly).
Thank $DEITY it isn't!
;-)
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unsure of error in passing an anonymous function to another function
2015-08-17 7:53 ` Joost Kremers
@ 2015-08-17 17:41 ` Grant Rettke
0 siblings, 0 replies; 5+ messages in thread
From: Grant Rettke @ 2015-08-17 17:41 UTC (permalink / raw)
To: Joost Kremers; +Cc: Emacs Help
Thank for all of your replies.
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
On Mon, Aug 17, 2015 at 2:53 AM, Joost Kremers
<joost.m.kremers@gmail.com> wrote:
> Ian Zimmerman wrote:
>> Elisp is not Scheme (sadly).
>
> Thank $DEITY it isn't!
>
> ;-)
>
>
> --
> Joost Kremers joostkremers@fastmail.fm
> Selbst in die Unterwelt dringt durch Spalten Licht
> EN:SiS(9)
^ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).