From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.bugs Subject: bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp Date: Fri, 04 Nov 2016 08:48:19 +0100 Message-ID: <87k2cj8z3w.fsf@mbork.pl> 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 X-Trace: blaine.gmane.org 1478245767 19788 195.159.176.226 (4 Nov 2016 07:49:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 4 Nov 2016 07:49:27 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 26.0.50.3 Cc: rfflrccrd@gmail.com, 21072@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 04 08:49:23 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 1c2ZFM-0002tb-Br for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Nov 2016 08:49:08 +0100 Original-Received: from localhost ([::1]:36927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2ZFP-0001h7-6J for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Nov 2016 03:49:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2ZFJ-0001h2-9b for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2016 03:49:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2ZFG-0003mf-5m for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2016 03:49:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2ZFG-0003m1-2A for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2016 03:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c2ZFF-000823-RZ for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2016 03:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marcin Borkowski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Nov 2016 07:49: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.147824568930812 (code B ref 21072); Fri, 04 Nov 2016 07:49:01 +0000 Original-Received: (at 21072) by debbugs.gnu.org; 4 Nov 2016 07:48:09 +0000 Original-Received: from localhost ([127.0.0.1]:42889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c2ZEP-00080u-59 for submit@debbugs.gnu.org; Fri, 04 Nov 2016 03:48:09 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:34972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c2ZEN-00080m-Pp for 21072@debbugs.gnu.org; Fri, 04 Nov 2016 03:48:08 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 828D0E64A4; Fri, 4 Nov 2016 08:48:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0zz7o-PlNFsy; Fri, 4 Nov 2016 08:48:04 +0100 (CET) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 5007FE626F; Fri, 4 Nov 2016 08:48:04 +0100 (CET) In-reply-to: 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:125323 Archived-At: On 2016-10-28, at 16:32, Drew Adams wrote: > Thanks for considering it. And congratulations on young Borkowski! Thanks! On 2016-11-02, at 19:25, Drew Adams wrote: >> 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. I would hope so. > No, not really. But use your own judgment, I guess. I guess your version is simpler (no need to use raw prefix arg), and hence better. > 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))) Very nice trick with the 'last-command, thanks! I included this in my code. I will also write some tests for that (it seems to work, but...) and send the code soon. >> 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. Again - I agree, this makes coding (though not necessarily testing!) simpler. Best, -- Marcin Borkowski