diff options
author | Yuan Fu <casouri@gmail.com> | 2022-06-14 15:59:46 -0700 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-06-14 15:59:46 -0700 |
commit | 98bfb240818bae14cd87a1ffeb8fae7cb7846e05 (patch) | |
tree | 16e8ab06875ed54e110cf98ccdbd7e78f15905c6 /lisp/files-x.el | |
parent | 184d212042ffa5a4f02c92085d9b6e8346d66e99 (diff) | |
parent | 787c4ad8b0776280305a220d6669c956d9ed8a5d (diff) | |
download | emacs-98bfb240818bae14cd87a1ffeb8fae7cb7846e05.tar.gz emacs-98bfb240818bae14cd87a1ffeb8fae7cb7846e05.tar.bz2 emacs-98bfb240818bae14cd87a1ffeb8fae7cb7846e05.zip |
Merge remote-tracking branch 'savannah/master' into feature/tree-sitter
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r-- | lisp/files-x.el | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index 0ae9fb076eb..4db6fbd22cc 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -740,22 +740,28 @@ If APPLICATION is nil, `connection-local-default-application' is used." "Apply connection-local variables according to `default-directory'. Execute BODY, and unwind connection-local variables." (declare (debug t)) - `(if (file-remote-p default-directory) - (let ((enable-connection-local-variables t) - (old-buffer-local-variables (buffer-local-variables)) - connection-local-variables-alist) - (hack-connection-local-variables-apply - (connection-local-criteria-for-default-directory)) - (unwind-protect - (progn ,@body) - ;; Cleanup. - (dolist (variable connection-local-variables-alist) - (let ((elt (assq (car variable) old-buffer-local-variables))) - (if elt - (set (make-local-variable (car elt)) (cdr elt)) - (kill-local-variable (car variable))))))) - ;; No connection-local variables to apply. - ,@body)) + `(with-connection-local-variables-1 (lambda () ,@body))) + +;;;###autoload +(defun with-connection-local-variables-1 (body-fun) + "Apply connection-local variables according to `default-directory'. +Call BODY-FUN with no args, and then unwind connection-local variables." + (if (file-remote-p default-directory) + (let ((enable-connection-local-variables t) + (old-buffer-local-variables (buffer-local-variables)) + connection-local-variables-alist) + (hack-connection-local-variables-apply + (connection-local-criteria-for-default-directory)) + (unwind-protect + (funcall body-fun) + ;; Cleanup. + (dolist (variable connection-local-variables-alist) + (let ((elt (assq (car variable) old-buffer-local-variables))) + (if elt + (set (make-local-variable (car elt)) (cdr elt)) + (kill-local-variable (car variable))))))) + ;; No connection-local variables to apply. + (funcall body-fun))) ;;;###autoload (defun path-separator () |