* Shortening words in region
@ 2022-08-13 16:31 uzibalqa via Users list for the GNU Emacs text editor
2022-08-13 17:42 ` Jean Louis
0 siblings, 1 reply; 6+ messages in thread
From: uzibalqa via Users list for the GNU Emacs text editor @ 2022-08-13 16:31 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Have been working on shortening words. But doing so on a word by word basis is quite slow. Thusly I am writing
a version that accepts a selected region.
This function uses a selected region, then changes initial parts oy words (replacing matching cog, col, com, con, cor, coun, and cum
with the letter "k".
What improvements can I do to it?
(defun shorten-region (beg end)
"TODO"
(interactive "r")
(narrow-to-region beg end)
(goto-char (point-min))
(insert (replace-regexp "\\<\\(co[glmnr]\\|coun\\|cum\\)" "k" nil beg end)) )
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shortening words in region
2022-08-13 16:31 Shortening words in region uzibalqa via Users list for the GNU Emacs text editor
@ 2022-08-13 17:42 ` Jean Louis
2022-08-13 18:19 ` uzibalqa
0 siblings, 1 reply; 6+ messages in thread
From: Jean Louis @ 2022-08-13 17:42 UTC (permalink / raw)
To: uzibalqa; +Cc: help-gnu-emacs@gnu.org
* uzibalqa via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-08-13 19:34]:
> Have been working on shortening words. But doing so on a word by
> word basis is quite slow. Thusly I am writing a version that accepts
> a selected region.
>
> This function uses a selected region, then changes initial parts oy
> words (replacing matching cog, col, com, con, cor, coun, and cum
> with the letter "k".
(rx (zero-or-more (or "col" "cog" "com" "con" "cor" "coun" "cum"))) ⇒ "\\(?:c\\(?:o\\(?:un\\|[glmnr]\\)\\|um\\)\\)*"
{C-h f rx RET}
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shortening words in region
2022-08-13 17:42 ` Jean Louis
@ 2022-08-13 18:19 ` uzibalqa
2022-08-13 18:22 ` uzibalqa
0 siblings, 1 reply; 6+ messages in thread
From: uzibalqa @ 2022-08-13 18:19 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs@gnu.org
Sent with Proton Mail secure email.
------- Original Message -------
On Saturday, August 13th, 2022 at 5:42 PM, Jean Louis <bugs@gnu.support> wrote:
> * uzibalqa via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-08-13 19:34]:
>
> > Have been working on shortening words. But doing so on a word by
> > word basis is quite slow. Thusly I am writing a version that accepts
> > a selected region.
> >
> > This function uses a selected region, then changes initial parts oy
> > words (replacing matching cog, col, com, con, cor, coun, and cum
> > with the letter "k".
>
>
> (rx (zero-or-more (or "col" "cog" "com" "con" "cor" "coun" "cum"))) ⇒ "\\(?:c\\(?:o\\(?:un\\|[glmnr]\\)\\|um\\)\\)*"
>
> {C-h f rx RET}
>
> --
> Jean
Like below?
(insert (replace-regexp-in-string
(rx (zero-or-more (or "col" "cog" "com" "con" "cor" "coun" "cum")))
"k" word))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shortening words in region
2022-08-13 18:19 ` uzibalqa
@ 2022-08-13 18:22 ` uzibalqa
2022-08-13 18:32 ` Jean Louis
0 siblings, 1 reply; 6+ messages in thread
From: uzibalqa @ 2022-08-13 18:22 UTC (permalink / raw)
To: uzibalqa; +Cc: Jean Louis, help-gnu-emacs@gnu.org
Sent with Proton Mail secure email.
------- Original Message -------
On Saturday, August 13th, 2022 at 6:19 PM, uzibalqa <uzibalqa@proton.me> wrote:
>
>
>
>
>
> Sent with Proton Mail secure email.
>
>
> ------- Original Message -------
> On Saturday, August 13th, 2022 at 5:42 PM, Jean Louis bugs@gnu.support wrote:
>
>
>
> > * uzibalqa via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-08-13 19:34]:
> >
> > > Have been working on shortening words. But doing so on a word by
> > > word basis is quite slow. Thusly I am writing a version that accepts
> > > a selected region.
> > >
> > > This function uses a selected region, then changes initial parts oy
> > > words (replacing matching cog, col, com, con, cor, coun, and cum
> > > with the letter "k".
> >
> > (rx (zero-or-more (or "col" "cog" "com" "con" "cor" "coun" "cum"))) ⇒ "\\(?:c\\(?:o\\(?:un\\|[glmnr]\\)\\|um\\)\\)*"
> >
> > {C-h f rx RET}
> >
> > --
> > Jean
Would you know how to apply rx to the following?
"\\(ly\\|ily\\|ley\\)\\>"
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-13 19:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-13 16:31 Shortening words in region uzibalqa via Users list for the GNU Emacs text editor
2022-08-13 17:42 ` Jean Louis
2022-08-13 18:19 ` uzibalqa
2022-08-13 18:22 ` uzibalqa
2022-08-13 18:32 ` Jean Louis
2022-08-13 19:01 ` uzibalqa
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).