Commit d97af5a0 authored by Chong Yidong's avatar Chong Yidong
Browse files

Clean up gdb-mi's usage of display-buffer.

* progmodes/gdb-mi.el (gdb-display-buffer-other-frame-action): New
variable, replacing gdb-frame-parameters.
(gdb-frame-io-buffer, gdb-frame-breakpoints-buffer)
(gdb-frame-threads-buffer, gdb-frame-memory-buffer)
(gdb-frame-disassembly-buffer, gdb-frame-stack-buffer)
(gdb-frame-locals-buffer, gdb-frame-registers-buffer): Use it.
(def-gdb-frame-for-buffer): Macro deleted.  It is easier to define
the functions directly with gdb-display-buffer-other-frame-action.
(gdb-display-breakpoints-buffer, gdb-display-threads-buffer)
(gdb-display-memory-buffer, gdb-display-disassembly-buffer)
(gdb-display-stack-buffer, gdb-display-locals-buffer)
(gdb-display-registers-buffer): Define directly.
(def-gdb-display-buffer): Macro deleted.
(gdb-display-buffer): Remove second and third args, callers don't
use them.  Defer to the default display-buffer behavior, apart
from making windows dedicated.
(gdb-setup-windows): Don't call display-buffer unnecessarily.

* window.el (display-buffer-pop-up-frame): Handle a
pop-up-frame-parameters alist entry.
(display-buffer): Document it.

* progmodes/gud.el (gud-display-line): Just use display-buffer.
parent d5172d4f
......@@ -619,6 +619,9 @@ now accept a third argument to avoid choosing the selected window.
*** New display action alist `inhibit-switch-frame', if non-nil, tells
display action functions to avoid changing which frame is selected.
*** New display action alist `pop-up-frame-parameters', if non-nil,
specifies frame parameters to give any newly-created frame.
** Completion
*** New function `completion-table-with-quoting' to handle completion
......
2012-08-26 Chong Yidong <cyd@gnu.org>
* progmodes/gdb-mi.el (gdb-display-buffer-other-frame-action): New
variable, replacing gdb-frame-parameters.
(gdb-frame-io-buffer, gdb-frame-breakpoints-buffer)
(gdb-frame-threads-buffer, gdb-frame-memory-buffer)
(gdb-frame-disassembly-buffer, gdb-frame-stack-buffer)
(gdb-frame-locals-buffer, gdb-frame-registers-buffer): Use it.
(def-gdb-frame-for-buffer): Macro deleted. It is easier to define
the functions directly with gdb-display-buffer-other-frame-action.
(gdb-display-breakpoints-buffer, gdb-display-threads-buffer)
(gdb-display-memory-buffer, gdb-display-disassembly-buffer)
(gdb-display-stack-buffer, gdb-display-locals-buffer)
(gdb-display-registers-buffer): Define directly.
(def-gdb-display-buffer): Macro deleted.
(gdb-display-buffer): Remove second and third args, callers don't
use them. Defer to the default display-buffer behavior, apart
from making windows dedicated.
(gdb-setup-windows): Don't call display-buffer unnecessarily.
* progmodes/gud.el (gud-display-line): Just use display-buffer.
* window.el (display-buffer-pop-up-frame): Handle a
pop-up-frame-parameters alist entry.
(display-buffer): Document it.
2012-08-26 Chong Yidong <cyd@gnu.org>
 
* isearch.el (search-whitespace-regexp): Make string and nil
......
......@@ -1413,29 +1413,6 @@ this trigger is subscribed to `gdb-buf-publisher' and called with
(with-current-buffer ,buffer
(apply ',expr args))))
;; Used to define all gdb-frame-*-buffer functions except
;; `gdb-frame-io-buffer'
(defmacro def-gdb-frame-for-buffer (name buffer &optional doc)
"Define a function NAME which shows gdb BUFFER in a separate frame.
DOC is an optional documentation string."
`(defun ,name (&optional thread)
,(when doc doc)
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
(display-buffer (gdb-get-buffer-create ,buffer thread)))))
(defmacro def-gdb-display-buffer (name buffer &optional doc)
"Define a function NAME which shows gdb BUFFER.
DOC is an optional documentation string."
`(defun ,name (&optional thread)
,(when doc doc)
(interactive)
(gdb-display-buffer
(gdb-get-buffer-create ,buffer thread) t)))
;; Used to display windows with thread-bound buffers
(defmacro def-gdb-preempt-display-buffer (name buffer &optional doc
split-horizontal)
......@@ -1511,8 +1488,7 @@ DOC is an optional documentation string."
(defun gdb-display-io-buffer ()
"Display IO of debugged program in a separate window."
(interactive)
(gdb-display-buffer
(gdb-get-buffer-create 'gdb-inferior-io) t))
(gdb-display-buffer (gdb-get-buffer-create 'gdb-inferior-io)))
(defun gdb-inferior-io--init-proc (proc)
;; Set up inferior I/O. Needs GDB 6.4 onwards.
......@@ -1540,19 +1516,24 @@ DOC is an optional documentation string."
(comint-exec io-buffer "gdb-inferior" nil nil nil)
(gdb-inferior-io--init-proc (get-buffer-process io-buffer))))))
(defconst gdb-frame-parameters
'((height . 14) (width . 80)
(defvar gdb-display-buffer-other-frame-action
`((display-buffer-reuse-window display-buffer-pop-up-frame)
(reusable-frames . 0)
(inhibit-same-window . t)
(pop-up-frame-parameters (height . 14)
(width . 80)
(unsplittable . t)
(tool-bar-lines . nil)
(menu-bar-lines . nil)
(minibuffer . nil)))
"A `display-buffer' action for displaying GDB utility frames.")
(put 'gdb-display-buffer-other-frame-action 'risky-local-variable t)
(defun gdb-frame-io-buffer ()
"Display IO of debugged program in a new frame."
"Display IO of debugged program in another frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
(display-buffer (gdb-get-buffer-create 'gdb-inferior-io))))
(display-buffer (gdb-get-buffer-create 'gdb-inferior-io)
gdb-display-buffer-other-frame-action))
(defvar gdb-inferior-io-mode-map
(let ((map (make-sparse-keymap)))
......@@ -1571,7 +1552,7 @@ DOC is an optional documentation string."
(defun gdb-inferior-filter (proc string)
(unless (string-equal string "")
(gdb-display-buffer (gdb-get-buffer-create 'gdb-inferior-io) t))
(gdb-display-buffer (gdb-get-buffer-create 'gdb-inferior-io)))
(with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
(comint-output-filter proc string)))
......@@ -2615,15 +2596,16 @@ If not in a source or disassembly buffer just set point."
(defun gdb-breakpoints-buffer-name ()
(concat "*breakpoints of " (gdb-get-target-string) "*"))
(def-gdb-display-buffer
gdb-display-breakpoints-buffer
'gdb-breakpoints-buffer
"Display status of user-settable breakpoints.")
(defun gdb-display-breakpoints-buffer (&optional thread)
"Display GDB breakpoints."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-breakpoints-buffer thread)))
(def-gdb-frame-for-buffer
gdb-frame-breakpoints-buffer
'gdb-breakpoints-buffer
"Display status of user-settable breakpoints in a new frame.")
(defun gdb-frame-breakpoints-buffer (&optional thread)
"Display GDB breakpoints in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-breakpoints-buffer thread)
gdb-display-buffer-other-frame-action))
(defvar gdb-breakpoints-mode-map
(let ((map (make-sparse-keymap))
......@@ -2684,15 +2666,16 @@ corresponding to the mode line clicked."
(defun gdb-threads-buffer-name ()
(concat "*threads of " (gdb-get-target-string) "*"))
(def-gdb-display-buffer
gdb-display-threads-buffer
'gdb-threads-buffer
"Display GDB threads.")
(defun gdb-display-threads-buffer (&optional thread)
"Display GDB threads."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-threads-buffer thread)))
(def-gdb-frame-for-buffer
gdb-frame-threads-buffer
'gdb-threads-buffer
"Display GDB threads in a new frame.")
(defun gdb-frame-threads-buffer (&optional thread)
"Display GDB threads in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-threads-buffer thread)
gdb-display-buffer-other-frame-action))
(def-gdb-trigger-and-handler
gdb-invalidate-threads (gdb-current-context-command "-thread-info")
......@@ -2868,26 +2851,22 @@ on the current line."
(def-gdb-thread-buffer-simple-command
gdb-frame-stack-for-thread
gdb-frame-stack-buffer
"Display a new frame with stack buffer for the thread at
current line.")
"Display another frame with stack buffer for thread at current line.")
(def-gdb-thread-buffer-simple-command
gdb-frame-locals-for-thread
gdb-frame-locals-buffer
"Display a new frame with locals buffer for the thread at
current line.")
"Display another frame with locals buffer for thread at current line.")
(def-gdb-thread-buffer-simple-command
gdb-frame-registers-for-thread
gdb-frame-registers-buffer
"Display a new frame with registers buffer for the thread at
current line.")
"Display another frame with registers buffer for the thread at current line.")
(def-gdb-thread-buffer-simple-command
gdb-frame-disassembly-for-thread
gdb-frame-disassembly-buffer
"Display a new frame with disassembly buffer for the thread at
current line.")
"Display another frame with disassembly buffer for the thread at current line.")
(defmacro def-gdb-thread-buffer-gud-command (name gud-command &optional doc)
"Define a NAME which will execute GUD-COMMAND with
......@@ -3290,21 +3269,16 @@ DOC is an optional documentation string."
(defun gdb-memory-buffer-name ()
(concat "*memory of " (gdb-get-target-string) "*"))
(def-gdb-display-buffer
gdb-display-memory-buffer
'gdb-memory-buffer
"Display memory contents.")
(defun gdb-display-memory-buffer (&optional thread)
"Display GDB memory contents."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-memory-buffer thread)))
(defun gdb-frame-memory-buffer ()
"Display memory contents in a new frame."
"Display memory contents in another frame."
(interactive)
(let* ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist
`((left-fringe . 0)
(right-fringe . 0)
(width . 83)
,@gdb-frame-parameters)))
(display-buffer (gdb-get-buffer-create 'gdb-memory-buffer))))
(display-buffer (gdb-get-buffer-create 'gdb-memory-buffer)
gdb-display-buffer-other-frame-action))
;;; Disassembly view
......@@ -3313,19 +3287,20 @@ DOC is an optional documentation string."
(gdb-current-context-buffer-name
(concat "disassembly of " (gdb-get-target-string))))
(def-gdb-display-buffer
gdb-display-disassembly-buffer
'gdb-disassembly-buffer
"Display disassembly for current stack frame.")
(defun gdb-display-disassembly-buffer (&optional thread)
"Display GDB disassembly information."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-disassembly-buffer thread)))
(def-gdb-preempt-display-buffer
gdb-preemptively-display-disassembly-buffer
'gdb-disassembly-buffer)
(def-gdb-frame-for-buffer
gdb-frame-disassembly-buffer
'gdb-disassembly-buffer
"Display disassembly in a new frame.")
(defun gdb-frame-disassembly-buffer (&optional thread)
"Display GDB disassembly information in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-disassembly-buffer thread)
gdb-display-buffer-other-frame-action))
(def-gdb-auto-update-trigger gdb-invalidate-disassembly
(let* ((frame (gdb-current-buffer-frame))
......@@ -3560,19 +3535,20 @@ member."
(gdb-current-context-buffer-name
(concat "stack frames of " (gdb-get-target-string))))
(def-gdb-display-buffer
gdb-display-stack-buffer
'gdb-stack-buffer
"Display backtrace of current stack.")
(defun gdb-display-stack-buffer (&optional thread)
"Display GDB backtrace for current stack."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-stack-buffer thread)))
(def-gdb-preempt-display-buffer
gdb-preemptively-display-stack-buffer
'gdb-stack-buffer nil t)
(def-gdb-frame-for-buffer
gdb-frame-stack-buffer
'gdb-stack-buffer
"Display backtrace of current stack in a new frame.")
(defun gdb-frame-stack-buffer (&optional thread)
"Display GDB backtrace for current stack in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-stack-buffer thread)
gdb-display-buffer-other-frame-action))
(defvar gdb-frames-mode-map
(let ((map (make-sparse-keymap)))
......@@ -3719,19 +3695,20 @@ member."
(gdb-current-context-buffer-name
(concat "locals of " (gdb-get-target-string))))
(def-gdb-display-buffer
gdb-display-locals-buffer
'gdb-locals-buffer
"Display local variables of current stack and their values.")
(defun gdb-display-locals-buffer (&optional thread)
"Display the local variables of current GDB stack."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-locals-buffer thread)))
(def-gdb-preempt-display-buffer
gdb-preemptively-display-locals-buffer
'gdb-locals-buffer nil t)
(def-gdb-frame-for-buffer
gdb-frame-locals-buffer
'gdb-locals-buffer
"Display local variables of current stack and their values in a new frame.")
(defun gdb-frame-locals-buffer (&optional thread)
"Display the local variables of the current GDB stack in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-locals-buffer thread)
gdb-display-buffer-other-frame-action))
;; Registers buffer.
......@@ -3818,19 +3795,20 @@ member."
(gdb-current-context-buffer-name
(concat "registers of " (gdb-get-target-string))))
(def-gdb-display-buffer
gdb-display-registers-buffer
'gdb-registers-buffer
"Display integer register contents.")
(defun gdb-display-registers-buffer (&optional thread)
"Display GDB register contents."
(interactive)
(gdb-display-buffer (gdb-get-buffer-create 'gdb-registers-buffer thread)))
(def-gdb-preempt-display-buffer
gdb-preemptively-display-registers-buffer
'gdb-registers-buffer nil t)
(def-gdb-frame-for-buffer
gdb-frame-registers-buffer
'gdb-registers-buffer
"Display integer register contents in a new frame.")
(defun gdb-frame-registers-buffer (&optional thread)
"Display GDB register contents in another frame."
(interactive)
(display-buffer (gdb-get-buffer-create 'gdb-registers-buffer thread)
gdb-display-buffer-other-frame-action))
;; Needs GDB 6.4 onwards (used to fail with no stack).
(defun gdb-get-changed-registers ()
......@@ -3917,26 +3895,26 @@ overlay arrow in source buffer."
(setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name)))
;;;; Window management
(defun gdb-display-buffer (buf dedicated &optional frame)
"Show buffer BUF.
If BUF is already displayed in some window, show it, deiconifying
the frame if necessary. Otherwise, find least recently used
window and show BUF there, if the window is not used for GDB
already, in which case that window is split first."
(let ((answer (get-buffer-window buf (or frame 0))))
(if answer
(display-buffer buf nil (or frame 0)) ;Deiconify frame if necessary.
(let ((window (get-lru-window)))
(if (eq (buffer-local-value 'gud-minor-mode (window-buffer window))
'gdbmi)
(let ((largest (get-largest-window)))
(setq answer (split-window largest))
(set-window-buffer answer buf)
(set-window-dedicated-p answer dedicated)
answer)
(set-window-buffer window buf)
window)))))
(defun gdb-display-buffer (buf)
"Show buffer BUF, and make that window dedicated."
(let ((window (display-buffer buf)))
(set-window-dedicated-p window t)
window))
;; (let ((answer (get-buffer-window buf 0)))
;; (if answer
;; (display-buffer buf nil 0) ;Deiconify frame if necessary.
;; (let ((window (get-lru-window)))
;; (if (eq (buffer-local-value 'gud-minor-mode (window-buffer window))
;; 'gdbmi)
;; (let ((largest (get-largest-window)))
;; (setq answer (split-window largest))
;; (set-window-buffer answer buf)
;; (set-window-dedicated-p answer t)
;; answer)
;; (set-window-buffer window buf)
;; window)))))
(defun gdb-preempt-existing-or-display-buffer (buf &optional split-horizontal)
"Find window displaying a buffer with the same
......@@ -3963,7 +3941,7 @@ SPLIT-HORIZONTAL and show BUF in the new window."
(if dedicated-window
(set-window-buffer
(split-window dedicated-window nil split-horizontal) buf)
(gdb-display-buffer buf t))))))
(gdb-display-buffer buf))))))
(error "Null buffer")))
;;; Shared keymap initialization:
......@@ -4067,7 +4045,7 @@ SPLIT-HORIZONTAL and show BUF in the new window."
'all-threads)
(defun gdb-frame-gdb-buffer ()
"Display GUD buffer in a new frame."
"Display GUD buffer in another frame."
(interactive)
(display-buffer-other-frame gud-comint-buffer))
......@@ -4089,13 +4067,12 @@ window is dedicated."
(defun gdb-setup-windows ()
"Layout the window pattern for `gdb-many-windows'."
(gdb-display-locals-buffer)
(gdb-display-stack-buffer)
(delete-other-windows)
(gdb-display-breakpoints-buffer)
(delete-other-windows)
;; Don't dedicate.
(gdb-get-buffer-create 'gdb-locals-buffer)
(gdb-get-buffer-create 'gdb-stack-buffer)
(gdb-get-buffer-create 'gdb-breakpoints-buffer)
(set-window-dedicated-p (selected-window) nil)
(switch-to-buffer gud-comint-buffer)
(delete-other-windows)
(let ((win0 (selected-window))
(win1 (split-window nil ( / ( * (window-height) 3) 4)))
(win2 (split-window nil ( / (window-height) 3)))
......
......@@ -2685,7 +2685,6 @@ Obeying it means displaying in another window the specified file and line."
(declare-function global-hl-line-highlight "hl-line" ())
(declare-function hl-line-highlight "hl-line" ())
(declare-function gdb-display-source-buffer "gdb-mi" (buffer))
(declare-function gdb-display-buffer "gdb-mi" (buf dedicated &optional size))
;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
;; and that its line LINE is visible.
......@@ -2702,10 +2701,7 @@ Obeying it means displaying in another window the specified file and line."
(window (and buffer
(or (get-buffer-window buffer)
(if (eq gud-minor-mode 'gdbmi)
(or (if (get-buffer-window buffer 'visible)
(display-buffer buffer nil 'visible))
(unless (gdb-display-source-buffer buffer)
(gdb-display-buffer buffer nil 'visible))))
(display-buffer buffer))))
(pos))
(if buffer
......
......@@ -4369,12 +4369,11 @@ of the window used."
(function :tag "function"))
:group 'windows)
;; Eventually, we want to turn this into a defvar; instead of
;; customizing this, the user should use a `pop-up-frame-parameters'
;; alist entry in `display-buffer-base-action'.
(defcustom pop-up-frame-alist nil
"Alist of parameters for automatically generated new frames.
You can set this in your init file; for example,
(setq pop-up-frame-alist '((width . 80) (height . 20)))
If non-nil, the value you specify here is used by the default
`pop-up-frame-function' for the creation of new frames.
......@@ -5108,6 +5107,10 @@ Recognized alist entries include:
window that already displays the buffer.
See `display-buffer-reuse-window'.
`pop-up-frame-parameters' -- Value specifies an alist of frame
parameters to give a new frame, if
one is created.
The ACTION argument to `display-buffer' can also have a non-nil
and non-list value. This means to display the buffer in a window
other than the selected one, even if it is already displayed in
......@@ -5250,8 +5253,14 @@ This works by calling `pop-up-frame-function'. If successful,
return the window used; otherwise return nil.
If ALIST has a non-nil `inhibit-switch-frame' entry, avoid
raising the new frame."
(let ((fun pop-up-frame-function)
raising the new frame.
If ALIST has a non-nil `pop-up-frame-parameters' entry, the
corresponding value is an alist of frame parameters to give the
new frame."
(let* ((params (cdr (assq 'pop-up-frame-parameters alist)))
(pop-up-frame-alist (append params pop-up-frame-alist))
(fun pop-up-frame-function)
frame window)
(when (and fun
(setq frame (funcall fun))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment