-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make default file permission configurable #410
Comments
Emacs, like most other programs, respects |
From: Ángel Castañeda ***@***.***>
Date: Sun, 11 Aug 2024 14:25:00 -0700
I prefer having my notes as `0600` instead of `0644` to make them
inaccessible by other users. Currently, I just `chmod go-r *` every
few days, but it'd be nice if denote could do this itself by exposing
an option and using it when creating new notes.
Do you think we should have something like this handled by Denote? I
cannot remember seeing it elsewhere and would rather not go down this
path.
Anyway, I am happy to include this in the manual. Here is a
proof-of-concept:
(defvar my-denote-permissions "600"
"My preferred file permissions for Denote files.")
(defun my-denote-change-file-permissions ()
"Change file permissions of the current file to `my-denote-permissions'."
(interactive)
(when (and buffer-file-name (denote-file-is-note-p buffer-file-name))
(shell-command
(format "chmod %s %s" my-denote-permissions buffer-file-name))))
Call the command 'my-denote-change-file-permissions' to operate on the
current file. If you want something more fully fledged that may prompt
you for a file, use this instead:
(defvar my-denote-permissions "600"
"My preferred file permissions for Denote files.")
(defun my-denote-change-file-permissions (file)
"Change the FILE's permissions to `my-denote-permissions'.
FILE is the `buffer-file-name' if it is a Denote file. Else prompt for
FILE in the variable `denote-directory'."
(interactive
(list
(if (and buffer-file-name (denote-file-is-note-p buffer-file-name))
buffer-file-name
(denote-file-prompt nil "Change file permissions of FILE" :require-match))))
(if (file-exists-p file)
(shell-command (format "chmod %s %s" my-denote-permissions file))
(error "`%s' is not a valid file name" file)))
I personally prefer the second method.
Note that you can also set up a hook for this, but it would then run the
function too many times. Probably not worth it.
…--
Protesilaos Stavrou
https://protesilaos.com
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I prefer having my notes as
0600
instead of0644
to make them inaccessible by other users. Currently, I justchmod go-r *
every few days, but it'd be nice if denote could do this itself by exposing an option and using it when creating new notes.The text was updated successfully, but these errors were encountered: