help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Number of open buffers?


From: lawrence mitchell
Subject: Re: Number of open buffers?
Date: Thu, 20 Nov 2003 21:50:08 +0000
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50

David Kastrup wrote:

[...]

> (defun get-number-of-file-buffers ()
>   (interactive)
>   (let ((num 0))
>     (dolist (buf (buffer-list) num)
>       (when (buffer-file-name buf)
>           (setq num (1+ num))))))

Assuming cl is loaded:

(defun get-number-of-file-buffers ()
  (loop for b in (buffer-list) count (buffer-file-name b)))

:)

>> Thanks. When I try to run it via eval-expr, saying

>> (insert get-number-of-file-buffers)

>> It says: Error: void-variable. Data: get-number-of-file-buffers

> Yes.  One calls a function by putting it after an opening
> parenthesis.  The way you tried to "call" it, just a variable of that
> name got referenced, and there is no such variable.  In addition, the
> function returns a numeric expression, and `insert' expects a string.

The OP may find reading the Emacs Lisp Introduction a useful
exercise, it's not that long, and, I think, explains the basics
of emacs lisp quite nicely.

-- 
lawrence mitchell <address@hidden>


reply via email to

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