Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Obsolete when-let and if-let #283

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ The function `directory-empty-p' only exists 28.1 or above; copied it."

(defun eask--guess-package-name (basename)
"Convert the BASENAME to a valid, commonly seen package name."
(when-let ((name (ignore-errors (downcase basename))))
(when-let* ((name (ignore-errors (downcase basename))))
(setq name (eask-s-replace "emacs-" "" name)
name (eask-s-replace "-emacs" "" name)
name (replace-regexp-in-string "[.-]el$" "" name))
Expand Down Expand Up @@ -744,21 +744,21 @@ otherwise, we retrieve it from the variable `package-archive-contents'."

For arguments NAME and CURRENT, please see function `eask-package-desc' for
full detials."
(when-let ((desc (eask-package-desc name current)))
(when-let* ((desc (eask-package-desc name current)))
(package-desc-version desc)))

(defun eask-package--version-string (pkg)
"Return PKG's version."
(if-let ((version (or (eask-package--version pkg t)
(eask-package--version pkg nil))))
(if-let* ((version (or (eask-package--version pkg t)
(eask-package--version pkg nil))))
(package-version-join version)
;; Just in case, but this should never happens!
"0"))

(defun eask-package-desc-url ()
"Return url from package descriptor."
(when eask-package-desc
(when-let ((extras (package-desc-extras eask-package-desc)))
(when-let* ((extras (package-desc-extras eask-package-desc)))
(cdr (assoc :url extras)))))

(defun eask-package-desc-keywords ()
Expand Down Expand Up @@ -1390,7 +1390,7 @@ version number. DESCRIPTION is the package description."
(if (file-exists-p eask-package-file)
(eask--try-construct-package-desc eask-package-file)
(eask-warn "Package-file seems to be missing `%s'" file))
(when-let
(when-let*
(((and (not eask-package-descriptor) ; prevent multiple definition error
(not eask-package-desc))) ; check if constructed
(pkg-file (eask-pkg-el)))
Expand Down Expand Up @@ -1584,7 +1584,7 @@ Execute forms BODY limit by the verbosity level (SYMBOL)."

(defun eask--ansi (symbol string)
"Paint STRING with color defined by log level (SYMBOL)."
(if-let ((ansi-function (cdr (assq symbol eask-level-color))))
(if-let* ((ansi-function (cdr (assq symbol eask-level-color))))
(funcall ansi-function string)
string))

Expand Down Expand Up @@ -1817,7 +1817,7 @@ Arguments FNC and ARGS are used for advice `:around'."

(defun eask-package-elc-files ()
"Return package files' elc in workspace."
(when-let ((elcs (mapcar (lambda (elm) (concat elm "c")) (eask-package-el-files))))
(when-let* ((elcs (mapcar (lambda (elm) (concat elm "c")) (eask-package-el-files))))
(setq elcs (cl-remove-if-not (lambda (elm) (file-exists-p elm)) elcs))
elcs))

Expand Down
2 changes: 1 addition & 1 deletion lisp/clean/elc.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
nil t))

(eask-start
(if-let ((files (eask-package-elc-files)))
(if-let* ((files (eask-package-elc-files)))
(progn
(mapc #'eask-delete-file files)
(eask-msg "")
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
(eask-setup-paths)

(if-let ((name (eask-argv 0)))
(if-let* ((name (eask-argv 0)))
(eask-with-progress
(ansi-green "Exporting environment variables... ")
(eask-exec-export-env)
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/info.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
(when-let* ((url (or (eask-package-desc-url) eask-website-url))
((not (string-empty-p url))))
(eask-println (ansi-cyan url)))
(when-let ((keywords (or (eask-package-desc-keywords) eask-keywords)))
(when-let* ((keywords (or (eask-package-desc-keywords) eask-keywords)))
(eask-println "")
(eask-println "keywords: %s" (string-join keywords ", ")))
(eask-println "")
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/install.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ For argument FILE, please see function `package-install-file' for the details."
;; XXX: You must refresh content before you install the package,
;; see https://github.com/ericdallo/jet.el/issues/1
(eask-pkg-init)
(if-let ((names (eask-args)))
(if-let* ((names (eask-args)))
;; If package [name..] are specified, we try to install it
(eask-install-packages names)
;; Else we try to install package from the working directory
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/list.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ contents."
(if (= depth 0)
(eask-msg (eask-list--align depth " %-80s") name version archive summary)
(eask-msg (eask-list--align depth) name "" "" ""))
(when-let ((reqs (package-desc-reqs desc))
((< depth max-depth)))
(when-let* ((reqs (package-desc-reqs desc))
((< depth max-depth)))
(dolist (req reqs)
(eask-list--print-pkg (car req) (1+ depth) max-depth pkg-alist)))))

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/load.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
nil t))

(eask-start
(if-let ((files (eask-expand-file-specs (eask-args))))
(if-let* ((files (eask-expand-file-specs (eask-args))))
(mapc #'load-file files)
(eask-info "(Nothing to load.)")))

Expand Down
4 changes: 2 additions & 2 deletions lisp/core/loc.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

(require 'markdown-mode)
;; Start LOC
(if-let ((files (or (eask-expand-file-specs (eask-args))
(eask-package-files)))
(if-let* ((files (or (eask-expand-file-specs (eask-args))
(eask-package-files)))
(eask-output (get-buffer-create "*eask-output*")))
(with-current-buffer eask-output
(erase-buffer)
Expand Down
6 changes: 3 additions & 3 deletions lisp/core/recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

(defun eask-recipe-string ()
"Return the recipe format in string."
(when-let ((url (eask-package-desc-url)))
(when-let* ((url (eask-package-desc-url)))
(let* ((fetcher (cond ((string-match-p "github.com" url) 'github)
((string-match-p "gitlab.com" url) 'gitlab)
(t 'git)))
Expand All @@ -35,8 +35,8 @@
recipe)))

(eask-start
(if-let ((recipe (eask-recipe-string))
(name (eask-guess-package-name)))
(if-let* ((recipe (eask-recipe-string))
(name (eask-guess-package-name)))
(progn
(eask-msg "")
(eask-msg "recipes/%s:" name)
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/reinstall.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

(eask-start
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
(if-let ((names (eask-args)))
(if-let* ((names (eask-args)))
;; If package [name..] are specified, we try to install it
(eask-reinstall--packages names)
(if-let* ((name (intern (eask-guess-package-name)))
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/search.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

(eask-start
(eask-pkg-init)
(if-let ((queries (eask-args)))
(if-let* ((queries (eask-args)))
(let ((result))
(dolist (query queries)
(setq result (append result (eask-search--packages query))))
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/status.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
("Invocation" ,invocation-directory)
("Build No." ,emacs-build-number)
("System configuration" ,system-configuration)
,(when-let ((emacs-build-time)
(time (format-time-string "%Y-%m-%d" emacs-build-time)))
,(when-let* ((emacs-build-time)
(time (format-time-string "%Y-%m-%d" emacs-build-time)))
`("Build time" ,time))
("System type" ,system-type)))

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/uninstall.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

(eask-start
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
(if-let ((names (eask-args)))
(if-let* ((names (eask-args)))
(eask-uninstall--packages names)
(if-let* ((name (intern (eask-guess-package-name)))
((package-installed-p name)))
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/upgrade.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

(defun eask-upgrade--package-all ()
"Upgrade for archive packages."
(if-let ((upgrades (eask-package--upgrades)))
(if-let* ((upgrades (eask-package--upgrades)))
(progn
(mapc #'eask-upgrade--package upgrades)
(eask-msg "")
Expand All @@ -68,7 +68,7 @@

(eask-start
(eask-pkg-init)
(if-let ((names (eask-args)))
(if-let* ((names (eask-args)))
(dolist (name names)
(setq name (intern name))
(if (package-installed-p name)
Expand Down
2 changes: 1 addition & 1 deletion lisp/extern/package-build/25/package-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ value specified in the file \"NAME.el\"."
nil t)
(match-string-no-properties 1)))
"No description available.")
(when-let ((require-lines (lm-header-multiline "package-requires")))
(when-let* ((require-lines (lm-header-multiline "package-requires")))
(package--prepare-dependencies
(package-read-from-string (mapconcat #'identity require-lines " "))))
:kind (or kind 'single)
Expand Down
2 changes: 1 addition & 1 deletion lisp/extern/package-build/25/package-recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ file is invalid, then raise an error."
(let ((val (plist-get plist key)))
(when val
(cl-assert (stringp val) nil "%s must be a string but is %S" key val))))
(when-let ((spec (plist-get plist :files)))
(when-let* ((spec (plist-get plist :files)))
;; `:defaults' is only allowed as the first element.
;; If we find it in that position, skip over it.
(when (eq (car spec) :defaults)
Expand Down
26 changes: 13 additions & 13 deletions lisp/extern/package-build/26/package-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ main library to a version that qualifies as a release, ignoring
any pre-releases.

Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING)."
(when-let ((lib (package-build--main-library rcp)))
(when-let* ((lib (package-build--main-library rcp)))
(with-temp-buffer
(let (commit date version)
(save-excursion
Expand Down Expand Up @@ -426,7 +426,7 @@ Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING)."
(defun package-build-pkg-version (rcp)
"Return version specified in the \"NAME-pkg.el\" file.
Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING)."
(when-let ((file (package-build--pkgfile rcp)))
(when-let* ((file (package-build--pkgfile rcp)))
(let ((regexp (or (oref rcp version-regexp) package-build-version-regexp))
commit date version)
(catch 'before-latest
Expand Down Expand Up @@ -617,8 +617,8 @@ Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING).
(list rcommit rtime (package-version-join version))))))

(defun package-build--ensure-count-increase (rcp version ahead)
(if-let ((previous (cdr (assq (intern (oref rcp name))
(package-build-archive-alist)))))
(if-let* ((previous (cdr (assq (intern (oref rcp name))
(package-build-archive-alist)))))
;; Because upstream may have rewritten history, we cannot be certain
;; that appending the new count of commits would result in a version
;; string that is greater than the version string used for the
Expand Down Expand Up @@ -993,7 +993,7 @@ value specified in the file \"NAME.el\"."
(if (fboundp 'lm-maintainers)
(lm-maintainers)
(with-no-warnings
(when-let ((maintainer (lm-maintainer)))
(when-let* ((maintainer (lm-maintainer)))
(list maintainer)))))
(package-desc-from-define
name version
Expand All @@ -1003,7 +1003,7 @@ value specified in the file \"NAME.el\"."
^;;; [^ ]*\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" nil t)
(match-string-no-properties 1)))
"No description available.")
(when-let ((require-lines (lm-header-multiline "package-requires")))
(when-let* ((require-lines (lm-header-multiline "package-requires")))
(package--prepare-dependencies
(package-read-from-string
(mapconcat #'identity require-lines " "))))
Expand Down Expand Up @@ -1564,13 +1564,13 @@ a package."
(defun package-build--archive-alist-for-json ()
"Return the archive alist in a form suitable for JSON encoding."
(cl-flet ((format-person
(person)
(let ((name (car person))
(mail (cdr person)))
(if (and name mail)
(format "%s <%s>" name mail)
(or name
(format "<%s>" mail))))))
(person)
(let ((name (car person))
(mail (cdr person)))
(if (and name mail)
(format "%s <%s>" name mail)
(or name
(format "<%s>" mail))))))
(cl-mapcan (lambda (entry)
(list (intern (format ":%s" (car entry)))
(let* ((info (cdr entry))
Expand Down
2 changes: 1 addition & 1 deletion lisp/extern/package-build/26/package-recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ file is invalid, then raise an error."
(let ((val (plist-get plist key)))
(when val
(cl-assert (stringp val) nil "%s must be a string but is %S" key val))))
(when-let ((spec (plist-get plist :files)))
(when-let* ((spec (plist-get plist :files)))
;; `:defaults' is only allowed as the first element.
;; If we find it in that position, skip over it.
(when (eq (car spec) :defaults)
Expand Down
4 changes: 2 additions & 2 deletions lisp/generate/recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
;;; Core

(eask-start
(if-let ((recipe (eask-recipe-string))
(name (eask-guess-package-name)))
(if-let* ((recipe (eask-recipe-string))
(name (eask-guess-package-name)))
(let* ((eask-recipe-path (or (eask-args 0) eask-recipe-path))
(eask-recipe-path (expand-file-name eask-recipe-path))
(recipe-file (expand-file-name name eask-recipe-path))
Expand Down
8 changes: 4 additions & 4 deletions lisp/init/cask.el
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ Optional argument CONTENTS is used for nested directives. e.g. development."
(insert "\n " (eask-2str file))))
(insert ")\n"))

(when-let ((pkg-desc (eask--cask-package-descriptor)))
(when-let* ((pkg-desc (eask--cask-package-descriptor)))
(insert "\n")
(insert "(package-descriptor \"" (eask-2str pkg-desc) "\")\n"))

(insert "\n")
(insert "(script \"test\" \"echo \\\"Error: no test specified\\\" && exit 1\")\n")

(when-let ((sources (eask--cask-sources)))
(when-let* ((sources (eask--cask-sources)))
(insert "\n")
(dolist (source sources)
(insert "(source '" (eask-2str (cadr source)) ")\n")))
Expand All @@ -185,13 +185,13 @@ Optional argument CONTENTS is used for nested directives. e.g. development."
(unless (eask--cask-reqs-no-emacs)
(insert "\n")) ; Make sure end line exists!

(when-let ((pkgs (eask--cask-reqs-no-emacs)))
(when-let* ((pkgs (eask--cask-reqs-no-emacs)))
(insert "\n")
(dolist (pkg pkgs)
(let ((val (mapconcat #'eask-2str (cdr pkg) "\" \"")))
(insert "(depends-on \"" val "\")\n"))))

(when-let ((pkgs (eask--cask-reqs-dev-no-emacs)))
(when-let* ((pkgs (eask--cask-reqs-dev-no-emacs)))
(insert "\n")
(insert "(development\n")
(dolist (pkg pkgs)
Expand Down
8 changes: 4 additions & 4 deletions lisp/init/keg.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ If no found the Keg file, returns nil."
entry-point)))
(insert content)

(when-let ((scripts (alist-get 'scripts contents)))
(when-let* ((scripts (alist-get 'scripts contents)))
(dolist (script scripts)
(let* ((cmds (cadr script))
(_ (pop cmds))
(cmds (mapconcat #'identity cmds " ")))
(insert "(script \"" (eask-2str (car script))
"\" " (prin1-to-string cmds) ")\n"))))

(when-let ((sources (alist-get 'sources contents)))
(when-let* ((sources (alist-get 'sources contents)))
(insert "\n")
(dolist (source sources)
(insert "(source '" (eask-2str source) ")\n")))
Expand All @@ -106,12 +106,12 @@ If no found the Keg file, returns nil."
(unless (alist-get 'packages contents)
(insert "\n")) ; Make sure end line exists!

(when-let ((pkgs (alist-get 'packages contents)))
(when-let* ((pkgs (alist-get 'packages contents)))
(insert "\n")
(dolist (pkg pkgs)
(insert "(depends-on \"" (eask-2str (car pkg)) "\")\n")))

(when-let ((devs (alist-get 'devs contents)))
(when-let* ((devs (alist-get 'devs contents)))
(insert "\n")
(insert "(development\n")
(dolist (dev devs)
Expand Down
2 changes: 1 addition & 1 deletion lisp/init/source.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
;; Files found, do the action!
(files
(dolist (file files)
(when-let ((new-filename (eask-init-source--convert file)))
(when-let* ((new-filename (eask-init-source--convert file)))
(push new-filename converted-files)))
;; Automatically rename file into Eask file when only one file is converted!
(when (= (length converted-files) 1)
Expand Down
4 changes: 2 additions & 2 deletions lisp/run/command.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
((eask-all-p)
(dolist (name (reverse eask-commands))
(eask-run-command--execute name)))
((when-let ((commands (eask-args)))
(if-let ((unmatched (eask-run-command--unmatched-commands commands)))
((when-let* ((commands (eask-args)))
(if-let* ((unmatched (eask-run-command--unmatched-commands commands)))
(progn ; if there are unmatched commands, don't even try to execute
(eask-info "(Missing command%s: `%s`)"
(eask--sinr unmatched "" "s")
Expand Down
Loading
Loading