From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#21275: 24.5; Selection deleted with electric pair mode in cc mode Date: Thu, 20 Aug 2015 22:46:42 -0700 (PDT) Message-ID: <550bc0c3-70ea-4b61-9d4b-b4e5656f49a3@default> References: <87a8trcqbp.fsf@moondust.localdomain> <20150818150431.42639.qmail@mail.muc.de> <20150820215506.GC3105@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1440136047 8321 80.91.229.3 (21 Aug 2015 05:47:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Aug 2015 05:47:27 +0000 (UTC) Cc: "N. Jackson" , 21275@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 21 07:47:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZSfAY-00064j-Qu for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Aug 2015 07:47:15 +0200 Original-Received: from localhost ([::1]:39974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSfAX-0001Ce-N9 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Aug 2015 01:47:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSfAT-0001C6-Dp for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2015 01:47:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSfAS-0007eO-77 for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2015 01:47:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSfAM-0007dy-B8; Fri, 21 Aug 2015 01:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZSfAL-0004gy-T5; Fri, 21 Aug 2015 01:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 21 Aug 2015 05:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21275 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 21275-submit@debbugs.gnu.org id=B21275.144013600818016 (code B ref 21275); Fri, 21 Aug 2015 05:47:01 +0000 Original-Received: (at 21275) by debbugs.gnu.org; 21 Aug 2015 05:46:48 +0000 Original-Received: from localhost ([127.0.0.1]:34064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZSfA7-0004gV-Di for submit@debbugs.gnu.org; Fri, 21 Aug 2015 01:46:47 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:19265) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZSfA5-0004gM-K9 for 21275@debbugs.gnu.org; Fri, 21 Aug 2015 01:46:46 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7L5kiLo008104 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Aug 2015 05:46:44 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t7L5kh5u029091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 21 Aug 2015 05:46:44 GMT Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t7L5khph008083; Fri, 21 Aug 2015 05:46:43 GMT In-Reply-To: <20150820215506.GC3105@acm.fritz.box> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105634 Archived-At: Hi Alan, Yes, it's a workaround for electric-pair mode. And yes, delete-selection mo= de got there first. A few decades earlier. ;-) My point is that this workaround for electric-pair should have an "electric= -pair" name, not a "delete-selection" name. It is not something used by del= ete-selection. > > > > +(defun delete-selection-uses-region-p () > > > > > > The way I read it, this name says "a function which tells us if > > > delete-selection uses the region". >=20 > > No idea what this is all about, .... >=20 > It's for when delete-selection-mode and electric-pair-mode are both > enabled. What was happening (in C Mode, etc.) was that the user > would mark an object and type "(", expecting e-p-m to put a pair > of parens around the marked object; however d-s-m got in first, > and deleted (?killed) the region before the parens were put around > the now empty region. >=20 > There was already a solution for this for when "(" is bound to > self-insert-command - this is fairly arcane, and involves setting a > particular variable to function which returns t in the pertinent > circumstances. >=20 > This function was previously coded as a lambda. However, I needed > to use it for the pertinent CC Mode functions too, so I extracted > it into a defun, giving it the name `delete-selection-uses-region-p'. =20 > The "delete-seleection" bit is the prefix, shared by the other > de\(fun\|var\)s in the file. In what file? Why is the prefix "delete-selection", and not "electric-pair"? > > .... but if this is for `electric-pair-mode' and not for > > `delete-selection-mode' then the name should reflect that -\ > > call it `electric-pair-SOMETHING'. >=20 > It's for when BOTH minor modes are enabled, to enable them to play > nicely with eachother. But it's in delsel.el, hence the prefix. It's for electric-pair to move into the delete-selection neighborhood. It's an electric-pair thing. Delete-selection mode doesn't need it - never has. > > Is this something that `delete-selection-mode' needs? > > Or is it for something else? >=20 > See above. AFAICT, it is not for delete-selection mode. It is a hack so that electric-pair mode can adapt to delete-selection=20 mode. Nothing wrong with that, in principle. When a new feature is added, it often has to accommodate existing behavior. My point is that the name should reflect the fact that this is a workaround for electric-pair mode, so that it DTRT. If you had to add another workaround for e-p mode, so that it DTRT with commas or whatever, that would be no different. Such things are about e-p; their names should reflect that. If you also want to refer, in the name, to the thing you are working around for e-p mode, that's OK, but the prefix of the name should be e-p: `elec-pair-hack-to-tolerate-delsel' or whatever. > > > > + "Return non-nil when the current command uses the region. >=20 > > What does it mean for a command to "use the region"? >=20 > That isn't very good, is it? It basically means, from e-p-m's > point of view "I'm going to be "using" the region, so don't > you go and delete it!". That still doesn't speak to what "using the region" means. It sounds like what is important is that you are protecting the region for e-p. If so, the name and description should reflect that need, not just "using the region". > > > It's not about "the current command" but about > > > self-insert-command (which may be the current command or > > > may be called by the current command). >=20 > > What does it mean for such a command (or any other command) to > > "use the region"? That info should presumably be in the doc > > string. >=20 > I think you're right, here. I'll have another look at it. Anyway, it's not very important. Just one opinion. I'd recommend writing the explanation and names from the point of view of e-p (only). HTH - Drew