unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>,  contovob@tcd.ie,  emacs-devel@gnu.org
Subject: Re: Searching for line beginning
Date: Thu, 18 Aug 2022 14:37:42 +0200	[thread overview]
Message-ID: <87mtc1hgmh.fsf@gnus.org> (raw)
In-Reply-To: <jwvwnb7cckv.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 17 Aug 2022 07:52:48 -0400")

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).




  reply	other threads:[~2022-08-18 12:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-13 15:43 Searching for line beginning Eli Zaretskii
2022-08-13 16:20 ` Stefan Monnier
2022-08-13 17:58   ` Eli Zaretskii
2022-08-14 12:54   ` Eli Zaretskii
2022-08-14 15:33 ` Basil L. Contovounesios
2022-08-14 15:36   ` Eli Zaretskii
2022-08-14 15:43     ` Lars Ingebrigtsen
2022-08-14 15:48       ` Eli Zaretskii
2022-08-15  4:28         ` Lars Ingebrigtsen
2022-08-15 11:29           ` Eli Zaretskii
2022-08-15 11:37             ` Lars Ingebrigtsen
2022-08-15 12:00               ` Eli Zaretskii
2022-08-17  2:49                 ` Richard Stallman
2022-08-17 10:41                   ` Lars Ingebrigtsen
2022-08-17 11:48                   ` Eli Zaretskii
2022-08-17 11:52               ` Stefan Monnier
2022-08-18 12:37                 ` Lars Ingebrigtsen [this message]
2022-08-14 17:24     ` Stefan Monnier

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=87mtc1hgmh.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).