From: Thomas Lord <lord@emf.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Chong Yidong <cyd@stupidchicken.com>,
Dan Nicolaescu <dann@ics.uci.edu>,
emacs-devel@gnu.org, "Kim F. Storm" <storm@cua.dk>
Subject: Re: Shift selection using interactive spec
Date: Sun, 16 Mar 2008 14:00:03 -0700 [thread overview]
Message-ID: <47DD8A53.8090902@emf.net> (raw)
In-Reply-To: <jwv63vmh62o.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 9661 bytes --]
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
> 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*."
> I have the strong impression that you do not know
> what is the "temporary" form of transient-mark-mode" (this is
> a transient-mark-mode that's activated until the region is "consumed")
>
You are right that I don't know about that. I poked around in simple.el
a little to see if I could find what you meant but I didn't. So, please
point
me to the code.
That aside, first you had to invent "motion" commands, and now there
is another category of commands that are "consuming" commands. Ugh.
This proliferation of categories is the price for using a binary "active"
flag rather than the three-variable system. How are those categories
supposed to compose, anyway? That is, if I call a "consuming" command
as a function, does that make my command also "consuming"? This seems
fragile and hard to control.
> and neither do you know about the "only" form of transient-mark-mode
> (that is a form of transient-mark-mode which is deactivated after the
> very next command).
>
>
You keep misunderstanding me. I understand (enough) about how transient
mark mode models "activation". What I'm saying in response to that design,
not in ignorance of it, is that "activation" is the wrong model and that
the
three-variable model is the model users are thinking of. And the three
variable
model seems to come out cleanly in code. And the three variable model
extends
and complements the traditional Emacs mark stack.
There's a funny bit in the Emacs documentation:
Novice Emacs Lisp programmers often try to use the mark for the wrong
purposes. The mark saves a location for the user's convenience.
Most editing commands should not alter the mark.
I'm not, by a long shot, calling you a novice. Really. But the
admonishment of that bit in the documentation applies to this
problem in a subtle way.
The marker (not mark but marker) which is set when a user is
shift-selecting: it does not, in GUIs, act like a "location [saved] for
the user's convenience". Yes, it's a saved location. Yes, it's a
convenience
feature. But commands don't actually *use* that marker in the same
way that they use traditional Emacs *marks*.
The boolean "active" flag is an attempt to turn the top of the
traditional mark stack into a discriminated union. When that flag is
set, the marker on the top of the mark stack is supposed to behave
"like the beginning of a shift-selected-region". But that's ugly and
complicated because it changes the model that commands are "used to"
about what the mark stack means. The mark stack is a saved location
for the user to pop back to -- except when it isn't because it's a saved
location for the very different behavior of a shift-selected region.
The three-variable model -- the concept of a "fat cursor" that is
sensitive to the cycle phases of interaction -- is exactly what all those
other GUI programs do and it is quite consonant with traditional Emacs.
It's a much simpler approach.
>> What users expect, in the traditional GUI paradigm, is a kind of
>> mark that doesn't toggle between "activated" and "deactivated" but,
>> rather, is always active when present but which commands tend to
>> cause to go away entirely. Let's dub that "the mistake". The
>> mistake is adding an "active" flag instead of a separate tentative
>> mark.
>>
>
> In what way is it different, really? The problem is how/when to
> activate/set it and how/when to deactivate/unset it. Whether it's
> a flag or a mark makes no difference.
>
>
It makes a difference in terms of the amount of existing code that
needs to be modified. In the three variable system, most existing
code can remain ignorant of the three variables -- TRT happens by
default.
>> It's *because* of the mistake that, for example, Stefan is now
>> positing the existence of a formal category of "motion commands"
>> that have to be modified to call a function that dynamically
>> asserts that they are motion commands.
>>
>
> ??? The notion of "motion commands" is needed because the behavior we
> want is "when a motion command is bound to a non-shifted key but is
> activated via the shifted of that key, we want the motion to select
> a region".
>
Better (more consistent, simpler) is: "when a command is bound to a
non-shifted
key but is invoked via a shifted sequence, we want the shift-select
region to
remain active during that command". There's no need to talk about
"motion".
> Try it in your typical GUI editor: S-arrow will select a region, but S-a
> will just insert an upper-case A.
>
That's different. S-A (at least conceptually) has a non-default
binding. It doesn't,
by default, "insert 'a' and be in shift-select mode".
Not many modes have "hyper" bindings. A good test for a design might
be how
easy it is for eccentric users to say "Ok, I want 'shift-select'
functionality but, in Emacs,
I'd prefer it via the hyper key, not the shift key". So, H-S-A would,
very reasonably,
insert an upper case 'A' and be in shift-select mode.
(I was thinking, personally, that I might use a foot pedal for
shift-select mode.)
> I.e. this need is 100% unrelated to the way the selected region is
> implemented and when/how it gets de-selected.
>
>
It's true that a traditional mark stack plus a binary variable can be used
to emulate the three-variable solution. However, that emulation requires
far broader and more conceptually dissonant changes than the three variable
solution.
-t
> Stefan
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 12825 bytes --]
next prev parent reply other threads:[~2008-03-16 21:00 UTC|newest]
Thread overview: 167+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-13 23:29 Shift selection using interactive spec Chong Yidong
2008-03-14 0:44 ` Thomas Lord
2008-03-14 0:10 ` David Kastrup
2008-03-14 1:22 ` Thomas Lord
2008-03-14 9:46 ` David Kastrup
2008-03-14 10:01 ` Johan Bockgård
2008-03-14 10:30 ` David Kastrup
2008-03-14 11:18 ` Thomas Lord
2008-03-14 11:11 ` Thomas Lord
2008-03-14 10:42 ` David Kastrup
2008-03-14 11:36 ` Thomas Lord
2008-03-14 11:50 ` Thomas Lord
2008-03-14 11:39 ` David Kastrup
2008-03-14 18:41 ` Thomas Lord
2008-03-14 4:06 ` Dan Nicolaescu
2008-03-14 14:26 ` Kim F. Storm
2008-03-14 14:32 ` Chong Yidong
2008-03-14 14:53 ` Kim F. Storm
2008-03-14 16:19 ` David Kastrup
2008-03-14 15:54 ` Stefan Monnier
2008-03-14 16:09 ` Drew Adams
2008-03-14 20:52 ` Chong Yidong
2008-03-14 20:59 ` David Kastrup
2008-03-14 21:08 ` Chong Yidong
2008-03-15 0:56 ` Stefan Monnier
2008-03-15 2:02 ` Chong Yidong
2008-03-15 3:31 ` Stefan Monnier
2008-03-15 14:07 ` Chong Yidong
2008-03-15 15:07 ` Stefan Monnier
2008-03-15 17:11 ` Chong Yidong
2008-03-15 20:52 ` Stefan Monnier
2008-03-15 21:45 ` Thomas Lord
2008-03-16 14:15 ` Chong Yidong
2008-03-16 14:37 ` Lennart Borgman (gmail)
2008-03-15 22:01 ` shift-select harmony Thomas Lord
2008-03-15 23:38 ` Thomas Lord
2008-03-15 17:16 ` Shift selection using interactive spec Kim F. Storm
2008-03-15 20:59 ` Thomas Lord
2008-03-16 23:31 ` Alan Mackenzie
2008-03-15 21:08 ` Thomas Lord
2008-03-16 0:27 ` Chong Yidong
2008-03-16 1:37 ` Thomas Lord
2008-03-16 9:09 ` Mathias Dahl
2008-03-16 14:21 ` Chong Yidong
2008-03-16 16:56 ` Thomas Lord
2008-03-16 16:34 ` Dear lazyweb (Re: Shift selection using interactive spec) Thomas Lord
2008-03-16 18:40 ` Shift selection using interactive spec Stefan Monnier
2008-03-16 21:00 ` Thomas Lord [this message]
2008-03-16 20:45 ` Thien-Thi Nguyen
2008-03-16 21:46 ` Thomas Lord
2008-03-16 21:24 ` Thien-Thi Nguyen
2008-03-16 22:27 ` Thomas Lord
2008-03-16 23:04 ` Lennart Borgman (gmail)
2008-03-16 23:17 ` Lennart Borgman (gmail)
2008-03-17 0:46 ` Thomas Lord
2008-03-17 0:21 ` Lennart Borgman (gmail)
2008-03-17 1:16 ` Thomas Lord
2008-03-16 23:35 ` Stephen J. Turnbull
2008-03-17 0:55 ` Thomas Lord
2008-03-17 2:23 ` Stefan Monnier
2008-03-17 3:12 ` Thomas Lord
2008-03-17 2:21 ` Stefan Monnier
2008-03-17 3:47 ` what's the point (re shift selection) Thomas Lord
2008-03-16 14:40 ` Shift selection using interactive spec Chong Yidong
2008-03-16 15:04 ` Lennart Borgman (gmail)
2008-03-16 17:13 ` Thomas Lord
2008-03-17 0:54 ` Chong Yidong
2008-03-17 2:40 ` Stefan Monnier
2008-03-17 3:24 ` Chong Yidong
2008-03-17 13:26 ` Stefan Monnier
2008-03-17 16:33 ` Chong Yidong
2008-03-17 17:21 ` Lennart Borgman (gmail)
2008-03-17 19:11 ` Stefan Monnier
2008-03-17 21:10 ` Chong Yidong
2008-03-17 21:44 ` Drew Adams
2008-03-18 11:40 ` Kim F. Storm
2008-03-18 14:16 ` Chong Yidong
2008-03-18 15:07 ` Kim F. Storm
2008-03-18 16:24 ` Stefan Monnier
2008-03-18 17:54 ` Drew Adams
2008-03-20 5:03 ` Chong Yidong
2008-03-23 1:39 ` Stefan Monnier
2008-03-17 22:24 ` martin rudalics
2008-03-17 22:37 ` Lennart Borgman (gmail)
2008-03-18 0:50 ` Thomas Lord
2008-03-18 7:48 ` martin rudalics
2008-03-18 17:46 ` Thomas Lord
2008-03-18 17:36 ` Lennart Borgman (gmail)
2008-03-18 19:07 ` Thomas Lord
2008-03-18 7:48 ` martin rudalics
2008-03-17 22:53 ` Chong Yidong
2008-03-18 3:12 ` Stefan Monnier
2008-03-18 7:49 ` martin rudalics
2008-03-18 16:36 ` Stefan Monnier
2008-03-18 16:44 ` Lennart Borgman (gmail)
2008-03-18 14:45 ` Chong Yidong
2008-03-18 16:39 ` Stefan Monnier
2008-03-18 18:28 ` Chong Yidong
2008-03-18 21:42 ` Stefan Monnier
2008-03-18 22:30 ` Kim F. Storm
2008-03-18 22:39 ` Lennart Borgman (gmail)
2008-03-19 4:40 ` M Jared Finder
2008-03-26 8:09 ` David Kastrup
2008-03-26 10:48 ` Juri Linkov
2008-03-26 11:32 ` David Kastrup
2008-03-26 11:39 ` Juri Linkov
2008-03-26 12:20 ` David Kastrup
2008-03-26 13:14 ` Johan Bockgård
2008-03-26 13:26 ` David Kastrup
2008-03-26 14:52 ` Stefan Monnier
2008-03-27 0:46 ` Juri Linkov
2008-03-26 12:02 ` Lennart Borgman (gmail)
2008-03-26 11:47 ` Lennart Borgman (gmail)
2008-03-26 22:26 ` Richard Stallman
2008-03-26 23:31 ` Lennart Borgman (gmail)
2008-03-27 7:02 ` David Kastrup
2008-03-27 8:19 ` Lennart Borgman (gmail)
2008-03-27 8:41 ` David Kastrup
2008-03-27 13:57 ` Lennart Borgman (gmail)
2008-03-27 14:39 ` David Kastrup
2008-03-27 15:01 ` Juanma Barranquero
2008-03-27 15:34 ` David Kastrup
2008-03-27 15:41 ` Juanma Barranquero
2008-03-27 15:13 ` Johan Bockgård
2008-03-27 19:41 ` Richard Stallman
2008-03-27 23:52 ` Juri Linkov
2008-03-28 7:33 ` David Kastrup
2008-03-29 0:47 ` Juri Linkov
2008-03-29 7:03 ` David Kastrup
2008-03-29 11:53 ` Lennart Borgman (gmail)
2008-03-29 12:30 ` Juri Linkov
2008-03-29 14:07 ` David Kastrup
2008-03-29 14:45 ` Lennart Borgman (gmail)
2008-03-29 15:09 ` David Kastrup
2008-03-29 15:30 ` Lennart Borgman (gmail)
2008-03-30 0:52 ` Juri Linkov
2008-03-30 17:56 ` David Kastrup
2008-03-30 5:49 ` Richard Stallman
2008-03-28 4:05 ` M Jared Finder
2008-03-28 11:10 ` David Kastrup
2008-03-28 17:14 ` Lennart Borgman (gmail)
2008-03-28 20:05 ` David Kastrup
2008-03-28 23:49 ` Lennart Borgman (gmail)
2008-03-28 20:42 ` Richard Stallman
2008-03-28 21:47 ` Chong Yidong
2008-03-28 22:01 ` David Kastrup
2008-03-30 0:48 ` Juri Linkov
2008-03-30 17:55 ` David Kastrup
2008-03-30 18:55 ` Juri Linkov
2008-03-27 0:49 ` Juri Linkov
2008-03-27 2:59 ` Chong Yidong
2008-03-27 19:41 ` Richard Stallman
2008-03-27 23:48 ` Juri Linkov
2008-03-28 20:41 ` Richard Stallman
2008-03-29 0:54 ` Juri Linkov
2008-03-29 1:15 ` Lennart Borgman (gmail)
2008-03-29 16:37 ` Richard Stallman
2008-03-30 1:05 ` Juri Linkov
2008-03-30 4:12 ` Stefan Monnier
2008-03-30 18:33 ` Juri Linkov
2008-03-31 16:24 ` Richard Stallman
2008-03-30 19:56 ` Richard Stallman
2008-03-30 22:46 ` Juri Linkov
2008-03-26 22:26 ` Richard Stallman
2008-03-18 17:45 ` Thomas Lord
2008-03-16 2:33 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2008-03-16 12:58 Robert J. Chassell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47DD8A53.8090902@emf.net \
--to=lord@emf.net \
--cc=cyd@stupidchicken.com \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=storm@cua.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.