 
       (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
               rdebug-debugger-support-minor-mode-map-when-active)
-      (when rdebug-many-windows (rdebug-setup-windows-initially))
+      (when rdebug-many-windows
+        (rdebug-setup-windows-initially))
 
       (run-hooks 'rdebug-mode-hook))))
+
+
+(defun rdebug-set-windows (&optional name)
+  "Rename the processor buffer to correspond to script name NAME.
+
+When `rdebug-many-windows' is non-nil, the initial debugger
+window layout is used."
+  (interactive "sProgram name: ")
+  (rdebug-debug-enter "rdebug-set-windows"
+    (rdebug-set-window-configuration-state 'debugger t)
+    (rdebug-common-initialization)
+    (when name
+      (setq gud-target-name name)
+      (setq gud-comint-buffer (current-buffer)))
+    (when gud-last-frame
+      (setq gud-last-last-frame gud-last-frame))
+    (rename-buffer (format "*rdebug-cmd-%s*" gud-target-name))
+
+    (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
+            rdebug-debugger-support-minor-mode-map-when-active)
+    (when rdebug-many-windows
+      (rdebug-setup-windows))))
 
 
 (defun rdebug-quit ()

  (message
   "Type `M-x rdebug-display-original-window-configuration RET' to restore."))

(defun rdebug-set-windows (&optional name)
  "Rename the processor buffer to correspond to script name NAME.

When `rdebug-many-windows' is non-nil, the initial debugger
window layout is used."
  (interactive "sProgram name: ")
  (when name
    (setq gud-target-name name)
    (setq gud-comint-buffer (current-buffer)))
  (when gud-last-frame
    (setq gud-last-last-frame gud-last-frame))
  (rename-buffer (format "*rdebug-cmd-%s*" gud-target-name))
  (when rdebug-many-windows
    (rdebug-setup-windows)))

;; Fontification and keymaps for secondary buffers (breakpoints, stack)


  "Populate the Rdebug 'Debugger' menu."
  (let ((menu (make-sparse-keymap))
        (common-map (make-sparse-keymap)))
    ;; Use a simple common map to find the best key sequence to
    ;; display in menu.
    (rdebug-populate-common-keys common-map)

    (define-key map [menu-bar debugger] (cons "Debugger" menu))

    (define-key menu [break-delete]
      (rdebug-menu-item common-map "Delete breakpoint" 'gud-remove
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [break]
      (rdebug-menu-item common-map "Set breakpoint" 'gud-break
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [finish]
      (rdebug-menu-item common-map "Step out" 'gud-finish
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [step]
      (rdebug-menu-item common-map "Step into" 'gud-step
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [next]
      (rdebug-menu-item common-map "Step over" 'gud-next
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [cont]
      (rdebug-menu-item common-map "Continue" 'gud-cont
                        :enable '(get-buffer-process gud-comint-buffer)))

    (define-key map [menu-bar debugger line1] '(menu-item "--"))

    (define-key menu [stop]
      (rdebug-menu-item
       common-map "Stop the debugger" 'rdebug-quit
       :enable '(get-buffer-process gud-comint-buffer)))

    (define-key menu [start]
      (rdebug-menu-item common-map "Start the debugger" 'rdebug))

    (define-key map [menu-bar debugger line2] '(menu-item "--"))

    ;; Placeholder used when populating the menu of the secondary buffers.
    (define-key menu [placeholder] nil)

    ;; --------------------
