[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs
From: |
Marcin Borkowski |
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 |
User-agent: |
mu4e 0.9.17; emacs 26.0.50.3 |
On 2016-10-28, at 16:32, Drew Adams <drew.adams@oracle.com> wrote:
> Thanks for considering it. And congratulations on young Borkowski!
Thanks!
On 2016-11-02, at 19:25, Drew Adams <drew.adams@oracle.com> 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