(inhibit-file-name-operation operation))
(apply operation args)))
+(defvar buffer-file-type)
+(defvar last-coding-system-used)
(defun epg-file-write-region (start end filename &optional append visit
lockname mustbenew)
(let* ((visit-file (if (stringp visit)
(coding-system (condition-case nil
(epg-file-run-real-handler
'write-region (list start end "/"))
- (file-error last-coding-system-used)))
+ (file-error (if (boundp 'last-coding-system-used)
+ last-coding-system-used
+ buffer-file-coding-system))))
;; start and end are normally buffer positions
;; specifying the part of the buffer to write.
;; If start is nil, that means to use the entire buffer contents.
(buffer-substring start end)))
coding-system)))
(with-temp-buffer
- (set-buffer-multibyte nil)
+ (if (fboundp 'set-buffer-multibyte)
+ (set-buffer-multibyte nil))
;; Optional fourth argument append if non-nil means
;; append to existing file contents (if any). If it is an integer,
;; seek to that offset in the file before writing.
(context (epg-make-context))
cipher)
(when (setq cipher (epg-encrypt-string context (buffer-string) nil))
- (if (memq system-type '(ms-dos windows-nt))
+ (if (and (memq system-type '(ms-dos windows-nt))
+ (boundp 'buffer-file-type))
(setq buffer-file-type t))
(epg-file-run-real-handler
'write-region
(when (or (eq visit t) (stringp visit))
(setq buffer-file-name filename)
(set-visited-file-modtime))
- (when (stringp visit)
- (setq buffer-file-name visit))
+ (if (stringp visit)
+ (setq buffer-file-name visit))
(when (or (eq visit t) (eq visit nil) (stringp visit))
(message "Wrote %s" visit-file))
- (setq last-coding-system-used coding-system)
+ (if (boundp 'last-coding-system-used)
+ (setq last-coding-system-used coding-system))
nil))
(defun epg-file-insert-file-contents (filename &optional visit beg end replace)
(let ((filename (expand-file-name filename))
(length 0))
(if (file-exists-p filename)
- (let* ((local-file
- (let ((inhibit-file-name-operation
- (when (eq inhibit-file-name-operation
- 'insert-file-contents)
- 'file-local-copy)))
- (file-local-copy filename)))
- (coding-system-for-read 'binary)
- (context (epg-make-context))
- string)
+ (let ((local-file
+ (let ((inhibit-file-name-operation
+ (when (eq inhibit-file-name-operation
+ 'insert-file-contents)
+ 'file-local-copy)))
+ (file-local-copy filename)))
+ (coding-system-for-read 'binary)
+ (context (epg-make-context))
+ string)
(unwind-protect
(progn
(setq string (epg-decrypt-file context (or local-file