Fix obsolete (when|if)-let messages in Emacs 26

This commit is contained in:
Henrik Lissner 2017-12-10 14:49:52 -05:00
parent e168118243
commit 76a4ae459d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
40 changed files with 110 additions and 103 deletions

View file

@ -31,7 +31,7 @@ DEFAULT-P is a boolean. If non-nil, it marks that email account as the
default/fallback account."
`(after! mu4e
(let ((account-vars ,letvars))
(when-let (address (cdr (assq 'user-mail-address account-vars)))
(when-let* ((address (cdr (assq 'user-mail-address account-vars))))
(cl-pushnew address mu4e-user-mail-address-list :test #'equal))
(let ((context (make-mu4e-context
:name ,label

View file

@ -88,7 +88,7 @@ playback.")
(defun +irc*circe-truncate-nicks ()
"Truncate long nicknames in chat output non-destructively."
(when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick))
(when-let* ((beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick)))
(goto-char beg)
(let ((end (next-single-property-change beg 'lui-format-argument))
(nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords)

View file

@ -261,7 +261,7 @@ __DATA__
(overlay-put ov 'category '+regex))
(cl-incf i)
(dotimes (i 10)
(when-let (text (match-string i))
(when-let* ((text (match-string i)))
(save-match-data
(with-current-buffer +regex--groups-buffer
(goto-char (point-max))

View file

@ -11,7 +11,7 @@
(interactive)
(doom-kill-matching-buffers "^\\*elfeed")
(dolist (file +rss-elfeed-files)
(when-let (buf (get-file-buffer (expand-file-name file +rss-org-dir)))
(when-let* ((buf (get-file-buffer (expand-file-name file +rss-org-dir))))
(kill-buffer buf))))
;;;###autoload

View file

@ -73,9 +73,9 @@ If ARG (universal argument), open selection in other-window."
(task-tags (mapcar #'car +ivy-task-tags))
(cmd
(format "%s -H -S --no-heading -- %s %s"
(or (when-let (bin (executable-find "rg"))
(or (when-let* ((bin (executable-find "rg")))
(concat bin " --line-number"))
(when-let (bin (executable-find "ag"))
(when-let* ((bin (executable-find "ag")))
(concat bin " --numbers"))
(error "ripgrep & the_silver_searcher are unavailable"))
(shell-quote-argument

View file

@ -13,7 +13,7 @@
"Evaluate a region between BEG and END and display the output."
(interactive "r")
(let ((load-file-name buffer-file-name))
(if-let (runner (cdr (assq major-mode +eval-runners)))
(if-let* ((runner (cdr (assq major-mode +eval-runners))))
(funcall runner beg end)
(quickrun-region beg end))))

View file

@ -7,7 +7,7 @@
(or (eq (current-buffer) +eval-repl-buffer)
(progn
(if (and +eval-repl-buffer (buffer-live-p +eval-repl-buffer))
(if-let (win (get-buffer-window +eval-repl-buffer))
(if-let* ((win (get-buffer-window +eval-repl-buffer)))
(select-window win)
(doom-popup-buffer +eval-repl-buffer))
(when command
@ -29,7 +29,7 @@
"Opens (or reopens) the REPL associated with the current major-mode and place
the cursor at the prompt."
(interactive)
(when-let (command (cdr (assq major-mode +eval-repls)))
(when-let* ((command (cdr (assq major-mode +eval-repls))))
(when (+eval--ensure-in-repl-buffer command)
(when (bound-and-true-p evil-mode)
(call-interactively #'evil-append-line))

View file

@ -74,7 +74,7 @@ function that creates and returns the REPL buffer."
(defun +eval*quickrun-auto-close (&rest _)
"Allows us to silently re-run quickrun from within the quickrun buffer."
(when-let (win (get-buffer-window quickrun--buffer-name))
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
(let ((inhibit-message t))
(quickrun--kill-running-process)
(message ""))

View file

@ -77,7 +77,7 @@ overwrite the destination file if it exists, without confirmation."
(pcase (catch 'status
(let ((old-path (buffer-file-name))
(new-path (expand-file-name new-path)))
(when-let (dest (+evil--copy-file old-path new-path force-p))
(when-let* ((dest (+evil--copy-file old-path new-path force-p)))
(delete-file old-path)
(kill-this-buffer)
(find-file new-path)
@ -95,7 +95,7 @@ overwrite the destination file if it exists, without confirmation."
:repeat nil
(interactive "<f><!>")
(pcase (catch 'status
(when-let (dest (+evil--copy-file (buffer-file-name) new-path force-p))
(when-let* ((dest (+evil--copy-file (buffer-file-name) new-path force-p)))
(message "File successfully copied to %s" dest)))
('overwrite-self (error "Cannot overwrite self"))
('aborted (message "Aborted"))

View file

@ -180,11 +180,11 @@ across windows."
(evil-embrace-enable-evil-surround-integration)
(defun +evil--embrace-get-pair (char)
(if-let (pair (cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist)))
(if-let* ((pair (cdr-safe (assoc (string-to-char char) evil-surround-pairs-alist))))
pair
(if-let (pair (assoc-default char embrace--pairs-list))
(if-let (real-pair (and (functionp (embrace-pair-struct-read-function pair))
(funcall (embrace-pair-struct-read-function pair))))
(if-let* ((pair (assoc-default char embrace--pairs-list)))
(if-let* ((real-pair (and (functionp (embrace-pair-struct-read-function pair))
(funcall (embrace-pair-struct-read-function pair)))))
real-pair
(cons (embrace-pair-struct-left pair) (embrace-pair-struct-right pair)))
(cons char char))))

View file

@ -70,8 +70,8 @@ properties:
(defun +jump|init ()
"Initialize `+jump-current-functions', used by `+jump/definition',
`+jump/references' and `+jump/documentation'."
(when-let (plist (cdr (assq major-mode +jump-function-alist)))
(when-let (backend (plist-get plist :xref-backend))
(when-let* ((plist (cdr (assq major-mode +jump-function-alist))))
(when-let* ((backend (plist-get plist :xref-backend)))
(make-variable-buffer-local 'xref-backend-functions)
(cl-pushnew backend xref-backend-functions :test #'eq))
(setq-local +jump-current-functions plist)))

View file

@ -11,7 +11,7 @@ and switches to insert mode if there are editable fields."
(cl-letf (((symbol-function 'region-beginning) (lambda () evil-visual-beginning))
((symbol-function 'region-end) (lambda () evil-visual-end)))
(yas-insert-snippet))
(when-let (snippet (car-safe (yas-active-snippets)))
(when-let* ((snippet (car-safe (yas-active-snippets))))
(let ((fields (yas--snippet-fields snippet)))
(evil-insert-state +1)
(unless fields (evil-change-state 'normal)))))

View file

@ -27,7 +27,7 @@ repository root."
(defun +vcs/git-browse-issues ()
"Open the github issues page for current repo."
(interactive)
(if-let (root (+vcs-root))
(if-let* ((root (+vcs-root)))
(browse-url (concat root "/issues"))
(user-error "No git root found!")))

View file

@ -53,7 +53,7 @@
;;;###autoload
(defun +workspace-get (name &optional noerror)
"Returns a workspace (perspective hash table) named NAME."
(when-let (persp (persp-get-by-name name))
(when-let* ((persp (persp-get-by-name name)))
(cond ((+workspace-p persp) persp)
((not noerror) (error "'%s' is an invalid workspace" name)))))

View file

@ -35,9 +35,9 @@ compilation database is present in the project.")
(or (file-exists-p (expand-file-name
(concat (file-name-sans-extension buffer-file-name)
".cpp")))
(when-let (file (car-safe (projectile-get-other-files
buffer-file-name
(projectile-current-project-files))))
(when-let* ((file (car-safe (projectile-get-other-files
buffer-file-name
(projectile-current-project-files)))))
(equal (file-name-extension file) "cpp")))))
(defun +cc-objc-header-file-p ()

View file

@ -10,14 +10,14 @@ ignore the cache."
(or (and (not refresh-p)
(gethash project-root +javascript-npm-conf))
(let ((package-file (expand-file-name "package.json" project-root)))
(when-let (json (and (file-exists-p package-file)
(json-read-file package-file)))
(when-let* ((json (and (file-exists-p package-file)
(json-read-file package-file))))
(puthash project-root json +javascript-npm-conf))))))
;;;###autoload
(defun +javascript-npm-dep-p (packages &optional project-root refresh-p)
(when-let (data (and (bound-and-true-p +javascript-npm-mode)
(+javascript-npm-conf project-root refresh-p)))
(when-let* ((data (and (bound-and-true-p +javascript-npm-mode)
(+javascript-npm-conf project-root refresh-p))))
(let ((deps (append (cdr (assq 'dependencies data))
(cdr (assq 'devDependencies data)))))
(cond ((listp packages)

View file

@ -27,8 +27,8 @@
(defun +javascript|init-flycheck-eslint ()
"Favor local eslint over global installs and configure flycheck for eslint."
(when (derived-mode-p 'js-mode)
(when-let ((exec-path (list (doom-project-expand "node_modules/.bin")))
(eslint (executable-find "eslint")))
(when-let* (((exec-path (list (doom-project-expand "node_modules/.bin")))
(eslint (executable-find "eslint"))))
(setq-local flycheck-javascript-eslint-executable eslint))
(when (flycheck-find-checker-executable 'javascript-eslint)
;; Flycheck has it's own trailing command and semicolon warning that was

View file

@ -35,8 +35,8 @@
;; (goto-char (point-min))
;; (while (progn (org-next-link) (not org-link-search-failed))
;; (setq element (org-element-context))
;; (when-let (file (and (eq (org-element-type element) 'link)
;; (expand-file-name (org-element-property :path element))))
;; (when-let* (file (and (eq (org-element-type element) 'link)
;; (expand-file-name (org-element-property :path element))))
;; (when (and (string= (org-element-property :type element) "file")
;; (string= (concat (file-name-base (directory-file-name (file-name-directory file))) "/")
;; org-attach-directory)

View file

@ -18,12 +18,12 @@
Uses the capture template specified by KEY. Otherwise, prompts you for one."
(interactive)
(let ((key (or key "n")))
(if-let (string (cond ((not (equal string ""))
string)
((region-active-p)
(buffer-substring-no-properties
(region-beginning)
(region-end)))))
(if-let* ((string (cond ((not (equal string ""))
string)
((region-active-p)
(buffer-substring-no-properties
(region-beginning)
(region-end))))))
(org-capture-string string key)
(org-capture nil key))))

View file

@ -4,7 +4,7 @@
"The directory where org files are kept.")
;; Ensure ELPA org is prioritized above built-in org.
(when-let (path (locate-library "org" nil doom--package-load-path))
(when-let* ((path (locate-library "org" nil doom--package-load-path)))
(setq load-path (delete path load-path))
(push (file-name-directory path) load-path))

View file

@ -9,6 +9,6 @@ ignore the cache."
(let ((project-root (or project-root (doom-project-root))))
(or (and (not refresh-p) (gethash project-root +php-composer-conf))
(let ((package-file (expand-file-name "composer.json" project-root)))
(when-let (data (and (file-exists-p package-file)
(json-read-file package-file)))
(when-let* ((data (and (file-exists-p package-file)
(json-read-file package-file))))
(puthash project-root data +php-composer-conf))))))

View file

@ -55,7 +55,7 @@ is loaded.")
(defun +python|detect-pyenv-version ()
"Detect the pyenv version for the current project and set the relevant
environment variables."
(when-let (version-str (shell-command-to-string "python --version 2>&1 | cut -d' ' -f2"))
(when-let* ((version-str (shell-command-to-string "python --version 2>&1 | cut -d' ' -f2")))
(setq version-str (string-trim version-str)
+python-current-version version-str)
(let ((pyenv-current-path (concat +python-pyenv-root "/versions/" version-str)))

View file

@ -43,7 +43,7 @@
(defun +ruby|detect-rbenv-version ()
"Detect the rbenv version for the current project and set the relevant
environment variables."
(when-let (version-str (shell-command-to-string "ruby --version 2>&1 | cut -d' ' -f2"))
(when-let* ((version-str (shell-command-to-string "ruby --version 2>&1 | cut -d' ' -f2")))
(setq version-str (string-trim version-str)
+ruby-current-version version-str)
(when (member version-str +ruby-rbenv-versions)

View file

@ -12,7 +12,7 @@ private/hlissner/snippets."
(defun +hlissner/yank-buffer-filename ()
"Copy the current buffer's path to the kill ring."
(interactive)
(if-let (filename (or buffer-file-name (bound-and-true-p list-buffers-directory)))
(if-let* ((filename (or buffer-file-name (bound-and-true-p list-buffers-directory))))
(message (kill-new (abbreviate-file-name filename)))
(error "Couldn't find filename in current buffer")))

View file

@ -41,8 +41,8 @@ module to be loaded."
(user-error ":feature workspaces is required, but disabled"))
(unless (+workspace-get "eshell" t)
(+workspace/new "eshell"))
(if-let (buf (cl-find-if (lambda (it) (string-match-p "^\\*doom:eshell" (buffer-name (window-buffer it))))
(doom-visible-windows)))
(if-let* ((buf (cl-find-if (lambda (it) (string-match-p "^\\*doom:eshell" (buffer-name (window-buffer it))))
(doom-visible-windows))))
(select-window (get-buffer-window buf))
(+eshell/open))
(doom/workspace-display)

View file

@ -4,7 +4,7 @@
(defun +gist/open-current ()
(interactive)
(gist-fetch-current)
(when-let (win (get-buffer-window "*github:gists*"))
(when-let* ((win (get-buffer-window "*github:gists*")))
(doom/popup-close win)))
;;;###autoload

View file

@ -21,7 +21,7 @@
(defun +neotree/collapse-or-up ()
"Collapse an expanded directory node or go to the parent node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(if (file-directory-p node)
(if (neo-buffer--expanded-node-p node)
(+neotree/collapse)
@ -32,7 +32,7 @@
(defun +neotree/collapse ()
"Collapse a neotree node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(when (file-directory-p node)
(neo-buffer--set-expand node nil)
(neo-buffer--refresh t))
@ -43,7 +43,7 @@
(defun +neotree/expand-or-open ()
"Expand or open a neotree node."
(interactive)
(when-let (node (neo-buffer--get-filename-current-line))
(when-let* ((node (neo-buffer--get-filename-current-line)))
(cond ((file-directory-p node)
(neo-buffer--set-expand node t)
(neo-buffer--refresh t)

View file

@ -13,7 +13,7 @@
;;;###autoload
(defun +pass-get-field (entry fields)
(unless noninteractive
(if-let (data (if (listp entry) entry (auth-pass-parse-entry entry)))
(if-let* ((data (if (listp entry) entry (auth-pass-parse-entry entry))))
(cl-loop for key in (doom-enlist fields)
when (assoc key data)
return (cdr it))
@ -28,7 +28,7 @@
(+pass-get-field entry 'secret))
(defun +pass-ivy-action--open-url (entry)
(if-let (url (+pass-get-field entry +pass-url-fields))
(if-let* ((url (+pass-get-field entry +pass-url-fields)))
(and (or (string-match-p "https?://" url)
(error "Field for %s doesn't look like an url" item))
(browse-url url))
@ -48,7 +48,7 @@
(error "Couldn't find entry: %s" item))))
(defun +pass-ivy-action--copy-username (entry)
(if-let (user (+pass-get-field entry +pass-user-fields))
(if-let* ((user (+pass-get-field entry +pass-user-fields)))
(progn (password-store-clear)
(message "Copied username to the kill ring.")
(kill-new user))

View file

@ -108,11 +108,11 @@ but do not execute them."
;;;###autoload
(defun +tmux-list-windows (&optional session)
(if-let (lines
(+tmux (format "list-windows %s -F '#{window_id};#{session_id};#{window_active};#{window_name};#{window_activity_flag}'"
(if session
(concat "-t " (car session))
"-a"))))
(if-let* ((lines
(+tmux (format "list-windows %s -F '#{window_id};#{session_id};#{window_active};#{window_name};#{window_activity_flag}'"
(if session
(concat "-t " (car session))
"-a")))))
(cl-loop for line in (string-split lines "\n" t)
collect (let ((window (string-split line ";")))
(list (nth 0 window)
@ -124,13 +124,13 @@ but do not execute them."
;;;###autoload
(defun +tmux-list-panes (&optional sess-or-win)
(if-let (lines
(+tmux (format "list-panes %s -F '#{pane_id};#{window_id};#{session_id};#{pane_active};#{pane_title};#{pane_current_path}'"
(if sess-or-win
(concat (if (string-prefix-p "$" (car sess-or-win)) "-s ")
"-t "
(car sess-or-win))
"-a"))))
(if-let* ((lines
(+tmux (format "list-panes %s -F '#{pane_id};#{window_id};#{session_id};#{pane_active};#{pane_title};#{pane_current_path}'"
(if sess-or-win
(concat (if (string-prefix-p "$" (car sess-or-win)) "-s ")
"-t "
(car sess-or-win))
"-a")))))
(cl-loop for line in (string-split lines "\n" t)
collect (let ((pane (split-string line ";")))
(list (nth 0 pane)

View file

@ -50,7 +50,7 @@
(defvar +doom-modeline-current-window (frame-selected-window))
(defun +doom-modeline|set-selected-window (&rest _)
"Sets `+doom-modeline-current-window' appropriately"
(when-let (win (frame-selected-window))
(when-let* ((win (frame-selected-window)))
(unless (minibuffer-window-active-p win)
(setq +doom-modeline-current-window win))))