From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp Date: Wed, 2 Nov 2016 11:25:20 -0700 (PDT) Message-ID: References: <55A74B3C.8030608@gmail.com> <87k2jm2bay.fsf@amu.edu.pl> <83r3dln1ez.fsf@gnu.org> <87y47tzn0v.fsf@mbork.pl> <83lh3tmyzv.fsf@gnu.org> <87twihzhni.fsf@mbork.pl> <83fuu1mu25.fsf@gnu.org> <87eg9jynn0.fsf@mbork.pl> <83h9edkhjs.fsf@gnu.org> <874mabe5h6.fsf@mbork.pl> <83twibfil2.fsf@gnu.org> <87y47mcywp.fsf@mbork.pl> <87bmyrvzh1.fsf@mbork.pl> <878ttux198.fsf@mbork.pl> <366cfd22-c35c-4980-bc81-7f6df6c180a0@default> <87shra8hnz.fsf@mbork.pl> 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 1478111200 22940 195.159.176.226 (2 Nov 2016 18:26:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 2 Nov 2016 18:26:40 +0000 (UTC) Cc: rfflrccrd@gmail.com, 21072@debbugs.gnu.org To: Marcin Borkowski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 02 19:26:33 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1c20Ep-0002xv-0b for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Nov 2016 19:26:15 +0100 Original-Received: from localhost ([::1]:56902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c20Er-00025K-PC for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Nov 2016 14:26:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c20Eh-00024E-ET for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 14:26:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c20Ec-0005Ne-Br for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 14:26:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c20Ec-0005NY-8O for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 14:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c20Ec-0005Qx-01 for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 14:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Nov 2016 18:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21072 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21072-submit@debbugs.gnu.org id=B21072.147811114420856 (code B ref 21072); Wed, 02 Nov 2016 18:26:01 +0000 Original-Received: (at 21072) by debbugs.gnu.org; 2 Nov 2016 18:25:44 +0000 Original-Received: from localhost ([127.0.0.1]:40864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c20EK-0005QK-Dx for submit@debbugs.gnu.org; Wed, 02 Nov 2016 14:25:44 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:45502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c20EI-0005Q4-Jf for 21072@debbugs.gnu.org; Wed, 02 Nov 2016 14:25:42 -0400 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uA2IPa5O003538 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Nov 2016 18:25:36 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.13.8) with ESMTP id uA2IPZl2015026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Nov 2016 18:25:35 GMT Original-Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id uA2IPOCT028244; Wed, 2 Nov 2016 18:25:27 GMT In-Reply-To: <87shra8hnz.fsf@mbork.pl> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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" Xref: news.gmane.org gmane.emacs.bugs:125277 Archived-At: > Well, both these behaviors are manifestations of the same bug. > Below is the corrected version. (And below that a question.) The test cases I mentioned work now. Thx. I didn't try anything beyond those cases. Hopefully others will test a bit more. > > 6. Interactively, I would rather see repeated use of `C-M-h', > > after an initial use of `C-M-h' with a negative prefix arg=20 > > (e.g. `M-- C-M-h'), continue to select defuns backward. > > IOW, not need to use `M--' explicitly for each `C-M-h'. > > > > You can just hold down `C-M-h', to select multiple defuns > > forward. I would like to be able to do the same thing, > > but backward, by using `M-- C-M-h C-M-h C-M-h C-M-h...' > > (just hold down the chord). > > > > If you do that, then a negative prefix arg should not mean > > backward; it should just mean change direction (backward if > > previous command was not `mark-defun'). >=20 > Just to be sure: you mean only the minus sign as argument, not > a negative number? No, not really. But use your own judgment, I guess. This is the kind of behavior I had in mind. This is for `transpose-sexps', but it shows the behavior. _Any_ negative arg flips the direction. At the outset, a negative arg means move backward. The absolute value of ARG is the number of sexps to move over. (defun reversible-transpose-sexps (arg) "Reversible and repeatable `transpose-sexps'. Like `transpose-sexps', but: 1. Leaves point after the moved sexp. 2. When repeated, a negative prefix arg flips the direction." (interactive "p") (when (eq last-command 'rev-transp-sexps-back) (setq arg (- arg))) (transpose-sexps arg) (unless (natnump arg) (backward-sexp (abs arg)) (skip-syntax-backward " .") (setq this-command 'rev-transp-sexps-back))) (If you happen to try this with ARG=3D0, be aware that what you see is just the peculiar `transpose-sexps' behavior for ARG=3D0. This is not related to the code here.) > I'm also wondering whether to allow that for > non-interactive use, too: I'm pretty sure nobody would want to call > (mark-defun '-) from Lisp code, and it might make testing slightly > easier. I think the behavior should be the same. But see above. The arg passed should be numeric (positive, zero, or negative), IMO.