From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: Shift selection using interactive spec Date: Mon, 17 Mar 2008 00:04:58 +0100 Message-ID: <47DDA79A.6010706@gmail.com> References: <87k5k69p92.fsf@stupidchicken.com> <200803140408.m2E47hPU014494@sallyv1.ics.uci.edu> <87prtxpekk.fsf@kfs-lx.rd.rdm> <87abl11ilo.fsf@stupidchicken.com> <874pb9koyw.fsf@stupidchicken.com> <87od9gzqv9.fsf@stupidchicken.com> <87bq5gytbi.fsf@stupidchicken.com> <8763vndi0r.fsf@kfs-lx.rd.rdm> <47DC3AB2.9070502@emf.net> <87ejabv7gg.fsf@stupidchicken.com> <47DC79DE.1000201@emf.net> <47DD8A53.8090902@emf.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1205708743 21900 80.91.229.12 (16 Mar 2008 23:05:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Mar 2008 23:05:43 +0000 (UTC) Cc: Chong Yidong , Dan Nicolaescu , Stefan Monnier , "Kim F. Storm" , emacs-devel@gnu.org To: Thomas Lord Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 17 00:06:11 2008 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 1Jb1vQ-0004WB-1e for ged-emacs-devel@m.gmane.org; Mon, 17 Mar 2008 00:05:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jb1uq-0006AF-C4 for ged-emacs-devel@m.gmane.org; Sun, 16 Mar 2008 19:05:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jb1um-000694-18 for emacs-devel@gnu.org; Sun, 16 Mar 2008 19:05:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jb1uk-00068N-UG for emacs-devel@gnu.org; Sun, 16 Mar 2008 19:05:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jb1uk-00068G-R0 for emacs-devel@gnu.org; Sun, 16 Mar 2008 19:05:14 -0400 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jb1uj-0003jG-WA for emacs-devel@gnu.org; Sun, 16 Mar 2008 19:05:14 -0400 Original-Received: from c83-254-148-228.bredband.comhem.se ([83.254.148.228]:61053 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1Jb1ud-0002PC-4X; Mon, 17 Mar 2008 00:05:08 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 In-Reply-To: <47DD8A53.8090902@emf.net> X-Antivirus: avast! (VPS 080316-0, 2008-03-16), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.148.228 X-ACL-Warn: Too high rate of unknown addresses received from you X-Scan-Result: No virus found in message 1Jb1ud-0002PC-4X. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1Jb1ud-0002PC-4X d3eac5aec1583734a904e6eb42f62122 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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:92781 Archived-At: Thomas Lord wrote: > Stefan Monnier wrote: >> I do not follow you, Tom: how would the right arrow magically forget >> your tentative mark? > > > There are three, per-buffer variables: > > tentative-mark: > the "other side" (besides the point) of the current, > shift-selected region, as far as primitive operations > on buffers are concerned. The tenative-mark, if not > nil, combines with the point to create a "fat cursor" -- > e.g., primitive insertion operations delete the contents > of the fat cursor before inserting. > > maybe-preserved-tentative-mark: > The value of tentative-mark as last observed by the > user. That is, before every interactive command > invocation, the value of tentative-mark is unconditionally > copied to become the value of maybe-preserved-.... > > preserved-tentative-mark: > The value that, in the opinion of the currently running > command, should become the value of transient-mark > after the command completes. By default, this is nil. > Command loops, when interactively invoked commands > return, unconditionally copy the value of perserved-tentative-mark > to tentative-mark. > > So, suppose I type S-right-arrow, invoking shift-select mode. > That invokes a generic function -- let's dub it treat-as-shifted-sequence. > That function creates a marker at the point and sets > preserved-tentative-mark > to that new marker. Then it looks up what the unshifted sequence > right-arrow > is bound to and runs that command. That command (forward-char) is > ignorant of the three variables so it doesn't change them at all. When > control returns to the command loop, the value of preserved-tentative-mark > is copied to tentative-mark -- so now there is a tentative-mark (start of a > shift-mark region) set. > > Typing S-right-arrow again has almost the same effect. Instead of > creating a new marker, the generic function treat-as-shifted-sequence > notices that, this time, maybe-preserved-tentative-mark is non-nil. > Rather than create a new mark, it just copies that value to preserved-.... > So, the tentative mark (start of shift region) is preserved. > > But then you type just right-arrow, with no shift. When invoked, > tentative-mark and maybe-preserved-.... are still both set to that > original mark, but preserved-tentative-mark has its default value of > nil. The right arrow binding (forward char) is still ignorant of those > three variables. It changes nothing. When control returns to the > command loop, preserved-... (which is bound to nil) is copied to > tentative-mark I translate it to something like this in elisp code: ;;;; pre-pre ;; treat-as-shifted: (setq maybe-preserved-tm tm) (if shifted (setq preserved-tm (if tm tm (make-marker))) (setq preserved-tm nil)) ;;;; run unshifted command + hooks ;; Neither maybe-preserved-tm or preserved-tm ;; are touched here (maybe not even known) ;;;; post-post ;; (if buffer-was-changed (setq preserved-tm nil) (unless preserved-tm (when user-wants-it (setq preserved-tm maybe-preserved-tm)))) (setq tm preserved-tm) >> In what way is that different from setting >> mark-active to nil? > > There are two aspects to the answer: cleanliness and > semantics. > > Cleanliness: the three variable proposal needs a *tiny bit* > of new code in the C part of Emacs. In exchange, it > doesn't need transitive-mark or delete-mark... elisp code > at all (because the default behaviors are better). > > Cleanliness again: In the three variable system, most > commands DTRT by default, even if they remain ignorant > of the three variables. > > Semantics: the three variable model is sensitive to > "cycle phases" in user interaction. maybe-perserved-... > is a reliable source of the value of the tentative mark as > of the time the user last saw it. preserved-.... is > how function control what the value of the tentative > mark will be when the user next sees it. tentative-mark > itself is the value honored by primitives. Making > those distinctions has a side effect: the default behaviors > comes out correctly, for free, and the non-default > behaviors are trivial to implement in generic ways. > In contrast, just having a binary distinction between > an active and inactive mark means having to make those > other distinctions harder to implement -- lots of functions > have to be modified because that's the only way left > to make those distinctions. It's *why* you're ending up > thinking about distinguishing "motion commands" and > the like. Maybe the simple form is just: "I dunno. > The three-variable implementation is just cleaner. > It happens to hit a sweet spot that way. It just *is*."