[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: Sat, 31 Mar 2007 07:49:11 +0200
User-agent: Thunderbird (X11/20060516)

David Hansen schrieb:
On 29 Mar 2007 14:32:05 GMT Joost Kremers wrote:

Andreas Roehler wrote:
needed a check at several occassions, if the current line
contains printable characters.

What about the following to solve this?

(defun empty-line-p ()
  "Returns t if cursor is at an empty line "
      (looking-at "^[ \t\f\r]*$")
you don't need the if-statement here:

(defun empty-line-p ()
  "Returns t if cursor is at an empty line "
    (looking-at "^[ \t\f\r]*$")))

looking-at already returns t or nil.

And to avoid some painful bug hunting (happened to me with nearly
the same code)
What about to collect minor tools like this somewhere?

 wrap it in a `save-match-data'.


OK, thanks. So I got this now:

(defcustom empty-line-p-chars "^[ \t\f\r]*$"
: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]