emacs icon indicating copy to clipboard operation
emacs copied to clipboard

Use let* instead of let

Open gongzhitaao opened this issue 4 years ago • 2 comments

https://github.com/arcticicestudio/nord-emacs/blob/d828752e270978a56bde19986c98b1bbe8f51386/nord-theme.el#L101

It would be much easier and less error-prone if we use let* instead of let. let* allows to use the variable defined before the current line. For example:

(let* ((class '((class color) (min-colors 89)))
  ;; omit lines
  (nord12 (if (nord-display-truecolor-or-graphic-p) "#D08770" "brightyellow"))
  ;; omit lines
  ;; (nord-annotation (if (nord-display-truecolor-or-graphic-p) "#D08770 "brightyellow")) <-- original
  (nord-annotation (if (nord-display-truecolor-or-graphic-p) nord12 "brightyellow"))

gongzhitaao avatar Mar 15 '20 15:03 gongzhitaao

Hi @gongzhitaao :wave:, thanks for your contribution :+1:

That sounds like a good and inexpensive improvement 😄 Unfortunately I'm not really familiar with Lisp at all so I'll need to check and test if there might be problems when it comes to the special Emacs Lisp syntax derivations. Maybe someone with more experience post some feedback or some examples/links if it is used in other popular themes too without any disadvantages.

arcticicestudio avatar Apr 07 '20 12:04 arcticicestudio

Some examples:

  • Solarized: https://github.com/bbatsov/solarized-emacs/blob/master/solarized.el#L242
  • sanityinc-tomorrow: https://github.com/purcell/color-theme-sanityinc-tomorrow/blob/master/color-theme-sanityinc-tomorrow.el#L144
  • Monokai: https://github.com/oneKelvinSmith/monokai-emacs/blob/master/monokai-theme.el#L188
  • Emacs one: https://github.com/balajisivaraman/emacs-one-themes/blob/master/one-themes.el#L77

The only different between let* and let is let* allows you to use variables previously defined.

gongzhitaao avatar Apr 08 '20 00:04 gongzhitaao