From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: Function-Problem Date: Wed, 17 Aug 2016 15:59:41 +0200 Message-ID: <87shu3v6lu.fsf@wanadoo.es> References: <5715d4d8-fe9c-851f-8a2c-308a9da10e37@mailbox.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1471462367 28885 195.159.176.226 (17 Aug 2016 19:32:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 Aug 2016 19:32:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 17 21:32:40 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 1ba6Zr-0007Ac-V6 for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Aug 2016 21:32:40 +0200 Original-Received: from localhost ([::1]:49275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba6Zp-0000np-2H for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Aug 2016 15:32:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba1O4-0006WO-OY for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 10:00:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ba1Nz-0000WH-Jh for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 10:00:07 -0400 Original-Received: from [195.159.176.226] (port=59011 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ba1Nz-0000S7-Cj for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 10:00:03 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ba1No-0001gq-AF for help-gnu-emacs@gnu.org; Wed, 17 Aug 2016 15:59:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:g6L+3rcJq2S/8F+bMvqVyxiJIGk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Wed, 17 Aug 2016 15:31:41 -0400 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:111168 Archived-At: Klaus Jantzen writes: > 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 Look into `save-excursion'. > (res 0) > ) > (beginning-of-line) > (if (re-search-forward "^[ ]+$\|^$" lep t) You need to escape the `\' above: "^[ ]+$\\|^$". Also, instead of using `+' you could use `*' which matches zero or more instances and just use "^[ ]*$". > (progn (goto-char cpp) ; line is blank/empty > (message "t") > t) > (progn (goto-char cpp) ; line is not blank/empty > (message "nil") > (return nil)) `return' does not belong here. It is a Common Lisp extension. Just say `nil' the same way you say `t' at the end of the previous `progn'. > ) > ) ; end of let > ) ; end of 'blank-line-p' > ==== > Thanks for any hint. HTH.