ginqi7 / leetcode-emacs

an emacs plugin to write leetcode programs
37 stars 5 forks source link

This is an Emacs plugin that makes it easier and faster to write leetcode programs.

** Prerequisites

This tool is based on leetcode-cli, You can install the latest version through its [[https://github.com/skygragon/leetcode-cli][website]].

The backend leetcode-cli changed to other implement [[https://github.com/clearloop/leetcode-cli][github]]

** Installing

+BEGIN_SRC emacs-lisp

(use-package leetcode :config (setq leetcode-language "java") )

+END_SRC

*** Change leetcode-cli config You will find leetcode-cli config in "~/.leetcode/leetcode.toml"

+begin_src toml

[code] editor = 'cat' lang = 'java'

+end_src

You should change editor to 'cat', let leetcode-cli don't open a editor to edit the anwser file.

You can change the answer languary using 'lang' item. *** Configurable Variable There are some variable

+begin_src emacs-lisp

leetcode-hide-no-auth-problems ;; Whether to hide topics that do not have permission, default value is t

+end_src

** Features *** login / logout

New leetcode-cli not provides command to login / logout. You just need login/logout leetcode in Chrome, the leetcode-cli will use the Chrome cookie to access leetcode website.

** List all questions leetcode-list-all*:

+HTML:

There will hide 🔒 problems.

If you select a problem and click or press return will open the problem code.

+HTML:

*** Filter questions by difficulty

You can filter problems by difficulty:

+HTML:

*** Filter questions by tag You can filter problems by tag:

+HTML:

*** Filter questions by keyword You can filter problems by keyword:

+HTML:

** Show a specific question leetcode-show n*: show a description and generate a code's template of a specific question. The parameter of function is the question's index number.

+HTML:

** Show next question leetcode-show-next*:

If you solve the question in order, you can go to the next question through =leetcode-show-next=.

+HTML:

** Submit the question answer leetcode-submit*:

+HTML:

** Test the question answer leetcode-test*:

Like leetcode-submit , you can using leetcode-test function to test current buffer using some default test cases.

+HTML:

** Quickly jump max index problem in local leetcode-show-local-max-problem*

Use this function, you can quickly jump the max index problem in your local file. You needn't go to your leetcode directory to find last file you handled

** Interactively filter and select problem and open it leetcode-interactive* You could filter and select and open problem interactively.

+HTML: