* Shortening words in a selected region
@ 2022-08-13 15:12 uzibalqa via Users list for the GNU Emacs text editor
0 siblings, 0 replies; only message in thread
From: uzibalqa via Users list for the GNU Emacs text editor @ 2022-08-13 15:12 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Have the following function to shorten specific words, inserting `k' for words with initial `cog', `col', `com', `con',
`cor', `coun', `cum'. The word "corrupt" then becomes "krupt". One simply puts the cursor point on a word and
execute the function using "M-x shorten-word".
I would like to have an equivalent function that works on words in a selected region this time round.
(defun shorten-word ()
"Shortens certain words by introducing the letter 'k'."
(interactive)
(let* ( (bounds (bounds-of-thing-at-point 'word))
(word (buffer-substring (car bounds) (cdr bounds)))
(point (point)) )
(goto-char (car bounds))
(delete-char (length word)) (insert (replace-regexp-in-string "\\<\\(co[glmnr]\\|coun\\|cum\\)" "k" word))
(goto-char point)))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-13 15:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-13 15:12 Shortening words in a selected region uzibalqa via Users list for the GNU Emacs text editor
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).