[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transposing words over middle words

From: Stefan Monnier
Subject: Re: Transposing words over middle words
Date: Wed, 22 Nov 2017 16:33:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> Than again, maybe M-t should work like `C-0 M-t` whenever the region
>> is active so you don't even need the C-u at all.

> Here is an advice to make that happen, respecting possible prefixes.

> (defun tn-transpose-dwim-advice (transpose-subr &rest args)
>   (if (and (use-region-p) (= (cadr args) 1))
>       ;;                      MOVER  dwim  SPECIAL
>       (apply transpose-subr (car args) 0 (cddr args))
>     (apply transpose-subr args)))

> (advice-add 'transpose-subr :around #'tn-transpose-dwim-advice)

Indeed, thanks.
The equivalent direct patch to the source code is below,


diff --git a/lisp/simple.el b/lisp/simple.el
index 84fedbc537..4eaeaf15f6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -7173,7 +7173,7 @@ transpose-subr
                       (progn (funcall mover (- x)) (point))))))
        pos1 pos2)
-     ((= arg 0)
+     ((or (= arg 0) (and (= arg 1) (use-region-p)))
        (setq pos1 (funcall aux 1))
        (goto-char (or (mark) (error "No mark set in this buffer")))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]