From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arash Esbati Newsgroups: gmane.emacs.help Subject: Re: Shortening words with multiple rules Date: Wed, 17 Aug 2022 08:16:52 +0200 Message-ID: <86wnb7xuln.fsf@gnu.org> References: <86tu6c4lg1.fsf@gnu.org> <86zgg4mpqf.fsf@gnu.org> <0ted8gWpziSeCqNIXIk-7J8IFrB2n29gZ5zJoBSzzCaLgig-oKvge9-s7T5Ss8Gbv2BxzrcSZjAUQg4pMD9HlPna-ETm22UNu6PVqZYLa18=@proton.me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6677"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 Cc: 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 08:18:45 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 1oOCO5-0001UQ-GO for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 08:18:45 +0200 Original-Received: from localhost ([::1]:42238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOCO3-0008LD-Oe for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 02:18:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOCMY-0008Fz-0U for help-gnu-emacs@gnu.org; Wed, 17 Aug 2022 02:17:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:42118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOCMX-00073o-FQ; Wed, 17 Aug 2022 02:17:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=NaNEy+/DFbsEVDKJ4ViegvNzyhkrNpYAMlp1Y6PcUB8=; b=XK3TbUM7cRWJ6tycALcm DBl8I6QyqjuMMyuv1VA+1EJbmdcucO33N1FVw31jo6tGS39hP7iFWoS8XRHZPAuW2SsheOewyuLsj 8Npv6uKF7SpUP0IpWFs6TL3rw1+zUi1ZeY79W8L8zTszb/McXhpv2/V1tgGfP5npRBEM0/Fz9wIv0 WQjTEh+ekInAUx2qI/arKIPFgIjFzLsp3tsAoTqOHchZQs1vYwKJrtOVXMlJ8olbPNaKZ2o4dpXft jOZE3nDHcBC6u9nd9knYVjQ+45VSl/I0MeJyD35rbIF4eEXa7W+bDJScXkskAWpWecei5+0ddMH3y 4Tb6F9Nu2MAgcA==; Original-Received: from pd9fb77f7.dip0.t-ipconnect.de ([217.251.119.247]:62298 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOCMX-000697-00; Wed, 17 Aug 2022 02:17:09 -0400 In-Reply-To: (uzibalqa@proton.me's message of "Wed, 17 Aug 2022 04:18:09 +0000") 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:138897 Archived-At: uzibalqa writes: > What is left is to do is the ability to insert the letter `p' for > medial `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