unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: Joshua Lambert <jlambert.lis.tech@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Iterating over buffer lines
Date: Sat, 17 Jun 2023 21:17:25 +0200	[thread overview]
Message-ID: <ZI4GxRLzOuZGShzz@tuxteam.de> (raw)
In-Reply-To: <CAGGu9j1gub_8kb92kkD30QmxLmZz8XJrwhyAPtYONE3OLe_zew@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2199 bytes --]

(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 PM <tomas@tuxteam.de> wrote:
> >
> > The above means that you are inserting stuff at the beginning of the
> > current line, right?
> 
> 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.
> 
> (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-num)))
>            (insert string-separator)
>            (forward-line))))))

Hm. So you want to pass an extra arg to call where `my-string-pad-concat ...' is?

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  parent reply	other threads:[~2023-06-17 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 22:19 Iterating over buffer lines Joshua Lambert
2023-06-17  0:10 ` Platon Pronko
2023-06-17  3:28   ` Joshua Lambert
2023-06-17  4:48     ` tomas
     [not found]       ` <CAGGu9j1gub_8kb92kkD30QmxLmZz8XJrwhyAPtYONE3OLe_zew@mail.gmail.com>
2023-06-17 19:17         ` tomas [this message]
2023-06-18  1:17     ` Platon Pronko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZI4GxRLzOuZGShzz@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=jlambert.lis.tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).