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 04:18:09 +0000 Message-ID: References: <86tu6c4lg1.fsf@gnu.org> <86zgg4mpqf.fsf@gnu.org> <0ted8gWpziSeCqNIXIk-7J8IFrB2n29gZ5zJoBSzzCaLgig-oKvge9-s7T5Ss8Gbv2BxzrcSZjAUQg4pMD9HlPna-ETm22UNu6PVqZYLa18=@proton.me> 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="8020"; 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 06:19:11 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 1oOAWN-0001wY-2Q for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 06:19:11 +0200 Original-Received: from localhost ([::1]:53036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOAWL-0005O9-HL for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 00:19:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOAVi-0005O1-5H for help-gnu-emacs@gnu.org; Wed, 17 Aug 2022 00:18:30 -0400 Original-Received: from mail-4325.protonmail.ch ([185.70.43.25]:11487) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOAVe-0006Jw-2I; Wed, 17 Aug 2022 00:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1660709902; x=1660969102; bh=8QPF8AAG2igkuzXJKeD0flXSoKbCqaYETdI7Tpz/+c4=; 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=bXWDCYSB23u5j2DItVaHkBAkKJ098vWU55VIDBcMigES2CBpoLGju3ftBKV1JxeX7 LUH9AeW72K6fcUifi7uKsWqUMBf6FelXwpS0NBsb8QHRHZsRFRXVu/ZhTrUs+PxedQ QbCv1H3KaY0jFtXBI2CZlQbHCk/RmXkJMy2MkBoEDaivDTnxg9a6xX15SCtA5NPjpw pCTJZkPacZDTvigDg5v/id8K05N4qJ1Leu4MuR7C0DVtz0nNpHoM2iKe8gtOZEqMOo dUhDvb/345G+GyoYI50l0qnKzUQE2Y5qGqDouhenvrMeNvb8uXMJ+iDSRmHKVZGLEd oINyMJCFBzPDw== In-Reply-To: <0ted8gWpziSeCqNIXIk-7J8IFrB2n29gZ5zJoBSzzCaLgig-oKvge9-s7T5Ss8Gbv2BxzrcSZjAUQg4pMD9HlPna-ETm22UNu6PVqZYLa18=@proton.me> Feedback-ID: 52887082:user:proton Received-SPF: pass client-ip=185.70.43.25; envelope-from=uzibalqa@proton.me; helo=mail-4325.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, 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:138896 Archived-At: Arash, I have come up with a variation of what you wrote (defun shorten-word-b () "Shortens a word according to specific rules." (interactive) (let* ((bounds (bounds-of-thing-at-point 'word)) =09 (s (car bounds)) =09 (case-fold-search nil) =09 (p (point-marker))) (when s (goto-char s) (cond ;;----------------------------------------------- ;; Insert `k' for words with initial ;; `cog', `col', `com', `con', `cor', `coun', `cum'. ((looking-at (concat "\\<" =09 (regexp-opt '("cog" "col" "com" "con" "cor" "cum" "coun")))) =09 (replace-match "k")) ;;----------------------------------------------- ;; Insert `l' for words with final ;; `ley', `ily', and `ly'. ((search-forward-regexp (concat (regexp-opt '("ley" "ily" "ly")) "\\>")) =09(replace-match "l")) (t nil)) (goto-char p)) (set-marker p nil))) What is left is to do is the ability to insert the letter `p' for medial `p= le' in a word. Medially means that the character sequence appears inside the word with at = least one character on each side op the character sequence `ple`. An example would be the word= complementary, where "ple" occurs from character 4 to character 7.