1 ;;; honest-report.el --- make bug report with screenshot and keylog
3 ;; Copyright (C) 2005-2019
4 ;; HIRAOKA Kazuyuki <khi@users.osdn.me>
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; This program is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; The GNU General Public License is available by anonymouse ftp from
17 ;; prep.ai.mit.edu in pub/gnu/COPYING. Alternately, you can write to
18 ;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
24 ;; This small tool helps you write clear bug report.
25 ;; Just type M-x honest-report to show recent keys and screen shots.
26 ;; Copy them into your bug report.
29 ;; Write a wrapper of `honest-report' with your favorite header and footer.
32 ;; Text properties are ignored in screen shot.
33 ;; In particular, too large region can be copied for outline-mode
34 ;; because all closed items are shown as opened.
38 (defun honest-report (&optional header footer)
40 (let ((ver (honest-report-version))
41 (key (honest-report-recent-keys))
42 (msg (honest-report-message))
43 (scr (honest-report-screenshot)))
45 (mapc (lambda (a) (apply #'honest-report-insert a))
48 ("Emacs version" ,ver)
50 ("Recent messages" ,msg)
54 (goto-char (point-max))))
56 (defun honest-report-insert (title content)
58 (insert "* " title ":\n\n" content "\n\n")))
62 (defun honest-report-setup ()
63 (let ((report-buf (format-time-string "honest-report-%Y%m%d-%H%M%S")))
64 (switch-to-buffer report-buf)))
66 ;; snap:///usr/share/emacs/21.4/lisp/mail/emacsbug.el#136:(insert (mapconcat (lambda (key)
67 (defun honest-report-recent-keys ()
68 (mapconcat (lambda (key)
69 (if (or (integerp key)
72 (single-key-description key)
73 (prin1-to-string key nil)))
77 (defun honest-report-screenshot ()
78 (mapconcat (lambda (w)
79 (with-current-buffer (window-buffer w)
80 (let ((b (max (window-start w) (point-min)))
81 (e (min (window-end w t) (point-max))))
82 (format "--- %s ---\n%s"
84 (buffer-substring-no-properties b e)))))
85 (honest-report-window-list)
88 (defun honest-report-window-list ()
90 This function exists only for emacs20 (and meadow-1.15),
91 which lack `window-list'."
93 (walk-windows (lambda (w) (setq ws (cons w ws))))
96 (defun honest-report-message ()
97 (with-current-buffer (or (get-buffer "*Messages*")
98 (get-buffer " *Message-Log*"))
100 (goto-char (point-max))
102 (buffer-substring-no-properties (point) (point-max)))))
104 (defun honest-report-version ()
105 (mapconcat (lambda (sv) (format "[%s] %s" (car sv) (cdr sv)))
106 (honest-report-version-assoc)
109 (defun honest-report-version-assoc ()
112 ("Emacs" . ,(format "%s (%s) of %s"
115 (honest-report-emacs-build-time)))
116 ("system" . ,system-type)
117 ("window system" . ,window-system)
118 ,(let ((f 'Meadow-version))
119 ;; cheat to avoid warning while byte-compilation.
121 (cons "Meadow" (funcall f))))
122 ("ENV" . ,(mapconcat (lambda (v) (format "%s=%s" v (getenv v)))
123 '("LC_ALL" "LC_CTYPE" "LANGUAGE" "LANG")
127 (defun honest-report-emacs-build-time ()
128 (if (stringp emacs-build-time)
129 emacs-build-time ;; xemacs
130 (format-time-string "%Y-%m-%d"
135 (provide 'honest-report)
137 ;;; honest-report.el ends here