From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: Iterating over buffer lines Date: Sat, 17 Jun 2023 21:17:25 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NVn7PChYzfhlA3rG" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6672"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Joshua Lambert Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 17 21:18:08 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 1qAbR2-0001Xh-2A for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 17 Jun 2023 21:18:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAbQR-0002dt-TH; Sat, 17 Jun 2023 15:17:31 -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 1qAbQP-0002dk-Cf for help-gnu-emacs@gnu.org; Sat, 17 Jun 2023 15:17:29 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAbQN-0007HN-Ev for help-gnu-emacs@gnu.org; Sat, 17 Jun 2023 15:17:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=okfFG64d1A2/q6SvfQKMFV9CkooRDBH+lzsaDXE18q8=; b=t9Z/ukfM6tiHcyOdty4hHI+oA1 21B7lu06vS5gosZlyjMdx8nkbSH1s/uSsopMVZ29TFSWUhe6wEdsJTL/fj+Hlrwc+omCYQr/LSwPY g8BujHQSwkguT4r04GLB7KWA89hYxY3ZReqAuKzVerFHT1litG2e3z08x0JMcCHt4fR6ez5CliL+l FZQ0cPLzwCYNtw/Lj0zMLZsF+3CK5zBEFPe5SAGgityfDhnruPuBIFTZnzCXfQPgWCPgaoNg5IsPA xONveQCXMTrqNReSSU1JvDPTzM3cHnMwi5SMr4e37JoZePCs6LZmgsISB5hRT4uF3bEahMZKvpI/K agcFnLhA==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qAbQL-00011F-2v; Sat, 17 Jun 2023 21:17:25 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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_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:143978 Archived-At: --NVn7PChYzfhlA3rG Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable (I re-added the list to the CC: I guess you are interested in getting some help, and I'm not necessarily the best at this) On Sat, Jun 17, 2023 at 09:09:37AM -0500, Joshua Lambert wrote: > On Fri, Jun 16, 2023 at 11:48=E2=80=AFPM wrote: > > > > The above means that you are inserting stuff at the beginning of the > > current line, right? >=20 > Yes. That is correct. OK. [...] > > I.e.: do you need to (save-excursion ...) around `some-chosen-function'? > > What do you do with its result? That kind of things. > > > Sorry I have not sent enough or the correct information. I may not > need to save the excursion but it is a nice user feature I would like > to keep. If you have your "protocol" clear, that's fine :-) > The function that follows works like I want but is very repetitive > given what I mention below. In order for me to run various data > cleanup processes, I exchange the (my-string-pad-concat > (my-get-string-from-line field-num)) with other function calls. One > correctly pads a string as needed. (this is internal padding that has > to follow complicated logic.) Another removes unneeded spaces from > other strings. So forth. Each of those provides a string to be > inserted at the beginning of each line. >=20 > (defun my-make-region-sortable (&optional field-num beg end) > "Create a padded string for each line in region. > Interactively, BEG and END are the region." > (interactive "*p\nr") > (let ((beg2 (if (region-active-p) > beg > (line-beginning-position))) > (end2 (if (region-active-p) > end > (line-end-position)))) > (save-excursion > (save-restriction > (narrow-to-region beg2 end2) > (goto-char (point-min)) > (while (not (eobp)) > (goto-char (line-beginning-position)) > (insert (my-string-pad-concat (my-get-string-from-line field-n= um))) > (insert string-separator) > (forward-line)))))) Hm. So you want to pass an extra arg to call where `my-string-pad-concat ..= =2E' is? Cheers --=20 t --NVn7PChYzfhlA3rG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZI4GvgAKCRAFyCz1etHa RpP3AJ0ddFZkpVdWv0GWpqOMTW9Ox2VT8ACeOwHRmP/UF31xPA4EpJyZcPZj/W8= =dFPx -----END PGP SIGNATURE----- --NVn7PChYzfhlA3rG--