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: Marcin Borkowski
Subject: Re: How to test if the current line contains only white-spache?
Date: Wed, 25 Nov 2015 21:36:33 +0100
User-agent: mu4e 0.9.13; emacs 25.0.50.1

On 2015-11-25, at 15:04, Nicolas Richard <nrichard@ulb.ac.be> wrote:

> Rolf Ade <rolf@pointsman.de> writes:
>> For some random minor elisp code I need to know, if the current line
>> contains only white-space characters[1].
>>
>> I came up with this somewhat convoluted code:
>>
>> (beginning-of-line)
>> (skip-chars-forward " \t")
>> (let ((text-start (current-column)))
>>   (end-of-line)
>>   (if (= text-start (current-column))
>>       t
>>     nil)
>
> FWIW I would do :
> (save-excursion
>   (beginning-of-line)
>   (skip-chars-forward " \t")
>   (eolp))
>
> but IANAL(isper).

Nice!  And quite possibly faster, since no regex is involved.  OTOH, I'm
not sure whether this (or any other solution, for that matter) would
work with visual lines (or what it actually /should/ do).

Regards,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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