[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: empty-line-p

From: Andreas Roehler
Subject: Re: empty-line-p
Date: Fri, 30 Mar 2007 08:14:08 +0200
User-agent: Thunderbird (X11/20060516)

Stefan Monnier schrieb:
 (if (looking-at "^[ \t\f\r]*$")

  (if <foo> t nil)

is an eta-regexp, which can be advantageously reduced to just <foo>.


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")
   (when ispec
     (message "%s" (looking-at empty-line-p-chars)))
   (looking-at empty-line-p-chars)))

reply via email to

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