1 ;;; honest-report.el --- make bug report with screenshot and keylog
3 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017
4 ;; HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
5 ;; $Id: honest-report.el,v 1.13 2011-12-31 15:07:29 hira Exp $
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; The GNU General Public License is available by anonymouse ftp from
18 ;; prep.ai.mit.edu in pub/gnu/COPYING. Alternately, you can write to
19 ;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
25 ;; This small tool helps you write clear bug report.
26 ;; Just type M-x honest-report to show recent keys and screen shots.
27 ;; Copy them into your bug report.
30 ;; Write a wrapper of `honest-report' with your favorite header and footer.
33 ;; Text properties are ignored in screen shot.
34 ;; In particular, too large region can be copied for outline-mode
35 ;; because all closed items are shown as opened.
39 (defun honest-report (&optional header footer)
41 (let ((ver (honest-report-version))
42 (key (honest-report-recent-keys))
43 (msg (honest-report-message))
44 (scr (honest-report-screenshot)))
46 (mapc (lambda (a) (apply #'honest-report-insert a))
49 ("Emacs version" ,ver)
51 ("Recent messages" ,msg)
55 (goto-char (point-max))))
57 (defun honest-report-insert (title content)
59 (insert "* " title ":\n\n" content "\n\n")))
63 (defun honest-report-setup ()
64 (let ((report-buf (format-time-string "honest-report-%Y%m%d-%H%M%S")))
65 (switch-to-buffer report-buf)))
67 ;; snap:///usr/share/emacs/21.4/lisp/mail/emacsbug.el#136:(insert (mapconcat (lambda (key)
68 (defun honest-report-recent-keys ()
69 (mapconcat (lambda (key)
70 (if (or (integerp key)
73 (single-key-description key)
74 (prin1-to-string key nil)))
78 (defun honest-report-screenshot ()
79 (mapconcat (lambda (w)
80 (with-current-buffer (window-buffer w)
81 (let ((b (max (window-start w) (point-min)))
82 (e (min (window-end w t) (point-max))))
83 (format "--- %s ---\n%s"
85 (buffer-substring-no-properties b e)))))
86 (honest-report-window-list)
89 (defun honest-report-window-list ()
91 This function exists only for emacs20 (and meadow-1.15),
92 which lack `window-list'."
94 (walk-windows (lambda (w) (setq ws (cons w ws))))
97 (defun honest-report-message ()
98 (with-current-buffer (or (get-buffer "*Messages*")
99 (get-buffer " *Message-Log*"))
101 (goto-char (point-max))
103 (buffer-substring-no-properties (point) (point-max)))))
105 (defun honest-report-version ()
106 (mapconcat (lambda (sv) (format "[%s] %s" (car sv) (cdr sv)))
107 (honest-report-version-assoc)
110 (defun honest-report-version-assoc ()
113 ("Emacs" . ,(format "%s (%s) of %s"
116 (honest-report-emacs-build-time)))
117 ("system" . ,system-type)
118 ("window system" . ,window-system)
119 ,(let ((f 'Meadow-version))
120 ;; cheat to avoid warning while byte-compilation.
122 (cons "Meadow" (funcall f))))
123 ("ENV" . ,(mapconcat (lambda (v) (format "%s=%s" v (getenv v)))
124 '("LC_ALL" "LC_CTYPE" "LANGUAGE" "LANG")
128 (defun honest-report-emacs-build-time ()
129 (if (stringp emacs-build-time)
130 emacs-build-time ;; xemacs
131 (format-time-string "%Y-%m-%d"
136 (provide 'honest-report)
138 ;;; honest-report.el ends here