Skip to content

Commit ba55e09

Browse files
committed
Remove setf dependency on window setup
1 parent bdb2179 commit ba55e09

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

gdb-mi.el

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,7 @@ HAS-CHILDREN should be t when this node has children."
10511051
(gdb--set-window-buffer middle-right (gdb--frames-get-buffer session))
10521052
(gdb--set-window-buffer bottom-left (gdb--watchers-get-buffer session))
10531053
(gdb--set-window-buffer bottom-right (gdb--variables-get-buffer session))
1054-
(setf (gdb--session-source-window session) top-left)
1055-
(gdb--display-source-buffer))))
1054+
(gdb--display-source-buffer top-left))))
10561055

10571056
(defun gdb--switch-buffer (buffer-fun)
10581057
(gdb--with-valid-session
@@ -1825,15 +1824,19 @@ stopped thread before running the command. If FORCE-STOPPED is
18251824

18261825
;; ------------------------------------------------------------------------------------------
18271826
;; Source buffers
1828-
(defun gdb--display-source-buffer (&optional override-file override-line force)
1827+
(defun gdb--display-source-buffer (&optional force override-file override-line)
18291828
"Display buffer of the selected source, and mark the current line.
1829+
When FORCE is non-nil, the source window will be created and shown.
1830+
FORCE may be the new window to display the source buffer.
1831+
18301832
The source file and line are fetched from the selected frame, unless OVERRIDE-FILE and OVERRIDE-LINE are set,
18311833
in which case those will be used.
1832-
OVERRIDE-LINE may also be `no-mark', which forces it to not mark any line.
1833-
When FORCE is non-nil, it will display it, even if the window does not exist and a disassembly buffer is visible."
1834+
OVERRIDE-LINE may also be `no-mark', which forces it to not mark any line."
18341835
(gdb--with-valid-session
18351836
(gdb--remove-all-symbols session 'source-indicator t)
18361837

1838+
(when (window-live-p force) (setf (gdb--session-source-window session) force))
1839+
18371840
(let* ((frame (gdb--session-selected-frame session))
18381841
(file (cond (override-file)
18391842
(frame (gdb--frame-file frame))))
@@ -1843,7 +1846,8 @@ When FORCE is non-nil, it will display it, even if the window does not exist and
18431846
(window (gdb--session-source-window session))
18441847
recenter-redisplay)
18451848

1846-
(unless (or (window-live-p window) (and (not force) (gdb--disassembly-is-visible)))
1849+
(when (and (not (window-live-p window))
1850+
(or force (and buffer (not (gdb--disassembly-is-visible)))))
18471851
(setq window (gdb--create-frame-for-buffer session (gdb--comint-get-buffer session)))
18481852
(setf (gdb--session-source-window session) window))
18491853

@@ -1910,7 +1914,7 @@ it from the list."
19101914
(cl-pushnew 'gdb--frames (gdb--session-buffer-types-to-update session))))))
19111915

19121916
(defun gdb--set-initial-file (file)
1913-
(gdb--display-source-buffer (gdb--complete-path file) 'no-mark))
1917+
(gdb--display-source-buffer nil (gdb--complete-path file) 'no-mark))
19141918

19151919
(defun gdb--get-thread-info (&optional id-str)
19161920
(gdb--command (concat "-thread-info " id-str) 'gdb--context-thread-info))
@@ -2514,7 +2518,7 @@ _i_nferior i/o | _f_rames | _d_isassembly | _w_atcher | ^ ^ |
25142518
("r" (gdb--switch-buffer 'gdb--registers-get-buffer))
25152519
("s" (progn (setf (gdb--session-source-window (gdb--infer-session)) (and (not gdb--open-buffer-new-frame)
25162520
(selected-window)))
2517-
(gdb--display-source-buffer nil nil t)))
2521+
(gdb--display-source-buffer t)))
25182522
("<f12>" (setq gdb--open-buffer-new-frame (not gdb--open-buffer-new-frame)) :exit nil))
25192523

25202524
(defun gdb-toggle-breakpoint (&optional arg)

0 commit comments

Comments
 (0)