-;;; bug-hunter.el --- Hunt down errors in elisp files -*- lexical-binding: t; -*-
+;;; bug-hunter.el --- Hunt down errors by bisecting elisp files -*- lexical-binding: t; -*-
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Author: Artur Malabarba <emacs@endlessparentheses.com>
-;; URL: http://github.com/Malabarba/elisp-bug-hunter
-;; Version: 0.5
+;; URL: https://github.com/Malabarba/elisp-bug-hunter
+;; Version: 1.0.1
;; Keywords: lisp
;; Package-Requires: ((seq "1.3") (cl-lib "0.5"))
;; ,----
;; | M-x bug-hunter-init-file RET i
;; `----
-;; The Bug Hunter will start a separate Emacs frame several times, and
-;; then it will ask you each time whether that frame presented the
+;; The Bug Hunter will start a separate Emacs instance several times, and
+;; then it will ask you each time whether that instance presented the
;; problem you have. After doing this about 5--12 times, you’ll be given
;; the results.
;;
(defconst bug-hunter--interactive-explanation
"You have asked to do an interactive hunt, here's how it goes.
-1) I will start a new Emacs frame.
+1) I will start a new Emacs instance, which opens a new frame.
2) You will try to reproduce your problem on the new frame.
3) When you’re done, close that frame.
4) I will ask you if you managed to reproduce the problem.
(defconst bug-hunter--assertion-reminder
"Remember, the assertion must be an expression that returns
non-nil in your current (problematic) Emacs state, AND that
-returns nil on a clean Emacs instance."
+returns nil on a clean Emacs instance.
+If you're unsure how to write an assertion, you can try the interactive
+hunt instead, or see some examples in the Readme:
+ https://github.com/Malabarba/elisp-bug-hunter"
"Printed to the user if they provide a bad assertion.")
(defvar bug-hunter--current-head nil
"")
(when (> size 16)
(format "\n ... %s omitted expressions ...\n\n"
- (- size 14)))
+ (- size 14)))
(when (> size 16)
(mapconcat (lambda (x) (bug-hunter--pretty-format x 4))
(seq-drop forms (- size 7)) "")))))
(concat "The assertion returned the following value here:\n"
(bug-hunter--pretty-format (cadr error) 4)))
(t (format "The following error was signaled here:\n %S"
- error))))
+ error))))
(when expression
(bug-hunter--report " Caused by the following expression:\n%s"
(bug-hunter--pretty-format expression 4)))
(delete-file file-name))))
(defun bug-hunter--run-form-interactively (form)
- "Run FORM in a graphical frame and ask user about the outcome."
+ "Run FORM in a graphical instance and ask user about the outcome."
(let ((file-name (bug-hunter--print-to-temp (list 'prin1 form))))
(unwind-protect
(bug-hunter--run-emacs file-name "-Q")
(vector (length safe) ret-val))
(ret-val
(apply #'bug-hunter--bisect
- assertion
- safe
- (bug-hunter--split head)))
+ assertion
+ safe
+ (bug-hunter--split head)))
;; Issue in the tail.
(t (apply #'bug-hunter--bisect
- assertion
- (append safe head)
- ;; If tail has length 1, we already know where the issue is,
- ;; but we still do this to get the return value.
- (bug-hunter--split tail))))))
+ assertion
+ (append safe head)
+ ;; If tail has length 1, we already know where the issue is,
+ ;; but we still do this to get the return value.
+ (bug-hunter--split tail))))))
(defun bug-hunter--bisect-start (forms assertion)
"Run a bisection search on list of FORMS using ASSERTION.
;; Prepare buffer, and make sure they've seen it.
(switch-to-buffer (bug-hunter--init-report-buffer assertion bug-hunter--estimate))
(when (eq assertion 'interactive)
- (read-char-choice "Please the instructions above and type 6 when ready. " '(?6)))
+ (read-char-choice "Please read the instructions above and type 6 when ready. " '(?6)))
(cond
;; Check for errors when reading the init file.
(if assertion
(concat "The assertion returned nil after loading the entire file.\n"
bug-hunter--assertion-reminder)
- "No errors signaled after loading the entire file. If you're
-looking for something that's not an error, you need to provide an
-assertion. See this link for some examples:
- https://github.com/Bruce-Connor/elisp-bug-hunter")
+ "No errors signaled after loading the entire file.
+If you're looking for something that's not an error, use the
+interactive hunt instead of the error hunt. If you have some
+elisp proficiency, you can also use the assertion hunt, see this
+link for some examples:
+ https://github.com/Malabarba/elisp-bug-hunter")
(or assertion "")))
;; Make sure we're in a forest, not a volcano.