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 10:55:10 +0200 Message-ID: <86tu6c4lg1.fsf@gnu.org> References: 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="27737"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 Cc: uzibalqa To: uzibalqa via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 16 10:56:49 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 1oNsNV-00077E-M4 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 10:56:49 +0200 Original-Received: from localhost ([::1]:37772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNsNT-0006pp-Pb for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 04:56:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNsME-0006nh-0w for help-gnu-emacs@gnu.org; Tue, 16 Aug 2022 04:55:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNsMC-0007i8-RG; Tue, 16 Aug 2022 04:55:29 -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=lSXhZFgX4d/MHeY4XHUp+hoe7EEgDf1moT1iOs8K6FQ=; b=SJ0SmGAgmcFRXXiz+Tm6 b9qTLRXUU2x83S8C0JRY16m2+NoZ05238PVrKLArTpK/ORbrB+qQTL7ENQHpYkGBhSu2mjlaHNrwO sPqANUt57A4riizlYaKgWDTg/r4JLo+wclRiSYZ6KuatruO9ZEZJM+12AsFpekJDC5ULBZMa6tZM6 o3jVMg7wnbQ6IXp82/0Sakz55a7uXd64XlnV6v4BMC7gwG4TXxmHcvejW7HHFeMghzcINrCdl2aQC oKKW+rO6S6Hjz3PxdKZvkC1kWVWilUlbIPmoHeD7eTAzF0WU9lBQnkXk2fhJV5PTH7xSrpkxcFrWU fsqXSfJrCKTcYg==; Original-Received: from pd9fb77f7.dip0.t-ipconnect.de ([217.251.119.247]:57516 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNsMC-0001lU-28; Tue, 16 Aug 2022 04:55:28 -0400 In-Reply-To: (uzibalqa via Users list for the's message of "Tue, 16 Aug 2022 00:49:11 +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:138889 Archived-At: uzibalqa via Users list for the GNU Emacs text editor writes: > The following function shortens words according to specific rules. The sp= ecific > rule for the function is to replace a word beginning with the character s= equence > `cog', `col', `com', `con', `cor', `coun', or `cum', and replacing the ma= tch by > the letter `k'=E2=80=8B. > > How can I have a function that is able to perform a number of rules rathe= r than > just a single one. Does this template help? (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")) ;; Other rules (t nil)) (goto-char p)) (set-marker p nil))) Best, Arash