[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Swapping Substrings
From: |
Philipp Stephani |
Subject: |
Re: Swapping Substrings |
Date: |
Sat, 31 Oct 2020 12:57:18 +0100 |
Am Sa., 31. Okt. 2020 um 11:22 Uhr schrieb jai-bholeki via Users list
for the GNU Emacs text editor <help-gnu-emacs@gnu.org>:
>
> I need to swap two sub-strings in a word. The idea is that with the cursor
> within a string, the two sub-strings get swapped.
>
> Examples:
>
> For the word ParSkip with point on the letter S, one gets SkipPar
>
> For the word Keybinding with point on the letter b, one gets bindingKey
Maybe something like this:
(defun my-transpose ()
(interactive "*")
(let ((point (point)))
(cl-destructuring-bind (begin . end) (bounds-of-thing-at-point
'word-strictly)
(goto-char begin)
(insert (delete-and-extract-region point end)))))