help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Word count in Emacs


From: B. T. Raven
Subject: Re: Word count in Emacs
Date: Sat, 15 Sep 2012 18:11:11 -0500
User-agent: Mozilla/5.0 (Windows NT 5.0; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]