diff options
| author | KΓ©vin Le Gouguec <kevin.legouguec@gmail.com> | 2025-01-22 09:32:56 +0100 |
|---|---|---|
| committer | KΓ©vin Le Gouguec <kevin.legouguec@gmail.com> | 2025-01-22 23:53:24 +0100 |
| commit | a8924d1fa1e2ce5f921d3aa54bd3205a6ff3f5b7 (patch) | |
| tree | e2d406fc69e30389ed3afd90ee3e35cd9c02250e | |
| parent | 4fc04f6c0dcf574ac714ded5c01d2dd9627f665f (diff) | |
| download | dotfiles-a8924d1fa1e2ce5f921d3aa54bd3205a6ff3f5b7.tar.xz | |
Ditch when-let
Obsoleted. While in there, rewrite to taste:
- could just switch to when-let*, but I hear and-let* is more
idiomatic for code that returns values; when(-let) OTOH denotes
side-effects.
- project-root (singular) has been available since 28, which is in
Debian stable. Good enough.
- I know about π-let*'s (VALUEFORM) shorthand now.
- β(string-trim-right root "/")β? π€
| -rw-r--r-- | .emacs | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -632,19 +632,25 @@ UPSTREAMS is a list of fetch URLs." ;;;; Frame title. (defun my/project-root () - (when-let ((project (project-current))) - (car (project-roots project)))) + (and-let* ((project (project-current))) + (project-root project))) (defun my/project-name () - (when-let ((root (my/project-root))) - (when (not (file-equal-p root "~")) - (file-name-nondirectory (string-trim-right root "/"))))) + (and-let* ((root (my/project-root)) + ;; Home is under VC to track dotfile changes. Not a + ;; "project" I want shown in the UI though. + ((not (file-equal-p root "~")))) + (file-name-nondirectory (directory-file-name root)))) (defun my/connection-name () - (when-let ((method (file-remote-p default-directory 'method))) - (if (string-match-p "sudo" method) - method - (format "%s:%s" method (file-remote-p default-directory 'host))))) + (let ((method (file-remote-p default-directory 'method))) + (pcase method + ;; No method: nil. + ('nil method) + ;; sudo(edit): just "METHOD". + ((pred (string-match-p "sudo")) method) + ;; Default: "METHOD:HOST". + (_ (format "%s:%s" method (file-remote-p default-directory 'host)))))) (defun my/frame-title-format () (let ((prefix |
