From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.help Subject: Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. Date: Thu, 23 Sep 2021 10:10:51 +0000 Message-ID: <0ece9c42fd90dd5e62ef@heytings.org> References: <0e97aad3-ca78-8a5a-2ecf-2e4f5205477d@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30320"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 23 12:11:54 2021 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 1mTLhq-0007fh-Db for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 12:11:54 +0200 Original-Received: from localhost ([::1]:34768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTLhp-0004ns-B4 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 06:11:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTLgt-0004kL-8j for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 06:10:55 -0400 Original-Received: from heytings.org ([95.142.160.155]:47958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTLgr-0004wM-LR for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 06:10:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1632391851; bh=L+k7SPl4NDoJEsEu6RRQqtbT7vWXcsazmy9HSJFOQ7Y=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=IGpSfOQrsJjm1SEq34EQa/cvbB2UML0kQyGfHCe30E8PRUiX/qnnAkvCvHM+uvwLI 1F+kPhzIeTmRS2XNxPUBUmVj27AZ8Tftqk7G4sK0C+cUdTo+q1mLfiZ6v5QzEgi3Es UNdCjff71pgr7kPyKP1U1M0G06C5KpjpPxBxv/Xh+SXU9Uo6x5p99pfyX0U4a8Fd1R +RDNlryYcoBNvAQ2TFLKrJtGvVGp/rirzF5r7V5bpS6hf/ifnAzqmHPDKfOrJOVyEZ tfyH4moEJ3tp4Vb+FwJDjb+SiO437cnJEfOkI6RVnJ/Y8Ayvi2KaymZqmrSNnXodXu HunjdwpaCV1Ew== In-Reply-To: Received-SPF: pass client-ip=95.142.160.155; envelope-from=gregory@heytings.org; helo=heytings.org 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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:133176 Archived-At: > > But how to increase/decrease in steps that are not equal to 1? > And this is exactly the point of macros: you can easily define another macro with the parameters you now need. E.g. if you want to multiply the numbers by 2 you just have to change (insert (format "%d" (1+ (number-at-point)))) into (insert (format "%d" (* 2 (number-at-point)))) Of course, if this is something you regularly need, it's better to use a defun, or to record the macro in your init file by copy-pasting the result of M-x insert-kbd-macro.