From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alp Aker Newsgroups: gmane.emacs.help Subject: Re: Word count in Emacs Date: Fri, 14 Sep 2012 15:28:55 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1347650997 4276 80.91.229.3 (14 Sep 2012 19:29:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Sep 2012 19:29:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "B. T. Raven" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 14 21:30:01 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 1TCbaT-0000BS-BI for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Sep 2012 21:30:01 +0200 Original-Received: from localhost ([::1]:46675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCbaP-0000hc-A5 for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Sep 2012 15:29:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCbZd-0000ZK-St for help-gnu-emacs@gnu.org; Fri, 14 Sep 2012 15:29:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCbZQ-0002CR-Gp for help-gnu-emacs@gnu.org; Fri, 14 Sep 2012 15:29:09 -0400 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:37547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCbZQ-0002By-96 for help-gnu-emacs@gnu.org; Fri, 14 Sep 2012 15:28:56 -0400 Original-Received: by iagk10 with SMTP id k10so3820274iag.0 for ; Fri, 14 Sep 2012 12:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=APc0/xJa632Ea5QMPF250zm6mbxrouLSBavwEdHaxzo=; b=JZmuFE4DtTCvliQZRkmBMhdPrH1n3yw6vTYpPgYl+pju0tl877hL5RhHoFphHRE8uN mntHJJ8hzCjyyP4QafwGKwgMcV6OA3rjjX+rO0ZQmt2AAkgiMqk5Tw1dDGXwQcOnxMoO GEpoD+VtEGKr9tjLbziv2h38rMs7Uh/KP2DIk/zuoiFHGPlnQ88wEsowAdf1QInwyn6N OrU3/NrTHoieAL7CkNdNDrocYBceOMhjK/OEP8UPKqCUFc24uNp0dYbQQWANhlbNNIPD WUUj09/Zd1HojBvnc6hazxCkHR/s+X7IrZvK7SgvLOu2qYxK5/LV1C2evEOBaijTCsup k20A== Original-Received: by 10.50.170.98 with SMTP id al2mr29743165igc.47.1347650935229; Fri, 14 Sep 2012 12:28:55 -0700 (PDT) Original-Received: by 10.64.106.199 with HTTP; Fri, 14 Sep 2012 12:28:55 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.169 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:86777 Archived-At: > 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+"))))))