From 8521996056c980d096f1ec935c34345f265d3665 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 24 Sep 2022 16:17:56 -0700 Subject: [PATCH] WIP Add vc-edit-next-command. --- lisp/vc/vc-hooks.el | 3 ++- lisp/vc/vc.el | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 7f0d9e4d86..6ad26cfe67 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -882,7 +882,8 @@ vc-prefix-map "=" #'vc-diff "D" #'vc-root-diff "~" #'vc-revision-other-window - "x" #'vc-delete-file) + "x" #'vc-delete-file + "!" #'vc-edit-next-command) (fset 'vc-prefix-map vc-prefix-map) (define-key ctl-x-map "v" 'vc-prefix-map) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4950a1a32d..595288d30f 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3244,6 +3244,31 @@ vc-update-change-log (vc-call-backend (vc-responsible-backend default-directory) 'update-changelog args)) +(defvar vc-filter-command-function) + +;;;###autoload +(defun vc-edit-next-command () + "Request editing the next VC shell command before execution. +This is a prefix command. It affects only a VC command executed +immediately after this one." + (interactive) + (letrec ((command this-command) + (keys (key-description (this-command-keys))) + (old vc-filter-command-function) + (echofun (lambda () keys)) + (postfun + (lambda () + (unless (eq this-command command) + (remove-hook 'post-command-hook postfun) + (remove-hook 'prefix-command-echo-keystrokes-functions + echofun) + (setq vc-filter-command-function old))))) + (add-hook 'post-command-hook postfun) + (add-hook 'prefix-command-echo-keystrokes-functions echofun) + (setq vc-filter-command-function + (lambda (&rest args) + (apply #'vc-user-edit-command (apply old args)))))) + (defun vc-default-responsible-p (_backend _file) "Indicate whether BACKEND is responsible for FILE. The default is to return nil always." -- 2.30.2