From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Klaus Jantzen Newsgroups: gmane.emacs.help Subject: Re: Function-Problem Date: Wed, 17 Aug 2016 19:06:51 +0200 Message-ID: References: <5715d4d8-fe9c-851f-8a2c-308a9da10e37@mailbox.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1471454081 31106 195.159.176.226 (17 Aug 2016 17:14:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 Aug 2016 17:14:41 +0000 (UTC) To: emacs-list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 17 19:14:37 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ba4QG-0007tz-AQ for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Aug 2016 19:14:36 +0200 Original-Received: from localhost ([::1]:48710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba4QD-0002Hn-DM for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Aug 2016 13:14:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba4Is-0004QH-MC for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 13:06:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ba4Io-0004K4-Fy for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 13:06:57 -0400 Original-Received: from mx2.mailbox.org ([80.241.60.215]:57611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba4Io-0004Jx-5o for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 13:06:54 -0400 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 6951443596 for ; Wed, 17 Aug 2016 19:06:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :mime-version:date:date:message-id:from:from:references:subject :subject:received; s=mail20150812; t=1471453612; bh=IMSVJLVDgvYW 8aRiTImKnwNDVWqOLSuNWwjOxMSAtzY=; b=IUIjqU/MFVNNcwDWC7Llblpq1k4r 1KT7SWRn4WElsYQdzaUIHQ45bWrt1vrhkw8hgBOAh3I3PdvwcDWIF65/caJgD6LO 38LvzPRB4hCPoaf6OondjhX7UkqTU9qe75VaRNiH6AMkchSnAw1Bv9tFkyzXANPF dTNt/DozmfT1r/iNNGAZgHzXxK2bFrF2r3iKBo4rvgDF2z6IwBMx3yEBRzC+F9sw IfIdXwAz0XpwzhSIvnzirc78MUm5MAkcL/i60RBkKWjXbYYpXBTUlWv5ZwF9J/WX KJgEwGv8U0aXzhBaAbSPItYzwwy1X7/3AXANoqBGmSyt+RaB/OVJapa2Kg== X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id TaK78cw88NrX for ; Wed, 17 Aug 2016 19:06:52 +0200 (CEST) In-Reply-To: <5715d4d8-fe9c-851f-8a2c-308a9da10e37@mailbox.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.241.60.215 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:111165 Archived-At: On 08/17/2016 12:49 PM, Klaus Jantzen wrote: > Hello, > > the attached function should return true if a line contains all blanks > or is empty. > > Currently the function returns a quick 'nil' and then the message > > "No catch for tag: --cl-block-nil--, nil" > > What is my problem? > > ===== > (defun blank-line-p () > "Returns t if line contains all blanks or is empty" > (let ((lep (line-end-position)) > (cpp (point)) ; the current position > (res 0) > ) > (beginning-of-line) > (if (re-search-forward "^[ ]+$\|^$" lep t) > (progn (goto-char cpp) ; line is blank/empty > (message "t") > t) > (progn (goto-char cpp) ; line is not blank/empty > (message "nil") > (return nil)) > ) > ) ; end of let > ) ; end of 'blank-line-p' > ==== > Thanks for any hint. Based on your suggestions, I rewrote the function as follows: ===== (defun blank-line-p () "Returns t if line contains only blanks or empty" (save-excursion (beginning-of-line) ; (if (looking-at-p "^[ ]+$\|^$") ; (1) ; (if (looking-at-p "^[ ]+$") ; (2) ; (if (looking-at-p "^$") ; (3) (if (looking-at-p "^$\|^[ ]+$") ; (1a) (progn ; (goto-char cpp) ; line is blank/empty (message "t") t) (progn ; (goto-char cpp) ; line is not blank/empty (message "nil") nil) ) ) ) ; end of 'blank-line-p' ===== This leads to a problem with the regular expression; if-(3) works, if-(2) works, but the combined regular expression in if-(1) or if-(1a) does not work. Where is my error in the RE? Is the combination not allowed in 'lookig-at-p'? -- K.D.J.