From: PJ Weisberg <pjweisberg@gmail.com>
To: "gebser@mousecar.com" <gebser@mousecar.com>
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: function evaluated, but cannot execute
Date: Tue, 26 Apr 2011 14:48:39 -0700 [thread overview]
Message-ID: <BANLkTinTXC2yx2s7o4aB9-a0O+FUifmN3Q@mail.gmail.com> (raw)
In-Reply-To: <4DB7385B.9040707@mousecar.com>
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'.
--
-PJ
next prev parent reply other threads:[~2011-04-26 21:48 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 [this message]
2011-04-26 22:17 ` ken
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=BANLkTinTXC2yx2s7o4aB9-a0O+FUifmN3Q@mail.gmail.com \
--to=pjweisberg@gmail.com \
--cc=gebser@mousecar.com \
--cc=help-gnu-emacs@gnu.org \
/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.