unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Condider adding buffer-mode
Date: Tue, 29 Oct 2013 17:56:18 -0400	[thread overview]
Message-ID: <jwvli1bhhpj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAM9Zgm2zbQutmEsE9qpfug1z0=vzGpVG=p+ZpPF6Gripc+=T8g@mail.gmail.com>

> 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)))
vs
   (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.


        Stefan



  reply	other threads:[~2013-10-29 21:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24 14:22 Condider adding buffer-mode Bozhidar Batsov
2013-10-24 21:46 ` Stefan Monnier
2013-10-29 15:53   ` Bozhidar Batsov
2013-10-29 16:36     ` Stefan Monnier
2013-10-29 17:28       ` Bozhidar Batsov
2013-10-29 21:56         ` Stefan Monnier [this message]
2013-10-30  9:34           ` Bozhidar Batsov
2013-10-30 12:41             ` Stefan Monnier
2013-10-31 12:57               ` Bozhidar Batsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvli1bhhpj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=bozhidar.batsov@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).