X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/a4a72c07ec3abd4f6a7a6c8dafee1e6bbf118062..f10533854f4c7bb54247a11981191bf37b70cb36:/packages/bug-hunter/bug-hunter.el diff --git a/packages/bug-hunter/bug-hunter.el b/packages/bug-hunter/bug-hunter.el index 6faa5a18f..30c2c8e45 100644 --- a/packages/bug-hunter/bug-hunter.el +++ b/packages/bug-hunter/bug-hunter.el @@ -1,10 +1,10 @@ -;;; 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 -;; URL: http://github.com/Malabarba/elisp-bug-hunter -;; Version: 1.0 +;; URL: https://github.com/Malabarba/elisp-bug-hunter +;; Version: 1.3.1 ;; Keywords: lisp ;; Package-Requires: ((seq "1.3") (cl-lib "0.5")) @@ -110,7 +110,7 @@ non-nil in your current (problematic) Emacs state, AND that 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/Bruce-Connor/elisp-bug-hunter" + https://github.com/Malabarba/elisp-bug-hunter" "Printed to the user if they provide a bad assertion.") (defvar bug-hunter--current-head nil @@ -143,7 +143,10 @@ file.") nil) (end-of-file `(bug-caught (end-of-file) ,line ,col)) (invalid-read-syntax `(bug-caught ,er ,line ,col)) - (error (error "Ran into an error we don't understand, please file a bug report: %S" er))) + (error + (if (string= (elt er 1) "Invalid modifier in string") + `(bug-caught (invalid-modifier) ,line ,col) + (error "Ran into an error we don't understand, please file a bug report: %S" er)))) (nreverse out)))) (defun bug-hunter--read-contents (file) @@ -215,6 +218,9 @@ the file." (cl-case (car error) (end-of-file "There's a missing closing parenthesis, the expression on this line never ends.") + (invalid-modifier (concat "There's a string on this line with an invalid modifier." + "\n A \"modifier\" is a \\ followed by a few characters." + "\n For example, \\C-; is an invalid modifier.")) (invalid-read-syntax (let ((char (cadr error))) (if (member char '("]" ")")) @@ -288,7 +294,7 @@ ARGS are passed before \"-l FILE\"." (unwind-protect (bug-hunter--run-emacs file-name "-Q") (delete-file file-name)) - (y-or-n-p "Did you find the problem/bug in this instance? "))) + (y-or-n-p "Did you find the problem/bug in this instance (if you encounter some other issue, answer `n')? "))) (defun bug-hunter--wrap-forms-for-eval (forms) "Return FORMS wrapped in initialization code." @@ -304,7 +310,7 @@ ARGS are passed before \"-l FILE\"." "Execute FORMS in the background and test ASSERTION. See `bug-hunter' for a description on the ASSERTION. -If ASSERTION is 'interactive, the form is run through +If ASSERTION is `interactive', the form is run through `bug-hunter--run-form-interactively'. Otherwise, a slightly modified version of the form combined with ASSERTION is run through `bug-hunter--run-form'." @@ -416,7 +422,7 @@ 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/Bruce-Connor/elisp-bug-hunter") + https://github.com/Malabarba/elisp-bug-hunter") (or assertion ""))) ;; Make sure we're in a forest, not a volcano. @@ -425,9 +431,11 @@ link for some examples: (if assertion (concat "Assertion returned non-nil even on emacs -Q:" bug-hunter--assertion-reminder) - "Detected a signaled error even on emacs -Q. I'm sorry, but there -is something seriously wrong with your Emacs installation. -There's nothing more I can do here.") + "Detected a signaled error even on emacs -Q. This could mean three +things things: +1. The problem happens inside `package-initialize'. +2. You wrote the assertion wrong. +3. There's something seriously wrong with your Emacs installation.") (or assertion ""))) (t @@ -460,10 +468,17 @@ Wraps them in a progn if necessary to always return a single form. The user may decide to not provide input, in which case -'interactive is returned. Note, this is different from the user -typing `RET' at an empty prompt, in which case nil is returned." - (pcase (read-char-choice bug-hunter--hunt-type-prompt '(?i ?e ?a)) - (`?i 'interactive) +`interactive' is returned. Note, this is different from the user +typing RET at an empty prompt, in which case nil is returned." + (pcase (read-char-choice (if (display-graphic-p) + bug-hunter--hunt-type-prompt + (replace-regexp-in-string "To bisect interactively,.*\n" "" + bug-hunter--hunt-type-prompt)) + '(?i ?e ?a)) + (`?i + (unless (display-graphic-p) + (user-error "Sorry, but `interactive' bisection needs a graphical frame")) + 'interactive) (`?e nil) (_ (require 'simple) @@ -474,7 +489,11 @@ typing `RET' at an empty prompt, in which case nil is returned." (minibuffer-with-setup-hook (lambda () (add-hook 'completion-at-point-functions - #'elisp-completion-at-point nil t) + (if (fboundp 'elisp-completion-at-point) + #'elisp-completion-at-point + (with-no-warnings + #'lisp-completion-at-point)) + nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) (insert (read-from-minibuffer