diff options
| author | Yuan Fu | 2020-03-15 16:47:43 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2020-03-15 16:47:43 +0100 |
| commit | 9dccaf8a5cdb10dae597345ec3741475477a7d97 (patch) | |
| tree | 1c6c16db369257b4c0da7e3137dc383c8c202527 /lisp/window.el | |
| parent | ff862f55f4a51c96254a198c17910f90e45b8986 (diff) | |
| download | emacs-9dccaf8a5cdb10dae597345ec3741475477a7d97.tar.gz emacs-9dccaf8a5cdb10dae597345ec3741475477a7d97.zip | |
Add store/restore window configuration feature for gdb-mi
Add a feature that allows a user to save a gdb window
configuration (window layout) to a file with
'gdb-save-window-configuration' and load it back with
'gdb-load-window-configuration'. Set a default window configuration
by setting 'gdb-default-window-configuration-file'.
Add an option to make gdb preserve the window configuration
that the user had before starting gdb. In window.el, add
'with-window-non-dedicated'.
* lisp/progmodes/gdb-mi.el (top/level): Require 'pcase' and 'cl-seq'.
(gdb--window-configuration-before): New variable.
(gdb-restore-window-configuration-after-quit): New option.
(gdb-window-configuration-directory,
gdb-default-window-configuration-file): New variables.
(gdb): Save configuration on startup.
(gud-menu-map): Add "Load Layout" and "Save Layout" to menu. Add
"Restore Layout After Quit" button to menu. Rename "Restore Window
Layout" to "Restore Default Layout", add some help echo, and move it
from "GDB-MI" menu to "GDB-WINDOWs" menu.
(gdb-toggle-restore-window-configuration): New function.
(gdb-get-source-buffer): New function, extracted out of
'gdb-restore-window'.
(gdb-setup-windows): Add a condition branch that loads default window
configuration when available. Fix docstring.
(gdb-buffer-p, gdb-function-buffer-p, gdb--buffer-type,
gdb-save-window-configuration, gdb-load-window-configuration): New
functions.
(gdb-restore-windows): Edit docstring to mention
'gdb-default-window-configuration-file'.
(gdb-reset): Restore window configuration after quit.
* lisp/window.el (with-window-non-dedicated): New macro.
Diffstat (limited to 'lisp/window.el')
| -rw-r--r-- | lisp/window.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/window.el b/lisp/window.el index fc1e7d4a76c..b54f1633f5e 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -278,6 +278,24 @@ displays the buffer specified by BUFFER-OR-NAME before running BODY." | |||
| 278 | (funcall ,vquit-function ,window ,value) | 278 | (funcall ,vquit-function ,window ,value) |
| 279 | ,value))))) | 279 | ,value))))) |
| 280 | 280 | ||
| 281 | (defmacro with-window-non-dedicated (window &rest body) | ||
| 282 | "Evaluate BODY with WINDOW temporarily made non-dedicated. | ||
| 283 | If WINDOW is nil, use the selected window. Return the value of | ||
| 284 | the last form in BODY." | ||
| 285 | (declare (indent 1) (debug t)) | ||
| 286 | (let ((window-dedicated-sym (gensym)) | ||
| 287 | (window-sym (gensym))) | ||
| 288 | `(let* ((,window-sym (window-normalize-window ,window t)) | ||
| 289 | (,window-dedicated-sym (window-dedicated-p ,window-sym))) | ||
| 290 | (set-window-dedicated-p ,window-sym nil) | ||
| 291 | (unwind-protect | ||
| 292 | (progn ,@body) | ||
| 293 | ;; `window-dedicated-p' returns the value set by | ||
| 294 | ;; `set-window-dedicated-p', which differentiates non-nil and | ||
| 295 | ;; t, so we cannot simply use t here. That's why we use | ||
| 296 | ;; `window-dedicated-sym'. | ||
| 297 | (set-window-dedicated-p ,window-sym ,window-dedicated-sym))))) | ||
| 298 | |||
| 281 | ;; The following two functions are like `window-next-sibling' and | 299 | ;; The following two functions are like `window-next-sibling' and |
| 282 | ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so | 300 | ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so |
| 283 | ;; they don't substitute the selected window for nil), and they return | 301 | ;; they don't substitute the selected window for nil), and they return |