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 09:16:59 +0000 Message-ID: References: <86tu6c4lg1.fsf@gnu.org> <86zgg4mpqf.fsf@gnu.org> <0ted8gWpziSeCqNIXIk-7J8IFrB2n29gZ5zJoBSzzCaLgig-oKvge9-s7T5Ss8Gbv2BxzrcSZjAUQg4pMD9HlPna-ETm22UNu6PVqZYLa18=@proton.me> <86wnb7xuln.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="7427"; mail-complaints-to="usenet@ciao.gmane.io" Cc: uzibalqa via Users list for the GNU Emacs text editor To: Arash Esbati Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 17 11:19:01 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 1oOFCW-0001nP-GG for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 11:19:00 +0200 Original-Received: from localhost ([::1]:58132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOFCV-0005FO-0l for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 05:18:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOFAq-0005FC-KT for help-gnu-emacs@gnu.org; Wed, 17 Aug 2022 05:17:20 -0400 Original-Received: from mail-40138.protonmail.ch ([185.70.40.138]:60971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOFAn-00061V-HP for help-gnu-emacs@gnu.org; Wed, 17 Aug 2022 05:17:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1660727830; x=1660987030; bh=hs2zF3SROYrz/RPF5iROWWR+vw+15I95HRuKIGyoZzU=; 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=CVxFxXmi/sJip+2eUNga0U0F7BaWWuOU1IPWzLsEogMqBUjgREOJZLdKfJoQrNOTV 3w0HLOUdUZhqywjqJsK//sbwFqVpM6RNKkGq/RfBAVpPhvk/kzBvmUk7s8v476vMAc 4lj8fktPyot+VOHxeTQU6CFXEs8CXBERuCaw7fsbOKRTp2rCVPubpVSECJylwvLpXe zjPM7tBKSMGD/zlILOrmwID7GS3l0v71XwFDV9q/7O4USINMs5zeoaUzndiIDAriKy yerFD+l3OAH2EB1ZrQw+TP7np6zs4dcDoCPas31yHgTc4bBOVDgdVJV8UvwyR/PGVk 4AIyQwFPzxISA== In-Reply-To: <86wnb7xuln.fsf@gnu.org> 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, 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:138899 Archived-At: Sent with Proton Mail secure email. ------- Original Message ------- On Wednesday, August 17th, 2022 at 6:16 AM, Arash Esbati wr= ote: > uzibalqa uzibalqa@proton.me writes: > > > What is left is to do is the ability to insert the letter `p' for media= l` ple' in a word. > > > Maybe something like this: > > (defun shorten-word-b () > "Shortens a word according to specific rules." > (interactive) > (let* ((bounds (bounds-of-thing-at-point 'word)) > (s (car bounds)) > (case-fold-search nil) > (e (make-marker)) > (p (point-marker))) > (when s > (set-marker e (cdr bounds)) > (goto-char s) > (cond > ;;----------------------------------------------- > ;; Insert `k' for words with initial ;;` cog', `col',` com', `con',` cor'= , `coun',` cum'. > ((looking-at (concat "\\<" > (regexp-opt '("cog" "col" "com" "con" "cor" "cum" "coun")))) > > (replace-match "k")) > > ;;----------------------------------------------- > ;; Insert `l' for words with final ;;` ley', `ily', and` ly'. > ((save-excursion > (re-search-forward (concat > (regexp-opt '("ley" "ily" "ly")) "\\>") > > e t)) > (replace-match "l")) > > ((save-excursion > (re-search-forward "ple" e t)) > (replace-match "l")) > > (t nil)) > (goto-char p)) > (set-marker e nil) > (set-marker p nil))) > > Best, Arash Trying the code upon the word "please" results in "pase" because you have not checked for mid-word in the final search.