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 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
|
||||
the entries in `trusted-files-list', only `default-directory'."
|
||||
the entries in `trusted-files-list', only the current buffer's path."
|
||||
:group 'trusted-files
|
||||
:tag "Resolve Symbolic Links for the Current Directory"
|
||||
:type 'boolean
|
||||
@ -160,7 +160,7 @@ passing them to `setopt'."
|
||||
"How to show the current buffer's trusted status in the mode line.
|
||||
There are three possible values:
|
||||
- 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-untrusted: as above, but only if the function failed
|
||||
- \\='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)
|
||||
"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.
|
||||
If `default-directory' is exactly trusted, return \\='temp-dir. If a parent
|
||||
directory of it is trusted, return \\='temp-subdir. For the cdr, return the
|
||||
directory that matched, or the BUFFER it itself matched."
|
||||
Return a cons. For the car if the BUFFER is trusted, return \\='temp-buffer. If
|
||||
BUFFER's parent directory is exactly trusted, return \\='temp-dir. If a higher
|
||||
up parent directory of it is trusted, return \\='temp-subdir. For the cdr,
|
||||
return the directory that matched, or the BUFFER it itself matched."
|
||||
(or
|
||||
(and (gethash buffer trusted-files--temporarily-trusted-cache)
|
||||
(cons 'temp-buffer buffer))
|
||||
@ -673,11 +673,8 @@ PATH is processed according to `trusted-files-truename-trusted-directories'."
|
||||
|
||||
;;;###autoload
|
||||
(defun trusted-files-add-current (&optional no-recursive no-revert)
|
||||
"Mark `default-directory' as a trusted directory.
|
||||
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'."
|
||||
"Mark the current buffer as a trusted file.
|
||||
NO-RECURSIVE and NO-REVERT are the same as for `trusted-files-add' (which see)."
|
||||
(interactive "P")
|
||||
(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)))))
|
||||
|
||||
(defun trusted-files-remove-current (&optional no-revert)
|
||||
"Mark `default-directory' as an untrusted directory.
|
||||
NO-REVERT is the same as for `trusted-files-remove' (which see).
|
||||
|
||||
`default-directory' is processed according to
|
||||
`trusted-files-truename-trusted-directories'."
|
||||
"Remove the current buffer from the list of trusted files.
|
||||
NO-REVERT is the same as for `trusted-files-remove' (which see)."
|
||||
(interactive)
|
||||
(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
|
||||
(path &optional no-recursive no-revert)
|
||||
"Temporarily trust PATH.
|
||||
PATH will be trusted until _ALL_ buffers that have it as their
|
||||
`default-directory' are closed. Unless NO-RECURSIVE is set, also trust
|
||||
subdirectories of `default-directory'. In this case buffers in all
|
||||
subdirectories of `default-directory' will also be trusted, and PATH will not be
|
||||
untrusted until _ALL_ of these buffers are closed as well.
|
||||
PATH will be trusted until _ALL_ buffers that visit files located in PATH are
|
||||
closed. Unless NO-RECURSIVE is set, also trust
|
||||
subdirectories of PATH. In this case buffers visiting files in all
|
||||
subdirectories of PATH will also be trusted, and PATH will not be untrusted
|
||||
until _ALL_ of these buffers are closed as well.
|
||||
|
||||
Unless NO-REVERT is set, prompt the user to call
|
||||
`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)
|
||||
"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
|
||||
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'.
|
||||
|
||||
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
|
||||
(defun trusted-files-remove-temporary-current-buffer (&optional no-revert)
|
||||
"Untrust the current buffer, however it's temporarily trusted.
|
||||
This will either untrust the current buffer directly, untrust its
|
||||
`default-directory', or untrust a parent of its `default-directory'. If need
|
||||
be, it may do multiple of these.
|
||||
"Untrust the current buffer, however it's temporarily trusted. This will
|
||||
either untrust the current buffer directly, untrust its visited file, or untrust
|
||||
a parent directory of its such. If need be, it may untrust multiple things.
|
||||
|
||||
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
|
||||
@ -869,8 +862,8 @@ the symbol \\='quote or \\='function and the second being a symbol."
|
||||
(null (cddr form)))))
|
||||
|
||||
(defmacro trusted-files-only-if-safe (function &optional replacement prefix suffix)
|
||||
"Return a function that will call FUNCTION if `default-directory' is safe.
|
||||
If REPLACEMENT is non-nil, call it instead of FUNCTION if `default-directory' is
|
||||
"Return a function that will call FUNCTION if the current buffer is safe. If
|
||||
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
|
||||
been called with.
|
||||
|
||||
@ -891,7 +884,7 @@ concatenating PREFIX, the name of FUNCTION, and SUFFIX."
|
||||
'(lambda))
|
||||
(&rest ,args)
|
||||
,@(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'."
|
||||
(cl-second function))))
|
||||
(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
|
||||
(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
|
||||
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
|
||||
@ -1053,8 +1046,8 @@ The check if performed with `trusted-files-safe-p'.%s"
|
||||
|
||||
;;;###autoload
|
||||
(defvar-keymap trusted-files-map
|
||||
:name "Trusted Files"
|
||||
:doc "Prefix keymap for working with trusted files."
|
||||
:prefix 'trusted-files-map
|
||||
"a" #'trusted-files-add
|
||||
"A" #'trusted-files-add-current
|
||||
"r" #'trusted-files-remove
|
||||
@ -1066,3 +1059,7 @@ The check if performed with `trusted-files-safe-p'.%s"
|
||||
|
||||
(provide 'trusted-files)
|
||||
;;; trusted-files.el ends here
|
||||
|
||||
;; Local Variables:
|
||||
;; jinx-local-words: "untrust untrusts"
|
||||
;; End:
|
||||
|
Loading…
Reference in New Issue
Block a user