Created
February 3, 2022 20:59
-
-
Save AkashaP/849b7e4e5fa9d208f101f082864cea03 to your computer and use it in GitHub Desktop.
Alternate Sly-db Display patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sly.el b/sly.el | |
index 0dbd6bbf..006d3934 100644 | |
--- a/sly.el | |
+++ b/sly.el | |
@@ -5509,13 +5509,24 @@ Also mark the window as a debugger window." | |
(let* ((action '(sly-db--display-in-prev-sly-db-window)) | |
(buffer (current-buffer)) | |
(win | |
- (if (cond ((eq sly-db-focus-debugger 'auto) | |
- (eq sly--send-last-command last-command)) | |
- (t sly-db-focus-debugger)) | |
- (progn | |
- (pop-to-buffer buffer action) | |
- (selected-window)) | |
- (display-buffer buffer action)))) | |
+ (if (get-buffer-window buffer) | |
+ (if (eq sly--send-last-command last-command) | |
+ (progn | |
+ (select-window (get-buffer-window buffer)) | |
+ (selected-window)) | |
+ (get-buffer-window buffer)) | |
+ (if (or (eq sly-db-focus-debugger 'auto) | |
+ (eq sly--send-last-command last-command)) | |
+ (progn | |
+ (pop-to-buffer buffer action) | |
+ (selected-window)) | |
+ (if (and sly--send-last-command last-command | |
+ (eq sly--send-last-command last-command)) | |
+ (progn | |
+ (select-window (display-buffer buffer action)) | |
+ (selected-window)) | |
+ (display-buffer buffer action))) | |
+ (get-buffer-window buffer)))) | |
(set-window-parameter win 'sly-db buffer) | |
win)) | |
@@ -5533,35 +5544,37 @@ pending Emacs continuations." | |
t) | |
() "Bug: sly-db-level is equal but condition differs\n%s\n%s" | |
sly-db-condition condition) | |
- (with-selected-window (sly-db--display-debugger thread) | |
- (unless (equal sly-db-level level) | |
- (let ((inhibit-read-only t)) | |
- (sly-db-mode) | |
- (add-hook 'kill-buffer-query-functions | |
- #'sly-db-confirm-buffer-kill | |
- nil t) | |
- (setq sly-current-thread thread) | |
- (setq sly-db-level level) | |
- (setq mode-name (format "sly-db[%d]" sly-db-level)) | |
- (setq sly-db-condition condition) | |
- (setq sly-db-restarts restarts) | |
- (setq sly-db-continuations conts) | |
- (sly-db-insert-condition condition) | |
- (insert "\n\n" (sly-db-in-face section "Restarts:") "\n") | |
- (setq sly-db-restart-list-start-marker (point-marker)) | |
- (sly-db-insert-restarts restarts 0 sly-db-initial-restart-limit) | |
- (insert "\n" (sly-db-in-face section "Backtrace:") "\n") | |
- (setq sly-db-backtrace-start-marker (point-marker)) | |
- (save-excursion | |
- (if frame-specs | |
- (sly-db-insert-frames (sly-db-prune-initial-frames frame-specs) t) | |
- (insert "[No backtrace]"))) | |
- (run-hooks 'sly-db-hook) | |
- (set-syntax-table lisp-mode-syntax-table))) | |
- (sly-recenter (point-min) 'allow-moving-point) | |
- (when sly--stack-eval-tags | |
- (sly-message "Entering recursive edit..") | |
- (recursive-edit))))) | |
+ ;; with-selected-window is the source of woes. Just forget about it. | |
+ ;; xref its implementation to understand why... | |
+ (sly-db--display-debugger thread) | |
+ (unless (equal sly-db-level level) | |
+ (let ((inhibit-read-only t)) | |
+ (sly-db-mode) | |
+ (add-hook 'kill-buffer-query-functions | |
+ #'sly-db-confirm-buffer-kill | |
+ nil t) | |
+ (setq sly-current-thread thread) | |
+ (setq sly-db-level level) | |
+ (setq mode-name (format "sly-db[%d]" sly-db-level)) | |
+ (setq sly-db-condition condition) | |
+ (setq sly-db-restarts restarts) | |
+ (setq sly-db-continuations conts) | |
+ (sly-db-insert-condition condition) | |
+ (insert "\n\n" (sly-db-in-face section "Restarts:") "\n") | |
+ (setq sly-db-restart-list-start-marker (point-marker)) | |
+ (sly-db-insert-restarts restarts 0 sly-db-initial-restart-limit) | |
+ (insert "\n" (sly-db-in-face section "Backtrace:") "\n") | |
+ (setq sly-db-backtrace-start-marker (point-marker)) | |
+ (save-excursion | |
+ (if frame-specs | |
+ (sly-db-insert-frames (sly-db-prune-initial-frames frame-specs) t) | |
+ (insert "[No backtrace]"))) | |
+ (run-hooks 'sly-db-hook) | |
+ (set-syntax-table lisp-mode-syntax-table))) | |
+ (sly-recenter (point-min) 'allow-moving-point) | |
+ (when sly--stack-eval-tags | |
+ (sly-message "Entering recursive edit..") | |
+ (recursive-edit)))) | |
(defun sly-db--display-in-prev-sly-db-window (buffer _alist) | |
(let ((window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment