Function: report-emacs-bug

report-emacs-bug is an autoloaded, interactive and byte-compiled function defined in emacsbug.el.gz.

Signature

(report-emacs-bug TOPIC)

Documentation

Report a bug in GNU Emacs.

Prompts for bug subject. Leaves you in a mail buffer.

Already submitted bugs can be found in the Emacs bug tracker:

  https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;max-bugs=100;base-order=1;bug-rev=1

View in manual

Probably introduced at or before Emacs version 24.1.

Key Bindings

Aliases

report-calc-bug (obsolete since 26.2) octave-submit-bug-report (obsolete since 24.4) simula-submit-bug-report (obsolete since 24.4) calc-report-bug (obsolete since 26.2)

Source Code

;; Defined in /usr/src/emacs/lisp/mail/emacsbug.el.gz
;;;###autoload
(defun report-emacs-bug (topic &optional _unused)
  "Report a bug in GNU Emacs.
Prompts for bug subject.  Leaves you in a mail buffer.

Already submitted bugs can be found in the Emacs bug tracker:

  https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;max-bugs=100;base-order=1;bug-rev=1"
  (declare (advertised-calling-convention (topic) "24.5"))
  (interactive "sBug Subject: ")
  ;; The syntax `version;' is preferred to `[version]' because the
  ;; latter could be mistakenly stripped by mailing software.
  (setq topic (concat emacs-version "; " topic))
  (let ((from-buffer (current-buffer))
	(can-insert-mail (or (report-emacs-bug-can-use-xdg-email)
			     (report-emacs-bug-can-use-osx-open)))
        user-point) ;; message-end-point
    ;; (setq message-end-point
    ;;       (with-current-buffer (messages-buffer)
    ;;         (point-max-marker)))
    (condition-case nil
        ;; For the novice user make sure there's always enough space for
        ;; the mail and the warnings buffer on this frame (Bug#10873).
        (unless report-emacs-bug-no-explanations
          (delete-other-windows)
          (set-window-dedicated-p nil nil)
          (set-frame-parameter nil 'unsplittable nil))
      (error nil))
    (compose-mail report-emacs-bug-address topic)
    (rfc822-goto-eoh)
    (insert "X-Debbugs-Cc: \n")
    ;; The rest of this does not execute if the user was asked to
    ;; confirm and said no.
    (when (derived-mode-p 'message-mode)
      ;; Message-mode sorts the headers before sending.  We sort now so
      ;; that report-emacs-bug-orig-text remains valid.  (Bug#5178)
      (message-sort-headers)
      ;; Stop message-mode stealing the properties we will add.
      (setq-local message-strip-special-text-properties nil)
      ;; Make sure we default to the From: address as envelope when sending
      ;; through sendmail.  FIXME: Why?
      (when (and (not (message--sendmail-envelope-from))
		 (message-bogus-recipient-p (message-make-address)))
        (setq-local message-sendmail-envelope-from 'header)))
    (rfc822-goto-eoh)
    (forward-line 1)
    ;; Move the mail signature to the proper place.
    (let ((signature (buffer-substring (point) (point-max)))
	  (inhibit-read-only t))
      (delete-region (point) (point-max))
      (insert signature)
      (backward-char (length signature)))
    (unless report-emacs-bug-no-explanations
      ;; Insert warnings for novice users.
      (if (not (equal "bug-gnu-emacs@gnu.org" report-emacs-bug-address))
	  (insert (format "The report will be sent to %s.\n\n"
			  report-emacs-bug-address))
	(insert "This bug report will be sent to the ")
	(insert-text-button
	 "Bug-GNU-Emacs"
	 'face 'link
	 'help-echo (concat "mouse-2, RET: Follow this link")
	 'action (lambda (_button)
		   (browse-url "https://lists.gnu.org/r/bug-gnu-emacs/"))
	 'follow-link t)
	(insert " mailing list\nand the GNU bug tracker at ")
	(insert-text-button
	 "debbugs.gnu.org"
	 'face 'link
	 'help-echo (concat "mouse-2, RET: Follow this link")
	 'action (lambda (_button)
		   (browse-url "https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;max-bugs=100;base-order=1;bug-rev=1"))
	 'follow-link t)

	(insert ".  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgment at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.\n\n")))

    (insert "Please describe exactly what actions triggered the bug, and\n"
	    "the precise symptoms of the bug.  If you can, give a recipe\n"
	    "starting from 'emacs -Q':\n\n")
    (let ((txt (delete-and-extract-region
                (save-excursion (rfc822-goto-eoh) (line-beginning-position 2))
                (point))))
      (insert (propertize "\n" 'display txt)))
    (setq user-point (point))
    (insert "\n\n")

    (insert "If Emacs crashed, and you have the Emacs process in the gdb debugger,\n"
	    "please include the output from the following gdb commands:\n"
	    "    'bt full' and 'xbacktrace'.\n")

    (let ((debug-file (expand-file-name "DEBUG" data-directory)))
      (if (file-readable-p debug-file)
	  (insert "For information about debugging Emacs, please read the file\n"
		  debug-file ".\n")))
    (let ((txt (delete-and-extract-region (1+ user-point) (point))))
      (insert (propertize "\n" 'display txt)))

    (emacs-build-description)
    (insert "Configured features:\n" system-configuration-features "\n\n")
    (fill-region (line-beginning-position -1) (point))
    (when (and (featurep 'native-compile)
               (null (native-comp-available-p)))
      (insert "(NATIVE_COMP present but libgccjit not available)\n\n"))
    (insert "Important settings:\n")
    (mapc
     (lambda (var)
       (let ((val (getenv var)))
	 (if val (insert (format "  value of $%s: %s\n" var val)))))
     '("EMACSDATA" "EMACSDOC" "EMACSLOADPATH" "EMACSNATIVELOADPATH" "EMACSPATH"
       "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES"
       "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS"))
    (insert (format "  locale-coding-system: %s\n" locale-coding-system))
    (insert "\n")
    (insert (format "Major mode: %s\n"
		    (format-mode-line
                     (buffer-local-value 'mode-name from-buffer)
                     nil nil from-buffer)))
    (insert "\n")
    (insert "Minor modes in effect:\n")
    (dolist (mode minor-mode-list)
      (and (boundp mode) (buffer-local-value mode from-buffer)
	   (insert (format "  %s: %s\n" mode
			   (buffer-local-value mode from-buffer)))))
    (insert "\n")
    (insert "Load-path shadows:\n")
    (let* ((msg "Checking for load-path shadows...")
	   (result "done")
	   (shadows (progn (message "%s" msg)
			   (condition-case nil (list-load-path-shadows t)
			     (error
			      (setq result "error")
			      "Error during checking")))))
      (message "%s%s" msg result)
      (insert (if (zerop (length shadows))
                  "None found.\n"
                shadows)))
    (insert (format "\nFeatures:\n%s\n" features))
    (fill-region (line-beginning-position 0) (point))

    (insert "\nMemory information:\n")
    (pp (garbage-collect) (current-buffer))

    ;; This is so the user has to type something in order to send easily.
    (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
    (keymap-set (current-local-map) "C-c C-i" #'info-emacs-bug)
    (if can-insert-mail
        (keymap-set (current-local-map) "C-c M-i"
                    #'report-emacs-bug-insert-to-mailer))
    (setq report-emacs-bug-send-command (get mail-user-agent 'sendfunc)
	  report-emacs-bug-send-hook (get mail-user-agent 'hookvar))
    (if report-emacs-bug-send-command
	(setq report-emacs-bug-send-command
	      (symbol-name report-emacs-bug-send-command)))
    (unless report-emacs-bug-no-explanations
      (with-output-to-temp-buffer "*Bug Help*"
	(princ "While in the mail buffer:\n\n")
        (let ((help
               (substitute-command-keys
                (format "%s%s%s%s"
                        (if report-emacs-bug-send-command
                            (format "  Type \\[%s] to send the bug report.\n"
                                    report-emacs-bug-send-command)
                          "")
                        "  Type \\[kill-buffer] \\`RET' to cancel (don't send it).\n"
                        (if can-insert-mail
                            "  Type \\[report-emacs-bug-insert-to-mailer] to \
copy text to your preferred mail program.\n"
                          "")
                        "  Type \\[info-emacs-bug] to visit in Info the Emacs Manual section
    about when and how to write a bug report, and what
    information you should include to help fix the bug."))))
          (with-current-buffer "*Bug Help*"
            (insert help))))
      (shrink-window-if-larger-than-buffer (get-buffer-window "*Bug Help*")))
    ;; Make it less likely people will send empty messages.
    (if report-emacs-bug-send-hook
        (add-hook report-emacs-bug-send-hook #'report-emacs-bug-hook nil t))
    (goto-char (point-max))
    (skip-chars-backward " \t\n")
    (setq-local report-emacs-bug-orig-text
                (buffer-substring-no-properties (point-min) (point)))
    (goto-char user-point)))