Skip to content

Commit

Permalink
forge-*-at-point: Account for tabulated-list-get-id returning nil
Browse files Browse the repository at this point in the history
That happens at the end of the buffer, including, but not limited
to, when the list is empty.
  • Loading branch information
tarsius committed Nov 1, 2023
1 parent 13959d3 commit 354563f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lisp/forge-issue.el
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ an error."
(or (thing-at-point 'forge-issue)
(magit-section-value-if 'issue)
(and (derived-mode-p 'forge-topic-list-mode)
(let ((topic (forge-get-topic (tabulated-list-get-id))))
(and-let* ((id (tabulated-list-get-id))
(topic (forge-get-topic id)))
(and (forge-issue-p topic)
topic)))
(and demand (user-error "No issue at point"))))
Expand Down
3 changes: 2 additions & 1 deletion lisp/forge-pullreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ an error."
(magit-section-value-if 'pullreq)
(forge-get-pullreq :branch (magit-branch-at-point))
(and (derived-mode-p 'forge-topic-list-mode)
(let ((topic (forge-get-topic (tabulated-list-get-id))))
(and-let* ((id (tabulated-list-get-id))
(topic (forge-get-topic id)))
(and (forge-pullreq-p topic)
topic)))
(and demand (user-error "No pull-request at point"))))
Expand Down
3 changes: 2 additions & 1 deletion lisp/forge-repo.el
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ an error."
(and-let* ((topic (forge-topic-at-point nil 'not-thingatpt)))
(forge-get-repository topic))
(and (derived-mode-p 'forge-repository-list-mode)
(forge-get-repository :id (tabulated-list-get-id)))
(and-let* ((id (tabulated-list-get-id)))
(forge-get-repository :id id)))
(and demand (user-error "No repository at point"))))

;;; Identity
Expand Down
3 changes: 2 additions & 1 deletion lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ an error. If NOT-THINGATPT is non-nil, then don't use
(magit-section-value-if '(issue pullreq))
(forge-get-pullreq :branch (magit-branch-at-point))
(and (derived-mode-p 'forge-topic-list-mode)
(forge-get-topic (tabulated-list-get-id)))
(and-let* ((id (tabulated-list-get-id)))
(forge-get-topic id)))
(and demand (user-error "No topic at point"))))

(put 'forge-topic 'thing-at-point #'forge-thingatpt--topic)
Expand Down

0 comments on commit 354563f

Please sign in to comment.