   "^[ \t]+[[]?\\([^:]+\\):\\([0-9]+\\):in `.*'"
   "Regular expression that describes a Ruby traceback line from $! list.")
 
-(defun rdebug-rdebugtrack-overlay-arrow (activation)
+(defun rdebugtrack-overlay-arrow (activation)
   "Activate or de arrow at beginning-of-line in current buffer."
   ;; This was derived/simplified from edebug-overlay-arrow
   (cond (activation
 	 (setq overlay-arrow-position (make-marker))
 	 (setq overlay-arrow-string "=>")
 	 (set-marker overlay-arrow-position (point) (current-buffer))
-	 (setq rdebug-rdebugtrack-is-tracking-p t))
-	(rdebug-rdebugtrack-is-tracking-p
+	 (setq rdebugtrack-is-tracking-p t))
+	(rdebugtrack-is-tracking-p
 	 (setq overlay-arrow-position nil)
-	 (setq rdebug-rdebugtrack-is-tracking-p nil))
+	 (setq rdebugtrack-is-tracking-p nil))
 	))
 
-(defun rdebug-rdebugtrack-track-stack-file (text)
+(defun rdebugtrack-track-stack-file (text)
   "Show the file indicated by the rdebug stack entry line, in a separate window.
 Activity is disabled if the buffer-local variable
-`rdebug-rdebugtrack-do-tracking-p' is nil.
-
-We depend on the rdebug input prompt matching `rdebug-rdebugtrack-input-prompt'
+`rdebugtrack-do-tracking-p' is nil.
+
+We depend on the rdebug input prompt matching `rdebugtrack-input-prompt'
 at the beginning of the line.
 " 
   ;; Instead of trying to piece things together from partial text

  "Queue of Makefile temp files awaiting execution.
Currently-active file is at the head of the list.")

(defvar rdebug-rdebugtrack-is-tracking-p t)





;; rdebugtrack 
(defcustom rdebugrack-mode-text " rdebug"
  "*String to display in the mode line when rdebugtrack mode is active.

\(When the string is not empty, make sure that it has a leading space.)"
  :tag "rdebug mode text"                ; To separate it from `global-...'
  :group 'rdebug
  :type 'string)

(define-minor-mode rdebugtrack-mode ()
  "Minor mode for tracking ruby debugging inside a process shell."
  :init-value nil
  ;; The indicator for the mode line.
  :lighter rdebugtrack-mode-text
  ;; The minor mode bindings.
  :keymap
  '(("\C-cg" . 'rdebug-goto-traceback-line)
    ("\C-cG" . 'rdebug-goto-dollarbang-traceback-line))
  :global nil
  :group 'rdebug
  (rdebugtrack-toggle-stack-tracking 1)
  (setq rdebugtrack-is-tracking-p t)
  (local-set-key "\C-cg" 'rdebug-goto-traceback-line)
  (local-set-key "\C-cG" 'rdebug-goto-dollarbang-traceback-line)
  (add-hook 'comint-output-filter-functions 'rdebugtrack-track-stack-file)
  (run-mode-hooks 'rdebugtrack-mode-hook))


(defun rdebugtrack-toggle-stack-tracking (arg)
  (interactive "P")
  (if (not (get-buffer-process (current-buffer)))
      (message "No process associated with buffer '%s'" (current-buffer))
    ;else
    ;; missing or 0 is toggle, >0 turn on, <0 turn off
    (if (or (not arg)
	    (zerop (setq arg (prefix-numeric-value arg))))
	(setq rdebugtrack-do-tracking-p (not rdebugtrack-do-tracking-p))
      (setq rdebugtrack-do-tracking-p (> arg 0)))
    (message "%sabled rdebug's rdebugtrack"
	     (if rdebugtrack-do-tracking-p "En" "Dis")))
  )

(defun turn-on-rdebugtrack-mode ()
  "Turn on rdebugtrack mode.

This function is designed to be added to hooks, for example:
  (add-hook 'comint-mode-hook 'turn-on-rdebugtrack-mode)"
  (interactive)
  (rdebugtrack-mode 1)
)

(defun turn-off-rdebugtrack ()
  (interactive)
  (setq rdebugtrack-is-tracking-p nil)
  (rdebugtrack-toggle-stack-tracking 0)
  (remove-hook 'comint-output-filter-functions 
	       'rdebugtrack-track-stack-file))

;; Add a designator to the minor mode strings if we are tracking
(or (assq 'rdebugtrack-minor-mode-string minor-mode-alist)
    (add-to-list 'minor-mode-alist 
		 '(rdebugtrack-is-tracking-p
		   rdebugtrack-minor-mode-string)))
;; rdebugtrack

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