2016-07-05 02:35:05 +00:00
|
|
|
|
;;; funcs.el --- Colors Layer functions File
|
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2016-07-05 02:35:05 +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/>.
|
|
|
|
|
|
2016-07-05 02:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; magit
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/magit-toggle-whitespace ()
|
|
|
|
|
"Toggle whitespace in `magit-diff-mode'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
|
|
|
|
|
magit-refresh-args
|
|
|
|
|
magit-diff-section-arguments))
|
|
|
|
|
(spacemacs//magit-dont-ignore-whitespace)
|
|
|
|
|
(spacemacs//magit-ignore-whitespace)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//magit-ignore-whitespace ()
|
|
|
|
|
"Ignore whitespace in `magit-diff-mode'"
|
|
|
|
|
(add-to-list (if (derived-mode-p 'magit-diff-mode)
|
|
|
|
|
'magit-refresh-args 'magit-diff-section-arguments) "-w")
|
|
|
|
|
(magit-refresh))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//magit-dont-ignore-whitespace ()
|
|
|
|
|
"Don't ignore whitespace in `magit-diff-mode'"
|
|
|
|
|
(setq magit-diff-options
|
|
|
|
|
(remove "-w"
|
|
|
|
|
(if (derived-mode-p 'magit-diff-mode)
|
|
|
|
|
magit-refresh-args
|
2019-02-21 07:31:05 +00:00
|
|
|
|
magit-diff-section-arguments)))
|
|
|
|
|
(magit-refresh))
|
2016-10-17 13:22:55 +00:00
|
|
|
|
|
2019-10-01 14:04:30 +00:00
|
|
|
|
(defun spacemacs/git-permalink ()
|
|
|
|
|
"Allow the user to get a permalink via git-link in a git-timemachine buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((git-link-use-commit t))
|
2019-08-15 16:57:05 +00:00
|
|
|
|
(call-interactively 'git-link-commit)))
|
2019-10-01 14:04:30 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs/git-permalink-copy-url-only ()
|
|
|
|
|
"Allow the user to get a permalink via git-link in a git-timemachine buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let (git-link-open-in-browser
|
|
|
|
|
(git-link-use-commit t))
|
2019-08-15 16:57:05 +00:00
|
|
|
|
(call-interactively 'git-link-commit)))
|
2019-10-01 14:04:30 +00:00
|
|
|
|
|
2016-10-17 13:22:55 +00:00
|
|
|
|
(defun spacemacs/git-link-copy-url-only ()
|
|
|
|
|
"Only copy the generated link to the kill ring."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let (git-link-open-in-browser)
|
2019-08-15 16:57:05 +00:00
|
|
|
|
(call-interactively 'git-link)))
|
2016-10-17 13:22:55 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs/git-link-commit-copy-url-only ()
|
|
|
|
|
"Only copy the generated link to the kill ring."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let (git-link-open-in-browser)
|
|
|
|
|
(call-interactively 'git-link-commit)))
|
2018-01-09 09:48:57 +00:00
|
|
|
|
|
2021-06-05 03:44:32 +00:00
|
|
|
|
(defun spacemacs//support-evilified-buffer-p ()
|
|
|
|
|
"Return non-nil if evil navigation should be enabled."
|
|
|
|
|
(or (eq dotspacemacs-editing-style 'vim)
|
|
|
|
|
(and (eq dotspacemacs-editing-style 'hybrid)
|
2018-06-08 06:20:47 +00:00
|
|
|
|
hybrid-style-enable-evilified-state)))
|
2018-01-09 09:48:57 +00:00
|
|
|
|
|
2020-06-04 21:50:03 +00:00
|
|
|
|
|
|
|
|
|
;; git blame transient state
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//git-blame-ts-toggle-hint ()
|
|
|
|
|
"Toggle the full hint docstring for the git blame transient state."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq spacemacs--git-blame-ts-full-hint-toggle
|
|
|
|
|
(not spacemacs--git-blame-ts-full-hint-toggle)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//git-blame-ts-hint ()
|
|
|
|
|
"Return a condensed/full hint for the git-blame transient state"
|
|
|
|
|
(concat
|
|
|
|
|
" "
|
|
|
|
|
(if spacemacs--git-blame-ts-full-hint-toggle
|
|
|
|
|
spacemacs--git-blame-ts-full-hint
|
|
|
|
|
(concat "[" (propertize "?" 'face 'hydra-face-red) "] help"
|
|
|
|
|
spacemacs--git-blame-ts-minified-hint))))
|
|
|
|
|
|
|
|
|
|
(spacemacs|transient-state-format-hint git-blame
|
|
|
|
|
spacemacs--git-blame-ts-minified-hint "\n
|
|
|
|
|
Chunks: _n_ _N_ _p_ _P_ _RET_ Commits: _b_ _r_ _f_ _e_ _q_")
|
|
|
|
|
|
|
|
|
|
(spacemacs|transient-state-format-hint git-blame
|
|
|
|
|
spacemacs--git-blame-ts-full-hint
|
|
|
|
|
(format "\n[_?_] toggle help
|
|
|
|
|
Chunks^^^^ Commits^^ Other
|
|
|
|
|
[_p_/_P_] prev /same commit [_b_] adding lines [_c_] cycle style
|
|
|
|
|
[_n_/_N_] next /same commit [_r_] removing lines [_Y_] copy hash
|
|
|
|
|
[_RET_]^^ show commit [_f_] last commit with lines [_B_] magit-blame
|
|
|
|
|
^^^^ [_e_] echo [_Q_] quit TS
|
|
|
|
|
^^^^ [_q_] quit blaming"))
|
2020-11-16 22:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Forge
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/forge-get-info-from-fetched-notification-error (err)
|
|
|
|
|
"Return info for given s-exp error return by `forge-pull-notifications'.
|
|
|
|
|
|
|
|
|
|
Call this function interactively and paste the s-exp from the error returned by
|
|
|
|
|
the `forge-pull-notifications' function.
|
|
|
|
|
|
|
|
|
|
Example of error:
|
|
|
|
|
|
|
|
|
|
error in process filter: ghub--signal-error: peculiar error:
|
|
|
|
|
((path \"query\" \"_Z2l0aHViLmNvbTowMTA6UmVwb3NpdG9yeTI5MDM3NDE6NTI0NzY1\")
|
|
|
|
|
(extensions (code . \"undefinedField\")
|
|
|
|
|
(typeName . \"Query\")
|
|
|
|
|
(fieldName . \"nil\"))
|
|
|
|
|
(locations ((line . 2) (column . 1)))
|
|
|
|
|
(message . \"Field 'nil' doesn't exist on type 'Query'\"))
|
|
|
|
|
|
|
|
|
|
Function adapted from issue:
|
|
|
|
|
https://github.com/magit/forge/issues/80#issuecomment-456103195
|
|
|
|
|
"
|
|
|
|
|
(interactive "xs-exp: ")
|
|
|
|
|
(message "%s" err)
|
|
|
|
|
(let* ((query_value (third (car err)))
|
|
|
|
|
(result (car (forge-sql
|
|
|
|
|
[:select [owner name]
|
|
|
|
|
:from repository
|
|
|
|
|
:where (= id $s1)]
|
|
|
|
|
(base64-encode-string
|
|
|
|
|
(mapconcat
|
|
|
|
|
#'identity
|
|
|
|
|
(butlast
|
|
|
|
|
(split-string
|
|
|
|
|
(base64-decode-string (substring query_value 1))
|
|
|
|
|
":"))
|
|
|
|
|
":")
|
|
|
|
|
t)))))
|
|
|
|
|
(message "repository: %s/%s" (car result) (cadr result))))
|