(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 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