help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to test if the current line contains only white-spache?


From: Emanuel Berg
Subject: Re: How to test if the current line contains only white-spache?
Date: Sat, 21 Nov 2015 03:26:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Marcin Borkowski <mbork@mbork.pl> writes:

>> I don't think you can be categorical about it.
>
> Of course I can. Though maybe I shouldn't. ;-)

"Ho ho ho" - I heard that one in the
techno-incubator...

>> (save-excursion (beginning-of-line) (point))
>> and
>> (line-beginning-position)
>> The code is easier and faster to write, read, and understand.

> Is it really clear? I'm not sure.

It consists of fewer letters and the words express the
return value explicitly. With

    (save-excursion (beginning-of-line) (point))

you have a combination of three different
forms/functions with Emacs-specific lingo at that, and
that combination/lingo has to make sense to you.

> Besides, I've just checked the /implementation/ of
> `line-beginning-position', and I have some bad news
> for you. I'm not fluent in C, nut AFAICT, it's even
> uglier than the Elisp variant: there is no
> `save-excursion' just a temporary variable for the
> original position of point

So it does move point? The help says "This function
does not move point." - that might refer to the user
experience and not the implementation tho. (So the
user knows he doesn't have to enclose it with
`save-excursion'.)

> So, how is the C `line-beginning-position' better than
>
> (defun elisp-line-beginning-position ()
> (save-excursion (beginning-of-line) (point)))?
>
> (apart from being less general)? It is just /faster/,
> but not more /elegant/ or /pure/.

It is less general (i.e., more to the, eh, "point") -
but it is also more general since it is included in
the vanilla Emacs.

As for elegance and purity those algorithms from the
religio-mythical age are discontinued.

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]