]> git.notmuchmail.org Git - notmuch/commit - emacs/notmuch-show.el
emacs: avoid unnecessary let-bindings
authorJonas Bernoulli <jonas@bernoul.li>
Sun, 10 Jan 2021 14:01:06 +0000 (15:01 +0100)
committerDavid Bremner <david@tethera.net>
Fri, 15 Jan 2021 10:45:30 +0000 (06:45 -0400)
commitf47e3333b5478e43840e55710311aebdd441fc0e
treef6edef3451d1b1122be87a44af75fdd4b49537fc
parent25a8873c68f9ef033d393efaf7f4c46a29f798f4
emacs: avoid unnecessary let-bindings

To some extend this is a personal preference, but the preference is
strongly dependent on whether one is used to a language that makes it
necessary to use variables like this.

This makes it perfectly clear that we are first getting and then using
a "foo":

  (use-foo (get-foo))

Sure this has to be read "inside out", but that's something one better
gets used to quickly when dealing with lisp.  I don't understand why
one would want to write this instead:

  (let ((the-foo (get-foo)))
    (use-foo the-foo))

Both `get-foo' and `use-foo' are named in a way that make it very
clear that we are dealing with a "foo".  Storing the value in an
additional variable `the-foo' does not make this any more clear.

On the contrary I makes the reader wonder why the author choose to
use a variable.  Is the value used more than once?  Is the value
being retrieved in one context and then used in another (e.g. when
the current buffer changes)?
emacs/notmuch-address.el
emacs/notmuch-lib.el
emacs/notmuch-maildir-fcc.el
emacs/notmuch-show.el
emacs/notmuch-tag.el
emacs/notmuch-tree.el
emacs/notmuch.el