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

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

cl-dolist, dolist, cl-return,


From: Emanuel Berg
Subject: cl-dolist, dolist, cl-return,
Date: Wed, 08 Jul 2015 02:14:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

I just wrote the below code.

`cl-return' works for `cl-dolist', but not for
`dolist' because it hasn't an "implicit nil block ...
established around the loop". And there is no
`return'! I think this "cl-" stuff is confusing.
Anyone cares to explain?

By the way, I know there are one zillion loops
in Lisp. What is the conventional way to

    1. iterate a list
    2. until some condition is met for some element
    3. then break, to speak in C

?

And: With [cl-]dolist, if the list is an expression
and not an atom, does that get evaluated once, or does
it happen every iteration like, say, a string length
test would, again in C?

Also: why isn't there a "neq"?

Keep it up!

;; whole file: http://user.it.uu.se/~embe8573/conf/emacs-init/erc-my.el

(defun neq (a b)
  (not (eq a b) ))

(defun erc-kill-buffer-stay ()
  "Close the current ERC buffer (e.g., to leave a channel)
but stay in ERC if possible."
  (interactive)
  (cl-dolist (b (erc-buffer-list))
    (when (neq (current-buffer) b)
      (erc-cmd-LEAVE "")
      (switch-to-buffer b)
      (cl-return) )))
      
-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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