[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shortening words with multiple rules
From: |
uzibalqa |
Subject: |
Re: Shortening words with multiple rules |
Date: |
Tue, 16 Aug 2022 10:08:32 +0000 |
------- Original Message -------
On Tuesday, August 16th, 2022 at 8:55 AM, Arash Esbati <arash@gnu.org> wrote:
> uzibalqa via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
> writes:
>
> > 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.
>
>
> Does this template help?
It does help a lot. How would a match at the end of word (matching "ley" "ily"
"ly") look like, with your scheme?
> (defun shorten-word ()
> "Shortens a word according to specific rules."
> (interactive)
> (let* ((bounds (bounds-of-thing-at-point 'word))
> (s (car bounds))
> (case-fold-search nil)
> (p (point-marker)))
> (when s
> (goto-char s)
> (cond ((looking-at (regexp-opt '("cog" "col" "com" "con"
> "cor" "cum" "coun")
> "\\<\\("))
> (replace-match "k"))
> ;; Other rules
> (t nil))
> (goto-char p))
> (set-marker p nil)))
>
> Best, Arash
- Shortening words with multiple rules, uzibalqa, 2022/08/15
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/16
- Re: 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, 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
- Re: Shortening words with multiple rules, Arash Esbati, 2022/08/17
- Re: Shortening words with multiple rules, uzibalqa, 2022/08/17