From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: hw Newsgroups: gmane.emacs.devel Subject: Re: delete-selection-mode as default Date: Tue, 18 Sep 2018 00:11:05 +0200 Organization: my virtual residence Message-ID: <87musg0wyf.fsf@toy.adminart.net> References: <83k1nxvm5j.fsf@gnu.org> <87sh2ih0bp.fsf@fastmail.fm> <770f48a8-664a-40ae-8e03-19f6aad248b6@default> <20180910181615.GA4829@ACM> <874lev3bq4.fsf@toy.adminart.net> <20180912131602.GA5582@ACM> <87d0tihxzw.fsf@toy.adminart.net> <20180913174640.GB4019@ACM> <8736udkuit.fsf@toy.adminart.net> <20180914104833.GA4103@ACM> <83k1nojgia.fsf@gnu.org> <874leq799e.fsf@toy.adminart.net> <835zz5ie17.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1537222364 15979 195.159.176.226 (17 Sep 2018 22:12:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Sep 2018 22:12:44 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: spacibba@aol.com, joostkremers@fastmail.fm, npostavs@gmail.com, emacs-devel@gnu.org, yurivkhan@gmail.com, acm@muc.de, drew.adams@oracle.com, phillip.lord@russet.org.uk To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 18 00:12:39 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g21l0-00040l-9h for ged-emacs-devel@m.gmane.org; Tue, 18 Sep 2018 00:12:38 +0200 Original-Received: from localhost ([::1]:37553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g21n4-00005l-Ct for ged-emacs-devel@m.gmane.org; Mon, 17 Sep 2018 18:14:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g21lm-0008JM-Hz for emacs-devel@gnu.org; Mon, 17 Sep 2018 18:13:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g21lk-0003U3-AX for emacs-devel@gnu.org; Mon, 17 Sep 2018 18:13:26 -0400 Original-Received: from mo6-p02-ob.smtp.rzone.de ([2a01:238:20a:202:5302::6]:31501) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g21lj-0003SQ-Vd; Mon, 17 Sep 2018 18:13:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1537222402; s=strato-dkim-0002; d=adminart.net; h=References:Message-ID:Date:In-Reply-To:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=gjmmpkgj/P9FazR78umtxJ3ev1j3LFoj9WpeGbB3Usw=; b=AV+ffc17HzJLvMOgKKYNGSUfGDWwwPNn+Opq9Qrt/Tt0q1kG/iFa/dSGC2x/LkeE+G iqysVxkXFS+TS80X0a7QPKKw5eU1fJOUul6Yg3O/1OyQPMxLCz9/SfZo+uSOrdpfXja3 94Tw7bSB0caGb8r2gBqxORxeAE8FOIeewOfawbxkHlDos9AdiXp1BjZEH5Idl2UPKKig THeqfAXCF4U8NtrBHhjk9T60k0yNMpUCYMJU4eLefexHE9jB6se7vt/jqmr6b2mG3Anx csUMirg0WuFtEn5QVEZGQqc86yWUzJz6eu9BGdpQWBBv7CwmNXvXPDFFvk8zuCpEUue1 F71g== X-RZG-AUTH: ":O2kGeEG7b/pS1FS4THaxjVF9w0vVgfQ9xGcjwO5WMRo5c+h5ceMqQWZ3yrBp+AVdIIwXjneEe9k=" X-RZG-CLASS-ID: mo00 Original-Received: from himinbjorg.adminart.net by smtp.strato.de (RZmta 44.1 DYNA|AUTH) with ESMTPSA id 20bdb7u8HMDFAxo (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Tue, 18 Sep 2018 00:13:15 +0200 (CEST) Original-Received: from toy.adminart.net ([192.168.3.55]) by himinbjorg.adminart.net with esmtp (Exim 4.90_1) (envelope-from ) id 1g21la-0000XM-UV; Tue, 18 Sep 2018 00:13:14 +0200 In-Reply-To: <835zz5ie17.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 16 Sep 2018 19:48:52 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5302::6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:229906 Archived-At: Eli Zaretskii writes: >> From: hw >> Cc: Yuri Khan , spacibba@aol.com, >> joostkremers@fastmail.fm, npostavs@gmail.com, emacs-devel@gnu.org, >> acm@muc.de, drew.adams@oracle.com, phillip.lord@russet.org.uk >> Date: Sun, 16 Sep 2018 00:37:43 +0200 >>=20 >> Eli Zaretskii writes: >>=20 >> > [...] >> > The region is currently used for 3 purposes: navigation, invoking >> > commands on a region of text, and delete-selection-mode. >>=20 >> You don't need a region for commands to work on, a selection is enough. >>=20 >> That would allow to decouple navigation from (making) selections, and >> the concept of a region becomes obsolete, removing all the entanglement >> and greatly simplifying things. > > You forget the kill-ring and the kill/yank commands. Those are almost > exactly identical to what other apps give you with copy/paste, and the > latter use selections. So the reasons Emacs implements selections > using the region are more fundamental than just navigation. What are these fundamental reasons? Other programs, like joe, allow you to use the selection for navigation without having a region. >> > (If someone thinks that delete-selection-mode is a variant of >> > "invoking commands on a region of text", they are mistaken, and this >> > long discussion is one proof of that mistake.) >>=20 >> That's why I said it's misguided in that it is an entirely different >> idea. > > It's a very similar idea, see below. > >> > It should be clear from this discussion that there are fundamental >> > tensions between these 3 purposes. The first two can be reconciled by >> > using the "active" vs "inactive" region, something we already have. >> > This distinction is needed because an Emacs buffer will almost always >> > have a region, and therefore users need some knob to control whether a >> > command should act on the region or on the entire buffer. (It is >> > possible that we need some new command to "activate" the region, >> > because the current method are IMO unsatisfactory: they require >> > navigation, which is totally gratuitous.) >>=20 >> Just use a selection for commands to work on? There's no need to >> particularly activate a selected part of a buffer; it's kinda what a >> selection is for. A region is not needed here, either. > > Once again: in Emacs, selection _is_ the region, and for some very > good reasons. Not to me. The selection is what becomes highlighted when I make one. > You can, of course, start inventing an Emacs that is based on > selections. But if that Emacs will still support copy/paste inside > Emacs and vis-a-vis other apps, if it will support commands that > operate on the selected text and/or work different when some text is > selected -- then what you will have at the end is the same Emacs, just > one where the region is called "selection". OK, maybe you will lose > the ability to do "C-x C-x" for navigation -- but to what purpose? I never use that, why would I? > It should be possible to introduce a separate feature of "selection", > similar to what we already do with secondary-selection. But if you > want commands and features to be sensitive to such a selection, you > will have to write a lot of code and change a lot of commands. You > are, of course, welcome to work on that, but my idea was to try a much > simpler solution, one that doesn't need any significant changes in the > infrastructure or the implementation of the relevant commands. Do you mean the one that solves some problems with delete-selection-mode by "arming" the region instead of activating it? I'd rather call it "disarming" because disarming before killing makes more sense than arming before killing :) IIUC, your idea is to *generally* either "activate" a region or to "disarm" it, depending on which behaviour a user wants. I'm not sure how this is different from delete-selection-mode, and I think it needs more variations: By setting mark-even-if-inactive to nil, I have "fortified" the region because nothing can be done with it unless it is "active". There are more variations, like disabling shift-selection and disabling making a selection with the trackball. That might make the region "protected". When it's also fortified, it would be "inert", unless it has been disarmed, in which case it would be "content". We'd have to find more funny names to designate all possible combinations of the fundamental variations. That would be the chance to throw out "active" and to replace it with "limiting". Then we could also have "highlightable", but that kinda throws out the concept of "the region" because we do not want the region to be highlighted all the time. Perhaps it could still be highlighted from starting to make the selection until something has been done with it when "highlightable" is desired. I would also want "marked", meaning that the mark is displayed. I like the idea because having a domain of fundamental region states that can be combined with each other can lead to more consistency, and the whole domain could be explained to users so they can get the behaviour they prefer by picking any combination of states. Currently, all the modes and options involved appear to be unrelated, and users may never find what suits them best because they don't know all the available options. Bringing them together in one domain would change that. > If you do NOT entertain the possibility of introducing such a new kind > of "selections", then it is IMO best to remember that in Emacs > "selection" and 'region" are synonyms. By using these terms as if > they were 2 different features you are just confusing this discussion. They actually *are* two different things for me. The selection is what I make to work with and what becomes highlighted. The region is something unwanted always lurking in the background waiting for me to make a mistake and making me feel uneasy. The problem is that Emacs is unable to make this important distinction. I could say that this confuses things. However, with mark-even-if-inactive set to nil, this lurking daemon has kinda been banished because it can only lurk and not do anything. >> > Instead of trying to reconcile them with some trick, we should >> > consider introducing a new "state" of the region, >>=20 >> You mean like a selection? :) Those do not require regions. > > Region and selection is the same thing in Emacs. That's the problem ... >> Since a region is obsolete, we could simply use C-spc to start making a >> selection and another C-spc to finish it. > > How is that different from typing C-SPC to start a region? it isn't. It is different because the end of the region is also being marked and becomes independent from point. Using the same key binding is only intended to make it easy. >> > or could be optionally activated by "C-x C-x" etc., given some >> > optional setting. >>=20 >> That is for navigation. > > No, it's also for "activating" the region (a.k.a. "selection"), which > causes some commands to "sense" the selected text. Navigating a buffer and making selections are two totally unrelated things. It doesn't make sense that the region be "navigating" (especially when it is not "active"). I might understand limiting navigation to the active region when transient-mark-mode is enabled --- but this doesn't come up because unfortunately, point can not be disentangled from the region. Besides, if a region was large enough that I would want to navigate it, I probably wouldn't want it highlighted. That would require "fortified" to be independent of "highlightable", which is currently not possible. >> A region is not needed for navigation between two points. You only need >> the two points, in this case, called mark and point. Just decouple them >> from selections. > > You can't: selection in Emacs is the region. That's the problem ... >> Users preferring d-s-m could enable the deletion option of selections. >> Then if they want to delete a selection, they can make one and overwrite >> it. This doesn't need to be complicated. > > You are missing the point. The point is that sometimes the user > doesn't want a selection to be replaced by a character she types, and > other times she does. The issue at hand is how to design a UI that > will allow both possibilities, without telling the users to turn on or > off delete-selection-mode for that purpose. Do you mean there is a big problem with delete-selection-mode when transient-mark-mode is disabled because then there is "maybe sometimes" a selection a user may want to replace by inserting characters? This problem wouldn't exist if the region could be disentangled from making selections. I'm not sure if it does exist because nobody would use d-s-m without t-m-m unless they wanted to do something that doesn't make sense. Other than that, Emacs would have to read the users` minds to figure out what they want with each character they insert. >> >> With transient-mark-mode being the Emacs default, I=E2=80=99m incline= d to >> >> consider it a bug that certain commands act on the inactive region >> >> when t-m-m is enabled, and possibly a flaw that (interactive "r") >> >> makes it so easy to define such commands. >> > >> > It's not a bug, it's a feature: commands that make no sense without >> > the region, like "upcase-region", should not need me to activate the >> > region for them to do what I expect them. >>=20 >> What when they implicitly and secretly activate something you wanted >> deactivated and do something you didn't expect? > > "Parse error". Sorry, I don't understand what you meant here. Upcase-region works without activating the region first though transient-mark-mode says that commands should be limited to the "active" region. So for upcase-region to work when no region is "active", it is as if the region is secretly activated so that upcase-region can work, and this may be unexpected. >> When a selection is required for a command that does something with a >> selection, the command can not work when there is no selection, and it >> is a bug when it does so nonetheless, like through Emacs assuming there >> was a selection when there actually is none (because Emacs lacks the >> ability to distinguish if something is selected or not because its >> insistence on obsolete regions gets in the way). > > This flies in the face of a long tradition in Emacs to provide DWIMish > operation, whereby if something makes a lot of sense in some > specialized situation, Emacs should do that automatically, even if it > deviates from the "normal" operation. A notable example is what C-t > does when point is at end of line. > > So if some effect of a command would make sense when it is invoked > without any "selection", we program Emacs to do that, and that is not > a bug at all, it's why Emacs shines in many situations where other > editors don't. That's a difficult thing because it creates inconsistencies. In this case, one problem is that the region is changing all the time through inserting characters (or files) and through navigation. That is actually always the problem, plus you can't even see the region and not even the mark. So MOTT, you have a region (which you call selection) that is entirely random, unlike a selection which has explicitly been made to contain what it is supposed to contain. You really can't call the region a selection. Nothing in particular has been selected, and things merely happen to have ended up the way they did and, because of technical limitations, a region is randomly formed. Now you have a mode the purpose of which is to limit commands to a region that has been made active. To make a region active, you have to select it, so you're actually making a selection. This mode is already inconsistent because it allows commands to do things with a region even when there is no active region, so these commands may do random things because the region is a random thing. You take that even further by having commands that imply doing something only with a region. Why would you expect a user who is working in a mode that limits commands doing things with a region to doing them with a selection to want to use commands implying they do something with a region? Why would you expect this user who wants to work with selections rather than with regions to want to work with regions instead? At least there needs to be a replacement for upcase-region and the like that work with the selection. In case of upcase-region, it could be called upcase. That would bring more consistency. BTW, upcase-dwim is flawed because it *extends* to the active region *if* the region contains more than one word. That contradicts transient-mark-mode and requires another state besides "limiting": "extending". However, upcase-dwim is also limited to the active region, so "limiting" together with "extending" can become a problem for region states because it becomes unclear again what exactly is desired. >> It's a clash between transient-mark-mode enabled and disabled. In one >> case, the behaviour is a bug because the mode suggests that commands >> doing something must not do it with regions but with selections (active >> regions); in the other, it's fine because there is always something for >> commands that do something with something to do what they do because >> there's always a region, and the second case implies that it is >> generally fine for software to make mistakes of the users worse rather >> than protecting them from them. >>=20 >> Actually, the second case is merely a slip-up, like driving your car >> into the wall at full throttle and no seat belts on, either just because >> you can, or unintentionally. For some reason, only with >> transient-mark-mode enabled, this becomes obvious because it has been >> overlooked at least for the unintentional variant. It probably was >> never wanted even without transient-mark-mode, i. e. the intentional >> variant. > > "Parse error". "One case"? "second case"? What is this about? The two cases are the different results of the different behaviours caused by transient-mark-mode either enabled or disabled, as described. The same behaviour can be a bug or a design flaw, depending on t-m-m. That refers to operations that imply doing something with a region, like downcase-region. The design flaw was probably never intended. >> Or why would I want something like upcase-region to suddenly mess up >> random parts of a buffer? > > Only they aren't random. They are as random as the region, and the region is entirely random. >> A region is not a selection, it's only a random part of the buffer >> that has somehow gotten between mark and point, perhaps when mark >> and point were used for navigation, or when I moved around, or when >> the mark happened to be set somewhere last time I yanked something, >> or when the cat stepped over the keyboard while I was pressing Ctrl >> or when it hit the cursor keys ... > > The region _is_ selection in Emacs. That's the problem ... > If you want Emacs to do something with text in the region, you will > redefine the region before invoking the command I always do that. That's "making a selection", and it's the selection I work with, not the region. The only time the region is not random is when it is a(n active) selection. > -- unless you know the region is already set up as you want it, > e.g. because you have just yanked the text to which you want to apply > the command. I work with selections, not with regions. I can't even see the region. Before I yank text, the selection is gone because it goes away when copying. > This is exactly why region and its integration with commands in Emacs > is a very valuable feature. How is this inflexibility a valuable feature? >> > Other commands, which make sense both when there is and there isn't a >> > region, need an indication of what the user wants them to do, and >> > whether the region is active is that indication. >>=20 >> The indication is whether there is a selection or not. > > Same thing. No, there is a big difference between a selection and a highlighted region. >> The problem is the region. It's not needed for anything and keeps >> getting in the way. > > Not in Emacs, it isn't. It is *the* problem.