[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Searching for line beginning
From: |
Lars Ingebrigtsen |
Subject: |
Re: Searching for line beginning |
Date: |
Thu, 18 Aug 2022 14:37:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> How 'bout adding an optional argument?
That's also an option, but there's already an optional parameter here,
so we'd end up with
(buffer-substring (line-beginning-position nil t) (line-end-position nil t))
etc all over the place, which is a mouthful to both type and read.
I've done some grepping and reading code in the Emacs code base to
broadly guesstimate how much code means "give me a line" when they say
"give me a line" (as opposed to a field), and I think it's basically
most. So I think just adding a new function name for the behaviour most
code is looking for would be a better long time solution.
I was also wondering how much the optional N argument is used (because I
wondered whether the new function should perhaps be N-less, because the
N value isn't intuitive -- -1 and 1 aren't symmetric), and it's a lot
more than I would have guessed -- about a third of the calls have a
non-nil/non-1 N. Like:
;; Insert the entries just found.
(while (= (line-beginning-position 0) (1- (point)))
(backward-char))
and
(insert "\n")
(put-text-property
(line-beginning-position 0) (line-beginning-position)
'mpc-file (mpc-songs-hashcons (cdr (assq 'file song))))
and
(narrow-to-region (line-beginning-position)
(line-beginning-position 2))
Now, some of these are just bad code (or were written before
`propertize' existed), but the N will stay in the new function (if
added).
- Re: Searching for line beginning, (continued)
- Re: Searching for line beginning, Lars Ingebrigtsen, 2022/08/14
- Re: Searching for line beginning, Eli Zaretskii, 2022/08/14
- Re: Searching for line beginning, Lars Ingebrigtsen, 2022/08/15
- Re: Searching for line beginning, Eli Zaretskii, 2022/08/15
- Re: Searching for line beginning, Lars Ingebrigtsen, 2022/08/15
- Re: Searching for line beginning, Eli Zaretskii, 2022/08/15
- Re: Searching for line beginning, Richard Stallman, 2022/08/16
- Re: Searching for line beginning, Lars Ingebrigtsen, 2022/08/17
- Re: Searching for line beginning, Eli Zaretskii, 2022/08/17
- Re: Searching for line beginning, Stefan Monnier, 2022/08/17
- Re: Searching for line beginning,
Lars Ingebrigtsen <=
- Re: Searching for line beginning, Stefan Monnier, 2022/08/14