From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: How to test if the current line contains only white-spache? Date: Sun, 15 Nov 2015 01:18:28 -0800 Message-ID: References: <87r3js7e8l.fsf@linux-qg7d.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1447657137 13081 80.91.229.3 (16 Nov 2015 06:58:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Nov 2015 06:58:57 +0000 (UTC) Cc: Rolf Ade To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 16 07:58:51 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZyDkY-0006jK-Bt for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Nov 2015 07:58:50 +0100 Original-Received: from localhost ([::1]:46112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyDkX-0004IH-TL for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Nov 2015 01:58:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxtSC-0001Qs-OU for help-gnu-emacs@gnu.org; Sun, 15 Nov 2015 04:18:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxtSB-0003mV-UO for help-gnu-emacs@gnu.org; Sun, 15 Nov 2015 04:18:32 -0500 Original-Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:36570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxtSB-0003m3-P4 for help-gnu-emacs@gnu.org; Sun, 15 Nov 2015 04:18:31 -0500 Original-Received: by pacdm15 with SMTP id dm15so143394612pac.3 for ; Sun, 15 Nov 2015 01:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Pohu41N/UWuQp1HjQSbcDtCxOcrvWsYJakN7YIHOhts=; b=vs4qeqBH7ZnMkM2XHXK1tEL8J+NVqx7W7yOrfazU3xQRW+Gipv/7dD9xY8QUP4Uejt QrKldTbhqSBKjkxTbO/UBRr3d0MskeI2VGCUqIkUGwvjfYcHp6XXhT+13dh1rK1qP7lT +6QUL3QwO15dfWMhi8E5Xom/1q5KHO7SgR6ZlWcUx1tvfSK2b8eRMzragRxdRB9RFGmo OpiHwcAWOnWiz18uh4sBsdS2D3lLarDY0fytIcSdHz29fkfoe2kdrCyivX01TdL/7gKY sQYFkJhjvVhTOV030V2BJY4Xghnsi76kZbF1BP+EJLZYWRHXCoDUnbKrIqaJz6iBLWFx vNJA== X-Received: by 10.68.231.7 with SMTP id tc7mr45995632pbc.108.1447579110784; Sun, 15 Nov 2015 01:18:30 -0800 (PST) Original-Received: from ?IPv6:2605:e000:1419:600e:5148:ed4e:2ed3:eaff? ([2605:e000:1419:600e:5148:ed4e:2ed3:eaff]) by smtp.gmail.com with ESMTPSA id ij3sm29654346pbb.62.2015.11.15.01.18.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 15 Nov 2015 01:18:30 -0800 (PST) X-Mailer: iPhone Mail (13B143) In-Reply-To: <87r3js7e8l.fsf@linux-qg7d.fritz.box> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::229 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108084 Archived-At: > 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