diff options
Diffstat (limited to 'lisp/net/tramp-compat.el')
| -rw-r--r-- | lisp/net/tramp-compat.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index b83f9f0724e..203d3ede98f 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el | |||
| @@ -330,6 +330,29 @@ CONDITION can also be a list of error conditions." | |||
| 330 | (autoload 'netrc-parse "netrc") | 330 | (autoload 'netrc-parse "netrc") |
| 331 | (netrc-parse file)))) | 331 | (netrc-parse file)))) |
| 332 | 332 | ||
| 333 | ;; Function `replace-regexp-in-region' is new in Emacs 28.1. | ||
| 334 | (defalias 'tramp-compat-replace-regexp-in-region | ||
| 335 | (if (fboundp 'replace-regexp-in-region) | ||
| 336 | #'replace-regexp-in-region | ||
| 337 | (lambda (regexp replacement &optional start end) | ||
| 338 | (if start | ||
| 339 | (when (< start (point-min)) | ||
| 340 | (error "Start before start of buffer")) | ||
| 341 | (setq start (point))) | ||
| 342 | (if end | ||
| 343 | (when (> end (point-max)) | ||
| 344 | (error "End after end of buffer")) | ||
| 345 | (setq end (point-max))) | ||
| 346 | (save-excursion | ||
| 347 | (let ((matches 0) | ||
| 348 | (case-fold-search nil)) | ||
| 349 | (goto-char start) | ||
| 350 | (while (re-search-forward regexp end t) | ||
| 351 | (replace-match replacement t) | ||
| 352 | (setq matches (1+ matches))) | ||
| 353 | (and (not (zerop matches)) | ||
| 354 | matches)))))) | ||
| 355 | |||
| 333 | (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) | 356 | (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) |
| 334 | (put (intern elt) 'tramp-suppress-trace t)) | 357 | (put (intern elt) 'tramp-suppress-trace t)) |
| 335 | 358 | ||