Use when-let instead of awhen

This commit is contained in:
contrapunctus 2022-01-15 10:28:59 +05:30
parent 671b7c2ab6
commit 0564bde343
1 changed files with 3 additions and 4 deletions

View File

@ -2920,17 +2920,16 @@ _u_: next word ^_l_: edit lines^ _s_: next whole symbol
("a" ag "ag")
("h" find-grep "find-grep"))
#+END_SRC
** General
#+BEGIN_SRC emacs-lisp
(require 'anaphora)
(defun my-compile-project (file &optional prefix cmd)
"Enter ancestor directory containing FILE and run compile command CMD.
If CMD is not supplied, use `compile-command'.
With PREFIX argument and omitted CMD, prompt for command."
(interactive "fDominating File: \nP")
(awhen (locate-dominating-file default-directory file)
(cd it))
(when-let ((dir (locate-dominating-file default-directory file)))
(cd dir))
(compile
(cond (prefix
(compilation-read-command