From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Platon Pronko Newsgroups: gmane.emacs.help Subject: Re: Iterating over buffer lines Date: Sat, 17 Jun 2023 08:10:33 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20397"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: Joshua Lambert , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 17 02:11:15 2023 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 1qAJX9-0005En-Pc for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 17 Jun 2023 02:11:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAJWd-0006uL-DQ; Fri, 16 Jun 2023 20:10:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAJWc-0006uB-9B for help-gnu-emacs@gnu.org; Fri, 16 Jun 2023 20:10:42 -0400 Original-Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qAJWa-0004ns-Lo for help-gnu-emacs@gnu.org; Fri, 16 Jun 2023 20:10:42 -0400 Original-Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-54fb3c168fcso1034419a12.0 for ; Fri, 16 Jun 2023 17:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686960639; x=1689552639; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+5ZBo/NT86rNUQcDtLwiXH8W4506pQOqxPLZJ2ROdTg=; b=CmLCsld4dDEmTLQE6Ux1DTDJdADvS+zjpc5zvxZmuOXUeIs5DAdiasPflnBRsp+W8u SL761YF3Eaz/0uVPZvMzzn07OjeZ7GVvGG+PUncJa77rRlI/S+O8XtqL3Q4cMtrpll1P yNYmxJiGsKxajeeBq7/Wcrb7ImbJ52cfnkLwhvW9ZszSFopBVsX7j8FCGTBHB/m9nt8o U1KEHTw2HNmoD8d6QTVYZ8ojBVASbjRG8wVMjFpULstRZ6ug/1cbMLqAshb0qMrI6h8J FmLGKR/rwe3nWKcezWE1lICOpNJYWFqeNhjvaLd6GUocGxLluamggY5khBz+hlGOtrnu kvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686960639; x=1689552639; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+5ZBo/NT86rNUQcDtLwiXH8W4506pQOqxPLZJ2ROdTg=; b=d952p5wjUtC6CwC+H79kC8RbCFj2ZjeuPN6oUM3vMbrjOVjoc1YtPkClilovQ2+Yom tZrOGhxQX55AY4dmfoPKcoHGbBEibMMJPXhGrPVuENq/50T+pLiJtZoxNWuDsjqWb4l8 pUSMpybu1IbPEck8xHShfxgHmktUhfHgLCAPzVSuSX1ZfUNHeZRLEcW90DaD82fJqdwG YHouyqGcukuXwaca27jzWI11hh+HAHuXIXn07ILL68KPbeS9OjbQnT6oqoqBnGl77hPn jRDT4QhDrye5NkLMTm/Q+nY55UmBDs9vEhh0Gk7G+YgIFhElHeEZ/V9znACVxdTXZ9wD ZEig== X-Gm-Message-State: AC+VfDwhNQLETlNpxoQt1rkqLydt86IS6vTQ71/9aaGxRzi3lWAqdyg2 +fPZrf+ut+dXbTrZJm3lJOgcCOqJMkY= X-Google-Smtp-Source: ACHHUZ71shOgJ6qZaSIQI2qQFuyfU34SVwjsX0pTyfPJjFj0CqRboKL8EEKywgkmNGN8koIHpo2Jqw== X-Received: by 2002:a17:90a:fb53:b0:25b:e4bb:6788 with SMTP id iq19-20020a17090afb5300b0025be4bb6788mr3312808pjb.0.1686960638502; Fri, 16 Jun 2023 17:10:38 -0700 (PDT) Original-Received: from [192.163.0.137] ([103.24.106.35]) by smtp.gmail.com with ESMTPSA id w5-20020a17090aea0500b0025bfda134ccsm1898784pjy.16.2023.06.16.17.10.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jun 2023 17:10:37 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=platon7pronko@gmail.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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, NICE_REPLY_A=-0.093, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143964 Archived-At: On 2023-06-17 06:19, Joshua Lambert wrote: > I have created some functions that make changes to one buffer line of > a csv file. Let's call those functions a, b and c. Each of those take > one or more arguments. I want to create a separate interactive > function that does what function a, b, and c do, but on every line of > the region. I successfully created a function (act-on-region-by-line) > to go through all lines in a region and then call function a, function > b, or function c. But, It seems redundant to have multiple functions > that have 9-15 lines similar and one line different, the one that > specifies function a, b or c. What is the best way to be efficient in > this situation? > > I have attempted to pass function b as a parameter, but I am slow to > understand how to do that. Is that the best way, or is there another? > > Thanks, > J Lambert > It's a bit difficult to understand what the problem is without seeing the code. Can you show the code for your latest attempt? Yes, passing function as a parameter seems to be the best way. And partial function application might be useful here as well. -- Best regards, Platon Pronko PGP 2A62D77A7A2CB94E