[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs-wiki publishing/file permission
From: |
Ted Zlatanov |
Subject: |
Re: emacs-wiki publishing/file permission |
Date: |
Fri, 31 Jan 2003 11:39:19 -0500 |
User-agent: |
Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 (sparc-sun-solaris2.8) |
On 31 Jan 2003, nospam@krid.de wrote:
> I have a default umask of 027 here at work. When I write up
> emacs-wiki pages and publish them, the published pages have
> permissions of 0640, naturally. I'd like to change their default
> permission to 0644. Can I do that without changing my umask? Is
> there a way to tell emacs to use a specific umask in a specific
> directory?
I use the following code. There's some packages out there that do
something similar, but none did what I needed. Maybe someone should
release this as a real ELisp package if they find it useful...
Oh yes, it requires the cl package.
Ted
;; automatically set permissions from the file tzz-permissions-file
;; Example:
;; all file saves of buffers whose name matches "cgi.*html" or
;; "cgi.*pm" are mode 644 (rw-r--r--), all "cgi.*pl" are 755
;; (rwxr-xr-x)
;; contents of tzz-permissions-file:
;; 644 cgi.*html
;; 644 cgi.*pm
;; 755 cgi.*pl
(setq tzz-permissions-file "~/.permissions")
(setq tzz-write-file-verbose t)
(defun tzz-read-permissions()
"Read the permissions file"
(let ((permissions-file-name tzz-permissions-file)
alist)
(if (file-readable-p permissions-file-name)
(with-temp-buffer (insert-file-contents-literally permissions-file-name)
(while (re-search-forward
"\\([0-7]\\{3,4\\}\\)[ \t]+\\(.*\\)\n" nil t)
(setq alist (cons (cons (match-string 2)
(match-string 1))
alist)))
alist)
nil)))
(setq tzz-permissions-alist (tzz-read-permissions))
(defun tzz-write-file-hook ()
(interactive)
"Do personal setting of file permissions"
(dolist (cell tzz-permissions-alist nil)
(let ((permission (string-to-number (cdr cell) 8))
(regex (car cell)))
(when (string-match regex buffer-file-name)
(when tzz-write-file-verbose
(message "setting permissions of %s to %o" buffer-file-name
permission))
(set-file-modes buffer-file-name permission)))))
(add-hook 'after-save-hook 'tzz-write-file-hook)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: emacs-wiki publishing/file permission,
Ted Zlatanov <=