6
6
; ; Keywords: extensions, tools
7
7
; ; URL: https://github.com/kaiwk/leetcode.el
8
8
; ; 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
10
10
11
11
; ; This program is free software; you can redistribute it and/or modify
12
12
; ; it under the terms of the GNU General Public License as published by
@@ -127,15 +127,21 @@ The elements of :problems has attributes:
127
127
" Filter rows by difficulty, it can be \" easy\" , \" medium\" and \" hard\" ." )
128
128
(defconst leetcode--all-difficulties '(" easy" " medium" " hard" ))
129
129
130
+ (defconst leetcode--paid " •" " Paid mark." )
130
131
(defconst leetcode--checkmark " ✓" " Checkmark for accepted problem." )
131
132
(defconst leetcode--buffer-name " *leetcode*" )
132
133
(defconst leetcode--description-buffer-name " *leetcode-description*" )
133
134
(defconst leetcode--testcase-buffer-name " *leetcode-testcase*" )
134
135
(defconst leetcode--result-buffer-name " *leetcode-result*" )
135
136
137
+ (defface leetcode-paid-face
138
+ '((t (:foreground " gold" )))
139
+ " Face for `leetcode--paid' ."
140
+ :group 'leetcode )
141
+
136
142
(defface leetcode-checkmark-face
137
143
'((t (:foreground " #5CB85C" )))
138
- " Face for `leetcode--checkmark' "
144
+ " Face for `leetcode--checkmark' . "
139
145
:group 'leetcode )
140
146
141
147
(defface leetcode-easy-face
@@ -273,6 +279,7 @@ USER-AND-PROBLEMS is an alist comes from
273
279
:easy .ac_easy
274
280
:medium .ac_medium
275
281
:hard .ac_hard))
282
+ (leetcode--debug " problem status pairs: %s" .stat_status_pairs)
276
283
; ; problem list
277
284
(setq leetcode--all-problems
278
285
(list
@@ -301,6 +308,7 @@ USER-AND-PROBLEMS is an alist comes from
301
308
302
309
(defun leetcode--set-tags (all-tags )
303
310
" Set `leetcode--all-tags' and `leetcode--all-problems' with ALL-TAGS."
311
+ (leetcode--debug " all tags: %s" all-tags)
304
312
(let-alist all-tags
305
313
; ; set problems tags
306
314
(dolist (problem (plist-get leetcode--all-problems :problems ))
@@ -422,9 +430,15 @@ Return a list of rows, each row is a vector:
422
430
; ; position
423
431
(number-to-string (plist-get p :pos ))
424
432
; ; 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
+ " " ))
428
442
; ; acceptance
429
443
(plist-get p :acceptance )
430
444
; ; difficulty
@@ -451,11 +465,11 @@ Return a list of rows, each row is a vector:
451
465
452
466
(defun leetcode--row-tags (row )
453
467
" Get tags from ROW."
454
- (aref row 6 ))
468
+ (aref row 5 ))
455
469
456
470
(defun leetcode--row-difficulty (row )
457
471
" Get difficulty from ROW."
458
- (aref row 5 ))
472
+ (aref row 4 ))
459
473
460
474
(defun leetcode--filter (rows )
461
475
" 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:
539
553
(defun leetcode-refresh ()
540
554
" Make `tabulated-list-entries' ."
541
555
(interactive )
542
- (let* ((header-names '(" " " #" " Problem" " Paid-Only " " Acceptance" " Difficulty" " Tags" ))
556
+ (let* ((header-names '(" " " #" " Problem" " Acceptance" " Difficulty" " Tags" ))
543
557
(rows (leetcode--filter (leetcode--problems-rows)))
544
558
(headers (leetcode--make-tabulated-headers header-names rows)))
545
559
(with-current-buffer (get-buffer-create leetcode--buffer-name)
@@ -858,11 +872,12 @@ Get current entry by using `tabulated-list-get-entry' and use
858
872
(interactive )
859
873
(let* ((entry (tabulated-list-get-entry ))
860
874
(pos (aref entry 1 ))
861
- (title (aref entry 2 ))
875
+ (title (substring-no-properties ( aref entry 2 ) nil -2 )) ; strip paid mark
862
876
(difficulty (aref entry 4 ))
863
877
(problem (aio-await (leetcode--fetch-problem title)))
864
878
(buf-name leetcode--description-buffer-name)
865
879
(html-margin " " ))
880
+ (leetcode--debug " select title: %s" title)
866
881
(let-alist problem
867
882
(when (get-buffer buf-name)
868
883
(kill-buffer buf-name))
0 commit comments