unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Christopher Dimech <dimech@gmx.com>
To: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Transpose Sentences but stay at point
Date: Fri, 30 Oct 2020 00:26:51 +0100	[thread overview]
Message-ID: <trinity-860fddda-3612-4e26-8998-04f86e257d42-1604014011162@3c-app-mailcom-bs12> (raw)

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






                 reply	other threads:[~2020-10-29 23:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=trinity-860fddda-3612-4e26-8998-04f86e257d42-1604014011162@3c-app-mailcom-bs12 \
    --to=dimech@gmx.com \
    --cc=help-gnu-emacs@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.
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).