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: Barry Margolin
Subject: Re: How to test if the current line contains only white-spache?
Date: Sat, 14 Nov 2015 13:42:46 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <87r3js7e8l.fsf@linux-qg7d.fritz.box>,
 Rolf Ade <rolf@pointsman.de> wrote:

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

(save-excursion
  (beginning-of-line)
  (looking-at "[ \t]*$"))

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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