[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Shortening words with multiple rules
From: |
uzibalqa |
Subject: |
Shortening words with multiple rules |
Date: |
Tue, 16 Aug 2022 00:49:11 +0000 |
The following function shortens words according to specific rules. The specific
rule for the function is to replace a word beginning with the character sequence
`cog', `col', `com', `con', `cor', `coun', or `cum', and replacing the match by
the letter `k'.
How can I have a function that is able to perform a number of rules rather than
just a single one.
(defun shorten-word ()
"Shortens a word according to specific rules."
(interactive)
(let* ( (bounds (bounds-of-thing-at-point 'word))
(word (buffer-substring (car bounds) (cdr bounds)))
(point (point))
(impl "[RX]") )
(goto-char (car bounds)) (delete-char (length word))
(cond
(equal translate-regexps "[RX]")
(insert (replace-regexp-in-string
(rx (seq word-start
(or (seq "co" (any "glmnr")) "coun" "cum")))
"k" word))
(t
(insert (replace-regexp-in-string "\\<\\(co[glmnr]\\|coun\\|cum\\)" "k" word))))
(goto-char point)))
- Shortening words with multiple rules,
uzibalqa <=
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/16
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/16
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/16
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/16
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/16
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/17
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/17
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/17
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/17
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/17