|
From: | Andreas Roehler |
Subject: | Re: empty-line-p |
Date: | Fri, 30 Mar 2007 08:14:08 +0200 |
User-agent: | Thunderbird 1.5.0.4 (X11/20060516) |
Stefan Monnier schrieb:
(if (looking-at "^[ \t\f\r]*$") t nil)))(if <foo> t nil) is an eta-regexp, which can be advantageously reduced to just <foo>. Stefan PS: The classical eta-regexp is (lambda (x) (<foo> x)), which is equivalent to just <foo>. Another variant is (cons (car <foo>) (cdr <foo>)), which eta-reduces to just <foo>.
Thanks a lot both. Rewrote it in order to let the user decide, which chars should be considered as "empty". Also provided an interactive spec. __ Andreas Roehler (defcustom empty-line-p-chars "^[ \t\f\r]*$" "Permitted chars on a line, which should be considered as \"empty\" nonetheless" :type 'regexp :group 'convenience) (defun empty-line-p (&optional ispec) "Returns t if cursor is at an empty line, nil otherwise. Displays result in minibuffer when called interactive." (interactive "p") (save-excursion (beginning-of-line) (when ispec (message "%s" (looking-at empty-line-p-chars))) (looking-at empty-line-p-chars)))
[Prev in Thread] | Current Thread | [Next in Thread] |