From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: Re: region-active-p Date: Fri, 26 Oct 2007 14:38:48 +0900 Message-ID: <87hckeigev.fsf@uwakimon.sk.tsukuba.ac.jp> References: <200710191149.59775.andreas.roehler@online.de> <87lk9wseuf.fsf@catnip.gol.com> <200710212122.57935.andreas.roehler@online.de> <87sl4071ef.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193377106 13095 80.91.229.12 (26 Oct 2007 05:38:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Oct 2007 05:38:26 +0000 (UTC) Cc: juri@jurta.org, emacs-devel@gnu.org, andreas.roehler@online.de, monnier@iro.umontreal.ca, miles@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 26 07:38:26 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IlHtq-0003pj-1V for ged-emacs-devel@m.gmane.org; Fri, 26 Oct 2007 07:38:26 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlHth-00007I-Ck for ged-emacs-devel@m.gmane.org; Fri, 26 Oct 2007 01:38:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IlHtc-0008UZ-Er for emacs-devel@gnu.org; Fri, 26 Oct 2007 01:38:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IlHtZ-0008Na-7H for emacs-devel@gnu.org; Fri, 26 Oct 2007 01:38:11 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlHtZ-0008NL-0N for emacs-devel@gnu.org; Fri, 26 Oct 2007 01:38:09 -0400 Original-Received: from mtps01.sk.tsukuba.ac.jp ([130.158.97.223]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IlHtJ-0008Ie-RD; Fri, 26 Oct 2007 01:37:54 -0400 Original-Received: from uwakimon.sk.tsukuba.ac.jp (unknown [130.158.99.156]) by mtps01.sk.tsukuba.ac.jp (Postfix) with ESMTP id BE2691535B3; Fri, 26 Oct 2007 14:37:49 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id 0A6B41A2E12; Fri, 26 Oct 2007 14:38:49 +0900 (JST) In-Reply-To: X-Mailer: VM 7.17 under 21.5 (beta28) "fuki" (+CVS-20070621) XEmacs Lucid X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81748 Archived-At: Richard Stallman writes: > > When commands in XEmacs call [region-active-p], do they also test > > for a nonempty region? Or do they operate on the region > > when it is empty? > > Core commands defined in Lisp don't test (at least not within 3 lines, > checked with grep -3), but they're generally wrappers for functions > defined in C that do test (eg, the casefilling commands). > > I don't entirely understand the answer. Maybe I did not state the > question clearly. When you say they "don't test", what precisely > don't they test? They don't test "for a nonempty region". > Are you sayimg that they call `region-active-p' but do not test > whether the region is nonempty? Yes. Specifically, the function that calls `region-active-p' does not. However, in the cases I looked at, that function simply dispatches to a more primitive function that acts on the region. The more primitive function checks for non-empty in those cases. The typical idiom is (defun fill-paragraph-or-region (arg) "Fill the current region, if it's active; otherwise, fill the paragraph. See `fill-paragraph' and `fill-region' for more information." (interactive "*P") (if (region-active-p) (call-interactively 'fill-region) (call-interactively 'fill-paragraph))) `fill-region' *does* check that the region is nonempty before doing any work.