Show conflicts in smerge ts hint
Use a dynamic hint for the smerge transient state in order to show the current and total numbers of conflicts, and make the full hint toggleable. * CHANGELOG.develop: Add an entry for this change. * layers/+source-control/version-control/config.el (spacemacs--smerge-ts-full-hint-toggle): New variable. * layers/+source-control/version-control/funcs.el (spacemacs//smerge-ts-hint): New function. Return a string indicating the index of the current conflict and the total number of conflicts detected by smerge-mode. If spacemacs--smerge-ts-full-hint-toggle is true, append the smerge transient state's full hint. (spacemacs//smerge-ts-toggle-hint): Toggle showing the full hint for the smerge transient state. * layers/+source-control/version-control/packages.el (version-control/init-smerge-mode): Define the transient state in :init so we can use spacemacs|transient-state-format-hint. Use spacemacs//smerge-ts-hint to display a dynamic hint. Bind the ? key to spacemacs//smerge-ts-toggle-hint.
This commit is contained in:
parent
e8cdaac8d3
commit
ec0a535b27
|
@ -2813,6 +2813,8 @@ Other:
|
|||
- Added smerge transient state key bindings (thanks to duianto):
|
||||
~SPC g r e >~ ediff
|
||||
~SPC g r K >~ kill current
|
||||
- Added current and total conflicts to smerge transient state's hint
|
||||
(thanks to Miciah Dashiel Butler Masters)
|
||||
- New packages:
|
||||
- =browse-at-remote= which replaces =github-browse-file=
|
||||
(thanks Eugene Yaremenko)
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(defvar spacemacs--smerge-ts-full-hint-toggle nil
|
||||
"Display smerge transient-state documentation.")
|
||||
|
||||
(defvar version-control-global-margin t
|
||||
"If non-nil, will show diff margins globally.")
|
||||
|
||||
|
|
|
@ -128,3 +128,27 @@
|
|||
:off (spacemacs/vcs-disable-margin-globally)
|
||||
:documentation "Enable diff margins globally."
|
||||
:evil-leader "T C-d")
|
||||
|
||||
(defun spacemacs//smerge-ts-hint ()
|
||||
"Return a hint for the smerge transient state.
|
||||
Return a string indicating the index of the current conflict and
|
||||
the number of conflicts detected by `smerge-mode'."
|
||||
(concat
|
||||
(cl-loop for ol being the overlays
|
||||
with pos = (point)
|
||||
if (eq (overlay-get ol 'smerge) 'conflict)
|
||||
count ol into total
|
||||
and if (<= (overlay-start ol) pos)
|
||||
count ol into idx
|
||||
finally return (format "conflict [%d/%d]" idx total))
|
||||
(if spacemacs--smerge-ts-full-hint-toggle
|
||||
spacemacs--smerge-ts-full-hint
|
||||
(concat " (["
|
||||
(propertize "?" 'face 'hydra-face-red)
|
||||
"] help)"))))
|
||||
|
||||
(defun spacemacs//smerge-ts-toggle-hint ()
|
||||
"Toggle the full hint docstring for the smerge transient state."
|
||||
(interactive)
|
||||
(setq spacemacs--smerge-ts-full-hint-toggle
|
||||
(not spacemacs--smerge-ts-full-hint-toggle)))
|
||||
|
|
|
@ -263,21 +263,24 @@
|
|||
:diminish smerge-mode
|
||||
:commands spacemacs/smerge-transient-state/body
|
||||
:init
|
||||
(spacemacs/set-leader-keys
|
||||
"gr" 'spacemacs/smerge-transient-state/body)
|
||||
:config
|
||||
(progn
|
||||
(spacemacs|define-transient-state smerge
|
||||
:title "Smerge Transient State"
|
||||
:doc "
|
||||
(spacemacs/set-leader-keys
|
||||
"gr" 'spacemacs/smerge-transient-state/body)
|
||||
(spacemacs|transient-state-format-hint smerge
|
||||
spacemacs--smerge-ts-full-hint
|
||||
"\n
|
||||
Movement^^^^ Merge Action^^ Diff^^ Other
|
||||
---------------^^^^ ----------------^^ --------------^^ ---------------------------^^
|
||||
[_n_]^^ next hunk [_b_] keep base [_<_] base/mine [_C_] combine curr/next hunks
|
||||
[_N_/_p_] prev hunk [_m_] keep mine [_=_] mine/other [_u_] undo
|
||||
[_j_]^^ next line [_a_] keep all [_>_] base/other [_q_] quit
|
||||
[_k_]^^ prev line [_o_] keep other [_r_] refine
|
||||
^^^^ [_c_] keep current [_e_] ediff
|
||||
^^^^ [_K_] kill current"
|
||||
^^^^ [_c_] keep current [_e_] ediff [_?_]^^ toggle help
|
||||
^^^^ [_K_] kill current")
|
||||
(spacemacs|define-transient-state smerge
|
||||
:title "Smerge Transient State"
|
||||
:hint-is-doc t
|
||||
:dynamic-hint (spacemacs//smerge-ts-hint)
|
||||
:bindings
|
||||
;; move
|
||||
("n" smerge-next)
|
||||
|
@ -301,7 +304,8 @@
|
|||
("C" smerge-combine-with-next)
|
||||
("K" smerge-kill-current)
|
||||
("u" undo-tree-undo)
|
||||
("q" nil :exit t)))))
|
||||
("q" nil :exit t)
|
||||
("?" spacemacs//smerge-ts-toggle-hint)))))
|
||||
|
||||
(defun version-control/init-browse-at-remote ()
|
||||
(use-package browse-at-remote
|
||||
|
|
Loading…
Reference in a new issue