unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tomas Nordin <tomasn@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 29346@debbugs.gnu.org
Subject: bug#29346: dwim transpose-subr opportunity?
Date: Sun, 26 Nov 2017 14:54:20 +0100	[thread overview]
Message-ID: <87d145w3g3.fsf@fliptop> (raw)
In-Reply-To: <83k1ynfxwm.fsf@gnu.org>

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





  reply	other threads:[~2017-11-26 13:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 22:00 bug#29346: dwim transpose-subr opportunity? Tomas Nordin
2017-11-18  7:48 ` Eli Zaretskii
2017-11-18 13:35   ` Tomas Nordin
2017-11-18 14:45     ` Eli Zaretskii
2017-11-26 13:54       ` Tomas Nordin [this message]
2020-08-10 14:10   ` Lars Ingebrigtsen
2017-11-25 11:51 ` bug#29346: dwim transpose-subr opportunity new suggestion Tomas Nordin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d145w3g3.fsf@fliptop \
    --to=tomasn@posteo.net \
    --cc=29346@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).