From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Suggestion for C-t (transpose-chars)
Date: Fri, 27 Jul 2007 02:28:08 +0200 [thread overview]
Message-ID: <874pjq4rmv.fsf@debby.local.net> (raw)
In-Reply-To: <u8x9aq1pv.fsf@gnu.org> (Eli Zaretskii's message of "Fri\, 20 Jul 2007 23\:06\:36 +0300")
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
next prev parent reply other threads:[~2007-07-27 0:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2007-07-31 17:05 ` Richard Stallman
2007-08-07 21:29 ` Dieter Wilhelm
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=874pjq4rmv.fsf@debby.local.net \
--to=dieter@duenenhof-wilhelm.de \
--cc=eliz@gnu.org \
--cc=emacs-devel@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).