all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#29346: dwim transpose-subr opportunity?
@ 2017-11-17 22:00 Tomas Nordin
  2017-11-18  7:48 ` Eli Zaretskii
  2017-11-25 11:51 ` bug#29346: dwim transpose-subr opportunity new suggestion Tomas Nordin
  0 siblings, 2 replies; 7+ messages in thread
From: Tomas Nordin @ 2017-11-17 22:00 UTC (permalink / raw)
  To: 29346

Hello List

Not a bug report but maybe a feature request. I was wondering if there
is an opportunity for a dwim feature of the transpose-<thing> set of
functions by something like the following:

1 file changed, 1 insertion(+), 1 deletion(-)
lisp/simple.el | 2 +-

modified   lisp/simple.el
@@ -6967,7 +6967,7 @@ transpose-subr
                       (progn (funcall mover (- x)) (point))))))
        pos1 pos2)
     (cond
-     ((= arg 0)
+     ((or (= arg 0) (use-region-p))
       (save-excursion
        (setq pos1 (funcall aux 1))
        (goto-char (or (mark) (error "No mark set in this buffer")))


The intention is that a 0 number prefix argument is not necessary if
there is a region so that use-region-p is non-nil. I have tried it in
some various ways and to me it seem to work, but I don't know all the
delicate ways in which those commands might be used. What do you think?

It gets a bit silly as suggested though, I guess the logic should be
something like (or (= arg 0) (and transpose-dwim (use-region-p)))

Best regards
--
Tomas





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity?
  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
  2020-08-10 14:10   ` Lars Ingebrigtsen
  2017-11-25 11:51 ` bug#29346: dwim transpose-subr opportunity new suggestion Tomas Nordin
  1 sibling, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2017-11-18  7:48 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: 29346

> From: Tomas Nordin <tomasn@posteo.net>
> Date: Fri, 17 Nov 2017 23:00:29 +0100
> 
> @@ -6967,7 +6967,7 @@ transpose-subr
>                        (progn (funcall mover (- x)) (point))))))
>         pos1 pos2)
>      (cond
> -     ((= arg 0)
> +     ((or (= arg 0) (use-region-p))
>        (save-excursion
>         (setq pos1 (funcall aux 1))
>         (goto-char (or (mark) (error "No mark set in this buffer")))
> 
> 
> The intention is that a 0 number prefix argument is not necessary if
> there is a region so that use-region-p is non-nil. I have tried it in
> some various ways and to me it seem to work, but I don't know all the
> delicate ways in which those commands might be used. What do you think?

I think this would be a source of inadvertent mistakes and
annoyances.  Transient Mark mode is on by default, which means M-t can
frequently do something the user didn't intend it to, just because the
region happened to be active.  A similar situation exists with typing
DEL when the region is active, but at least in that case we behave
like many GUI applications out there, so we can hope the user is ready
for that and expects that to happen.  (I'm never ready, which is
probably the reason why I turn Transient Mark mode off.)  With M-t, we
don't have that defense.

> It gets a bit silly as suggested though, I guess the logic should be
> something like (or (= arg 0) (and transpose-dwim (use-region-p)))

Maybe.  But I wonder why this relatively rare use case is so important
as to mandate a new defcustom, whose only purpose is to save the user
from typing M-0 or "C-u 0".  Just because people didn't read the doc
string and therefore didn't know about the special meaning of an
argument of zero?  But then they will not know about the proposed
magic, either.

Thanks.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity?
  2017-11-18  7:48 ` Eli Zaretskii
@ 2017-11-18 13:35   ` Tomas Nordin
  2017-11-18 14:45     ` Eli Zaretskii
  2020-08-10 14:10   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Tomas Nordin @ 2017-11-18 13:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29346

Eli Zaretskii <eliz@gnu.org> writes:

> I think this would be a source of inadvertent mistakes and
> annoyances.  Transient Mark mode is on by default, which means M-t can
> frequently do something the user didn't intend it to, just because the
> region happened to be active.  A similar situation exists with typing

Is an example of that the following

    ^Jack and Jill over ^jumped the hill.

The first '^' is for the mark and next is for point, making an active
region, and now I hit M-t because I wanted to swap 'over' with 'jump',
but instead I swapped 'Jack' with 'jumped'.

Just for my understanding. Or is there better examples?

>> It gets a bit silly as suggested though, I guess the logic should be
>> something like (or (= arg 0) (and transpose-dwim (use-region-p)))
>
> Maybe.  But I wonder why this relatively rare use case is so important
> as to mandate a new defcustom, whose only purpose is to save the user
> from typing M-0 or "C-u 0".  Just because people didn't read the doc

I was mostly thinking not to disturb the long lasting default I think,
or the possible annoyances as you say.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity?
  2017-11-18 13:35   ` Tomas Nordin
@ 2017-11-18 14:45     ` Eli Zaretskii
  2017-11-26 13:54       ` Tomas Nordin
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2017-11-18 14:45 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: 29346

> From: Tomas Nordin <tomasn@posteo.net>
> Cc: 29346@debbugs.gnu.org
> Date: Sat, 18 Nov 2017 14:35:22 +0100
> 
> > I think this would be a source of inadvertent mistakes and
> > annoyances.  Transient Mark mode is on by default, which means M-t can
> > frequently do something the user didn't intend it to, just because the
> > region happened to be active.  A similar situation exists with typing
> 
> Is an example of that the following
> 
>     ^Jack and Jill over ^jumped the hill.
> 
> The first '^' is for the mark and next is for point, making an active
> region, and now I hit M-t because I wanted to swap 'over' with 'jump',
> but instead I swapped 'Jack' with 'jumped'.
> 
> Just for my understanding. Or is there better examples?

You understood me, that's exactly what I had in mind.

> >> It gets a bit silly as suggested though, I guess the logic should be
> >> something like (or (= arg 0) (and transpose-dwim (use-region-p)))
> >
> > Maybe.  But I wonder why this relatively rare use case is so important
> > as to mandate a new defcustom, whose only purpose is to save the user
> > from typing M-0 or "C-u 0".  Just because people didn't read the doc
> 
> I was mostly thinking not to disturb the long lasting default I think,
> or the possible annoyances as you say.

Thanks for clarifying that.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity new suggestion
  2017-11-17 22:00 bug#29346: dwim transpose-subr opportunity? Tomas Nordin
  2017-11-18  7:48 ` Eli Zaretskii
@ 2017-11-25 11:51 ` Tomas Nordin
  1 sibling, 0 replies; 7+ messages in thread
From: Tomas Nordin @ 2017-11-25 11:51 UTC (permalink / raw)
  To: 29346

Hi Debbugs

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity?
  2017-11-18 14:45     ` Eli Zaretskii
@ 2017-11-26 13:54       ` Tomas Nordin
  0 siblings, 0 replies; 7+ messages in thread
From: Tomas Nordin @ 2017-11-26 13:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29346

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#29346: dwim transpose-subr opportunity?
  2017-11-18  7:48 ` Eli Zaretskii
  2017-11-18 13:35   ` Tomas Nordin
@ 2020-08-10 14:10   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-10 14:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tomas Nordin, 29346

Eli Zaretskii <eliz@gnu.org> writes:

>> It gets a bit silly as suggested though, I guess the logic should be
>> something like (or (= arg 0) (and transpose-dwim (use-region-p)))
>
> Maybe.  But I wonder why this relatively rare use case is so important
> as to mandate a new defcustom, whose only purpose is to save the user
> from typing M-0 or "C-u 0".  Just because people didn't read the doc
> string and therefore didn't know about the special meaning of an
> argument of zero?  But then they will not know about the proposed
> magic, either.

I think the conclusion here was that it didn't seem worth it to add a
new variable to control this behaviour (since `M-0' easy to type), so
I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-10 14:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-08-10 14:10   ` Lars Ingebrigtsen
2017-11-25 11:51 ` bug#29346: dwim transpose-subr opportunity new suggestion Tomas Nordin

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.