unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Transpose Sentences but stay at point
@ 2020-10-29 23:26 Christopher Dimech
  0 siblings, 0 replies; only message in thread
From: Christopher Dimech @ 2020-10-29 23:26 UTC (permalink / raw)
  To: Help Gnu Emacs

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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-29 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 23:26 Transpose Sentences but stay at point Christopher Dimech

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