From 4c1e23b82d59e26fc22f6b115b32d8aee79c3e87 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 28 Nov 2008 13:23:15 +0100 Subject: [PATCH] Emacs factor mode: bug fix: don't depend on cl's DO. --- misc/factor.el | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/misc/factor.el b/misc/factor.el index 998261e4e6..ba1c633466 100644 --- a/misc/factor.el +++ b/misc/factor.el @@ -596,23 +596,28 @@ buffer." (defconst factor--regex-error-marker "^Type :help for debugging") (defconst factor--regex-data-stack "^--- Data stack:") -(defun factor--prune-stack (ans) - (do ((res '() (cons (car s) res)) (s ans (cdr s))) - ((or (not s) - (and (car res) (string-match factor--regex-stack-effect (car res))) - (string-match factor--regex-data-stack (car s))) - (and (not (string-match factor--regex-error-marker (car res))) - (nreverse res))))) +(defun factor--prune-ans-strings (ans) + (nreverse + (catch 'done + (let ((res)) + (dolist (a ans res) + (cond ((string-match factor--regex-stack-effect a) + (throw 'done (cons a res))) + ((string-match factor--regex-data-stack a) + (throw 'done res)) + ((string-match factor--regex-error-marker a) + (throw 'done nil)) + (t (push a res)))))))) (defun factor--see-ans-to-string (ans) - (let ((s (mapconcat #'identity (factor--prune-stack ans) " "))) + (let ((s (mapconcat #'identity (factor--prune-ans-strings ans) " ")) + (font-lock-verbose nil)) (and (> (length s) 0) - (let ((font-lock-verbose nil)) - (with-temp-buffer - (insert s) - (factor-mode) - (font-lock-fontify-buffer) - (buffer-string)))))) + (with-temp-buffer + (insert s) + (factor-mode) + (font-lock-fontify-buffer) + (buffer-string))))) (defun factor--see-current-word (&optional word) (let ((word (or word (factor--symbol-at-point))))