|
From: | Emanuel Berg |
Subject: | Re: How to test if the current line contains only white-spache? |
Date: | Tue, 17 Nov 2015 01:26:42 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Rolf Ade <rolf@pointsman.de> writes: > Works fine and is much simpler. Thanks. Here is another solution that is all C, and doesn't move point. Is that an advantage? ... (Open question.) (defun blank-line () (interactive) (message (if (string-match "^[[:space:]]*$" (buffer-substring-no-properties (line-beginning-position) (line-end-position) )) "blank" "not so") )) Non-interactive use could be: (defun blank-line-p () (string-match "^[[:space:]]*$" (buffer-substring-no-properties (line-beginning-position) (line-end-position) ))) (blank-line-p) ; nil (progn (previous-line 2) (blank-line-p) ) ; 0, i.e. non-nil - (when 0 t) => t ; (when nil t) => nil Keep it up! -- underground experts united http://user.it.uu.se/~embe8573
[Prev in Thread] | Current Thread | [Next in Thread] |