From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: uzibalqa Newsgroups: gmane.emacs.help Subject: Re: Shortening words with multiple rules Date: Wed, 17 Aug 2022 00:09:35 +0000 Message-ID: <0ted8gWpziSeCqNIXIk-7J8IFrB2n29gZ5zJoBSzzCaLgig-oKvge9-s7T5Ss8Gbv2BxzrcSZjAUQg4pMD9HlPna-ETm22UNu6PVqZYLa18=@proton.me> References: <86tu6c4lg1.fsf@gnu.org> <86zgg4mpqf.fsf@gnu.org> Reply-To: uzibalqa Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1724"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Arash Esbati , uzibalqa via Users list for the GNU Emacs text editor To: uzibalqa Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 17 02:10:38 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO6dp-0000Gn-5V for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 02:10:37 +0200 Original-Received: from localhost ([::1]:50680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO6do-0006aA-5y for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 20:10:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO6cz-0006Zt-OH for help-gnu-emacs@gnu.org; Tue, 16 Aug 2022 20:09:45 -0400 Original-Received: from mail-40138.protonmail.ch ([185.70.40.138]:64325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO6cw-0005i2-A8 for help-gnu-emacs@gnu.org; Tue, 16 Aug 2022 20:09:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1660694980; x=1660954180; bh=1uX2BwU0bR3Infh25Cin67u/0kGZKEm7nvSHSMGBHTM=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=FDWttrX9TlJcheiIU6EkbUeD5+k25Ngq64NDPVPLDfm+iaQ18ANkw0p4qQOmd1ckb +uz2uaSy1UnuwdBRmHIylmWbTs3YkLfO3eIGbYTrRs2KUZM6gYDQSU74E+0u858GUX N8TYECUn8Fhma34zYhtHu6c1fzxFkr5MRQMGoddgDzkUgkcWA/CWQe5uGbovvL8bWJ TGrzc9oIud+a6Ik0okrGu+RiEcgh+vMroIb9h9yoUjxRqmmq99DzBcoYnLbF/jpjOV 1ipPD5KyW94a141jxg9/zZpqFajnEoHGG6eRv+/MmFFtgVCbSetnqr+tz8u2CN710Z qLxJI6H4ImqSA== In-Reply-To: Feedback-ID: 52887082:user:proton Received-SPF: pass client-ip=185.70.40.138; envelope-from=uzibalqa@proton.me; helo=mail-40138.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, TO_EQ_FM_DIRECT_MX=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138894 Archived-At: ------- Original Message ------- On Tuesday, August 16th, 2022 at 7:06 PM, uzibalqa wro= te: > ------- Original Message ------- > On Tuesday, August 16th, 2022 at 10:45 AM, Arash Esbati arash@gnu.org wro= te: > > > > > 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".