Skip to content

Commit

Permalink
fix: Obsolete when-let and if-let
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Nov 17, 2024
1 parent 9ad9898 commit ab7c061
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 50 deletions.
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
2 changes: 1 addition & 1 deletion lisp/core/loc.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

(require 'markdown-mode)
;; Start LOC
(if-let ((files (or (eask-expand-file-specs (eask-args))
(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
Expand Down
4 changes: 2 additions & 2 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,7 +35,7 @@
recipe)))

(eask-start
(if-let ((recipe (eask-recipe-string))
(if-let* ((recipe (eask-recipe-string))
(name (eask-guess-package-name)))
(progn
(eask-msg "")
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
10 changes: 5 additions & 5 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,7 +617,7 @@ 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))
(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
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
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
2 changes: 1 addition & 1 deletion lisp/generate/recipe.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
;;; Core

(eask-start
(if-let ((recipe (eask-recipe-string))
(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))
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
4 changes: 2 additions & 2 deletions lisp/run/script.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
((eask-all-p) ; Run all scripts
(dolist (data (reverse eask-scripts))
(eask-run-command--export (cdr data))))
((when-let ((scripts (eask-args)))
(if-let ((unmatched (eask-run-script--unmatched-scripts scripts)))
((when-let* ((scripts (eask-args)))
(if-let* ((unmatched (eask-run-script--unmatched-scripts scripts)))
(progn ; if there are unmatched scripts, don't even try to execute
(eask-info "(Missing script%s: `%s`)"
(eask--sinr unmatched "" "s")
Expand Down
4 changes: 2 additions & 2 deletions lisp/source/add.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ The argument EXISTS is use to search for correct position to insert new source."
"Ask source overwrite if needed.
Arguments NAME and URL are main arguments for this command."
(if-let ((exists (assoc name package-archives))
(old-url (cdr exists)))
(if-let* ((exists (assoc name package-archives))
(old-url (cdr exists)))
(cond ((string= old-url url)
(eask-info "(Nothing has changed due to the URLs are the same)"))
((yes-or-no-p
Expand Down
2 changes: 1 addition & 1 deletion lisp/source/delete.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
(eask-start
(let* ((args (eask-args))
(name (nth 0 args)))
(if-let ((exists (assoc name package-archives)))
(if-let* ((exists (assoc name package-archives)))
(eask-source-delete name)
(eask-info "(Invalid source name, `%s')" name)
(eask-help "source/delete"))))
Expand Down

0 comments on commit ab7c061

Please sign in to comment.