From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Elias_M=C3=A5rtenson?= Newsgroups: gmane.emacs.devel Subject: Re: delete-selection-mode as default Date: Fri, 14 Sep 2018 23:15:01 +0800 Message-ID: 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004e976f0575d64ad0" X-Trace: blaine.gmane.org 1536938006 30690 195.159.176.226 (14 Sep 2018 15:13:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Sep 2018 15:13:26 +0000 (UTC) Cc: hw@adminart.net, spacibba@aol.com, joostkremers@fastmail.fm, Noam Postavsky , emacs-devel , Alan Mackenzie , Eli Zaretskii , Drew Adams , Phillip Lord To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 14 17:13:21 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 1g0pmZ-0007py-IZ for ged-emacs-devel@m.gmane.org; Fri, 14 Sep 2018 17:13:19 +0200 Original-Received: from localhost ([::1]:52156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0pof-0004fZ-UB for ged-emacs-devel@m.gmane.org; Fri, 14 Sep 2018 11:15:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0poW-0004ai-Fp for emacs-devel@gnu.org; Fri, 14 Sep 2018 11:15:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0poU-0001IF-HF for emacs-devel@gnu.org; Fri, 14 Sep 2018 11:15:20 -0400 Original-Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]:55591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g0poS-00019v-HY; Fri, 14 Sep 2018 11:15:16 -0400 Original-Received: by mail-it0-x244.google.com with SMTP id d10-v6so3025581itj.5; Fri, 14 Sep 2018 08:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iNGsroyGLa2yNhjeOVcyBXFlxLGeMFlzSlRF4Md1dYU=; b=IZbI/J3JSsKvNkkT/yJtqJLmKXH6kGr43zvjgUc/VQTx+4KZ5zi7dz01NhFdhmsYyR Rke6E1Q5IRJa7X6NaAv2Nca2dUtNtSWByRPly0ncSuolPBBA9oxcyRRXZ/Wk7nRBoslx E5pMX/Uf/U6M5gk3q/hWcWQZNSlkt/f63Sa1QYfTBI8JQeolcNzDTiKZNmgI+0OOKCyb b14aHv1ys1fPAaE/CZg6G8gRuh2N2+wUClNj4SPvMZm/6h8s5fatwn4abanlJ5PN9PcG uQnbsu/OqkKL4BUhF3aHcDRfWrTXsnL1/qBQE2mwbgYPsaOlPkPneUSEb0U7pRMiXZOL icdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iNGsroyGLa2yNhjeOVcyBXFlxLGeMFlzSlRF4Md1dYU=; b=PIbdwSMb1KSt6QuwZrVIzKuHjLQdPEsrrIk9F017IB+Jx4IE0nC5J/yHsEzoMsToeI rxycDMZNG85ZTcL7k6of02gRzq6ta5RuHC2nXaP0wjFWNV0VgtbzfUJ/8+No8fsZNZDd PeWFPzWPr1k+QV/Ba9X+Lq4dUTZTO7I3P7OTRoAMpHUhPwlYTXpIKAlLb+O7hpFmiHGn EnkZbut6txZFsacD41vqn3nY1D44hf5nbGW9nCgYKqhQMvXC6/v4HF+lwktle+p3a6d9 sq4xFHomd9tQUbaxvyTxMOEgvi7MFGGaHUbMhjYZ8F1MjRWvpgD3R277/qp0fGzKoq4C +fOg== X-Gm-Message-State: APzg51CpISwkcgED1NzRC4Ru0DplBIP44W26u7ORYyagstXq+S2OuK0u VRh2+MzcYxxBR8T5W6zOptq02y6hLfb0VPXRYvc= X-Google-Smtp-Source: ANB0VdZbAGQrDurAlGvDMLb9BGCF8Mok3+cM28onGKvUe5KNrkmHeq7LG+z++2OOxdDuubWjNGzy10PxDrqx8GJBF7g= X-Received: by 2002:a24:7a85:: with SMTP id a127-v6mr2687164itc.117.1536938113666; Fri, 14 Sep 2018 08:15:13 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::244 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:229785 Archived-At: --0000000000004e976f0575d64ad0 Content-Type: text/plain; charset="UTF-8" On Fri, 14 Sep 2018 at 21:43, Yuri Khan wrote: > One other thing that I want is that the region be highlighted if and > only if it is going to be the target of the next command I give, > because I like to look before I leap. It seems transient-mark-mode is > intended to give me this by adding the concept of active region and > highlighting the region when it is active. However, many commands act > on the region even if it is inactive. kill-region and > copy-region-as-kill are two such commands. I am sure there are many > more, because it is much easier to write: > > (defun my-command (BEGIN END) > (interactive "r") > ;; do something between BEGIN and END > ) > > than: > > (defun my-command (BEGIN END) > (interactive (if (use-region-p) > (list (min (point) (mark)) (max (point) (mark))) > ;; figure out what to do when no region is active > ;; * act on the whole buffer > ;; * act on the current narrowing > ;; * signal an error > ;; * do something else sensible > (list ?? ??))) > ;; do something between BEGIN and END > ) > I've seen functions implemented like that, and I would consider those buggy. It's going directly against the concept of the point and mark as being the region. I know some people want the same behaviour as gedit or whatever editor is default in desktop environments these days, but the Emacs way really is powerful and it would be useful if people who want to change things at least understood this concept first. Regards, Elias --0000000000004e976f0575d64ad0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, 14 Sep= 2018 at 21:43, Yuri Khan <yurivk= han@gmail.com> wrote:
=C2=A0
One other thing that I want is that the region be highlighted if= and
only if it is going to be the target of the next command I give,
because I like to look before I leap. It seems transient-mark-mode is
intended to give me this by adding the concept of active region and
highlighting the region when it is active. However, many commands act
on the region even if it is inactive. kill-region and
copy-region-as-kill are two such commands. I am sure there are many
more, because it is much easier to write:

(defun my-command (BEGIN END)
=C2=A0 (interactive "r")
=C2=A0 ;; do something between BEGIN and END
)

than:

(defun my-command (BEGIN END)
=C2=A0 (interactive (if (use-region-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list = (min (point) (mark)) (max (point) (mark)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; figure out= what to do when no region is active
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; * act on t= he whole buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; * act on t= he current narrowing
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; * signal a= n error
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; * do somet= hing else sensible
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list ?? ??))= )
=C2=A0 ;; do something between BEGIN and END
)

I've seen functions implemented l= ike that, and I would consider those buggy. It's going directly against= the concept of the point and mark as being the region. I know some people = want the same behaviour as gedit or whatever editor is default in desktop e= nvironments these days, but the Emacs way really is powerful and it would b= e useful if people who want to change things at least understood this conce= pt first.

Regards,
Elias
--0000000000004e976f0575d64ad0--