[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: |
John Mastro |
Subject: |
Re: How to test if the current line contains only white-spache? |
Date: |
Sun, 15 Nov 2015 01:18:28 -0800 |
> 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)
>
> (and that is, obviously, without saving point position and wrapping
> into and a defun and maybe other bells and whistles).
>
> I wonder, what much simpler and more elegant solution I'm missing.
An alternative would be to use a regexp.
Here's an (untested, typed-on-mobile) example:
(beginning-of-line)
(looking-at-p "^[ \t]*$")
--
john
- Re: How to test if the current line contains only white-space?, (continued)
- Message not available
- Re: How to test if the current line contains only white-space?, Rolf Ade, 2015/11/20
- Re: How to test if the current line contains only white-spache?, Alex Bennée, 2015/11/26
- predicates (was: Re: How to test if the current line contains only white-spache?), Emanuel Berg, 2015/11/26
- Message not available
- Re: predicates, Pascal J. Bourguignon, 2015/11/26
- Re: predicates, Emanuel Berg, 2015/11/27
Re: How to test if the current line contains only white-spache?, Yuri Khan, 2015/11/16
Re: How to test if the current line contains only white-spache?,
John Mastro <=
Re: How to test if the current line contains only white-spache?, Nicolas Richard, 2015/11/25
Message not available