all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* cl-dolist, dolist, cl-return,
@ 2015-07-08  0:14 Emanuel Berg
  2015-07-08  0:31 ` John Mastro
  0 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2015-07-08  0:14 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-07-11 18:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6511.1436314595.904.help-gnu-emacs@gnu.org>
2015-07-08  3:25 ` cl-dolist, dolist, cl-return, Pascal J. Bourguignon
2015-07-08 10:17   ` Emanuel Berg
2015-07-08 14:02     ` Drew Adams
2015-07-08 23:10       ` Emanuel Berg
     [not found]       ` <mailman.6588.1436397019.904.help-gnu-emacs@gnu.org>
2015-07-08 23:56         ` Pascal J. Bourguignon
2015-07-08  0:14 Emanuel Berg
2015-07-08  0:31 ` John Mastro
2015-07-08  3:09   ` Stefan Monnier
2015-07-08 10:25     ` Emanuel Berg
2015-07-08 14:44       ` Stefan Monnier
2015-07-08 23:19         ` Emanuel Berg
2015-07-09  1:49           ` John Mastro
2015-07-09 22:00             ` Emanuel Berg
     [not found]             ` <mailman.6636.1436479362.904.help-gnu-emacs@gnu.org>
2015-07-10 18:44               ` Barry Margolin
2015-07-11 18:52                 ` Emanuel Berg
2015-07-10 16:57           ` Stefan Monnier
2015-07-08 10:23   ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.