diff --git a/modules/init-company.el b/modules/init-company.el index 555634a0..8f88b274 100644 --- a/modules/init-company.el +++ b/modules/init-company.el @@ -39,7 +39,7 @@ (when (or (save-match-data (looking-at "\\W")) (= (point) (point-max))) (cons (or (match-string 1) "") t))))) - (candidates (when-let ((repo (forge-get-repository 'full))) + (candidates (when-let* ((repo (forge-get-repository 'full))) (cl-remove-if-not (lambda (assignee) (string-prefix-p arg assignee)) @@ -47,7 +47,7 @@ (propertize (cadr assignee) 'full-name (caddr assignee))) (oref repo assignees))))) - (annotation (when-let ((assignee (get-text-property 0 'full-name arg))) + (annotation (when-let* ((assignee (get-text-property 0 'full-name arg))) (format " [%s]" assignee))))) :config diff --git a/modules/init-flycheck.el b/modules/init-flycheck.el index 79e7b0d6..3090217d 100644 --- a/modules/init-flycheck.el +++ b/modules/init-flycheck.el @@ -97,20 +97,20 @@ See URL `http://mypy-lang.org/'." :predicate flycheck-buffer-saved-p :error-explainer (lambda (error) - (when-let ((error-code (flycheck-error-id error)) - (mypy-version - (replace-regexp-in-string - "mypy \\(\\(?:[0-9]\\.\\)+[0-9]\\).*\n" - "\\1" - (shell-command-to-string "mypy --version"))) - (error-codes-alist - (exordium-setf-when-nil - (alist-get (intern mypy-version) - exordium--flycheck-mypy-error-codes-alist) - (exodrium--flycheck-mypy-retrieve-error-codes - mypy-version))) - (explanation (alist-get (intern error-code) - error-codes-alist))) + (when-let* ((error-code (flycheck-error-id error)) + (mypy-version + (replace-regexp-in-string + "mypy \\(\\(?:[0-9]\\.\\)+[0-9]\\).*\n" + "\\1" + (shell-command-to-string "mypy --version"))) + (error-codes-alist + (exordium-setf-when-nil + (alist-get (intern mypy-version) + exordium--flycheck-mypy-error-codes-alist) + (exodrium--flycheck-mypy-retrieve-error-codes + mypy-version))) + (explanation (alist-get (intern error-code) + error-codes-alist))) (lambda () (with-current-buffer standard-output (insert explanation) @@ -161,7 +161,7 @@ See URL `http://pypi.python.org/pypi/ruff'." line-end)) :error-explainer (lambda (error) - (when-let (error-code (flycheck-error-id error)) + (when-let* (error-code (flycheck-error-id error)) (lambda () (flycheck-call-checker-process 'exordium-python-ruff nil standard-output t "rule" error-code) diff --git a/modules/init-forge.el b/modules/init-forge.el index b24b5a48..1b04f0f3 100644 --- a/modules/init-forge.el +++ b/modules/init-forge.el @@ -83,26 +83,26 @@ USERNAME, AUTH, and HOST behave as for `ghub-request'." (defun exordium-forge-mark-ready-for-rewiew () "Mark the thing (the PR) at point as ready for review." (interactive) - (if-let ((url (forge-get-url (or (forge-post-at-point) - (forge-current-topic)))) - (_ (string-match - "//\\([^/]+\\)/\\([^/]+\\)/\\([^/]+\\)/pull/\\([0-9]+\\)$" - url)) - (number (match-string 4 url)) - (host (car (alist-get (match-string 1 url) - forge-alist - nil nil #'string=))) - (username (magit-git-string "config" - (concat "github." host ".user"))) - (id (exordium-ghub-graphql--pull-request-id - (match-string 2 url) - (match-string 3 url) - (string-to-number number) - :username username :auth 'forge :host host)) - (not-a-draft-anymore - (not (exordium-ghub-grqphql--mark-pull-request-ready-for-review - id - :username username :auth 'forge :host host)))) + (if-let* ((url (forge-get-url (or (forge-post-at-point) + (forge-current-topic)))) + (_ (string-match + "//\\([^/]+\\)/\\([^/]+\\)/\\([^/]+\\)/pull/\\([0-9]+\\)$" + url)) + (number (match-string 4 url)) + (host (car (alist-get (match-string 1 url) + forge-alist + nil nil #'string=))) + (username (magit-git-string "config" + (concat "github." host ".user"))) + (id (exordium-ghub-graphql--pull-request-id + (match-string 2 url) + (match-string 3 url) + (string-to-number number) + :username username :auth 'forge :host host)) + (not-a-draft-anymore + (not (exordium-ghub-grqphql--mark-pull-request-ready-for-review + id + :username username :auth 'forge :host host)))) (message "PR #%s is ready for review." number) (user-error "Nothing at point that is a PR or mark failed"))) @@ -167,15 +167,15 @@ Each element of TO-DELETE is in the same format as used in (defun exordium-forge-cleanup-known-repositories () "Cleanup forge repositories whose worktree doesn't exist anymore." (interactive) - (if-let ((to-delete (cl-remove-if - (lambda (repo) - (if-let ((worktree (car repo))) - (file-exists-p worktree) - t)) - (forge-sql [:select [worktree githost owner name] - :from repository - :order-by [(asc owner) (asc name)]] - [worktree githost owner name])))) + (if-let* ((to-delete (cl-remove-if + (lambda (repo) + (if-let* ((worktree (car repo))) + (file-exists-p worktree) + t)) + (forge-sql [:select [worktree githost owner name] + :from repository + :order-by [(asc owner) (asc name)]] + [worktree githost owner name])))) (when (yes-or-no-p (exordium-forge-cleanup-known-repositories--question to-delete)) (async-start @@ -187,7 +187,7 @@ Each element of TO-DELETE is in the same format as used in ,(async-inject-variables "\\`\\(to-delete\\|forge-alist\\)\\'") (let (results) (dolist (repo to-delete) - (when-let ((forge-repo (forge-get-repository (cdr repo)))) + (when-let* ((forge-repo (forge-get-repository (cdr repo)))) (let ((t0 (current-time)) ;; Timeout is huge (10x what was the default at the ;; time of writing this) as db ops are long sometimes. diff --git a/modules/init-helm-projectile.el b/modules/init-helm-projectile.el index 141981fa..579bee93 100644 --- a/modules/init-helm-projectile.el +++ b/modules/init-helm-projectile.el @@ -42,7 +42,7 @@ (defun exordium-helm-projectile--exit-helm-and-do-ag () "Exit helm and run ag on first selected candidate." (interactive) - (if-let ((project (car (helm-marked-candidates)))) + (if-let* ((project (car (helm-marked-candidates)))) (helm-run-after-exit #'helm-do-ag project) (error "No candidates selected"))) @@ -56,7 +56,7 @@ (defun exordium-helm-projectile--exit-helm-and-do-rg () "Exit helm and switch project to first selected candidate and run rg there." (interactive) - (if-let ((project (car (helm-marked-candidates)))) + (if-let* ((project (car (helm-marked-candidates)))) (helm-run-after-exit #'exordium-helm-projectile--switch-project-and-do-rg project) (error "No candidates selected"))) diff --git a/modules/init-iwyu.el b/modules/init-iwyu.el index bb491cc1..db94a97b 100644 --- a/modules/init-iwyu.el +++ b/modules/init-iwyu.el @@ -129,19 +129,19 @@ arguments in `exordium-iwyu-extra-args'." with '.h' extension) it uses the corresponding implementation, i.e., the file with '.cpp' extension." (interactive) - (if-let ((compile-commands-json - (cl-find-if #'file-exists-p - (mapcar (lambda (build-dir) - (concat (file-name-as-directory (concat (projectile-project-root) - build-dir)) - "compile_commands.json")) - '("cmake.bld/Linux" "build" "cmake-build" "cmake-build/linux_64_static_ninja_Debug")))) - (file-name (file-name-nondirectory buffer-file-name))) + (if-let* ((compile-commands-json + (cl-find-if #'file-exists-p + (mapcar (lambda (build-dir) + (concat (file-name-as-directory (concat (projectile-project-root) + build-dir)) + "compile_commands.json")) + '("cmake.bld/Linux" "build" "cmake-build" "cmake-build/linux_64_static_ninja_Debug")))) + (file-name (file-name-nondirectory buffer-file-name))) (iwyu-start-process-for compile-commands-json (if (string= "h" (file-name-extension file-name)) (concat (file-name-sans-extension file-name) ".cpp") - file-name)) + file-name)) (message "Cannot find compile_commands.json for this project"))) diff --git a/modules/init-lib.el b/modules/init-lib.el index 56733746..5d98c070 100644 --- a/modules/init-lib.el +++ b/modules/init-lib.el @@ -59,7 +59,7 @@ dirs. Input is a string and output is a list of strings." (defun exordium-browse-url-at-point () "Open an URL at point." (interactive) - (when-let ((url (thing-at-point 'url))) + (when-let* ((url (thing-at-point 'url))) (browse-url url))) (defmacro exordium-setf-when-nil (&rest args) diff --git a/modules/init-org.el b/modules/init-org.el index b4e4e353..b6fd8265 100644 --- a/modules/init-org.el +++ b/modules/init-org.el @@ -56,10 +56,10 @@ This is a spin off https://stackoverflow.com/a/66911315/519827, but REFRESH is s (org-mark-subtree) (setq beg (point)) (setq end (mark))) - (when-let ((info (org-babel-get-src-block-info t)) - (params (org-babel-process-params (nth 2 info))) - (result-params (cdr (assq :result params))) - ((string-match-p "graphics" result-params))) + (when-let* ((info (org-babel-get-src-block-info t)) + (params (org-babel-process-params (nth 2 info))) + (result-params (cdr (assq :result params))) + ((string-match-p "graphics" result-params))) (org-display-inline-images nil nil beg end))))) (add-hook 'org-babel-after-execute-hook #'exordium--org-babel-after-execute) diff --git a/modules/init-treesit.el b/modules/init-treesit.el index 0c6b7acb..368eadca 100644 --- a/modules/init-treesit.el +++ b/modules/init-treesit.el @@ -3,9 +3,9 @@ ;;;; Configuration for Treesitter (defun exordium--add-forward-ts-hook (mode) - (when-let ((ts-hook (intern (concat (symbol-name mode) "-ts-mode-hook"))) - (hook (intern (concat (symbol-name mode) "-mode-hook"))) - ((and (symbolp ts-hook) (symbolp hook)))) + (when-let* ((ts-hook (intern (concat (symbol-name mode) "-ts-mode-hook"))) + (hook (intern (concat (symbol-name mode) "-mode-hook"))) + ((and (symbolp ts-hook) (symbolp hook)))) (add-hook ts-hook #'(lambda () (run-hooks hook))))) @@ -60,8 +60,8 @@ :custom (font-lock-maximum-decoration t) :config - (when-let ((language-name (alist-get 'ruby-mode - tree-sitter-major-mode-language-alist))) + (when-let* ((language-name (alist-get 'ruby-mode + tree-sitter-major-mode-language-alist))) (add-to-list 'tree-sitter-major-mode-language-alist (cons 'enh-ruby-mode language-name))) (add-to-list 'tree-sitter-major-mode-language-alist diff --git a/modules/init-util-cl.t.el b/modules/init-util-cl.t.el index 81a45846..b57e349a 100644 --- a/modules/init-util-cl.t.el +++ b/modules/init-util-cl.t.el @@ -18,12 +18,12 @@ "Collect results into `exordium--test-found-obsoltete-aliases'. This is meant to be applied as an advice around `elisp-refs--show-results'." - (when-let ((files (mapcar (lambda (result) - (string-trim-right - (string-trim-left (buffer-name (cdr result)) - " \\*refs-") - "\\*")) - (cl-third args)))) + (when-let* ((files (mapcar (lambda (result) + (string-trim-right + (string-trim-left (buffer-name (cdr result)) + " \\*refs-") + "\\*")) + (cl-third args)))) (add-to-list 'exordium--test-found-obsolete-aliases (cons (cl-first args) files)))) diff --git a/modules/init-util.el b/modules/init-util.el index c9a7cfce..81338b39 100644 --- a/modules/init-util.el +++ b/modules/init-util.el @@ -503,53 +503,53 @@ Otherwise escape quotes in the inner string (rationalising escaping)." ;; string delimeter: first and last two quotes are a separate sexp, and ;; the `forward-sexp' only works from the most inner quote. However, ;; in emacs-27, the `forward-sexp' works only from the most outer quote. - (when-let ((orig-start (if (region-active-p) - (let* ((pt (min (region-beginning) - (region-end))) - (c (char-after pt))) - (when (or (eq c ?\') (eq c ?\")) - pt)) - (when-let ((pos (nth 8 (syntax-ppss))) - (c (char-after pos))) - (if (and (< (1+ (point-min)) pos) - (eq c (char-after (- pos 1))) - (eq c (char-after (- pos 2)))) - (- pos 2) - (- pos 0))))) - (orig-quote (char-after orig-start)) - (new-quote (pcase orig-quote - (?\' ?\") - (?\" ?\'))) - (quote-length (if (and (eq orig-quote + (when-let* ((orig-start (if (region-active-p) + (let* ((pt (min (region-beginning) + (region-end))) + (c (char-after pt))) + (when (or (eq c ?\') (eq c ?\")) + pt)) + (when-let* ((pos (nth 8 (syntax-ppss))) + (c (char-after pos))) + (if (and (< (1+ (point-min)) pos) + (eq c (char-after (- pos 1))) + (eq c (char-after (- pos 2)))) + (- pos 2) + (- pos 0))))) + (orig-quote (char-after orig-start)) + (new-quote (pcase orig-quote + (?\' ?\") + (?\" ?\'))) + (quote-length (if (and (eq orig-quote (char-after (+ orig-start 1))) - (eq orig-quote - (char-after (+ orig-start 2)))) - 3 - 1)) - (orig-end (if (region-active-p) - (let* ((pt (max (region-beginning) - (region-end))) - (c (char-after (1- pt)))) - (when (eq c orig-quote) - pt)) - (save-excursion - (goto-char orig-start) - (forward-char (if (version< emacs-version "28") - 0 - (logand quote-length 2))) - (forward-sexp) - (forward-char (if (version< emacs-version "28") - 0 - (logand quote-length 2))) - (point))))) + (eq orig-quote + (char-after (+ orig-start 2)))) + 3 + 1)) + (orig-end (if (region-active-p) + (let* ((pt (max (region-beginning) + (region-end))) + (c (char-after (1- pt)))) + (when (eq c orig-quote) + pt)) + (save-excursion + (goto-char orig-start) + (forward-char (if (version< emacs-version "28") + 0 + (logand quote-length 2))) + (forward-sexp) + (forward-char (if (version< emacs-version "28") + 0 + (logand quote-length 2))) + (point))))) (goto-char orig-start) (delete-char quote-length) (insert-char new-quote quote-length) (while (< (point) (- orig-end quote-length)) (if flip-inner - (if-let ((a-quote (pcase (char-after) - (?\' ?\") - (?\" ?\')))) + (if-let* ((a-quote (pcase (char-after) + (?\' ?\") + (?\" ?\')))) (progn (delete-char 1) (insert-char a-quote))