2015-12-18 15:01:58 +00:00
|
|
|
|
;;; core-debug.el --- Spacemacs Core File -*- lexical-binding: t; -*-
|
2015-09-28 19:38:06 +00:00
|
|
|
|
;;
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;; Copyright (c) 2012-2022 Sylvain Benner & Contributors
|
2015-09-28 19:38:06 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
;;
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
;;
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;;; Commentary:
|
2015-09-28 19:38:06 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;; Interface to time execution of intialization, and collecting system information
|
|
|
|
|
;; for reporting bugs.
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
;; defined in init.el
|
|
|
|
|
(defvar emacs-start-time)
|
|
|
|
|
(defvar spacemacs-version)
|
|
|
|
|
(defvar dotspacemacs-distribution)
|
|
|
|
|
(defvar dotspacemacs-editing-style)
|
|
|
|
|
(defvar dotspacemacs--configuration-layers-saved)
|
|
|
|
|
(defvar evil-ex-commands)
|
|
|
|
|
(defvar configuration-layer-template-directory))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(declare-function profiler-report "profiler" ())
|
|
|
|
|
(declare-function profiler-stop "profiler" ())
|
|
|
|
|
(declare-function spacemacs//git-get-current-branch "core-release-management" ())
|
|
|
|
|
(declare-function spacemacs/git-get-current-branch-rev "core-release-management" ())
|
|
|
|
|
(declare-function configuration-layer/layer-used-p "core-configuration-layer" (layer-name))
|
|
|
|
|
(declare-function spacemacs/set-leader-keys-for-major-mode "core-keybindings" (mode key def &rest bindings))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Debug Facility
|
2015-12-16 17:45:50 +00:00
|
|
|
|
|
2015-12-18 15:01:58 +00:00
|
|
|
|
(defvar spacemacs-debug-timer-threshold 0.15
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Generate message if file takes longer than this number of seconds to load.")
|
2015-12-18 15:01:58 +00:00
|
|
|
|
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(defvar spacemacs-debugp nil)
|
2015-12-18 15:01:58 +00:00
|
|
|
|
(defvar spacemacs-debug-with-profile nil)
|
|
|
|
|
(defvar spacemacs-debug-with-timed-requires nil)
|
|
|
|
|
(defvar spacemacs-debug-with-adv-timers nil)
|
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
|
|
|
|
|
;;;;; Timers
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//timed-initialize (orig-func &rest args)
|
|
|
|
|
"Time the invocation of `package-initialize' and return the time in seconds.
|
|
|
|
|
ORIG-FUNC must be `package-initialize', ARGS are arguments passed to it."
|
|
|
|
|
(let ((start (current-time))
|
|
|
|
|
delta)
|
|
|
|
|
(prog1
|
|
|
|
|
(apply orig-func args)
|
|
|
|
|
(setq delta (float-time (time-since start)))
|
|
|
|
|
(when (> delta spacemacs-debug-timer-threshold)
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "package-initialize took %.3f sec\n" delta)))))))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//timed-require(orig-func &rest args)
|
|
|
|
|
"Time the execution of `require' and return the time in seconds.
|
|
|
|
|
ORIG-FUNC must be `require', ARGS are arguments passed to it."
|
|
|
|
|
(let ((start (current-time))
|
|
|
|
|
delta)
|
|
|
|
|
(prog1
|
|
|
|
|
(apply orig-func args)
|
|
|
|
|
(setq delta (float-time (time-since start)))
|
|
|
|
|
(when (> delta spacemacs-debug-timer-threshold)
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "File %s: Required %s: %.3f sec\n"
|
|
|
|
|
load-file-name (car args) delta)))))))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//timed-load(orig-func &rest args)
|
|
|
|
|
"Time the execution of `load' and return the time in seconds.
|
|
|
|
|
ORIG-FUNC must be `load', ARGS are arguments passed to it."
|
|
|
|
|
(let ((start (current-time))
|
|
|
|
|
delta)
|
|
|
|
|
(prog1
|
|
|
|
|
(apply orig-func args)
|
|
|
|
|
(setq delta (float-time (time-since start)))
|
|
|
|
|
(when (> delta spacemacs-debug-timer-threshold)
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "File %s: Loaded %s: %.3f sec\n"
|
|
|
|
|
load-file-name (car args) delta)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;; Accumulation Timers
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//load-timer (orig-func &rest args)
|
|
|
|
|
"Time execution of `load' or `require' since start of Emacs.
|
|
|
|
|
|
|
|
|
|
When the time taken for such invocation exceeds
|
|
|
|
|
`spacemacs-debug-timer-threshold', it's recorded in \"*load-times*\" buffer.
|
|
|
|
|
|
|
|
|
|
ORIG-FUNC is the function to be timed, this should be `load' or `require'.
|
|
|
|
|
ARGS are the arguments passed to ORIG-FUNC.
|
|
|
|
|
|
|
|
|
|
This function should not be used directly. Use `spacemacs||add-function-timer'
|
|
|
|
|
instead."
|
2015-12-18 15:01:58 +00:00
|
|
|
|
(let ((start (current-time))
|
|
|
|
|
(required (car args))
|
|
|
|
|
delta)
|
|
|
|
|
(prog1
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(apply orig-func args)
|
2015-12-18 15:01:58 +00:00
|
|
|
|
(setq delta (float-time (time-since start)))
|
|
|
|
|
(when (> delta spacemacs-debug-timer-threshold)
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "[%.3f] (%.3f) Load or require\n Feature: %s\n In file: %s\n\n"
|
|
|
|
|
(float-time (time-since emacs-start-time))
|
|
|
|
|
delta required load-file-name)))))))
|
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(defmacro spacemacs||add-function-timer (func)
|
|
|
|
|
"Time the execution of FUNC since start of Emacs.
|
|
|
|
|
|
|
|
|
|
A timer function is created and added as the `:around' advice to FUNC.
|
|
|
|
|
|
|
|
|
|
When the time taken for loading a package exceeds
|
|
|
|
|
`spacemacs-debug-timer-threshold', it's recorded in \"*load-times\" buffer."
|
|
|
|
|
(if (memq func '(load require))
|
|
|
|
|
`(advice-add ',func :around #'spacemacs//load-timer)
|
|
|
|
|
(let ((timer
|
|
|
|
|
(lambda (orig-func &rest args)
|
|
|
|
|
(let ((start (current-time))
|
|
|
|
|
delta)
|
|
|
|
|
(prog1
|
|
|
|
|
(apply orig-func args)
|
|
|
|
|
(setq delta (float-time (time-since start)))
|
|
|
|
|
(when (> delta spacemacs-debug-timer-threshold)
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "[%.3f] (%.3f) Function call\n Function: %s\n Args: %s\n\n"
|
|
|
|
|
(float-time (time-since emacs-start-time))
|
|
|
|
|
delta func args)))))))))
|
|
|
|
|
`(advice-add ',func :around #',timer))))
|
|
|
|
|
|
2015-12-18 15:01:58 +00:00
|
|
|
|
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(defun spacemacs/init-debug ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Set up debug hooks."
|
|
|
|
|
|
|
|
|
|
;; CPU + memory profiler
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(when spacemacs-debug-with-profile
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(require 'profiler)
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(profiler-start 'cpu+mem)
|
|
|
|
|
(add-hook 'after-init-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(run-with-idle-timer 2 nil (lambda ()
|
|
|
|
|
(profiler-report)
|
|
|
|
|
(profiler-stop))))))
|
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;; Timing the duration of each loading
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(when spacemacs-debug-with-timed-requires
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(require 'time-date)
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create "*load-times*")
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(insert (format "Threshold set at %.3f seconds\n\n"
|
|
|
|
|
spacemacs-debug-timer-threshold))
|
2016-01-07 03:50:13 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(advice-add 'package-initialize :around #'spacemacs//timed-initialize)
|
|
|
|
|
(advice-add 'require :around #'spacemacs//timed-require)
|
|
|
|
|
(advice-add 'load :around #'spacemacs//timed-load)))
|
2016-01-07 03:50:13 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;; Timing the accumulative duration of each loading
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(when spacemacs-debug-with-adv-timers
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(require 'time-date)
|
2016-01-07 03:50:13 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create "*load-times*")
|
|
|
|
|
(insert (format "Measured times greater than %.3f sec:\n\n"
|
|
|
|
|
spacemacs-debug-timer-threshold)))
|
|
|
|
|
|
|
|
|
|
(add-hook 'after-init-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(with-current-buffer "*load-times*"
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (format "[%.3f] Spacemacs finished initializing\n\n"
|
2021-04-15 21:05:53 +00:00
|
|
|
|
(float-time (time-since emacs-start-time)))))))
|
2016-01-07 03:50:13 +00:00
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(spacemacs||add-function-timer load)
|
|
|
|
|
(spacemacs||add-function-timer require)
|
|
|
|
|
(spacemacs||add-function-timer package-initialize)
|
|
|
|
|
(spacemacs||add-function-timer configuration-layer/load)
|
|
|
|
|
(spacemacs||add-function-timer configuration-layer//configure-package))
|
2016-01-07 04:23:01 +00:00
|
|
|
|
|
|
|
|
|
;; Keep debug-on-error on for stuff that is lazily loaded
|
|
|
|
|
(add-hook 'after-init-hook (lambda () (setq debug-on-error t))))
|
2015-12-18 15:01:58 +00:00
|
|
|
|
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
|
|
|
|
;; Report issue
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//describe-system-info-string ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Gather info about your Spacemacs setup and return it as a string."
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(format
|
|
|
|
|
(concat "#### System Info :computer:\n"
|
|
|
|
|
"- OS: %s\n"
|
|
|
|
|
"- Emacs: %s\n"
|
|
|
|
|
"- Spacemacs: %s\n"
|
|
|
|
|
"- Spacemacs branch: %s (rev. %s)\n"
|
|
|
|
|
"- Graphic display: %s\n"
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"- Running in daemon: %s\n"
|
2016-12-18 17:05:10 +00:00
|
|
|
|
"- Distribution: %s\n"
|
|
|
|
|
"- Editing style: %s\n"
|
|
|
|
|
"- Completion: %s\n"
|
|
|
|
|
"- Layers:\n```elisp\n%s```\n"
|
2021-04-28 05:04:53 +00:00
|
|
|
|
"- System configuration features: %s\n")
|
2016-12-18 17:05:10 +00:00
|
|
|
|
system-type
|
|
|
|
|
emacs-version
|
|
|
|
|
spacemacs-version
|
|
|
|
|
(spacemacs//git-get-current-branch)
|
|
|
|
|
(spacemacs/git-get-current-branch-rev)
|
|
|
|
|
(display-graphic-p)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(daemonp)
|
2016-12-18 17:05:10 +00:00
|
|
|
|
dotspacemacs-distribution
|
|
|
|
|
dotspacemacs-editing-style
|
2017-07-02 13:48:06 +00:00
|
|
|
|
(cond ((configuration-layer/layer-used-p 'helm)
|
2016-12-18 17:05:10 +00:00
|
|
|
|
'helm)
|
2017-07-02 13:48:06 +00:00
|
|
|
|
((configuration-layer/layer-used-p 'ivy)
|
2016-12-18 17:05:10 +00:00
|
|
|
|
'ivy)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
((configuration-layer/layer-used-p 'compleseus))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(t 'helm))
|
|
|
|
|
(pp-to-string dotspacemacs--configuration-layers-saved)
|
|
|
|
|
(bound-and-true-p system-configuration-features)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/describe-system-info ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Gather info about your Spacemacs setup and copy it to clipboard.
|
|
|
|
|
System information is copied to clipboard.
|
|
|
|
|
In case it's killed by other programs, it's also send to \"*Messages*\" buffer."
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((sysinfo (spacemacs//describe-system-info-string)))
|
|
|
|
|
(kill-new sysinfo)
|
|
|
|
|
(message sysinfo)
|
|
|
|
|
(message (concat "Information has been copied to clipboard.\n"
|
|
|
|
|
"You can paste it in the gitter chat.\n"
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Check the \"*Messages*\" buffer if you need to review it"))))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs//describe-last-keys-string ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Gather info about last few key inputs and return it as a string."
|
|
|
|
|
(let ((keys (key-description (recent-keys))))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(set-fill-column 60)
|
|
|
|
|
(insert keys)
|
|
|
|
|
(fill-region (point-min) (point-max))
|
|
|
|
|
(format "#### Emacs last keys :musical_keyboard: \n```text\n%s\n```\n" (buffer-string)))))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs/describe-last-keys ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Gather info about last few key inputs and copy it to clipboard."
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(interactive)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(let ((keys (spacemacs//describe-last-keys-string)))
|
|
|
|
|
(kill-new keys)
|
|
|
|
|
(message keys)
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(message (concat "Information has been copied to clipboard.\n"
|
|
|
|
|
(propertize
|
|
|
|
|
"PLEASE REVIEW THE DATA BEFORE GOING FURTHER AS IT CAN CONTAIN SENSITIVE DATA (PASSWORD, ...)\n"
|
|
|
|
|
'face 'font-lock-warning-face)
|
|
|
|
|
"You can paste it in the gitter chat.\n"
|
|
|
|
|
"Check the *Messages* buffer if you need to review it"))))
|
|
|
|
|
|
2021-04-13 12:10:40 +00:00
|
|
|
|
(defun spacemacs/describe-ex-command (ex-command)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Describe an `evil-ex-commands'.
|
|
|
|
|
EX-COMMAND must be a command in `evil-ex-commands'."
|
|
|
|
|
(interactive (list (completing-read "Describe ex-command: " evil-ex-commands nil t)))
|
2021-04-13 12:10:40 +00:00
|
|
|
|
(let* ((func (alist-get ex-command evil-ex-commands nil nil 'string=))
|
|
|
|
|
(prompt (if (stringp func)
|
|
|
|
|
"The ex-command :%s is an alias for the ex-command :%s. Describe :%s?"
|
|
|
|
|
"The ex-command :%s calls %s. Describe %s?")))
|
|
|
|
|
(when (y-or-n-p (format prompt
|
|
|
|
|
ex-command
|
|
|
|
|
func
|
|
|
|
|
func))
|
|
|
|
|
(if (stringp func)
|
|
|
|
|
(spacemacs/describe-ex-command func)
|
2021-04-15 21:05:53 +00:00
|
|
|
|
(describe-function func)))))
|
2021-04-13 12:10:40 +00:00
|
|
|
|
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(defun spacemacs/report-issue (arg)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Open a buffer with issue report template and system information.
|
|
|
|
|
When prefix ARG is non-nil, include the last keys pressed."
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(interactive "P")
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(let ((buf (generate-new-buffer "REPORT_SPACEMACS_ISSUE"))
|
|
|
|
|
(system-info (spacemacs//describe-system-info-string))
|
|
|
|
|
(backtrace (if (get-buffer "*Backtrace*")
|
|
|
|
|
(with-current-buffer "*Backtrace*"
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point-min)
|
|
|
|
|
(min (point-max) 1000)))
|
|
|
|
|
"<<BACKTRACE IF RELEVANT>>"))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(last-keys
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(if (and arg (y-or-n-p "Do you really want to include your last pressed keys, which may include some sensitive data? "))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(concat (spacemacs//describe-last-keys-string) "\n")
|
|
|
|
|
"")))
|
|
|
|
|
(switch-to-buffer buf)
|
2017-06-21 19:05:38 +00:00
|
|
|
|
(let ((ov (make-overlay (point-min) (point-min)))
|
|
|
|
|
(prop-val
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(concat (propertize "REPLACE ALL UPPERCASE EXPRESSIONS\nPRESS `C-c C-c` TO SUBMIT, OR PRESS `C-c C-k` TO DISCARD"
|
2017-06-21 19:05:38 +00:00
|
|
|
|
'display
|
|
|
|
|
'(raise -1)
|
|
|
|
|
'face
|
|
|
|
|
'font-lock-warning-face)
|
|
|
|
|
"\n\n")))
|
|
|
|
|
(overlay-put ov 'after-string prop-val))
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(insert-file-contents (concat configuration-layer-template-directory "REPORTING.template"))
|
|
|
|
|
(cl-loop for (placeholder replacement) in `(("%SYSTEM_INFO%" ,system-info)
|
|
|
|
|
("%BACKTRACE%" ,backtrace)
|
|
|
|
|
("(%LAST_KEYS%)\n" ,last-keys))
|
|
|
|
|
do (save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(search-forward placeholder)
|
|
|
|
|
(replace-match replacement 'keep-case 'literal)))
|
2018-04-23 12:57:55 +00:00
|
|
|
|
(set-buffer-modified-p nil)
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(spacemacs/report-issue-mode)))
|
|
|
|
|
|
2018-04-23 12:57:55 +00:00
|
|
|
|
(defun spacemacs//report-issue-kill-buffer-query ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Check if issue has been edited when buffer is about to be killed.
|
|
|
|
|
This is intended to be used with `kill-buffer-query-functions'."
|
2018-04-23 12:57:55 +00:00
|
|
|
|
(if (buffer-modified-p)
|
|
|
|
|
(y-or-n-p "Issue has unsaved changes, kill buffer anyways? ")
|
|
|
|
|
t))
|
|
|
|
|
|
2017-06-21 19:05:38 +00:00
|
|
|
|
(define-derived-mode spacemacs/report-issue-mode text-mode "Report-Issue"
|
2016-12-18 17:05:10 +00:00
|
|
|
|
"Major mode for reporting issues with Spacemacs.
|
|
|
|
|
|
2022-02-15 06:29:01 +00:00
|
|
|
|
When done editing, you can type \\<spacemacs/report-issue-mode-map>\\[spacemacs//report-issue-done] to create the issue on GitHub.
|
|
|
|
|
You must be logged in already for this to work.
|
|
|
|
|
|
|
|
|
|
After you see that the issue has been created successfully, you can close this buffer.
|
|
|
|
|
|
|
|
|
|
At any time, you can type \\[kill-buffer] to close this buffer.
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
|
|
|
|
\\{spacemacs/report-issue-mode-map}
|
|
|
|
|
"
|
|
|
|
|
(font-lock-add-keywords 'spacemacs/report-issue-mode
|
2018-04-23 12:57:55 +00:00
|
|
|
|
'(("\\(<<.*?>>\\)" . 'font-lock-comment-face)))
|
|
|
|
|
(add-hook 'kill-buffer-query-functions
|
|
|
|
|
'spacemacs//report-issue-kill-buffer-query
|
|
|
|
|
nil t))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
|
|
|
|
(define-key spacemacs/report-issue-mode-map
|
|
|
|
|
(kbd "C-c C-c") 'spacemacs//report-issue-done)
|
|
|
|
|
(define-key spacemacs/report-issue-mode-map
|
|
|
|
|
(kbd "C-c C-k") 'kill-buffer)
|
|
|
|
|
|
|
|
|
|
(with-eval-after-load 'bind-map
|
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'spacemacs/report-issue-mode
|
|
|
|
|
"," 'spacemacs//report-issue-done
|
|
|
|
|
"c" 'spacemacs//report-issue-done
|
|
|
|
|
"a" 'kill-buffer
|
|
|
|
|
"k" 'kill-buffer))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//report-issue-done ()
|
2022-02-15 06:29:01 +00:00
|
|
|
|
"Try to create an GitHub issue with system info.
|
|
|
|
|
If the resulting URL is too long (> 8192 characters), it fallbacks to copying
|
|
|
|
|
the buffer content to clipboard and opens an empty GitHub issue page."
|
2016-12-18 17:05:10 +00:00
|
|
|
|
(interactive)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
(let* ((url-prefix "http://github.com/syl20bnr/spacemacs/issues/new?body=")
|
|
|
|
|
(body (url-hexify-string (buffer-string)))
|
|
|
|
|
(url (url-encode-url (concat url-prefix body))))
|
|
|
|
|
(if (< (length url) 8192)
|
|
|
|
|
(browse-url url)
|
|
|
|
|
(copy-region-as-kill (point-min) (point-max))
|
|
|
|
|
(browse-url url-prefix)
|
|
|
|
|
(message (concat "Information has been copied to clipboard.\n"
|
|
|
|
|
"Please paste it as the body of the GitHub issue.\n"
|
|
|
|
|
(propertize
|
|
|
|
|
"PLEASE REVIEW THE DATA BEFORE GOING FURTHER AS IT CAN CONTAIN SENSITIVE DATA (PASSWORD, ...)\n"
|
|
|
|
|
'face 'font-lock-warning-face))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; misc
|
|
|
|
|
(defun spacemacs/display-and-copy-version ()
|
|
|
|
|
"Echo the current spacemacs version and copy it."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((msg (format "Spacemacs v.%s" spacemacs-version)))
|
|
|
|
|
(message msg) (kill-new msg)))
|
2016-12-18 17:05:10 +00:00
|
|
|
|
|
2015-09-28 19:38:06 +00:00
|
|
|
|
(provide 'core-debug)
|
2022-02-15 06:29:01 +00:00
|
|
|
|
;;; core-debug.el ends here
|