From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. Date: Mon, 27 Sep 2021 16:08:33 +0200 Message-ID: References: <878rzj7xt8.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29359"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs , Hongyi Zhao To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 27 16:16:21 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 1mUrQa-0007SW-MH for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 16:16:21 +0200 Original-Received: from localhost ([::1]:45818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUrQY-0007l4-8s for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 10:16:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUrJ9-00068V-Q7 for help-gnu-emacs@gnu.org; Mon, 27 Sep 2021 10:08:41 -0400 Original-Received: from mail-vi1eur05olkn2070.outbound.protection.outlook.com ([40.92.90.70]:5600 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUrJ7-0002tm-IS for help-gnu-emacs@gnu.org; Mon, 27 Sep 2021 10:08:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8Dmv0Ao9YGJPY99Jkz11lZsXxP8bjjTTmDvfOL7Rvy6W0HvoRbem9gzRYa+4Mn5ZJd4jySpMEE2Mig+j05xIwjh7x+NvRRBFbUuXh/8FVRLUDKIERdW+yz27aTL6m5lZYQvASJr308MqVGpr9qFPPVP2+fCB/Tho9bvYH9x1xHUELkFuTCtrC54AUp7ItmeDWH6Agny+md8XHFRlUtt35WHeMzLSsC3acwZTmZyhosmMLNpntPJkUHsCQ7f0afq4Ek2lWZcqWkEXCePmcaK8UUMZDzVZwrZiNBnCVL4p0EwQznIYDB8q0UBN+4VBAONgJPvkht2tflFGey84etLFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=iI5InlkJ2oTU06WQCUyEN5sFjDSRhBoRE1GEOro4E+8=; b=BcT93WEdTxA97bKsw0Ic3Wh3618pPMW1AJi2VmE3t5k1/3VOHnE7SGt6qCYSdBPYSPyCCd8ofcUQrgsFi6BsoEJV9v/LpV0m0URDwmE1jbrQT4IDpzdCLkrcEYL0USGsInPJzLQelPH+r/nT7NqZPIn5yHhOiNs5S6llHuMeDYbqEri50rMj6UmXpvH6liILM/CnpxblJOOnj4pitvDrmuT2kE4cVe2P2NkAGhElh0yiMohMm8Wo6gaYkCiCgRXoJWjaVh7tdNb0iYaq8aHZBVojL38wwHg/bjNeCY+7e4Ncq6HNQu5NW8eK6X3A7Qua3xZtc7XwUUDYR7G8RPZFSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iI5InlkJ2oTU06WQCUyEN5sFjDSRhBoRE1GEOro4E+8=; b=GG6rPcGHV+6gSTP2ifi9HAAUm5ADtSMOwzos/8OxcUQHb8+wxfGJJeikFdZWfDbf69nSU7aSzvjAuFezeS6SgRXmCudI+M+YzvP3vDo7dAxJEUkkgnnVZoM2HhVINuz97WadWdvmN5F3pYR41P2x/wbbtwalJOZa2aGhu6IXwV/AnpNQkftv6rU5bWby/yxvbCpjJM3RN6txMz5hobfnD+xrrMNeafseLW3rIE9UqEomlhUGMqo5T7eNnL6KHG5JBYa6GG6gDkT1g+0pExeQazWV6ZG8CW+rCUHZOizE/25VEKcGCjo6dSepISo+khucrU5I8yCXb5ScnPVm8/b41g== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB3665.eurprd09.prod.outlook.com (2603:10a6:208:182::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Mon, 27 Sep 2021 14:08:35 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4544.021; Mon, 27 Sep 2021 14:08:34 +0000 In-Reply-To: (Arthur Miller's message of "Mon, 27 Sep 2021 03:03:16 +0200") X-TMN: [4OkNt67NHFNIannSKwU0+mHZZmfCgeWC] X-ClientProxiedBy: HE1PR09CA0063.eurprd09.prod.outlook.com (2603:10a6:7:3c::31) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87czoum7q6.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by HE1PR09CA0063.eurprd09.prod.outlook.com (2603:10a6:7:3c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 14:08:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5cc0621-a60d-4cd0-9749-08d981c04b2c X-MS-TrafficTypeDiagnostic: AM0PR09MB3665: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UO+KhFAEfTV8Krt63Y8rRau58Fna/eMC/t6tGniyLjp5fKvKTq2+BfSCCxcW+8A/c6oh+sAy86vCRBCY/XhElCwY/MxUVtQr7keC53X3Eo3/1CHyOpWjlx/+z385B9R2ofTNBQY6M43/LgBElvznK+9KxJwwUCgDDxw/tNOTx9Vm4jqRevFmy5Jh4cLFQmk+gDHqnAwTK61rvZjG0O71Q6x5hg3ywiGzwHB9TkSzhLKoVW3uDc8lbT8puQtrH6sdLXW89E8gZYXVPN9GvOb5goRgGraB2DfyhtH9Xt/ese9WjAFxL0nFizqtGWpBWnNbvjHeJicX7hzMeSwBOBpokAFpAhwXvoAmca+46i5ftjIjPsIHlH9F4OY89w0ir/DK0LCjXnxi5Xstk4v/UMHpu6dNOTTNxY+CjiwrMRZhlXUw9QqSqO+uybELXdpfZob2 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ym4/8hl60EUHU46gXt3An5uEMPV9c7/r6oZVcKqPYO/gF+IPDQ+udh4646R3/mXGdwEr6d5ufeP/WuHwWCFAmRjjbr0NVtZVlEdl8BCoMrILfUbEHj7bzrSgZa0XmcRy8/0n0T33C5QQV/kTvlAgKw== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: a5cc0621-a60d-4cd0-9749-08d981c04b2c X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 14:08:34.9013 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3665 Received-SPF: pass client-ip=40.92.90.70; envelope-from=arthur.miller@live.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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:133293 Archived-At: Arthur Miller writes: > Michael Heerdegen writes: > >> Hongyi Zhao writes: >> >>> Imagine I've got the following in a text file opened under Emacs: >>> >>> some 34 >>> word 30 >>> another 38 >>> thing 59 >>> to 39 >>> say 10 >>> here 47 >>> >>> and I want to turn into this, adding 1 to every number made of 2 digits: >>> >>> some 35 >>> word 31 >>> another 39 >>> thing 60 >>> to 40 >>> say 11 >>> here 48 >> >> You might want to give Calc a try for such things. It doesn't perfectly >> handle the editing part though since it doesn't know about rectangle >> commands (AFAICT - at least for insertion). >> >> So here is how I would do it: >> >> - mark the rectangular region spanning the numbers >> - `C-x * r': this will grab the number column as a matrix and pop up >> Calc >> - `1 RET +': will add 1 to all entries >> >> You now have the result as a matrix. What you have to do now manually >> using conventional rectangle commands is to kill the original numbers >> from the buffer (they are already marked, so `C-x r k'), and then kill >> and yank the numbers as rectangle from the Calc buffer. >> >> Calc also allows to add numbers in a row or column in any buffer in a >> similarly easy way. The Calc tutorial has some examples doing such >> things. >> >> Michael. > > And I was of course wrong :-) > > And sent mail again by misstake ... :-) > > Time for the sleep With some help from the reddit: | some | 34 | 35 | | word | 30 | 31 | | another | 38 | 39 | | thing | 59 | 60 | | to | 39 | 40 | | say | 10 | 11 | | here | 47 | 48 | #+TBLFM: $3='(1+ '$2);N It was even easier than I thought :).