[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Transpose Sentences but stay at point
From: |
Christopher Dimech |
Subject: |
Transpose Sentences but stay at point |
Date: |
Fri, 30 Oct 2020 00:26:51 +0100 |
Dear Compeers,
I am writing a function to Transpose Sentences but keep at same point
in the sentence, rather than going to the end or the beginning after
the transpose is completed.
Have put the following code:
(defun transpose-stc--impl (arg)
---(let ((bounds (bounds-of-thing-at-point 'sentence)))
------(when bounds
----------(let*
-------------( (pt-init (point))
---------------(pt-end-of-stc (cdr bounds))
---------------(pt-offset (- pt-init pt-end-of-stc))
---------------(pt-transpose
------------------(save-excursion
---------------------;; Without this, the first character will move the
previous word.
---------------------(goto-char pt-end-of-stc)
---------------------(if
------------------------;;
------------------------(condition-case err
---------------------------(progn ; No error
------------------------------(transpose-sentences arg)
------------------------------t
---------------------------)
---------------------------(message err)
-------------------------)
-------------------------;;
-------------------------(+ (point) pt-offset)
-------------------------;;
-------------------------nil
---------------------)
------------------)
---------------)
-------------)
-------------(when pt-transpose
----------------(goto-char pt-transpose))
-------------)
--------)
----)
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Transpose Sentences but stay at point,
Christopher Dimech <=