Fix the last commit
This commit is contained in:
parent
6d3b19fe46
commit
7ef055bc51
@ -45,7 +45,7 @@ Note that this does not affect the current file, see
|
|||||||
"If non-nil, use the `file-truename' of the current file when checking safety.
|
"If non-nil, use the `file-truename' of the current file when checking safety.
|
||||||
If this is nil, each link to a directory must individually be in
|
If this is nil, each link to a directory must individually be in
|
||||||
`trusted-files-list' to be considered safe. Note that this does _NOT_ effect
|
`trusted-files-list' to be considered safe. Note that this does _NOT_ effect
|
||||||
the entries in `trusted-files-list', only `default-directory'."
|
the entries in `trusted-files-list', only the current buffer's path."
|
||||||
:group 'trusted-files
|
:group 'trusted-files
|
||||||
:tag "Resolve Symbolic Links for the Current Directory"
|
:tag "Resolve Symbolic Links for the Current Directory"
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
@ -160,7 +160,7 @@ passing them to `setopt'."
|
|||||||
"How to show the current buffer's trusted status in the mode line.
|
"How to show the current buffer's trusted status in the mode line.
|
||||||
There are three possible values:
|
There are three possible values:
|
||||||
- t: always show the status
|
- t: always show the status
|
||||||
- \\='untrusted: show the status if `default-directory' is untrusted
|
- \\='untrusted: show the status if the current buffer is untrusted
|
||||||
- \\='dynamic: as above, but only if a protected function tried to run
|
- \\='dynamic: as above, but only if a protected function tried to run
|
||||||
- \\='dynamic-untrusted: as above, but only if the function failed
|
- \\='dynamic-untrusted: as above, but only if the function failed
|
||||||
- \\='dynamic-temporary: save as \\='dynamic, but also show when the buffer is
|
- \\='dynamic-temporary: save as \\='dynamic, but also show when the buffer is
|
||||||
@ -446,12 +446,12 @@ Unless RESOLVED is set, resolve PATH with
|
|||||||
|
|
||||||
(defun trusted-files--buffer-temporarily-trusted-p (buffer)
|
(defun trusted-files--buffer-temporarily-trusted-p (buffer)
|
||||||
"Return non-nil if BUFFER is temprarily trusted.
|
"Return non-nil if BUFFER is temprarily trusted.
|
||||||
This checks both BUFFER and BUFFER's `default-directory'.
|
This checks both BUFFER and BUFFER's parent directory.
|
||||||
|
|
||||||
Return a cons. For the car if the BUFFER is trusted, return \\='temp-buffer.
|
Return a cons. For the car if the BUFFER is trusted, return \\='temp-buffer. If
|
||||||
If `default-directory' is exactly trusted, return \\='temp-dir. If a parent
|
BUFFER's parent directory is exactly trusted, return \\='temp-dir. If a higher
|
||||||
directory of it is trusted, return \\='temp-subdir. For the cdr, return the
|
up parent directory of it is trusted, return \\='temp-subdir. For the cdr,
|
||||||
directory that matched, or the BUFFER it itself matched."
|
return the directory that matched, or the BUFFER it itself matched."
|
||||||
(or
|
(or
|
||||||
(and (gethash buffer trusted-files--temporarily-trusted-cache)
|
(and (gethash buffer trusted-files--temporarily-trusted-cache)
|
||||||
(cons 'temp-buffer buffer))
|
(cons 'temp-buffer buffer))
|
||||||
@ -673,11 +673,8 @@ PATH is processed according to `trusted-files-truename-trusted-directories'."
|
|||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun trusted-files-add-current (&optional no-recursive no-revert)
|
(defun trusted-files-add-current (&optional no-recursive no-revert)
|
||||||
"Mark `default-directory' as a trusted directory.
|
"Mark the current buffer as a trusted file.
|
||||||
NO-RECURSIVE and NO-REVERT are the same as for `trusted-files-add' (which see).
|
NO-RECURSIVE and NO-REVERT are the same as for `trusted-files-add' (which see)."
|
||||||
|
|
||||||
`default-directory' is processed according to
|
|
||||||
`trusted-files-truename-trusted-directories'."
|
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(trusted-files-add (trusted-files--buffer-path) no-recursive no-revert))
|
(trusted-files-add (trusted-files--buffer-path) no-recursive no-revert))
|
||||||
|
|
||||||
@ -711,11 +708,8 @@ PATH is processed according to `trusted-files-truename-trusted-directories'."
|
|||||||
(trusted-files--maybe-prompt-revert-newly-trusted-buffers)))))
|
(trusted-files--maybe-prompt-revert-newly-trusted-buffers)))))
|
||||||
|
|
||||||
(defun trusted-files-remove-current (&optional no-revert)
|
(defun trusted-files-remove-current (&optional no-revert)
|
||||||
"Mark `default-directory' as an untrusted directory.
|
"Remove the current buffer from the list of trusted files.
|
||||||
NO-REVERT is the same as for `trusted-files-remove' (which see).
|
NO-REVERT is the same as for `trusted-files-remove' (which see)."
|
||||||
|
|
||||||
`default-directory' is processed according to
|
|
||||||
`trusted-files-truename-trusted-directories'."
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(trusted-files-remove (trusted-files--buffer-path) no-revert))
|
(trusted-files-remove (trusted-files--buffer-path) no-revert))
|
||||||
|
|
||||||
@ -723,11 +717,11 @@ NO-REVERT is the same as for `trusted-files-remove' (which see).
|
|||||||
(defun trusted-files-add-temporary-directory
|
(defun trusted-files-add-temporary-directory
|
||||||
(path &optional no-recursive no-revert)
|
(path &optional no-recursive no-revert)
|
||||||
"Temporarily trust PATH.
|
"Temporarily trust PATH.
|
||||||
PATH will be trusted until _ALL_ buffers that have it as their
|
PATH will be trusted until _ALL_ buffers that visit files located in PATH are
|
||||||
`default-directory' are closed. Unless NO-RECURSIVE is set, also trust
|
closed. Unless NO-RECURSIVE is set, also trust
|
||||||
subdirectories of `default-directory'. In this case buffers in all
|
subdirectories of PATH. In this case buffers visiting files in all
|
||||||
subdirectories of `default-directory' will also be trusted, and PATH will not be
|
subdirectories of PATH will also be trusted, and PATH will not be untrusted
|
||||||
untrusted until _ALL_ of these buffers are closed as well.
|
until _ALL_ of these buffers are closed as well.
|
||||||
|
|
||||||
Unless NO-REVERT is set, prompt the user to call
|
Unless NO-REVERT is set, prompt the user to call
|
||||||
`trusted-files-revert-newly-trusted-buffers'.
|
`trusted-files-revert-newly-trusted-buffers'.
|
||||||
@ -812,7 +806,7 @@ PROMPT defaults to \"Temporarily Trusted Buffer: \"."
|
|||||||
(defun trusted-files-remove-temporary-buffer (&optional buffer-or-name no-revert)
|
(defun trusted-files-remove-temporary-buffer (&optional buffer-or-name no-revert)
|
||||||
"Untust BUFFER-OR-NAME if it is a temporarily trusted buffer.
|
"Untust BUFFER-OR-NAME if it is a temporarily trusted buffer.
|
||||||
If it was trusted, return non-nil, otherwise, return nil. Note that this only
|
If it was trusted, return non-nil, otherwise, return nil. Note that this only
|
||||||
untrusts BUFFER-OR-NAME, and not its `default-directory'. For that, see
|
untrusts BUFFER-OR-NAME, and not its directory. For that, see
|
||||||
`trusted-files-remove-temporary-directory'.
|
`trusted-files-remove-temporary-directory'.
|
||||||
|
|
||||||
Unless NO-REVERT is set, prompt the user to revert the buffer if it is deemed to
|
Unless NO-REVERT is set, prompt the user to revert the buffer if it is deemed to
|
||||||
@ -832,10 +826,9 @@ have outdated trust information. For an explanation of what this means, see
|
|||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun trusted-files-remove-temporary-current-buffer (&optional no-revert)
|
(defun trusted-files-remove-temporary-current-buffer (&optional no-revert)
|
||||||
"Untrust the current buffer, however it's temporarily trusted.
|
"Untrust the current buffer, however it's temporarily trusted. This will
|
||||||
This will either untrust the current buffer directly, untrust its
|
either untrust the current buffer directly, untrust its visited file, or untrust
|
||||||
`default-directory', or untrust a parent of its `default-directory'. If need
|
a parent directory of its such. If need be, it may untrust multiple things.
|
||||||
be, it may do multiple of these.
|
|
||||||
|
|
||||||
Unless NO-REVERT is set, prompt the user to revert the buffer if it is deemed to
|
Unless NO-REVERT is set, prompt the user to revert the buffer if it is deemed to
|
||||||
have outdated trust information. For an explanation of what this means, see
|
have outdated trust information. For an explanation of what this means, see
|
||||||
@ -869,8 +862,8 @@ the symbol \\='quote or \\='function and the second being a symbol."
|
|||||||
(null (cddr form)))))
|
(null (cddr form)))))
|
||||||
|
|
||||||
(defmacro trusted-files-only-if-safe (function &optional replacement prefix suffix)
|
(defmacro trusted-files-only-if-safe (function &optional replacement prefix suffix)
|
||||||
"Return a function that will call FUNCTION if `default-directory' is safe.
|
"Return a function that will call FUNCTION if the current buffer is safe. If
|
||||||
If REPLACEMENT is non-nil, call it instead of FUNCTION if `default-directory' is
|
REPLACEMENT is non-nil, call it instead of FUNCTION if the current buffer is
|
||||||
unsafe. REPLACEMENT is called with the same arguments that FUNCTION would have
|
unsafe. REPLACEMENT is called with the same arguments that FUNCTION would have
|
||||||
been called with.
|
been called with.
|
||||||
|
|
||||||
@ -891,7 +884,7 @@ concatenating PREFIX, the name of FUNCTION, and SUFFIX."
|
|||||||
'(lambda))
|
'(lambda))
|
||||||
(&rest ,args)
|
(&rest ,args)
|
||||||
,@(when do-defun
|
,@(when do-defun
|
||||||
(list (format "Execute `%s' when `default-directory' is safe.
|
(list (format "Execute `%s' when the current buffer is safe.
|
||||||
The safety check is done with `trusted-files-safe-p'."
|
The safety check is done with `trusted-files-safe-p'."
|
||||||
(cl-second function))))
|
(cl-second function))))
|
||||||
(require 'trusted-files)
|
(require 'trusted-files)
|
||||||
@ -902,7 +895,7 @@ The safety check is done with `trusted-files-safe-p'."
|
|||||||
|
|
||||||
(cl-defmacro trusted-files-add-hook-if-safe
|
(cl-defmacro trusted-files-add-hook-if-safe
|
||||||
(hook function &optional (depth nil depthp) (local nil localp))
|
(hook function &optional (depth nil depthp) (local nil localp))
|
||||||
"Like `add-hook', but only when `default-directory' is trusted.
|
"Like `add-hook', but only when the current buffer is trusted.
|
||||||
This will add FUNCTION to HOOK, initializing it if necessary. DEPTH and LOCAL
|
This will add FUNCTION to HOOK, initializing it if necessary. DEPTH and LOCAL
|
||||||
are the same as `add-hook' (which see). If FUNCTION is a symbol, it is wrapped
|
are the same as `add-hook' (which see). If FUNCTION is a symbol, it is wrapped
|
||||||
in a new function who's name is formed by concatenating the name of FUNCTION and
|
in a new function who's name is formed by concatenating the name of FUNCTION and
|
||||||
@ -1053,8 +1046,8 @@ The check if performed with `trusted-files-safe-p'.%s"
|
|||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defvar-keymap trusted-files-map
|
(defvar-keymap trusted-files-map
|
||||||
:name "Trusted Files"
|
|
||||||
:doc "Prefix keymap for working with trusted files."
|
:doc "Prefix keymap for working with trusted files."
|
||||||
|
:prefix 'trusted-files-map
|
||||||
"a" #'trusted-files-add
|
"a" #'trusted-files-add
|
||||||
"A" #'trusted-files-add-current
|
"A" #'trusted-files-add-current
|
||||||
"r" #'trusted-files-remove
|
"r" #'trusted-files-remove
|
||||||
@ -1066,3 +1059,7 @@ The check if performed with `trusted-files-safe-p'.%s"
|
|||||||
|
|
||||||
(provide 'trusted-files)
|
(provide 'trusted-files)
|
||||||
;;; trusted-files.el ends here
|
;;; trusted-files.el ends here
|
||||||
|
|
||||||
|
;; Local Variables:
|
||||||
|
;; jinx-local-words: "untrust untrusts"
|
||||||
|
;; End:
|
||||||
|
Loading…
Reference in New Issue
Block a user