summaryrefslogtreecommitdiff
path: root/elisp/geiser-repl.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-12 00:31:12 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-08-12 00:31:12 +0200
commit600ef3a419f61c738f0e054bad4c02925cb964f0 (patch)
tree5b0bf2653b14fb9211baafad7886c3c30cb8a1c6 /elisp/geiser-repl.el
parent6c06167e9a8fbf8d0b1eba9911db27ccbae165f8 (diff)
downloadgeiser-600ef3a419f61c738f0e054bad4c02925cb964f0.tar.gz
geiser-600ef3a419f61c738f0e054bad4c02925cb964f0.tar.bz2
Newish emacsen don't have comint-last-prompt-overlay
... so we have to check if it's defined and, in its defect, use the new shiny comint-last-prompt. A bit of refactoring resulted.
Diffstat (limited to 'elisp/geiser-repl.el')
-rw-r--r--elisp/geiser-repl.el37
1 files changed, 20 insertions, 17 deletions
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index f0c495e..8a3f6a6 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -266,6 +266,23 @@ module command as a string")
(geiser-repl--read-impl prompt)))
+;;; Prompt &co.
+
+(defun geiser-repl--last-prompt-end ()
+ (cond ((and (boundp 'comint-last-prompt) (markerp (cdr comint-last-prompt)))
+ (marker-position (cdr comint-last-prompt)))
+ ((and (boundp 'comint-last-prompt-overlay) comint-last-prompt-overlay)
+ (overlay-end comint-last-prompt-overlay))
+ (t (save-excursion (geiser-repl--bol) (point)))))
+
+(defun geiser-repl--last-prompt-start ()
+ (cond ((and (boundp 'comint-last-prompt) (markerp (car comint-last-prompt)))
+ (marker-position (car comint-last-prompt)))
+ ((and (boundp 'comint-last-prompt-overlay) comint-last-prompt-overlay)
+ (overlay-start comint-last-prompt-overlay))
+ (t (save-excursion (geiser-repl--bol) (point)))))
+
+
;;; REPL connections
(make-variable-buffer-local
@@ -369,12 +386,9 @@ module command as a string")
(defun geiser-repl--is-debugging ()
(let ((dp (geiser-con--connection-debug-prompt geiser-repl--connection)))
(and dp
- comint-last-prompt-overlay
(save-excursion
- (goto-char (overlay-start comint-last-prompt-overlay))
- (re-search-forward dp
- (overlay-end comint-last-prompt-overlay)
- t)))))
+ (goto-char (geiser-repl--last-prompt-start))
+ (re-search-forward dp (geiser-repl--last-prompt-end) t)))))
(defun geiser-repl--connection* ()
(let ((buffer (geiser-repl--set-up-repl geiser-impl--implementation)))
@@ -489,8 +503,7 @@ module command as a string")
(defun geiser-repl--beginning-of-defun ()
(save-restriction
- (when comint-last-prompt-overlay
- (narrow-to-region (overlay-end comint-last-prompt-overlay) (point)))
+ (narrow-to-region (geiser-repl--last-prompt-end) (point))
(let ((beginning-of-defun-function nil))
(beginning-of-defun))))
@@ -512,16 +525,6 @@ module command as a string")
(insert "\n")
(lisp-indent-line)))
-(defun geiser-repl--last-prompt-end ()
- (if comint-last-prompt-overlay
- (overlay-end comint-last-prompt-overlay)
- (save-excursion (geiser-repl--bol) (point))))
-
-(defun geiser-repl--last-prompt-start ()
- (if comint-last-prompt-overlay
- (overlay-start comint-last-prompt-overlay)
- (save-excursion (geiser-repl--bol) (point))))
-
(defun geiser-repl--nesting-level ()
(save-restriction
(narrow-to-region (geiser-repl--last-prompt-end) (point-max))