From: ken <gebser@mousecar.com>
To: PJ Weisberg <pjweisberg@gmail.com>
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: function evaluated, but cannot execute
Date: Tue, 26 Apr 2011 18:17:59 -0400 [thread overview]
Message-ID: <4DB74497.3010805@mousecar.com> (raw)
In-Reply-To: <BANLkTinTXC2yx2s7o4aB9-a0O+FUifmN3Q@mail.gmail.com>
On 04/26/2011 05:48 PM PJ Weisberg wrote:
> On Tuesday, April 26, 2011, ken <gebser@mousecar.com> wrote:
>> Testing little function to learn from...
>>
>> (defun my-prepend-to-file ()
>> "Prepend some hard-coded text to specified file."
>> (let ((oldbuf (current-buffer)))
>> (save-current-buffer
>> (set-buffer (get-buffer-create "/home/zl/tmp/test.html"))
>> (insert "\n\nText inserted by my-prepend-to-file.\n\n"))))
>>
>> I evaluate this function. No problem.
>>
>> I do "C-h f my-prepend-to-file RET", emacs displays in the other window:
>>
>> my-prepend-to-file is a Lisp function.
>>
>> (my-prepend-to-file)
>>
>> Prepend some hard-coded text to specified file.
>>
>> [back]
>>
>> But when I do "M-x my-prepend-to-file RET", emacs responds "[No match]".
>> So what's wrong?
>>
>>
>> tia,
>> ken
>
> Right after the docstring, put (interactive). (If the function took
> arguments you would have to put more stuff inside the 'interactive'
> form, but that's enough to be able to call it from M-x or with a
> keybinding.
>
> And you want 'find-file' or 'find-file-noselect' instead of 'get-buffer-create'.
>
Thanks for the tip. Yeah, for some reason get-buffer-create fails, does
nothing. Replacing it with find-file or *-select works fine. Strange
because I scarfed the code from an emacs Info page and the *Help* page
says get-buffer-create will accept a file as an arg. I'll just say,
"That's perplexing."
thanks++,
ken
--
Anything is easy if you know how to do it.
prev parent reply other threads:[~2011-04-26 22:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-26 21:25 function evaluated, but cannot execute ken
2011-04-26 21:35 ` Drew Adams
2011-04-26 21:48 ` PJ Weisberg
2011-04-26 22:17 ` ken [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DB74497.3010805@mousecar.com \
--to=gebser@mousecar.com \
--cc=help-gnu-emacs@gnu.org \
--cc=pjweisberg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.