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: visual-region-mode? Date: Wed, 03 Oct 2018 15:59:48 +0200 Organization: my virtual residence Message-ID: <871s973zcb.fsf@toy.adminart.net> References: <874lf0oul4.fsf@toy.adminart.net> <877ejuabdt.fsf_-_@toy.adminart.net> <878t473dhg.fsf@toy.adminart.net> <87pnxii2b7.fsf@toy.adminart.net> <87k1nm7eit.fsf@toy.adminart.net> <878t403dn5.fsf@toy.adminart.net> <878t3yv0p0.fsf@toy.adminart.net> <87d0t9ckzl.fsf@toy.adminart.net> <87a7oa1toa.fsf@toy.adminart.net> <87h8ibx6k5.fsf@toy.adminart.net> 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 1538581593 16220 195.159.176.226 (3 Oct 2018 15:46:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Oct 2018 15:46:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: charles@aurox.ch (Charles A. Roelli) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 03 17:46:29 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 1g7jM4-00047X-Oj for ged-emacs-devel@m.gmane.org; Wed, 03 Oct 2018 17:46:28 +0200 Original-Received: from localhost ([::1]:49421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7jOB-0005h3-Bk for ged-emacs-devel@m.gmane.org; Wed, 03 Oct 2018 11:48:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7jLi-0003Og-Hj for emacs-devel@gnu.org; Wed, 03 Oct 2018 11:46:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7jLg-00072D-Vs for emacs-devel@gnu.org; Wed, 03 Oct 2018 11:46:06 -0400 Original-Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:19057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7jLg-00071E-N1 for emacs-devel@gnu.org; Wed, 03 Oct 2018 11:46:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1538581563; 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=9kWVikOGsMOZhTPhywrl3IddW3pKsb8a9ny8oBkQkF4=; b=fHRpOTuFfeGMMeb+tVB+RV2g4PGBiyw9uLi9GPYZ6SjreL8WNPz8StbMrzRMpUDWvo F858+glsVvBGbdoma6Coyh8oM7jPFGWfMLshvq70W8TG5esWMiM4oJZLtFeL5vJ6NwUe 5whzOIpgaxlVDlLiMBCHRxd1vsiLqCJgoCmExhRdzwbdAyX5OT5n0Qo34GVkuiMRaCGa I9qz4huNKwYVY3o6ZuV90vBNxmoaGiImpcrWVkWn0scHEICAWy3XqeCJerXCKVcmL4QU To+ZbX1J2Rs3j4lJ3ISjqPdI+Zbm96IQFGmIgSAGbcAzRKVZaPAsNaaITa+JvGHhqq4b Ig4w== X-RZG-AUTH: ":O2kGeEG7b/pS1FS4THaxjVF9w0vVgfQ9xGcjwO5WMRo5c+h5ceMqQWZ3yrBp+AVdI4USjneHd9k=" X-RZG-CLASS-ID: mo00 Original-Received: from himinbjorg.adminart.net by smtp.strato.de (RZmta 44.2 DYNA|AUTH) with ESMTPSA id 907ec3u93Fjv5BW (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); Wed, 3 Oct 2018 17:45:57 +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 1g7jLY-0001i2-Ka; Wed, 03 Oct 2018 17:45:56 +0200 In-Reply-To: (Charles A. Roelli's message of "Thu, 27 Sep 2018 23:01:52 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::5 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:230203 Archived-At: charles@aurox.ch (Charles A. Roelli) writes: >> From: hw >> Cc: emacs-devel@gnu.org >> Date: Thu, 27 Sep 2018 00:00:42 +0200 >> >> > Yes, but since we have commands that offer behavior specific to active >> > regions, we have the so-called "temporary transient mark mode" -- >> > which is a hack to get around this problem. I'd rather have a way to >> > explicitly activate/deactivate the region. >>=20 >> I'm not sure this is a distinct mode; it seems more like the region is >> activated regardless of t-m-m being enabled or not and gets somehow >> disabled eventually. > > For what it's worth, the doc of the variable "transient-mark-mode" says: > > - The pair (only . OLDVAL) enables Transient Mark mode > temporarily. After any subsequent point motion command that is > not shift-translated, or any other action that would normally > deactivate the mark (e.g. buffer modification), the value of > =E2=80=98transient-mark-mode=E2=80=99 is set to OLDVAL. That sheds some light on the definition of exchange-point-and-mark in simple.el which I didn't fully understand. It either activates the region or deactivates it, i. e. there doesn't seem to be anything temporary about it. "Temporary" only seems to mean that the mode is enabled until the region is deactivated. That doesn't mean that it is actually temporary; it's the very same mode --- or isn't it? >> Why would I disable it permanently? I wouldn't have highlighting, there >> would be no way to fortify the region --- which is a requirement because >> it can not really be disabled due to a fundamental design flaw --- and I >> would have to narrow the buffer all the time to do something with a >> region and to widen it afterwards. > > You disable "t-m-m" if you don't want a "transient" mark -- as in, > activating and deactivating itself seemingly of its own volition. That isn't what it does. There are only very few cases where I expect the region to be deactivated and it isn't deactivated, and no cases in which the region is somehow activated all on its own. So why would I disable t-m-m? >> >> > and without the region randomly deactivating itself after certain >> >> > commands as it does with "t-m-m" switched on. >> >>=20 >> >> [...] >> >> >> >> Are you referring to commands deactivating the region?=20=20 >> > >> > Yes. See the doc of "t-m-m": >> > >> > The mark is "deactivated" by changing the buffer, >> > and after certain other operations that set the mark but whose >> > main purpose is something else--for example, incremental search, >> > M-<, and M->. >>=20 >> So this doesn't happen randomly but intentionally --- and you could >> re-activate the region if you still want to do something with it. > > Actually, the documentation lacks at least one other case: scrolling > that results in point moving, either with the keyboard or with the > mouse. That's one of several arbitrary decisions in the design of > t-m-m. That shows the fundamental design flaw of Emacs which doesn't allow to separate the region and thus selections from where the cursor is. I don't see how you could blame t-m-m for it. >> > I'd like to be able to carry this behavior over to commands that >> > require an active region for certain things, like M-% does for >> > replacing inside a region. >>=20 >> I guess the right, or consistent, way to do that might be to write more >> antagonistic functions that imply "region", like `query-replace-region'. >>=20 >> Why don't you make a selection when you want to do something with one? >> With t-m-m enabled, that automatically activates the region, and it is >> much better than doing stuff with random parts of the buffer. > > I'd rather tells Emacs when the region is active, than the other way > round. So you would rather have a "persistent region", i. e. a selection like joe has? Unfortunately, we can't really have that (unless the zones Drew suggested work in this way), and t-m-m is what comes closest to it. >> Other than that, I wonder what would go wrong if you made a key binding >> to a function that toggles `use-region-p' which you use before and >> perhaps after calling functions you want to have a different behaviour. >> Maybe `query-replace-region' could make use of that. > > This would be a binding to activate or deactivate the region, I think. > No extra command ("query-replace-region") should be necessary. It depends on what you prefer: extra commands to do stuff limited to the region, consistent with such commands that already exist, or explicitly activate the region to limit any command to do stuff with it. The latter could be what the temporaryness for t-m-m is supposed to cover. I simply leave t-m-m always enabled and have a key binding to activate the region with when I want to. The region is also fortified, and it does what I want. >> Of course, functions implying "region" don't make sense when t-m-m is >> enabled: t-m-m already implies "region" in the sense of "selection", >> somewhat overcoming the fundamental design flaw of "the region" and the >> idea of doing stuff randomly with parts of buffers. The functions >> implying "region" are merely children of this design flaw because they >> were only invented because nobody wants to narrow and widen their >> buffers to do something with parts of them. > > Narrowing still has its place in everyday editing. What do you use it for? >> (global-set-key "\C-x\C-x" 'my-exchange-point-and-mark) >> (global-set-key (kbd "") >> (lambda () >> "Toggle the activeness of the region." >> (interactive) >> (if mark-active (deactivate-mark) >> (activate-mark t)))) >> (global-set-key [C-f2] 'my-exchange-point-and-mark) >> (global-set-key [C-f3] 'previous-buffer) >> (global-set-key [C-f5] 'next-buffer) >>=20 >> Those are actual keys, i. e. I press only one key for them. It's rather >> convenient. (The key caps are labeled Print, Help, Record and Play.) >>=20 >> Unfortunately, it seems Unicomp is the only manufacturer still making >> really good keyboards, and the only one for 122 keys ... (The fine >> keyboard started working again the next day after I banged it a little, >> but I really like having more keys.) > > Neat, let us know how this approach goes. So far, it's nice. I need to do some programming to really find out, and it will be a while before I get to that. > I don't know what key we could allocate to a command that activates or > deactivates the region, since there are not free ones left on average > keyboards... That's why I like to have more keys. You could get one of these keyboards, they're awesome. The keyboard is part of customization. Other than that, having C-x C-x changed already helps, and in lack of another key, you could use it with the prefix to toggle the activeness of the region. >> On a side note, why is the function that activates the region called >> activate-mark and not activate-region? Is there some purpose or >> distinction involved we don't know about? > > People use "active mark" and "active region" interchangeably, AFAIK. > (I know I do!) That's confusing, and you could even have it so that activating the mark creates a persistent selection that isn't disabled after doing something with it while activating the region activates the selection only until you did something with it. >> > [...] >> > Btw, I'm culling most of the CC list since it seems no longer relevant. >>=20 >> I don't know who/what created this list; I suspect it might have been >> gnus. > > Those people had responded to this thread earlier, so they ended up on > the list automatically. Hm, that's an interesting feature.