Skip to content

Commit b3ec411

Browse files
authored
Merge pull request kaiwk#27 from kaiwk/develop
feat: add problem link in description buffer
2 parents ade8c0d + 423b335 commit b3ec411

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

leetcode.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ following possible value:
640640
(leetcode--show-submission-result res)
641641
(leetcode--loading-mode -1)))))))))
642642

643+
(defun leetcode--problem-link (title)
644+
"Generate problem link from title."
645+
(concat leetcode--base-url "/problems/" (leetcode--slugify-title title)))
646+
643647
(defun leetcode-show-description ()
644648
"Show current entry problem description.
645649
Get current entry by using `tabulated-list-get-entry' and use
@@ -676,7 +680,12 @@ Get current entry by using `tabulated-list-get-entry' and use
676680
title
677681
(append .codeSnippets nil)
678682
.sampleTestCase))
679-
'help-echo "solve the problem."))
683+
'help-echo "solve the problem.")
684+
(insert (make-string 4 ?\s))
685+
(insert-text-button "link"
686+
'action (lambda (btn)
687+
(browse-url (leetcode--problem-link title)))
688+
'help-echo "open the problem in browser."))
680689
(rename-buffer buf-name)
681690
(leetcode--problem-description-mode)
682691
(switch-to-buffer (current-buffer))))))

0 commit comments

Comments
 (0)