🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #741

Re: auto-save file protections

#741
From: Simon Marshall
Date: Fri, 23 Apr 1993 15:25
41 lines
2511 bytes
In article <C5wprE.Cs7@rice.edu> karim@rice.edu (Karim Esseghir) writes:
>I would like the auto-save file created for the *mail* buffer to be 
>protected against read/write from other users. How do I make emacs/
>epoch do this automatically upon creating the file?

This is the general answer.  It applies to files as well as buffers.

;;; Stuff to prevent autosaves from being readable.
;;; Simon Marshall (S.Marshall@dcs.hull.ac.uk).

(defvar auto-save-directory "~/AutoSaves"
  "*Name of directory to put auto saved files.
Should not end in a slash, and should be created with group and other
permissions restricted.")

(defun make-auto-save-file-name ()
  "Return file name to use for auto-saves of current buffer.
Files are in auto-save-directory.
Does not consider auto-save-visited-file-name; that is checked
before calling this function.
You can redefine this for customization.
See also auto-save-file-name-p."
  (let ((auto-save (if buffer-file-name
		       (concat buffer-file-name "#")
		     (expand-file-name (concat "%" (buffer-name) "#")))))
    (concat auto-save-directory "/" (replace-in-string auto-save "/" "#"))))

(defun replace-in-string (str from to)
  "Edit string STR, by replacing the substrings FROM to the substring TO"
  (let ((start (string-match from str)))
    (if start
	(concat (substring str 0 start) to
		(replace-in-string (substring str (+ start (length from)))
				   from to))
      str)))

Have fun.  Simon.
-- 
Simon Marshall, Dept. of Computer Science, University of Hull, Hull HU6 7RX, UK
  "Football isn't about life and death.  It's more important than that." Bill
Email: S.Marshall@cs.hull.ac.uk   Phone: +44 482 465951  Fax: 466666   Shankley
Technical Details
Message-ID: <1993Apr23.152518.24992@nessie.mcc.ac.uk>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!pipex!uknet!nessie!uts.mcc.ac.uk!ehgasm2
References: <C5wprE.Cs7@rice.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc7ee,1da0b5bdb761fd09
X-Google-Attributes: gidfc7ee,public
X-Google-Thread: 103b8b,1da0b5bdb761fd09
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1993-04-23 08:46:08 PST
Newsgroups: gnu.epoch.misc,gnu.emacs.help
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!pipex!uknet!nessie!uts.mcc.ac.uk!ehgasm2
From: ehgasm2@uts.mcc.ac.uk (Simon Marshall)
Subject: Re: auto-save file protections
Message-ID: <1993Apr23.152518.24992@nessie.mcc.ac.uk>
Sender: news@nessie.mcc.ac.uk (Usenet News System)
Organization: Manchester Computing Centre, Manchester, England
References: <C5wprE.Cs7@rice.edu>
Date: Fri, 23 Apr 1993 15:25:18 GMT
Lines: 41