FUEL: Ooops, infinite recursion fix.
							parent
							
								
									885cc0503b
								
							
						
					
					
						commit
						8be42496b3
					
				| 
						 | 
				
			
			@ -96,7 +96,8 @@
 | 
			
		|||
  (let ((reqs (assoc :requests c))
 | 
			
		||||
        (current (assoc :current c)))
 | 
			
		||||
    (setcdr current (prog1 (cadr reqs) (setcdr reqs (cddr reqs))))
 | 
			
		||||
    (if (and current (fuel-con--request-deactivated-p current))
 | 
			
		||||
    (if (and (cdr current)
 | 
			
		||||
             (fuel-con--request-deactivated-p (cdr current)))
 | 
			
		||||
        (fuel-con--connection-pop-request c)
 | 
			
		||||
      current)))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,6 +114,47 @@
 | 
			
		|||
  (add-hook 'comint-redirect-filter-functions
 | 
			
		||||
            'fuel-con--comint-redirect-filter t t))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;; Logging:
 | 
			
		||||
 | 
			
		||||
(defvar fuel-con--log-size 32000
 | 
			
		||||
  "Maximum size of the Factor messages log.")
 | 
			
		||||
 | 
			
		||||
(defvar fuel-con--log-verbose-p t
 | 
			
		||||
  "Log level for Factor messages.")
 | 
			
		||||
 | 
			
		||||
(define-derived-mode factor-messages-mode fundamental-mode "Factor Messages"
 | 
			
		||||
  "Simple mode to log interactions with the factor listener"
 | 
			
		||||
  (kill-all-local-variables)
 | 
			
		||||
  (buffer-disable-undo)
 | 
			
		||||
  (set (make-local-variable 'comint-redirect-subvert-readonly) t)
 | 
			
		||||
  (add-hook 'after-change-functions
 | 
			
		||||
            '(lambda (b e len)
 | 
			
		||||
               (let ((inhibit-read-only t))
 | 
			
		||||
                 (when (> b fuel-con--log-size)
 | 
			
		||||
                   (delete-region (point-min) b))))
 | 
			
		||||
            nil t)
 | 
			
		||||
  (setq buffer-read-only t))
 | 
			
		||||
 | 
			
		||||
(defun fuel-con--log-buffer ()
 | 
			
		||||
  (or (get-buffer "*factor messages*")
 | 
			
		||||
      (save-current-buffer
 | 
			
		||||
        (set-buffer (get-buffer-create "*factor messages*"))
 | 
			
		||||
        (factor-messages-mode)
 | 
			
		||||
        (current-buffer))))
 | 
			
		||||
 | 
			
		||||
(defsubst fuel-con--log-msg (type &rest args)
 | 
			
		||||
  (format "\n%s: %s\n" type (apply 'format args)))
 | 
			
		||||
 | 
			
		||||
(defsubst fuel-con--log-warn (&rest args)
 | 
			
		||||
  (apply 'fuel-con--log-msg 'WARNING args))
 | 
			
		||||
 | 
			
		||||
(defsubst fuel-con--log-error (&rest args)
 | 
			
		||||
  (apply 'fuel-con--log-msg 'ERROR args))
 | 
			
		||||
 | 
			
		||||
(defsubst fuel-con--log-info (&rest args)
 | 
			
		||||
  (if fuel-con--log-verbose-p (apply 'fuel-con--log-msg 'INFO args) ""))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;; Requests handling:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,30 +165,32 @@
 | 
			
		|||
           (str (and req (fuel-con--request-string req))))
 | 
			
		||||
      (when (and buffer req str)
 | 
			
		||||
        (set-buffer buffer)
 | 
			
		||||
        (comint-redirect-send-command str
 | 
			
		||||
                                      (get-buffer-create "*factor messages*")
 | 
			
		||||
                                      nil
 | 
			
		||||
                                      t)))))
 | 
			
		||||
        (when fuel-con--log-verbose-p
 | 
			
		||||
          (with-current-buffer (fuel-con--log-buffer)
 | 
			
		||||
            (let ((inhibit-read-only t))
 | 
			
		||||
              (insert (fuel-con--log-info "<%s>: %s"
 | 
			
		||||
                                          (fuel-con--request-id req) str)))))
 | 
			
		||||
        (comint-redirect-send-command str (fuel-con--log-buffer) nil t)))))
 | 
			
		||||
 | 
			
		||||
(defun fuel-con--comint-redirect-filter (str)
 | 
			
		||||
  (if (not fuel-con--connection)
 | 
			
		||||
      (format "\nERROR: No connection in buffer (%s)\n" str)
 | 
			
		||||
      (fuel-con--log-error "No connection in buffer (%s)" str)
 | 
			
		||||
    (let ((req (fuel-con--connection-current-request fuel-con--connection)))
 | 
			
		||||
      (if (not req) (format "\nERROR: No current request (%s)\n" str)
 | 
			
		||||
      (if (not req) (fuel-con--log-error "No current request (%s)" str)
 | 
			
		||||
        (let ((cont (fuel-con--request-continuation req))
 | 
			
		||||
              (id (fuel-con--request-id req))
 | 
			
		||||
              (rstr (fuel-con--request-string req))
 | 
			
		||||
              (buffer (fuel-con--request-buffer req)))
 | 
			
		||||
          (prog1
 | 
			
		||||
              (if (not cont)
 | 
			
		||||
                  (format "\nWARNING: Droping result for request %s:%S (%s)\n"
 | 
			
		||||
                          id rstr str)
 | 
			
		||||
                  (fuel-con--log-warn "<%s> Droping result for request %S (%s)"
 | 
			
		||||
                                      id rstr str)
 | 
			
		||||
                (condition-case cerr
 | 
			
		||||
                    (with-current-buffer (or buffer (current-buffer))
 | 
			
		||||
                      (funcall cont str)
 | 
			
		||||
                      (format "\nINFO: %s:%S processed\nINFO: %s\n" id rstr str))
 | 
			
		||||
                  (error (format "\nERROR: continuation failed %s:%S \nERROR: %s\n"
 | 
			
		||||
                                 id rstr cerr))))
 | 
			
		||||
                      (fuel-con--log-info "<%s>: processed\n\t%s" id str))
 | 
			
		||||
                  (error (fuel-con--log-error "<%s>: continuation failed %S \n\t%s"
 | 
			
		||||
                                              id rstr cerr))))
 | 
			
		||||
            (fuel-con--connection-clean-current-request fuel-con--connection)))))))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -253,13 +253,14 @@ invoking restarts as needed.
 | 
			
		|||
\\{fuel-debug-mode-map}"
 | 
			
		||||
  (interactive)
 | 
			
		||||
  (kill-all-local-variables)
 | 
			
		||||
  (buffer-disable-undo)
 | 
			
		||||
  (setq major-mode 'factor-mode)
 | 
			
		||||
  (setq mode-name "Fuel Debug")
 | 
			
		||||
  (use-local-map fuel-debug-mode-map)
 | 
			
		||||
  (fuel-debug--font-lock-setup)
 | 
			
		||||
  (setq fuel-debug--file nil)
 | 
			
		||||
  (setq fuel-debug--last-ret nil)
 | 
			
		||||
  (toggle-read-only 1)
 | 
			
		||||
  (setq buffer-read-only t)
 | 
			
		||||
  (run-hooks 'fuel-debug-mode-hook))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -261,6 +261,7 @@ buffer."
 | 
			
		|||
\\{fuel-help-mode-map}"
 | 
			
		||||
  (interactive)
 | 
			
		||||
  (kill-all-local-variables)
 | 
			
		||||
  (buffer-disable-undo)
 | 
			
		||||
  (use-local-map fuel-help-mode-map)
 | 
			
		||||
  (setq mode-name "Factor Help")
 | 
			
		||||
  (setq major-mode 'fuel-help-mode)
 | 
			
		||||
| 
						 | 
				
			
			@ -271,7 +272,7 @@ buffer."
 | 
			
		|||
  (fuel-autodoc-mode)
 | 
			
		||||
 | 
			
		||||
  (run-mode-hooks 'fuel-help-mode-hook)
 | 
			
		||||
  (toggle-read-only 1))
 | 
			
		||||
  (setq buffer-read-only t))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(provide 'fuel-help)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue