Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a buffer is empty?

Tags:

emacs

elisp

How to check if a buffer is empty? Checking if count-lines gives 0 is over-killing for this I think.

UPDATE: Yeah, phils's answer should work. Write it out:

(defun buffer-empty-p (&optional buffer)
  (= (buffer-size buffer) 0))
like image 421
updogliu Avatar asked Aug 19 '13 11:08

updogliu


1 Answers

buffer-size is a built-in function in `C source code'.

(buffer-size &optional BUFFER)

Return the number of characters in the current buffer.
If BUFFER, return the number of characters in that buffer instead.
like image 117
phils Avatar answered Nov 14 '22 15:11

phils