Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the debug mode (for recent coq verions). #788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion coq/coq-syntax.el
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,9 @@ Very similar to `coq-omit-proof-admit-command', but without the dot."
;; april2017: coq-8.7 removes special chars definitely and puts
;; <infomsg> and <warning> around all messages except errors.
;; We let our legacy regexp for some years and remove them, say, in 2020.
;; 09/2024: Adding more eager annotations to fix debug mode.
(defvar coq-shell-eager-annotation-start
"\376\\|\\[Reinterning\\|Warning:\\|TcDebug \\|<infomsg>\\|<warning>")
"\376\\|\\[Reinterning\\|Warning:\\|TcDebug \\|<infomsg>\\|<warning>\\|Going to execute:")

(defvar coq-shell-eager-annotation-end
"\377\\|done\\]\\|</infomsg>\\|</warning>\\|\\*\\*\\*\\*\\*\\*\\|) >")
Expand Down
32 changes: 20 additions & 12 deletions coq/coq.el
Original file line number Diff line number Diff line change
Expand Up @@ -1837,23 +1837,29 @@ at `proof-assistant-settings-cmds' evaluation time.")
(defun coq-display-debug-goal ()
(interactive)
(with-current-buffer proof-shell-buffer
(let ((pt (progn (save-excursion (forward-line -1) (point)))))
(goto-char (point-max))
(let ((pt (save-excursion (forward-line -1) (point)))
(last-prompt (save-excursion (forward-line -1)
(re-search-backward "</prompt>" nil t))))
(save-excursion
(re-search-backward "^TcDebug" pt t)
(re-search-backward "<infomsg>\\|^TcDebug\\|^</prompt>" nil t)
(when (looking-at "<infomsg>")
(let ((pt2 (point)))
(re-search-backward "Goal:\\|^TcDebug\\|^</prompt>" nil t)
(when (looking-at "Goal")
(pg-goals-display (buffer-substring (point) pt2) nil))))))))
(when (and
(re-search-backward "^TcDebug" pt t) ;; current TcDebug
(re-search-backward "^TcDebug" last-prompt t)) ;; previous one
(re-search-forward "^Goal:" pt t))
(beginning-of-line)
(let ((pt2 (point)))
(re-search-forward "</prompt>\\|^Debug:\\|^Going to execute:\\|^TcDebug" nil t)
(goto-char (match-beginning 0))
(pg-goals-display (buffer-substring pt2 (point)) nil)
(beginning-of-line)
(pg-response-message (buffer-substring (point) (point-max)))
)))))

;; overwrite the generic one, interactive prompt is Debug mode;; try to display
;; the debug goal in the goals buffer.
(defun proof-shell-process-interactive-prompt-regexp ()
"Action taken when `proof-shell-interactive-prompt-regexp' is observed."
(when (and (proof-shell-live-buffer)
; not already visible
t)
(when (proof-shell-live-buffer)
(switch-to-buffer proof-shell-buffer)
(coq-display-debug-goal)
(message "Prover expects input in %s buffer (if debug mode: h<return> for help))" proof-shell-buffer)))
Expand Down Expand Up @@ -2001,7 +2007,9 @@ at `proof-assistant-settings-cmds' evaluation time.")
proof-shell-eager-annotation-start coq-shell-eager-annotation-start
proof-shell-eager-annotation-start-length 32

proof-shell-interactive-prompt-regexp "TcDebug "
;; we need these two strings to be recognized so that the first appearing is
;; analyzed
proof-shell-interactive-prompt-regexp "TcDebug ([0-9]+) >\\|Going to execute:"

;; ****** is added at the end of warnings in emacs mode, this is temporary I
;; want xml like tags, and I want them removed before warning display.
Expand Down
Loading