From: Christopher Dimech <dimech@gmx.com>
To: moasenwood@zoho.eu
Cc: help-gnu-emacs@gnu.org
Subject: Re: Emacs Function to add dashes to leading spaces in a Selected Region
Date: Fri, 30 Oct 2020 04:17:37 +0100 [thread overview]
Message-ID: <trinity-3b3d494e-f219-42ee-8a4d-fcb6b9c63e11-1604027857934@3c-app-mailcom-bs12> (raw)
In-Reply-To: <87d010saly.fsf@zoho.eu>
I figured that I can use exactly the same function for transposing words,
to transpose sentences.
But currently I am just copying the code and replacing
(transpose-words arg)
with
(transpose-sentences arg)
I need assistance so that I could have just one function that can do both things.
(defun transpose-words--impl (arg)
---(let ((Wrd-Bounds (bounds-of-thing-at-point 'word)))
------;; ----------------------------------------------------------------
------(when Wrd-Bounds
---------(let*
------------( (Beg (point))
--------------(End (cdr Wrd-Bounds))
--------------(Shift (- Beg End))
--------------;; --------------------------------------------------------
--------------(Cursor-Psn
-----------------(save-excursion
--------------------(goto-char End) ; [#A]
--------------------(if
-----------------------;;
-----------------------(condition-case err
--------------------------(progn ; No error
----------------------------(transpose-words arg)
----------------------------t
--------------------------)
--------------------------(message err)
-----------------------)
-----------------------;;
-----------------------(+ (point) Shift)
-----------------------;;
-----------------------nil
--------------------)
-----------------)
--------------)
--------------;; --------------------------------------------------------
------------)
------------(when Cursor-Psn
---------------(goto-char Cursor-Psn)
------------)
---------)
------)
------;;-----------------------------------------------------------------
---) ; let bounds (start and end locations of word)
)
(defun transpose-wrd-forward ()
(interactive)
(transpose-words--impl 1)
)
(defun transpose-wrd-backward ()
(interactive)
(transpose-words--impl -1)
)
(global-set-key (kbd "M-H-<right>") #'transpose-stc-forward)
(global-set-key (kbd "M-H-<left>") #'transpose-stc-backward)
> Sent: Friday, October 30, 2020 at 3:36 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Emacs Function to add dashes to leading spaces in a Selected Region
>
> Christopher Dimech wrote:
>
> > I need an Emacs Function to add dashes to leading spaces in
> > a Selected Region. Require help to do this thing.
>
> Reading your post, "Transpose Sentences but stay at point", it would
> be helpful if your function could also have a REVERSE option.
Good point
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
next prev parent reply other threads:[~2020-10-30 3:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 23:34 Emacs Function to add dashes to leading spaces in a Selected Region Christopher Dimech
2020-10-30 0:12 ` Stephen Berman
2020-10-30 2:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-30 3:17 ` Christopher Dimech [this message]
2020-10-30 8:00 ` tomas
2020-10-30 14:28 ` Christopher Dimech
2020-10-31 20:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-11-05 3:15 ` David Masterson
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-3b3d494e-f219-42ee-8a4d-fcb6b9c63e11-1604027857934@3c-app-mailcom-bs12 \
--to=dimech@gmx.com \
--cc=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/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).