From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: robert.thorpe@antenova.com (Rob Thorpe) Newsgroups: gmane.emacs.help Subject: Re: what is the point of point-min? Date: 29 Aug 2003 05:44:00 -0700 Organization: http://groups.google.com/ Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <1a61f7e5.0308290444.10893c35@posting.google.com> References: <3F4E2B31.5070904@yahoo.com> NNTP-Posting-Host: deer.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1062164452 9879 80.91.224.253 (29 Aug 2003 13:40:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 29 Aug 2003 13:40:52 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 29 15:40:50 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19sjUg-0002Is-00 for ; Fri, 29 Aug 2003 15:40:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19sjT9-0006xb-8m for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Aug 2003 09:39:15 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 95 Original-NNTP-Posting-Host: 212.135.40.163 Original-X-Trace: posting.google.com 1062161041 24549 127.0.0.1 (29 Aug 2003 12:44:01 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: 29 Aug 2003 12:44:01 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:116250 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:12168 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12168 Jesper Harder wrote in message news:... > Barry Margolin writes: > > > Jesper Harder wrote: > > > >>Is this the way they work: > >> > >>(defun region-beginning () > >> (min (point) (mark))) > >> > >>(defun region-end () > >> (max (point) (mark))) > > > > Use the Source, Luke. > > If they were Lisp functions I would have just read the source. But > > * I hate reading C. > > * It's much more cumbersome to find the function definition for > built-in functions, i.e. there's no handy hyperlink to the source > when doing `C-h f' like there is for Lisp functions. > > >>or are there other instances where `region-beginning' is different > >>from `point'? > > > > Even if there aren't now, you should allow for the possibility in the > > future. > > Yes, in newly written code. But it might not be worthwhile to change > stable (currently feature-freezed) code with the possibility of > introducing bugs if there's no difference between (region-end) and > (max (point) (mark)). I don't know what this moaning about reading emacs source is about, its not easy, but its not exactly brain surgery. The behaviour of region-beginning is subtly different from point. Firstly as previous posters have mentioned it will swap the two around to put them in the right order. Secondly it will obey the value of the variable transient-mark-mode, if it is set to non-nil then the mark will deactivate when the buffer contents change. Given the function you have posted: (global-set-key [delete] (lambda () (interactive) (if mark-active (kill-region (point) (mark)) (delete-char 1)))) This version in transient mark mode will delete the region even though in this mode it is not thought of as existing after a character is inserted into the buffer. >>From editfns.c:- /* Return the start or end position of the region. BEGINNINGP non-zero means return the start. If there is no region active, signal an error. */ static Lisp_Object region_limit (beginningp) int beginningp; { extern Lisp_Object Vmark_even_if_inactive; /* Defined in callint.c. */ Lisp_Object m; if (!NILP (Vtransient_mark_mode) && NILP (Vmark_even_if_inactive) && NILP (current_buffer->mark_active)) Fsignal (Qmark_inactive, Qnil); m = Fmarker_position (current_buffer->mark); if (NILP (m)) error ("There is no region now"); if ((PT < XFASTINT (m)) == beginningp) m = make_number (PT); return m; } DEFUN ("region-beginning", Fregion_beginning, Sregion_beginning, 0, 0, 0, "Return position of beginning of region, as an integer.") () { return region_limit (1); } DEFUN ("region-end", Fregion_end, Sregion_end, 0, 0, 0, "Return position of end of region, as an integer.") () { return region_limit (0); }