From: "B. T. Raven" <btraven@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Word count in Emacs
Date: Sat, 15 Sep 2012 18:11:11 -0500 [thread overview]
Message-ID: <k331vq0ojl@news6.newsguy.com> (raw)
In-Reply-To: <mailman.8893.1347650994.855.help-gnu-emacs@gnu.org>
Die Fri Sep 14 2012 14:28:55 GMT-0500 (Central Daylight Time) Alp Aker
<alptekin.aker@gmail.com> scripsit:
>> Can anyone give me a clue why the following doesn't print a number in
>> the mini-buffer or to the *Messages* buffer?:
>>
>> (defun count-words (start end) ;; alias wce
>> "Print number of words in the region."
>> (interactive "r")
>> (save-excursion
>> (save-restriction
>> (narrow-to-region start end)
>> (goto-char (point-min))
>> (count-matches "\\sw+"))))
>
> As you've defined it, the function returns a number, but it's not the
> case that the return value of an interactive command is automatically
> echoed in the mini-buffer. Compare:
>
> (defun count-words (start end) ;; alias wce
> "Print number of words in the region."
> (interactive "r")
> (save-excursion
> (save-restriction
> (narrow-to-region start end)
> (goto-char (point-min))
> (message (number-to-string (count-matches "\\sw+"))))))
>
Thanks, Alp. That did it.
Ed
next prev parent reply other threads:[~2012-09-15 23:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 17:55 Word count in Emacs B. T. Raven
2012-09-14 18:14 ` Jambunathan K
2012-09-14 19:28 ` Alp Aker
[not found] ` <mailman.8893.1347650994.855.help-gnu-emacs@gnu.org>
2012-09-15 23:11 ` B. T. Raven [this message]
[not found] ` <mailman.8880.1347646427.855.help-gnu-emacs@gnu.org>
2012-09-15 23:23 ` B. T. Raven
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=k331vq0ojl@news6.newsguy.com \
--to=btraven@nihilo.net \
--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.