SLY: Fix prompt navigation.
parent
9baebf4073
commit
0ee966dcb0
|
@ -272,22 +272,35 @@ returns a string."
|
|||
#'ambrevar/sly-new-prompt)
|
||||
(advice-add 'sly-mrepl--insert-prompt :around #'ambrevar/sly-prepare-prompt)))
|
||||
|
||||
(defun ambrevar/sly-end-of-prompt-p ()
|
||||
(and (not (= (point) (point-min)))
|
||||
(not (get-text-property (point) 'sly-mrepl--prompt))
|
||||
(get-text-property (1- (point)) 'sly-mrepl--prompt)))
|
||||
|
||||
(defun ambrevar/sly-prompt-line-p ()
|
||||
(or (ambrevar/sly-end-of-prompt-p)
|
||||
(save-excursion
|
||||
(goto-char (line-beginning-position))
|
||||
(ambrevar/sly-end-of-prompt-p))))
|
||||
|
||||
(defun ambrevar/sly-mrepl-previous-prompt ()
|
||||
"Go to the beginning of the previous REPL prompt."
|
||||
(interactive)
|
||||
;; This has two wrinkles around the first prompt: (1) when going to
|
||||
;; the first prompt it leaves point at column 0 (1) when called from
|
||||
;; frist prompt goes to beginning of buffer. The correct fix is to
|
||||
;; patch comint.el's comint-next-prompt and comint-previous-prompt
|
||||
;; anyway...
|
||||
(let* ((inhibit-field-text-motion t)
|
||||
(pos (previous-single-char-property-change
|
||||
(previous-single-char-property-change (point)
|
||||
'sly-mrepl--prompt)
|
||||
'sly-mrepl--prompt)))
|
||||
(goto-char pos)
|
||||
(goto-char (line-beginning-position)))
|
||||
(end-of-line))
|
||||
(cl-flet ((go-back ()
|
||||
(goto-char
|
||||
(previous-single-char-property-change
|
||||
(point) 'sly-mrepl--prompt))))
|
||||
(if (ambrevar/sly-prompt-line-p)
|
||||
(progn
|
||||
(unless (ambrevar/sly-end-of-prompt-p)
|
||||
(goto-char (line-beginning-position)))
|
||||
(go-back)
|
||||
(go-back))
|
||||
(go-back))
|
||||
(unless (ambrevar/sly-prompt-line-p)
|
||||
;; We did not end up on a prompt, means we are above the first prompt.
|
||||
;; Return back.
|
||||
(ambrevar/sly-mrepl-next-prompt))))
|
||||
|
||||
(defun ambrevar/sly-mrepl-next-prompt ()
|
||||
"Go to the beginning of the next REPL prompt."
|
||||
|
|
Loading…
Reference in New Issue