help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shortening words in region


From: uzibalqa
Subject: Shortening words in region
Date: Sat, 13 Aug 2022 16:31:33 +0000

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]