From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: Word count in Emacs Date: Sat, 15 Sep 2012 18:11:11 -0500 Organization: NewsGuy - Unlimited Usenet $19.95 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347750917 11871 80.91.229.3 (15 Sep 2012 23:15:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Sep 2012 23:15:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 16 01:15:21 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TD1a1-0003p8-JX for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Sep 2012 01:15:17 +0200 Original-Received: from localhost ([::1]:34969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TD1Zx-0005lW-8A for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Sep 2012 19:15:13 -0400 Original-Path: usenet.stanford.edu!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!news6 Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: p73862f50a456303a30105790cfad722a18b43eefc445d9d8.newsdawg.com User-Agent: Mozilla/5.0 (Windows NT 5.0; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: X-Received-Bytes: 1857 Original-Xref: usenet.stanford.edu gnu.emacs.help:194460 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86801 Archived-At: Die Fri Sep 14 2012 14:28:55 GMT-0500 (Central Daylight Time) Alp Aker 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