[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#29346: dwim transpose-subr opportunity?
From: |
Tomas Nordin |
Subject: |
bug#29346: dwim transpose-subr opportunity? |
Date: |
Sun, 26 Nov 2017 14:54:20 +0100 |
Hello Debbugs
Sorry if this gets double posted, I sent it first directly to
29346@debbugs.gnu.org without hooking onto this thread and I couldn't
see any signs of it coming through somewhere.
Anyways, here is an update on the request/suggestion based on a
suggestion from the Emacs help list, with a custom addition from myself.
diff --git a/lisp/simple.el b/lisp/simple.el
index 41f22b2396..7773a7d5d1 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5431,6 +5431,15 @@ save-mark-and-excursion
(save-excursion ,@body)
(save-mark-and-excursion--restore ,saved-marker-sym)))))
+(defcustom transpose-active-region-dwim nil
+ "Make transpose commands act as with a zero prefix when region active.
+
+If non-nil, a zero prefix is not required to operate over mark
+and point when the region is active. See `transpose-words' for
+example, (the last sentence)."
+ :type 'boolean
+ :group 'editing-basics)
+
(defcustom use-empty-active-region nil
"Whether \"region-aware\" commands should act on empty regions.
If nil, region-aware commands treat the empty region as inactive.
@@ -6967,7 +6976,8 @@ transpose-subr
(progn (funcall mover (- x)) (point))))))
pos1 pos2)
(cond
- ((= arg 0)
+ ((or (= arg 0) (and (= arg 1) (use-region-p)
+ transpose-active-region-dwim))
(save-excursion
(setq pos1 (funcall aux 1))
(goto-char (or (mark) (error "No mark set in this buffer")))
Best regards
--
Tomas