diff options
| author | Michael Albinus | 2019-12-11 16:05:12 +0100 |
|---|---|---|
| committer | Michael Albinus | 2019-12-11 16:05:12 +0100 |
| commit | 8aaa92a4b648aef137eb9a7054fdffaed04328ff (patch) | |
| tree | 237d389c091bb52e11c9732dfee4d32f65a11f9f | |
| parent | eb7df2a4e304c7e2c35eb4df63056c98ee6324e9 (diff) | |
| download | emacs-8aaa92a4b648aef137eb9a7054fdffaed04328ff.tar.gz emacs-8aaa92a4b648aef137eb9a7054fdffaed04328ff.zip | |
Don't spam the echo area and the *Messages* buffer in Tramp
* lisp/net/tramp-sh.el (tramp-sh-handle-vc-registered):
When called during `revert-buffer', don't spam the echo area and
the *Messages* buffer.
| -rw-r--r-- | lisp/net/tramp-sh.el | 170 |
1 files changed, 88 insertions, 82 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 2aef6ea10fb..8de88d355f9 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3463,91 +3463,97 @@ the result will be a local, non-Tramp, file name." | |||
| 3463 | ;; can reset the file name handlers, and we make a second run of | 3463 | ;; can reset the file name handlers, and we make a second run of |
| 3464 | ;; `vc-registered', which returns the expected result without sending | 3464 | ;; `vc-registered', which returns the expected result without sending |
| 3465 | ;; any other remote command. | 3465 | ;; any other remote command. |
| 3466 | ;; When called during `revert-buffer', it shouldn't spam the echo area | ||
| 3467 | ;; and the *Messages* buffer. | ||
| 3466 | (defun tramp-sh-handle-vc-registered (file) | 3468 | (defun tramp-sh-handle-vc-registered (file) |
| 3467 | "Like `vc-registered' for Tramp files." | 3469 | "Like `vc-registered' for Tramp files." |
| 3468 | (when vc-handled-backends | 3470 | (when vc-handled-backends |
| 3469 | (with-temp-message "" | 3471 | (let ((tramp-message-show-message |
| 3470 | (with-parsed-tramp-file-name file nil | 3472 | (and (not revert-buffer-in-progress-p) tramp-message-show-message)) |
| 3471 | (with-tramp-progress-reporter | 3473 | (temp-message (unless revert-buffer-in-progress-p ""))) |
| 3472 | v 3 (format-message "Checking `vc-registered' for %s" file) | 3474 | (with-temp-message temp-message |
| 3473 | 3475 | (with-parsed-tramp-file-name file nil | |
| 3474 | ;; There could be new files, created by the vc backend. We | 3476 | (with-tramp-progress-reporter |
| 3475 | ;; cannot reuse the old cache entries, therefore. In | 3477 | v 3 (format-message "Checking `vc-registered' for %s" file) |
| 3476 | ;; `tramp-get-file-property', `remote-file-name-inhibit-cache' | 3478 | |
| 3477 | ;; could also be a timestamp as `current-time' returns. This | 3479 | ;; There could be new files, created by the vc backend. |
| 3478 | ;; means invalidate all cache entries with an older timestamp. | 3480 | ;; We cannot reuse the old cache entries, therefore. In |
| 3479 | (let (tramp-vc-registered-file-names | 3481 | ;; `tramp-get-file-property', `remote-file-name-inhibit-cache' |
| 3480 | (remote-file-name-inhibit-cache (current-time)) | 3482 | ;; could also be a timestamp as `current-time' returns. This |
| 3481 | (file-name-handler-alist | 3483 | ;; means invalidate all cache entries with an older timestamp. |
| 3482 | `((,tramp-file-name-regexp . tramp-vc-file-name-handler)))) | 3484 | (let (tramp-vc-registered-file-names |
| 3483 | 3485 | (remote-file-name-inhibit-cache (current-time)) | |
| 3484 | ;; Here we collect only file names, which need an operation. | 3486 | (file-name-handler-alist |
| 3485 | (tramp-with-demoted-errors | 3487 | `((,tramp-file-name-regexp . tramp-vc-file-name-handler)))) |
| 3486 | v "Error in 1st pass of `vc-registered': %s" | 3488 | |
| 3487 | (tramp-run-real-handler #'vc-registered (list file))) | 3489 | ;; Here we collect only file names, which need an operation. |
| 3488 | (tramp-message v 10 "\n%s" tramp-vc-registered-file-names) | 3490 | (tramp-with-demoted-errors |
| 3489 | 3491 | v "Error in 1st pass of `vc-registered': %s" | |
| 3490 | ;; Send just one command, in order to fill the cache. | 3492 | (tramp-run-real-handler #'vc-registered (list file))) |
| 3491 | (when tramp-vc-registered-file-names | 3493 | (tramp-message v 10 "\n%s" tramp-vc-registered-file-names) |
| 3492 | (tramp-maybe-send-script | 3494 | |
| 3493 | v | 3495 | ;; Send just one command, in order to fill the cache. |
| 3494 | (format tramp-vc-registered-read-file-names | 3496 | (when tramp-vc-registered-file-names |
| 3495 | (tramp-get-file-exists-command v) | 3497 | (tramp-maybe-send-script |
| 3496 | (format "%s -r" (tramp-get-test-command v))) | 3498 | v |
| 3497 | "tramp_vc_registered_read_file_names") | 3499 | (format tramp-vc-registered-read-file-names |
| 3498 | 3500 | (tramp-get-file-exists-command v) | |
| 3499 | (dolist | 3501 | (format "%s -r" (tramp-get-test-command v))) |
| 3500 | (elt | 3502 | "tramp_vc_registered_read_file_names") |
| 3501 | (ignore-errors | 3503 | |
| 3502 | ;; We cannot use `tramp-send-command-and-read', | 3504 | (dolist |
| 3503 | ;; because this does not cooperate well with | 3505 | (elt |
| 3504 | ;; heredoc documents. | 3506 | (ignore-errors |
| 3505 | (tramp-send-command | 3507 | ;; We cannot use `tramp-send-command-and-read', |
| 3506 | v | 3508 | ;; because this does not cooperate well with |
| 3507 | (format | 3509 | ;; heredoc documents. |
| 3508 | "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n" | 3510 | (tramp-send-command |
| 3509 | tramp-end-of-heredoc | 3511 | v |
| 3510 | (mapconcat #'tramp-shell-quote-argument | 3512 | (format |
| 3511 | tramp-vc-registered-file-names | 3513 | "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n" |
| 3512 | "\n") | 3514 | tramp-end-of-heredoc |
| 3513 | tramp-end-of-heredoc)) | 3515 | (mapconcat #'tramp-shell-quote-argument |
| 3514 | (with-current-buffer (tramp-get-connection-buffer v) | 3516 | tramp-vc-registered-file-names |
| 3515 | ;; Read the expression. | 3517 | "\n") |
| 3516 | (goto-char (point-min)) | 3518 | tramp-end-of-heredoc)) |
| 3517 | (read (current-buffer))))) | 3519 | (with-current-buffer (tramp-get-connection-buffer v) |
| 3518 | 3520 | ;; Read the expression. | |
| 3519 | (tramp-set-file-property | 3521 | (goto-char (point-min)) |
| 3520 | v (car elt) (cadr elt) (cadr (cdr elt)))))) | 3522 | (read (current-buffer))))) |
| 3521 | 3523 | ||
| 3522 | ;; Second run. Now all `file-exists-p' or `file-readable-p' | 3524 | (tramp-set-file-property |
| 3523 | ;; calls shall be answered from the file cache. We unset | 3525 | v (car elt) (cadr elt) (cadr (cdr elt)))))) |
| 3524 | ;; `process-file-side-effects' and `remote-file-name-inhibit-cache' | 3526 | |
| 3525 | ;; in order to keep the cache. | 3527 | ;; Second run. Now all `file-exists-p' or `file-readable-p' |
| 3526 | (let ((vc-handled-backends vc-handled-backends) | 3528 | ;; calls shall be answered from the file cache. We unset |
| 3527 | remote-file-name-inhibit-cache process-file-side-effects) | 3529 | ;; `process-file-side-effects' and `remote-file-name-inhibit-cache' |
| 3528 | ;; Reduce `vc-handled-backends' in order to minimize process calls. | 3530 | ;; in order to keep the cache. |
| 3529 | (when (and (memq 'Bzr vc-handled-backends) | 3531 | (let ((vc-handled-backends vc-handled-backends) |
| 3530 | (boundp 'vc-bzr-program) | 3532 | remote-file-name-inhibit-cache process-file-side-effects) |
| 3531 | (not (with-tramp-connection-property v vc-bzr-program | 3533 | ;; Reduce `vc-handled-backends' in order to minimize |
| 3532 | (tramp-find-executable | 3534 | ;; process calls. |
| 3533 | v vc-bzr-program (tramp-get-remote-path v))))) | 3535 | (when (and (memq 'Bzr vc-handled-backends) |
| 3534 | (setq vc-handled-backends (remq 'Bzr vc-handled-backends))) | 3536 | (boundp 'vc-bzr-program) |
| 3535 | (when (and (memq 'Git vc-handled-backends) | 3537 | (not (with-tramp-connection-property v vc-bzr-program |
| 3536 | (boundp 'vc-git-program) | 3538 | (tramp-find-executable |
| 3537 | (not (with-tramp-connection-property v vc-git-program | 3539 | v vc-bzr-program (tramp-get-remote-path v))))) |
| 3538 | (tramp-find-executable | 3540 | (setq vc-handled-backends (remq 'Bzr vc-handled-backends))) |
| 3539 | v vc-git-program (tramp-get-remote-path v))))) | 3541 | (when (and (memq 'Git vc-handled-backends) |
| 3540 | (setq vc-handled-backends (remq 'Git vc-handled-backends))) | 3542 | (boundp 'vc-git-program) |
| 3541 | (when (and (memq 'Hg vc-handled-backends) | 3543 | (not (with-tramp-connection-property v vc-git-program |
| 3542 | (boundp 'vc-hg-program) | 3544 | (tramp-find-executable |
| 3543 | (not (with-tramp-connection-property v vc-hg-program | 3545 | v vc-git-program (tramp-get-remote-path v))))) |
| 3544 | (tramp-find-executable | 3546 | (setq vc-handled-backends (remq 'Git vc-handled-backends))) |
| 3545 | v vc-hg-program (tramp-get-remote-path v))))) | 3547 | (when (and (memq 'Hg vc-handled-backends) |
| 3546 | (setq vc-handled-backends (remq 'Hg vc-handled-backends))) | 3548 | (boundp 'vc-hg-program) |
| 3547 | ;; Run. | 3549 | (not (with-tramp-connection-property v vc-hg-program |
| 3548 | (tramp-with-demoted-errors | 3550 | (tramp-find-executable |
| 3549 | v "Error in 2nd pass of `vc-registered': %s" | 3551 | v vc-hg-program (tramp-get-remote-path v))))) |
| 3550 | (tramp-run-real-handler #'vc-registered (list file))))))))) | 3552 | (setq vc-handled-backends (remq 'Hg vc-handled-backends))) |
| 3553 | ;; Run. | ||
| 3554 | (tramp-with-demoted-errors | ||
| 3555 | v "Error in 2nd pass of `vc-registered': %s" | ||
| 3556 | (tramp-run-real-handler #'vc-registered (list file)))))))))) | ||
| 3551 | 3557 | ||
| 3552 | ;;;###tramp-autoload | 3558 | ;;;###tramp-autoload |
| 3553 | (defun tramp-sh-file-name-handler (operation &rest args) | 3559 | (defun tramp-sh-file-name-handler (operation &rest args) |