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: Tue, 16 Aug 2022 12:45:12 +0200 Message-ID: <86zgg4mpqf.fsf@gnu.org> References: <86tu6c4lg1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26182"; 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 Tue Aug 16 12:46:47 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 1oNu5v-0006dm-5s for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 12:46:47 +0200 Original-Received: from localhost ([::1]:48296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNu5t-0006a8-H1 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 06:46:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNu4x-0006Z3-Vl for help-gnu-emacs@gnu.org; Tue, 16 Aug 2022 06:45:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNu4x-0002Yr-Cj; Tue, 16 Aug 2022 06:45:47 -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=Ho+oajr3lTt/oLZfHz9AITbflxe+/jF3aI0k5hPbxOc=; b=cZKzzruLABK2t5+tqRGl QNfYtqHVcCq77N7zLUzTzRZK0Uu38KFJqMhEukn4sY5SzHnYf1lMEkSZsSY0HXt2sPUYS3JJC49nf 3FjA4QkjZvR0bo55sDEoYNtx4GWfsAq0DJIKgrKz8r1rVEXcNxgIVNevkXq+GwIdwP0/7bDc19x/5 ZIsCru4ce2n4hjhJlTIXWks/9stPyebf712q8dvOvDUslmTz1p+RIcmw2BpEJXy8A6D9VeeBxPKrC UxrGAqlWGkO73oafxKZg24xxUFiz7YFQMTYzBHmAvou9XPwlw2QATgwvFIAGvP2RNv6PTu/44gFX6 yi4Gqk8vPIeGPw==; Original-Received: from pd9fb77f7.dip0.t-ipconnect.de ([217.251.119.247]:57092 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNu4m-0005P1-4I; Tue, 16 Aug 2022 06:45:42 -0400 In-Reply-To: (uzibalqa@proton.me's message of "Tue, 16 Aug 2022 10:08:32 +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:138891 Archived-At: uzibalqa 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