From 354563fb140816d56271a903e0c574efcaad91af Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Wed, 1 Nov 2023 16:23:37 +0100 Subject: [PATCH] forge-*-at-point: Account for tabulated-list-get-id returning nil That happens at the end of the buffer, including, but not limited to, when the list is empty. --- lisp/forge-issue.el | 3 ++- lisp/forge-pullreq.el | 3 ++- lisp/forge-repo.el | 3 ++- lisp/forge-topic.el | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/forge-issue.el b/lisp/forge-issue.el index 8e0e4d07..6274b3d6 100644 --- a/lisp/forge-issue.el +++ b/lisp/forge-issue.el @@ -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")))) diff --git a/lisp/forge-pullreq.el b/lisp/forge-pullreq.el index 117eaa78..9f4d3660 100644 --- a/lisp/forge-pullreq.el +++ b/lisp/forge-pullreq.el @@ -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")))) diff --git a/lisp/forge-repo.el b/lisp/forge-repo.el index cb246e9d..34de5c0b 100644 --- a/lisp/forge-repo.el +++ b/lisp/forge-repo.el @@ -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 diff --git a/lisp/forge-topic.el b/lisp/forge-topic.el index ccca4dda..7217991e 100644 --- a/lisp/forge-topic.el +++ b/lisp/forge-topic.el @@ -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)