From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>, emacs-devel@gnu.org
Subject: Re: Searching for line beginning
Date: Sun, 14 Aug 2022 13:24:31 -0400 [thread overview]
Message-ID: <jwvilmun3l9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83pmh2kfaj.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 14 Aug 2022 18:36:52 +0300")
Eli Zaretskii [2022-08-14 18:36:52] wrote:
>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Cc: emacs-devel@gnu.org
>> Date: Sun, 14 Aug 2022 18:33:00 +0300
>>
>> Eli Zaretskii [2022-08-13 18:43 +0300] wrote:
>>
>> > C-a (move-beginning-of-line) does this to find the line's beginning:
>> >
>> > ;; Move to beginning-of-line, ignoring fields and invisible text.
>> > (skip-chars-backward "^\n")
>> > (while (and (not (bobp)) (invisible-p (1- (point))))
>> > (goto-char (previous-char-property-change (point)))
>> > (skip-chars-backward "^\n"))
>> >
>> > Apart of the fields part (which can be handled by binding
>> > inhibit-field-text-motion), can anyone see a reason why not use
>> > line-beginning-position instead? The latter is much faster,
>> > especially when lines are very long.
>>
>> FWIW, one could also say (beginning-of-line) or (beginning-of-line 1)
>> instead of (goto-char (line-beginning-position)).
>
> As a matter of principle, I don't like calling commands from Lisp if I
> can avoid that, because commands frequently have extensive checks of
> the arguments that are redundant in non-interactive calls.
I also like to avoid moving point when it's possible/easy (my original
motivation was to avoid the extra tricky semantics of moving point in
the presence of things like `point-entered` and `intangible` properties,
but even with `inhibit-point-motion-hooks` permanently set to t I think
it's preferable not to move point when given the choice).
In the above loop, it seems it's easy not to move point.
Stefan
prev parent reply other threads:[~2022-08-14 17:24 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
2022-08-14 17:24 ` Stefan Monnier [this message]
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=jwvilmun3l9.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=contovob@tcd.ie \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/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).