[Top][All Lists]

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

Re: Condider adding buffer-mode

From: Stefan Monnier
Subject: Re: Condider adding buffer-mode
Date: Tue, 29 Oct 2013 17:56:18 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> Here's some real examples:
> (defun cider-util--clojure-buffers ()

Both uses of this are in something of the form

  (dolist (buffer (cider-util--clojure-buffers))
    (with-current-buffer buffer

so overall, it's exactly the example I provided.  I.e. you can just
throw away cider-util--clojure-buffers and replace the two uses with

  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      (when (derived-mode-p 'closure-mode)

which also fixes the bug in that code when the user uses a mode derived
from closure-mode.
>   (when (and buffer
>              (eq 'clojure-mode (with-current-buffer buffer major-mode))
>              (eq 'cider-repl-mode major-mode))
>     (setq cider-last-clojure-buffer buffer)))
> vs
>   (when (and buffer
>              (eq 'clojure-mode (buffer-mode buffer))
>              (eq 'cider-repl-mode major-mode))
>     (setq cider-last-clojure-buffer buffer)))
   (when (and buffer
              (with-current-buffer buffer (derived-mode-p 'clojure-mode))
              (derived-mode-p 'cider-repl-mode))
     (setq cider-last-clojure-buffer buffer)))

> Seems to me `buffer-mode' makes the code clearer, but that's subjective (as
> most things in life :-) )

Very marginally so.


reply via email to

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