1668 |
|
|
1669 |
my $len = length($pending); |
my $len = length($pending); |
1670 |
my $chunk = substr($pending, 0, $len & ~3); |
my $chunk = substr($pending, 0, $len & ~3); |
1671 |
|
$pending = substr($pending, $len & ~3 + 1); |
1672 |
|
|
1673 |
# Easy method: translate from chars to (pregenerated) six-bit packets, join, |
# Easy method: translate from chars to (pregenerated) six-bit packets, join, |
1674 |
# split in 8-bit chunks and convert back to char. |
# split in 8-bit chunks and convert back to char. |
1884 |
|
|
1885 |
(put 'with-parsed-tramp-file-name 'lisp-indent-function 2) |
(put 'with-parsed-tramp-file-name 'lisp-indent-function 2) |
1886 |
;; To be activated for debugging containing this macro |
;; To be activated for debugging containing this macro |
1887 |
(def-edebug-spec with-parsed-tramp-file-name t) |
;; It works only when VAR is nil. Otherwise, it can be deactivated by |
1888 |
|
;; (def-edebug-spec with-parsed-tramp-file-name 0) |
1889 |
|
;; I'm too stupid to write a precise SPEC for it. |
1890 |
|
(if (functionp 'def-edebug-spec) |
1891 |
|
(def-edebug-spec with-parsed-tramp-file-name t)) |
1892 |
|
|
1893 |
(defmacro tramp-let-maybe (variable value &rest body) |
(defmacro tramp-let-maybe (variable value &rest body) |
1894 |
"Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete. |
"Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete. |
6736 |
(tramp-make-auto-save-file-name (buffer-file-name))) |
(tramp-make-auto-save-file-name (buffer-file-name))) |
6737 |
ad-do-it)) |
ad-do-it)) |
6738 |
|
|
6739 |
|
;; In Emacs < 21.4 and XEmacs < 21.5 autosaved remote files have |
6740 |
|
;; permission 666 minus umask. This is a security threat. |
6741 |
|
|
6742 |
|
(defun tramp-set-auto-save-file-modes () |
6743 |
|
"Set permissions of autosaved remote files to the original permissions." |
6744 |
|
(let ((bfn (buffer-file-name))) |
6745 |
|
(when (and (stringp bfn) |
6746 |
|
(tramp-tramp-file-p bfn) |
6747 |
|
(stringp buffer-auto-save-file-name) |
6748 |
|
(not (equal bfn buffer-auto-save-file-name)) |
6749 |
|
(not (file-exists-p buffer-auto-save-file-name))) |
6750 |
|
(write-region "" nil buffer-auto-save-file-name) |
6751 |
|
(set-file-modes buffer-auto-save-file-name (file-modes bfn))))) |
6752 |
|
|
6753 |
|
(unless (or (> emacs-major-version 21) |
6754 |
|
(and (featurep 'xemacs) |
6755 |
|
(= emacs-major-version 21) |
6756 |
|
(> emacs-minor-version 4)) |
6757 |
|
(and (not (featurep 'xemacs)) |
6758 |
|
(= emacs-major-version 21) |
6759 |
|
(or (> emacs-minor-version 3) |
6760 |
|
(and (string-match "^21\\.3\\.\\([0-9]+\\)" emacs-version) |
6761 |
|
(>= (string-to-int (match-string 1 emacs-version)) 50))))) |
6762 |
|
(add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)) |
6763 |
|
|
6764 |
(defun tramp-subst-strs-in-string (alist string) |
(defun tramp-subst-strs-in-string (alist string) |
6765 |
"Replace all occurrences of the string FROM with TO in STRING. |
"Replace all occurrences of the string FROM with TO in STRING. |
6766 |
ALIST is of the form ((FROM . TO) ...)." |
ALIST is of the form ((FROM . TO) ...)." |