66; ; Keywords: extensions, tools
77; ; URL: https://github.com/kaiwk/leetcode.el
88; ; Package-Requires: ((emacs "26") (dash "2.16.0") (graphql "0.1.1") (spinner "1.7.3") (aio "1.0") (log4e "0.3.3"))
9- ; ; Version: 0.1.17
9+ ; ; Version: 0.1.18
1010
1111; ; This program is free software; you can redistribute it and/or modify
1212; ; it under the terms of the GNU General Public License as published by
@@ -127,15 +127,21 @@ The elements of :problems has attributes:
127127 " Filter rows by difficulty, it can be \" easy\" , \" medium\" and \" hard\" ." )
128128(defconst leetcode--all-difficulties '(" easy" " medium" " hard" ))
129129
130+ (defconst leetcode--paid " •" " Paid mark." )
130131(defconst leetcode--checkmark " ✓" " Checkmark for accepted problem." )
131132(defconst leetcode--buffer-name " *leetcode*" )
132133(defconst leetcode--description-buffer-name " *leetcode-description*" )
133134(defconst leetcode--testcase-buffer-name " *leetcode-testcase*" )
134135(defconst leetcode--result-buffer-name " *leetcode-result*" )
135136
137+ (defface leetcode-paid-face
138+ '((t (:foreground " gold" )))
139+ " Face for `leetcode--paid' ."
140+ :group 'leetcode )
141+
136142(defface leetcode-checkmark-face
137143 '((t (:foreground " #5CB85C" )))
138- " Face for `leetcode--checkmark' "
144+ " Face for `leetcode--checkmark' . "
139145 :group 'leetcode )
140146
141147(defface leetcode-easy-face
@@ -273,6 +279,7 @@ USER-AND-PROBLEMS is an alist comes from
273279 :easy .ac_easy
274280 :medium .ac_medium
275281 :hard .ac_hard))
282+ (leetcode--debug " problem status pairs: %s" .stat_status_pairs)
276283 ; ; problem list
277284 (setq leetcode--all-problems
278285 (list
@@ -301,6 +308,7 @@ USER-AND-PROBLEMS is an alist comes from
301308
302309(defun leetcode--set-tags (all-tags )
303310 " Set `leetcode--all-tags' and `leetcode--all-problems' with ALL-TAGS."
311+ (leetcode--debug " all tags: %s" all-tags)
304312 (let-alist all-tags
305313 ; ; set problems tags
306314 (dolist (problem (plist-get leetcode--all-problems :problems ))
@@ -422,9 +430,15 @@ Return a list of rows, each row is a vector:
422430 ; ; position
423431 (number-to-string (plist-get p :pos ))
424432 ; ; title
425- (plist-get p :title )
426- ; ; paid-only
427- (if (eq (plist-get p :paid-only ) t ) " Y" " N" )
433+ (concat
434+ (plist-get p :title )
435+ " "
436+ (if (eq (plist-get p :paid-only ) t )
437+ (prog1 leetcode--paid
438+ (put-text-property
439+ 0 (length leetcode--paid)
440+ 'font-lock-face 'leetcode-paid-face leetcode--paid))
441+ " " ))
428442 ; ; acceptance
429443 (plist-get p :acceptance )
430444 ; ; difficulty
@@ -451,11 +465,11 @@ Return a list of rows, each row is a vector:
451465
452466(defun leetcode--row-tags (row )
453467 " Get tags from ROW."
454- (aref row 6 ))
468+ (aref row 5 ))
455469
456470(defun leetcode--row-difficulty (row )
457471 " Get difficulty from ROW."
458- (aref row 5 ))
472+ (aref row 4 ))
459473
460474(defun leetcode--filter (rows )
461475 " Filter ROWS by `leetcode--filter-regex' , `leetcode--filter-tag' and `leetcode--filter-difficulty' ."
@@ -539,7 +553,7 @@ Return a list of rows, each row is a vector:
539553(defun leetcode-refresh ()
540554 " Make `tabulated-list-entries' ."
541555 (interactive )
542- (let* ((header-names '(" " " #" " Problem" " Paid-Only " " Acceptance" " Difficulty" " Tags" ))
556+ (let* ((header-names '(" " " #" " Problem" " Acceptance" " Difficulty" " Tags" ))
543557 (rows (leetcode--filter (leetcode--problems-rows)))
544558 (headers (leetcode--make-tabulated-headers header-names rows)))
545559 (with-current-buffer (get-buffer-create leetcode--buffer-name)
@@ -858,11 +872,12 @@ Get current entry by using `tabulated-list-get-entry' and use
858872 (interactive )
859873 (let* ((entry (tabulated-list-get-entry ))
860874 (pos (aref entry 1 ))
861- (title (aref entry 2 ))
875+ (title (substring-no-properties ( aref entry 2 ) nil -2 )) ; strip paid mark
862876 (difficulty (aref entry 4 ))
863877 (problem (aio-await (leetcode--fetch-problem title)))
864878 (buf-name leetcode--description-buffer-name)
865879 (html-margin " " ))
880+ (leetcode--debug " select title: %s" title)
866881 (let-alist problem
867882 (when (get-buffer buf-name)
868883 (kill-buffer buf-name))
0 commit comments