Skip to content

Commit ba96ef4

Browse files
authored
Explicitly set the windows for testcase and result buffers #70 (#109)
* Explicitly set the windows for testcase and result buffers #70 * Create the new buffer with the name right away then renaming later. * Reverting the changes done in previous commit. *html* buffer is created by the shr library and is only renamed by leetcode. An alternative could be to create a clone of the buffer with expected name and delete the *html* buffer.
1 parent e77e5e7 commit ba96ef4

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

leetcode.el

+14-11
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ The object with following attributes:
175175
"LeetCode programming language or sql for current problem internally.
176176
Default is programming language.")
177177

178+
(defvar leetcode--description-window nil
179+
"(Internal) Holds the reference to description window.")
180+
181+
(defvar leetcode--testcase-window nil
182+
"(Internal) Holds the reference to testcase window.")
183+
184+
(defvar leetcode--result-window nil
185+
"(Internal) Holds the reference to result window.")
186+
178187
(defconst leetcode--lang-suffixes
179188
'(("c" . ".c") ("cpp" . ".cpp") ("csharp" . ".cs")
180189
("golang" . ".go") ("java" . ".java") ("javascript" . ".js")
@@ -879,11 +888,11 @@ LeetCode require slug-title as the request parameters."
879888
| | Result |
880889
+---------------+----------------+"
881890
(delete-other-windows)
882-
(split-window-horizontally)
891+
(setq leetcode--description-window (split-window-horizontally))
883892
(other-window 1)
884-
(split-window-below)
893+
(setq leetcode--testcase-window (split-window-below))
885894
(other-window 1)
886-
(split-window-below)
895+
(setq leetcode--result-window (split-window-below))
887896
(other-window -1)
888897
(other-window -1))
889898

@@ -1274,16 +1283,10 @@ major mode by `leetcode-prefer-language'and `auto-mode-alist'."
12741283
(with-current-buffer (get-buffer-create testcase-buf-name)
12751284
(erase-buffer)
12761285
(insert testcase)
1277-
(display-buffer (current-buffer)
1278-
'((display-buffer-reuse-window
1279-
leetcode--display-testcase)
1280-
(reusable-frames . visible))))
1286+
(set-window-buffer leetcode--testcase-window (current-buffer)))
12811287
(with-current-buffer (get-buffer-create result-buf-name)
12821288
(erase-buffer)
1283-
(display-buffer (current-buffer)
1284-
'((display-buffer-reuse-window
1285-
leetcode--display-result)
1286-
(reusable-frames . visible)))))))
1289+
(set-window-buffer leetcode--result-window (current-buffer))))))
12871290

12881291
(aio-defun leetcode-restore-layout ()
12891292
"This command should be run in LeetCode code buffer.

0 commit comments

Comments
 (0)