[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: |
Wed, 17 Aug 2022 00:09:35 +0000 |
------- Original Message -------
On Tuesday, August 16th, 2022 at 7:06 PM, uzibalqa <uzibalqa@proton.me> wrote:
> ------- Original Message -------
> On Tuesday, August 16th, 2022 at 10:45 AM, Arash Esbati arash@gnu.org wrote:
>
>
>
> > uzibalqa uzibalqa@proton.me writes:
> >
> > > It does help a lot. How would a match at the end of word (matching
> > > "ley" "ily" "ly") look like, with your scheme?
> >
> > Maybe something like this:
> >
> > (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"))
> > ((looking-at (concat "[[:alpha:]]*?"
> > "\\("
> > (regexp-opt '("ley" "ily" "ly"))
> > "\\)\\>"))
> >
> > (replace-match "X" nil nil nil 1))
> > (t nil))
> > (goto-char p))
> > (set-marker p nil)))
> >
> > Best, Arash
Would like to allow hyphen in words and punctuation
Have started with
((looking-at (concat "[[:alpha:]]+[-]?"
"\\(" (regexp-opt '("ley" "ily" "ly")) "\\)\\>"))
(replace-match "l" nil nil nil 1))
But this replaced "family" with just the letter "l".
- 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, 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 <=
- 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