unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Suggestion for C-t (transpose-chars)
@ 2007-07-20  9:43 Dieter Wilhelm
  2007-07-20 10:30 ` Mathias Dahl
  2007-07-20 11:31 ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-07-20  9:43 UTC (permalink / raw)
  To: emacs-devel

Hi

With a prefix argument ARG C-t allows to *drag* a character ARG
characters away.  Even though the respective code is impressively
elegant I think it would be more helpful when one could *transpose*
two characters ARG characters away from point!

I guess this would also be helpful for non-touch-typists.  Isn't it
the case that one confuses only the sequence of two *neighbouring*
characters and realises that very often after typing one or two
additional ones?  I find myself often typing C-b, C-b, C-t and C-e.
With the suggested change it would save 4 keystrokes (C-2 and C-t).

Thanks for listening.

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20  9:43 Suggestion for C-t (transpose-chars) Dieter Wilhelm
@ 2007-07-20 10:30 ` Mathias Dahl
  2007-07-20 13:05   ` Dieter Wilhelm
  2007-07-20 11:31 ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Mathias Dahl @ 2007-07-20 10:30 UTC (permalink / raw)
  To: Dieter Wilhelm; +Cc: emacs-devel

> With a prefix argument ARG C-t allows to *drag* a character ARG
> characters away.  Even though the respective code is impressively
> elegant I think it would be more helpful when one could *transpose*
> two characters ARG characters away from point!

I am totally impressed that people use these commands! I suspect it
takes quite a while getting into the habit and actually do this,
instead of simply DEL DEL DEL ... and retype. I am even more impressed
when thinking about there being people that even used the prefix arg
to this command. Wow! What brain power it must have taken to get that
habituized. At tops at would use the occacional C-t after misspelling
`the' as `teh'. As you might suspect I don't use this command much, so
take my opinion lightly, but I do agree that what Dieter suggests
sound more useful than the current behavior. Also, in hope that I can
learn as well, I would love to hear about in which scenarios people
end up using this.

> I guess this would also be helpful for non-touch-typists.  Isn't it
> the case that one confuses only the sequence of two *neighbouring*
> characters and realises that very often after typing one or two
> additional ones?  I find myself often typing C-b, C-b, C-t and C-e.
> With the suggested change it would save 4 keystrokes (C-2 and C-t).

A comment about counting keys like this, I think it is misleading to
count that as 4 keystrokes, typing the same key twice is in my opinion
much easier than moving the fingers to type another one so I think it
should count as 3, or maybe 3.2... :) Also, and this is a very
uninformed opinion from one that have been touch typing (still
learning) for some months, but isn't the `t' slightly easier to type
than the `2', even more reducing the win?

Anyway, I just wanted to present some counter-arguments, maybe not
even good ones. :) Still, I agree that the proposed behavior sounds
more useful than the current one.

/Mathias

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20  9:43 Suggestion for C-t (transpose-chars) Dieter Wilhelm
  2007-07-20 10:30 ` Mathias Dahl
@ 2007-07-20 11:31 ` Eli Zaretskii
  2007-07-20 18:55   ` Dieter Wilhelm
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2007-07-20 11:31 UTC (permalink / raw)
  To: Dieter Wilhelm; +Cc: emacs-devel

> From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>
> Date: Fri, 20 Jul 2007 11:43:16 +0200
> 
> With a prefix argument ARG C-t allows to *drag* a character ARG
> characters away.  Even though the respective code is impressively
> elegant I think it would be more helpful when one could *transpose*
> two characters ARG characters away from point!

This behavior is so old in Emacs that I'd suggest to write a new
command that does what you want, and leave the original one alone.
Interested users could then rebind C-t to run that new command.

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 10:30 ` Mathias Dahl
@ 2007-07-20 13:05   ` Dieter Wilhelm
  0 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-07-20 13:05 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: emacs-devel

"Mathias Dahl" <mathias.dahl@gmail.com> writes:
>
...
> learn as well, I would love to hear about in which scenarios people
> end up using this.

Unrelated to C-t; but my favourite prefix argument is - with the combo
of M-c (we in Germany have to capitalise some too many words
unfortunately 8-)) and often one realises this after spelling the word
out.

>
...
>> additional ones?  I find myself often typing C-b, C-b, C-t and C-e.
>> With the suggested change it would save 4 keystrokes (C-2 and C-t).
>
> A comment about counting keys like this, I think it is misleading to
> count that as 4 keystrokes, typing the same key twice is in my opinion
> much easier than moving the fingers to type another one so I think it

Your are definitely right, I oversimplified this.  I once compared the
key counts between Emacs and VIM where I tried to take this better
into account.  When you are interested I'll send it to you privately,
it's only text.  

I think the most important hint for speeding up the key strokes as a
touch typist under Emacs is using the outer side of your palms (I
think it's called hypothenar in English) and the thumbs for ALT and
AltGr while you are using the fingers of the respective hand or the
other.

>
...
> uninformed opinion from one that have been touch typing (still
> learning) for some months, but isn't the `t' slightly easier to type
> than the `2', even more reducing the win?

No, even when the numbers are taking longer getting used to, if you
have the proper posture of your hands (the wrists a bit upheld) it
doesn't even take longer to type #s compared to chars.

>
...
-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 11:31 ` Eli Zaretskii
@ 2007-07-20 18:55   ` Dieter Wilhelm
  2007-07-20 19:14     ` Stefan Monnier
  2007-07-20 20:06     ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-07-20 18:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>
>> Date: Fri, 20 Jul 2007 11:43:16 +0200
>> 
>> With a prefix argument ARG C-t allows to *drag* a character ARG
>> characters away.  Even though the respective code is impressively
>> elegant I think it would be more helpful when one could *transpose*
>> two characters ARG characters away from point!
>
> This behavior is so old in Emacs that I'd suggest to write a new
> command that does what you want, and leave the original one alone.
> Interested users could then rebind C-t to run that new command.

Fair enough, I'll do that.  Would you suggest to make it public on the
Emacs Wiki?

But old code does not equal used code, I really like to argue that
above behaviour would make Emacs an (infinitesimal) bit better ;-).

  Dieter

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 18:55   ` Dieter Wilhelm
@ 2007-07-20 19:14     ` Stefan Monnier
  2007-08-07 20:56       ` Dieter Wilhelm
  2007-07-20 20:06     ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2007-07-20 19:14 UTC (permalink / raw)
  To: Dieter Wilhelm; +Cc: Eli Zaretskii, emacs-devel

>>> With a prefix argument ARG C-t allows to *drag* a character ARG
>>> characters away.  Even though the respective code is impressively
>>> elegant I think it would be more helpful when one could *transpose*
>>> two characters ARG characters away from point!
>> 
>> This behavior is so old in Emacs that I'd suggest to write a new
>> command that does what you want, and leave the original one alone.
>> Interested users could then rebind C-t to run that new command.

> Fair enough, I'll do that.  Would you suggest to make it public on the
> Emacs Wiki?

> But old code does not equal used code, I really like to argue that
> above behaviour would make Emacs an (infinitesimal) bit better ;-).

I value also the consistency with the other transposition commands (like
M-t and C-M-t), so we should also consider whether your suggested behavior
is better for those cases or not.

This said, I have no opinion on which behavior is better.


        Stefan

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 18:55   ` Dieter Wilhelm
  2007-07-20 19:14     ` Stefan Monnier
@ 2007-07-20 20:06     ` Eli Zaretskii
  2007-07-27  0:28       ` Dieter Wilhelm
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2007-07-20 20:06 UTC (permalink / raw)
  To: Dieter Wilhelm; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>
> Date: Fri, 20 Jul 2007 20:55:29 +0200
> 
> > This behavior is so old in Emacs that I'd suggest to write a new
> > command that does what you want, and leave the original one alone.
> > Interested users could then rebind C-t to run that new command.
> 
> Fair enough, I'll do that.  Would you suggest to make it public on the
> Emacs Wiki?

I'd rather you posted it here, as diffs to the appropriate Emacs Lisp
file.

> But old code does not equal used code, I really like to argue that
> above behaviour would make Emacs an (infinitesimal) bit better ;-).

Well, adding the new version will make everybody happy, so it's a
win-win situation.

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 20:06     ` Eli Zaretskii
@ 2007-07-27  0:28       ` Dieter Wilhelm
  2007-07-31 17:05         ` Richard Stallman
  0 siblings, 1 reply; 11+ messages in thread
From: Dieter Wilhelm @ 2007-07-27  0:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>
> I'd rather you posted it here, as diffs to the appropriate Emacs Lisp
> file.

Fine, here's my first idea.  I'll test it a while and see whether it's
really an improvement to the original defun (here called drag-chars).

Could I marry the two behaviours into one function in checking for
example whether the arguments are given with an C-u prefix or not?

        Dieter


Index: simple.el
===================================================================
--- simple.el	(revision 6)
+++ simple.el	(working copy)
@@ -3957,6 +3957,27 @@
       (select-window orig-window))))
 \f
 (defun transpose-chars (arg)
+  "Interchange characters around point.
+With prefix arg ARG, effect is to interchange adjacent characters
+ARG characters before point (ARG characters after point if ARG is
+negative).  If no argument and at end of line, the previous two
+characters are exchanged."
+  (interactive "*P")
+  (when (and (null arg) (eolp))
+    (setq arg 2))
+  (let* ((p (point))
+	 (p1 (- p (prefix-numeric-value arg)))
+	 (p2 (1+ p1)))
+    (when (< p1 (point-min))
+      (error "Beginning of buffer or narrowed region"))
+    (when (> p2 (point-max))
+      (error "End of buffer or narrowed region"))
+    (setq c (delete-and-extract-region p1 p2))
+    (goto-char p2)
+    (insert c)
+    (goto-char p)))
+
+(defun drag-chars (arg)
   "Interchange characters around point, moving forward one character.
 With prefix arg ARG, effect is to take character before point
 and drag it forward past ARG other characters (backward if ARG negative).


-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-27  0:28       ` Dieter Wilhelm
@ 2007-07-31 17:05         ` Richard Stallman
  2007-08-07 21:29           ` Dieter Wilhelm
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2007-07-31 17:05 UTC (permalink / raw)
  To: Dieter Wilhelm; +Cc: eliz, emacs-devel

C-t's argument handling should be consistent with M-t and C-M-t.

Right now, the argument is equivalent to a repeat count.  That is
conceptually simple.  A priori we should prefer that.  However, if
users generally prefer your change, that would outweigh the advantage
of conceptual simplicity.

Thus, the next step is to ask people to try it and see how they
respond.

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-20 19:14     ` Stefan Monnier
@ 2007-08-07 20:56       ` Dieter Wilhelm
  0 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-08-07 20:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> With a prefix argument ARG C-t allows to *drag* a character ARG
>>>> characters away.  Even though the respective code is impressively
>>>> elegant I think it would be more helpful when one could *transpose*
>>>> two characters ARG characters away from point!
>
> I value also the consistency with the other transposition commands (like

I also value consistency, see for example
http://permalink.gmane.org/gmane.emacs.devel/75058

> M-t and C-M-t), so we should also consider whether your suggested behavior
> is better for those cases or not.

In this case I would sacrifice the consistency between them.
Because--at least for my typing habits--the reasons for transposing
chars and words/sexps are of a different kind.

Transposing of characters has more to do with defective (touch) typing
and confusing words/sexps sequences has probably to do with some
misunderstanding/confusion of the sentence/code structure.

Thanks
-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Suggestion for C-t (transpose-chars)
  2007-07-31 17:05         ` Richard Stallman
@ 2007-08-07 21:29           ` Dieter Wilhelm
  0 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-08-07 21:29 UTC (permalink / raw)
  To: rms; +Cc: eliz, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> C-t's argument handling should be consistent with M-t and C-M-t.

As I've already written to S. Monnier, I would break the nice
symmetry.  Since the reasons for using C-t and M-t, C-M-t are stemming
from different sources.

Transposing characters is typing related, confusing words and sexps is
probably another brain defect ;-).  Thus the effects are also mostly
different: Neighbouring characters are merely exchanged but the
structure of words/sexps seem often stronger disturbed.

> Right now, the argument is equivalent to a repeat count.  That is
> conceptually simple.  A priori we should prefer that.  However, if
> users generally prefer your change, that would outweigh the advantage
> of conceptual simplicity.

I understand that when nobody shows interest I shall drop the subject.
No problem with this, I consider it a wise approach.

>
> Thus, the next step is to ask people to try it and see how they
> respond.

I'll try at some stage, thanks.

------------------------------
P.S.: I'd also like to preserve the old behaviour of C-t with a
switch.  I seems that--for my typing style--in seldom cases it is
desirable as well.

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

end of thread, other threads:[~2007-08-07 21:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-20  9:43 Suggestion for C-t (transpose-chars) Dieter Wilhelm
2007-07-20 10:30 ` Mathias Dahl
2007-07-20 13:05   ` Dieter Wilhelm
2007-07-20 11:31 ` Eli Zaretskii
2007-07-20 18:55   ` Dieter Wilhelm
2007-07-20 19:14     ` Stefan Monnier
2007-08-07 20:56       ` Dieter Wilhelm
2007-07-20 20:06     ` Eli Zaretskii
2007-07-27  0:28       ` Dieter Wilhelm
2007-07-31 17:05         ` Richard Stallman
2007-08-07 21:29           ` Dieter Wilhelm

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).