branch: master
commit e2c3271331800912e60f10355185af153fe40bb5
Author: rocky <[email protected]>
Commit: rocky <[email protected]>
Minimal support for running under eshell
More FSF copyrights
---
realgud/common/loc.el | 19 ++++++++++++++++---
realgud/common/send.el | 35 ++++++++++++++++++++++++++++-------
realgud/common/track-mode.el | 15 ++++++++++-----
realgud/common/track.el | 2 +-
4 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/realgud/common/loc.el b/realgud/common/loc.el
index fe4b214..00c75a0 100644
--- a/realgud/common/loc.el
+++ b/realgud/common/loc.el
@@ -1,6 +1,19 @@
-;;; Copyright (C) 2010, 2012, 2014-2015 Rocky Bernstein <[email protected]>
-;;; Debugger location
-;;; Commentary:
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <[email protected]>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; This describes a debugger location structure and has code for
;; working with them.
diff --git a/realgud/common/send.el b/realgud/common/send.el
index 3d752ec..85f26b5 100644
--- a/realgud/common/send.el
+++ b/realgud/common/send.el
@@ -16,6 +16,7 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(require 'comint)
+(require 'eshell)
(require 'load-relative)
(require-relative-list '("window") "realgud-")
(require-relative-list '("buffer/helper") "realgud-buffer-")
@@ -24,16 +25,36 @@
(declare-function comint-goto-process-mark 'comint)
(declare-function comint-send-input 'comint)
-(defun realgud-send-command-comint (process command-str)
+(defun realgud:send-input ()
+ "Sends command buffer line either to comint or eshell"
+ (interactive)
+ ;; FIXME DRY with code in realgud:send-command-common() and track-mode.el
+ (cond ((and (boundp 'eshell-mode) eshell-mode)
+ (eshell-send-input))
+ ((and (boundp 'comint-prompt-regexp)
+ (comint-check-proc (current-buffer)))
+ (comint-send-input))
+ ('t (error "We can only handle comint or eshell buffers")))
+ )
+
+(defun realgud:send-command-common (process command-str)
"Assume we are in a comint buffer. Insert COMMAND-STR and
send that input onto the process."
(if (eq 'run (process-status process))
(progn
- (comint-goto-process-mark)
- (setq comint-last-output-start
- (setq realgud-last-output-start (point-marker)))
+ ;; FIXME DRY with code in realgud:send-input() and track-mode.el
+ (cond ((and (boundp 'eshell-mode) eshell-mode)
+ (goto-char eshell-last-output-end)
+ (setq eshell-last-output-start
+ (setq realgud-last-output-start (point-marker))))
+ ((and (boundp 'comint-prompt-regexp)
+ (comint-check-proc (current-buffer)))
+ (comint-goto-process-mark)
+ (setq comint-last-output-start
+ (setq realgud-last-output-start (point-marker))))
+ ('t (error "We can only handle cmint or eshell buffers")))
(insert command-str)
- (comint-send-input)
+ (realgud:send-input)
)
;; else
(message "Process %s not in `run' state; not issuing %s"
@@ -77,7 +98,7 @@ results into the command buffer."
"Invoke the debugger COMMAND adding that command and the
results into the command buffer."
(let* ((cmdbuf (realgud-get-cmdbuf opt-buffer))
- (send-command-fn (or opt-send-fn (function
realgud-send-command-comint)))
+ (send-command-fn (or opt-send-fn (function
realgud:send-command-common)))
)
(if cmdbuf
(with-current-buffer cmdbuf
@@ -222,7 +243,7 @@ debugger prompt.
;; display of the command buffer.
(if realgud-prompts? (realgud-window-cmd-undisturb-src nil 't))
- (realgud-send-command command-str (function
realgud-send-command-comint))
+ (realgud-send-command command-str (function
realgud:send-command-common))
;; Wait for the process-mark to change before changing variables
;; that effect the hook processing.
diff --git a/realgud/common/track-mode.el b/realgud/common/track-mode.el
index c2c1dcd..4199181 100644
--- a/realgud/common/track-mode.el
+++ b/realgud/common/track-mode.el
@@ -38,10 +38,10 @@
(declare-function realgud-cmdbuf-info-set?
'realgud-buffer-command)
-
(defvar realgud-track-mode-map
(let ((map (copy-keymap shell-mode-map)))
(realgud-populate-debugger-menu map)
+ (define-key map "\r" 'realgud:send-input)
(define-key map [M-right] 'realgud-track-hist-newest)
(define-key map [M-down] 'realgud-track-hist-newer)
(define-key map [M-up] 'realgud-track-hist-older)
@@ -137,10 +137,15 @@ of this mode."
(set-marker comint-last-output-start (point)))
(set (make-local-variable 'tool-bar-map) realgud:tool-bar-map)
- (add-hook 'comint-output-filter-functions
- 'realgud-track-comint-output-filter-hook)
- (add-hook 'eshell-output-filter-functions
- 'realgud-track-eshell-output-filter-hook)
+ ;; FIXME DRY with code in send.el
+ (cond ((and (boundp 'eshell-mode) eshell-mode)
+ (add-hook 'eshell-output-filter-functions
+ 'realgud-track-eshell-output-filter-hook))
+ ((and (boundp 'comint-prompt-regexp)
+ (comint-check-proc (current-buffer)))
+ (add-hook 'comint-output-filter-functions
+ 'realgud-track-comint-output-filter-hook))
+ ('t (error "We can only handle comint or eshell buffers")))
(run-mode-hooks 'realgud-track-mode-hook))
;; else
(progn
diff --git a/realgud/common/track.el b/realgud/common/track.el
index 1c40ba8..24a531d 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -130,7 +130,7 @@ marks set in buffer-local variables to extract text"
(lexical-let* ((cmd-buff (current-buffer))
(cmd-mark (point-marker))
(loc (realgud:track-from-region eshell-last-output-start
- eshell-last-output-end
cmd-mark)))
+ eshell-last-output-end
cmd-mark)))
(realgud-track-loc-action loc cmd-buff 't)))
)