Skip to content

Commit

Permalink
Use eieio pcase pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Nov 2, 2023
1 parent a0f4d4c commit a36101f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
28 changes: 14 additions & 14 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -864,20 +864,20 @@ information."
(forge--branch-pullreq (forge-get-pullreq pullreq))))

(defun forge-checkout-worktree-default-read-directory-function (pullreq)
(with-slots (number head-ref) pullreq
(let ((path (read-directory-name
(format "Checkout #%s in new worktree: " number)
(file-name-directory
(directory-file-name default-directory))
nil nil
(let ((branch (forge--pullreq-branch-internal pullreq)))
(if (string-match-p "\\`pr-[0-9]+\\'" branch)
(number-to-string number)
(format "%s-%s" number
(string-replace "/" "-" head-ref)))))))
(when (equal path "")
(user-error "The empty string isn't a valid path"))
path)))
(pcase-let* (((eieio number head-ref) pullreq)
(path (read-directory-name
(format "Checkout #%s in new worktree: " number)
(file-name-directory
(directory-file-name default-directory))
nil nil
(let ((branch (forge--pullreq-branch-internal pullreq)))
(if (string-match-p "\\`pr-[0-9]+\\'" branch)
(number-to-string number)
(format "%s-%s" number
(string-replace "/" "-" head-ref)))))))
(when (equal path "")
(user-error "The empty string isn't a valid path"))
path))

;;; Marks

Expand Down
32 changes: 16 additions & 16 deletions lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -644,23 +644,23 @@ This mode itself is never used directly."

;;;;; Refs

(cl-defun forge-insert-topic-refs
(&optional (topic forge-buffer-topic))
(cl-defun forge-insert-topic-refs (&optional (topic forge-buffer-topic))
(magit-insert-section (topic-refs)
(with-slots (cross-repo-p base-repo base-ref head-repo head-ref) topic
(let ((separator (propertize ":" 'font-lock-face 'magit-dimmed))
(deleted (propertize "(deleted)" 'font-lock-face 'magit-dimmed)))
(insert (format "%-11s" "Refs: ")
(if cross-repo-p
(concat base-repo separator base-ref)
base-ref)
(propertize "..." 'font-lock-face 'magit-dimmed)
(if cross-repo-p
(if (and head-repo head-ref)
(concat head-repo separator head-ref)
deleted)
(or head-ref deleted))
"\n")))))
(pcase-let
(((eieio cross-repo-p base-repo base-ref head-repo head-ref) topic)
(separator (propertize ":" 'font-lock-face 'magit-dimmed))
(deleted (propertize "(deleted)" 'font-lock-face 'magit-dimmed)))
(insert (format "%-11s" "Refs: ")
(if cross-repo-p
(concat base-repo separator base-ref)
base-ref)
(propertize "..." 'font-lock-face 'magit-dimmed)
(if cross-repo-p
(if (and head-repo head-ref)
(concat head-repo separator head-ref)
deleted)
(or head-ref deleted))
"\n"))))

;;;;; Assignees

Expand Down

0 comments on commit a36101f

Please sign in to comment.