branch: elpa/git-commit commit 4512a3f0d0b4bc9fc3d711d9acda82c56d03a475 Author: Andrey Smirnov <andrew.smir...@gmail.com> Commit: Kyle Meyer <k...@kyleam.com>
magit-utils: Implement `with-connection-local-variables' kludge In order to be able to use `with-connection-local-variables' in Emacs 25 and 26, implement a kludge that provides minimum functionality required by Magit. Modified-by: Kyle Meyer <k...@kyleam.com> Cosmetic tweaks to docstring whitespace. --- lisp/magit-utils.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lisp/magit-utils.el b/lisp/magit-utils.el index 75b4393c32..29730dead0 100644 --- a/lisp/magit-utils.el +++ b/lisp/magit-utils.el @@ -1198,6 +1198,31 @@ See <https://github.com/raxod502/straight.el/issues/520>." (setq filename target)))) (file-chase-links filename)) +;;; Kludges for older Emacs versions + +(if (fboundp 'with-connection-local-variables) + (defalias 'magit--with-connection-local-variables + 'with-connection-local-variables) + (defmacro magit--with-connection-local-variables (&rest body) + "Abridged `with-connection-local-variables' for pre Emacs 27 compatibility. +Bind shell file name and switch for remote execution. +`with-connection-local-variables' isn't available until Emacs 27. +This kludge provides the minimal functionality required by +Magit." + `(if (file-remote-p default-directory) + (let* ((vec (tramp-dissect-file-name default-directory)) + (shell-file-name (tramp-get-method-parameter + vec + 'tramp-remote-shell)) + (shell-command-switch (mapconcat + #'identity + (tramp-get-method-parameter + vec + 'tramp-remote-shell-args) + " "))) + (progn ,@body)) + ,@body))) + ;;; Miscellaneous (defun magit-message (format-string &rest args)