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: Sat, 27 Oct 2007 14:20:16 +0900 Message-ID: <87bqal2kxb.fsf@uwakimon.sk.tsukuba.ac.jp> References: <200710191149.59775.andreas.roehler@online.de> <87hckeigev.fsf@uwakimon.sk.tsukuba.ac.jp> <200710261017.33513.andreas.roehler@online.de> <877ilai63w.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 1193462385 14761 80.91.229.12 (27 Oct 2007 05:19:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2007 05:19:45 +0000 (UTC) Cc: reinersteib+gmane@imap.cc, andreas.roehler@online.de, emacs-devel@gnu.org, juri@jurta.org, 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 Sat Oct 27 07:19:44 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 1Ile5F-0002iL-Cl for ged-emacs-devel@m.gmane.org; Sat, 27 Oct 2007 07:19:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ile56-0003qr-CC for ged-emacs-devel@m.gmane.org; Sat, 27 Oct 2007 01:19:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ile51-0003nd-RX for emacs-devel@gnu.org; Sat, 27 Oct 2007 01:19:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ile4z-0003iv-5z for emacs-devel@gnu.org; Sat, 27 Oct 2007 01:19:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ile4z-0003iT-0D for emacs-devel@gnu.org; Sat, 27 Oct 2007 01:19:25 -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 1Ile4r-00006P-2L; Sat, 27 Oct 2007 01:19:17 -0400 Original-Received: from uwakimon.sk.tsukuba.ac.jp (unknown [130.158.99.156]) by mtps01.sk.tsukuba.ac.jp (Postfix) with ESMTP id A4AD61535A8; Sat, 27 Oct 2007 14:19:15 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id C21291A2E12; Sat, 27 Oct 2007 14:20:17 +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:81828 Archived-At: Richard Stallman writes: > > If there is no extension, just the mark set, > > `zmacs-region-extent' is nil and `region-active-p' > > returns nil therefor. > > Right. However, if zmacs-region-extent is non-nil, it is possible > that (region-beginning) equals (region-end), in which case there is > (usually) no point in operating on the region. It is that check that > Richard is asking about AFAICS. > > That really puzzles me. `region-active-p' does not check that the region has non-zero length. My point is that whether it makes sense to operate on a region of length zero depends on the operation, so `region-active-p' doesn't try to decide. Note that Andreas and I are talking at cross-purposes to some extent, because his usage of "extent", although impeccable as English, differs from XEmacs terminology where it denotes a specific type of Lisp_Object, approximately an Emacs overlay. This confused me, and I'm probably not responding to him in a way that's useful to him or you. > It seems to say that in the following XEmacs code > > (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))) > > with an active but empty region, region-active-p sometimes returns t > and sometimes returns nil. (This is because zmacs-region-extent might > be nil, or might be t and empty.) > > Do I understand correctly? No, if the region is active but empty (by which I mean having zero length), `region-active-p' will return non-nil and `fill-region' will be called. An active region exists if and only if `zmacs-region-extent' contains an extent object. Code that activates the region does so by setting `zmacs-region-extent' to an extent whose endpoints are point and mark, and whose face property is 'zmacs-region. Deactivation is done by setting `zmacs-region-extent' to nil.