How to disable auto-save in emacs only for files opened as root

2

I want to use emacs auto-save feature with tramp, but only for file that I don't open using sudo. My current configuration, based on the tramp documentation, looks like this:

;;;;;;;; BAKUCP ;;;;;;;;
;; Backup remote files locally to stop autosave pain
(setq tramp-backup-directory "~/.emacs-backup")
(unless (file-directory-p tramp-backup-directory)
  (make-directory tramp-backup-directory))
(if (file-accessible-directory-p tramp-backup-directory)
    (setq tramp-auto-save-directory tramp-backup-directory)
  (error "Cannot write to ~/.emacs-backup"))
;; Don't backup su and sudo files
(setq backup-enable-predicate
      (lambda (name)
        (and (normal-backup-enable-predicate name)
             (not
              (let ((method (file-remote-p name 'method)))
                (when (stringp method)
                  (member method '("su" "sudo"))))))))

It is forbidding creating remote backups of files edited as superuser but auto-saved files are still created on my local machine. Is there any way to disable that without disabling auto-save at all?

radious

Posted 2015-07-30T21:58:35.940

Reputation: 194

1I do not know whether @Michael Albinus monitors the Emacs tag on superuser, but he is the Tramp maven/expert/guru. If the original poster does not receive a response within a reasonable period of time, it may behoove the O.P. to post in stackoverflow or emacs.stackexchange. – lawlist – 2015-08-02T04:59:26.607

I didn't know about emacs.stackexchange, thanks for this tip. If I don't get response in next few days, I'll post there and/or on appropriate mailing lists. – radious – 2015-08-03T18:22:12.417

No answers