Fix try 2
This commit is contained in:
parent
fe31d46166
commit
edf6ca74f3
1 changed files with 31 additions and 35 deletions
|
@ -9,14 +9,14 @@
|
|||
|
||||
(require 'projectile)
|
||||
|
||||
(defvar auto-load-project-trusted-gpg-key-fingerprints
|
||||
(defvar auto-load-project/trusted-gpg-key-fingerprints
|
||||
'()
|
||||
"The list of GPG fingerprint you trust when decrypting a gpg file.
|
||||
You can retrieve the fingerprints of your own private keys
|
||||
with: `gpg --list-secret-keys' (take care of removing the
|
||||
spaces when copauto-load-project-pasting here)")
|
||||
spaces when copy/pasting here)")
|
||||
|
||||
(defun auto-load-project-get-sign-key (file)
|
||||
(defun auto-load-project/get-sign-key (file)
|
||||
"Return the fingerprint of they key that signed FILE.
|
||||
|
||||
To sign a file you should used
|
||||
|
@ -29,44 +29,40 @@ To sign a file you should used
|
|||
"|grep VALIDSIG"
|
||||
"|awk '{print $3}'"))))
|
||||
|
||||
(defun auto-load-project-trusted-gpg-origin-p (file)
|
||||
(defun auto-load-project/trusted-gpg-origin-p (file)
|
||||
"Return non-nil if the FILE is encrypted with a trusted key."
|
||||
(member (auto-load-project-get-sign-key file)
|
||||
auto-load-project-trusted-gpg-key-fingerprints))
|
||||
(member (auto-load-project/get-sign-key file)
|
||||
auto-load-project/trusted-gpg-key-fingerprints))
|
||||
|
||||
(defconst auto-load-project-project-file "project.el"
|
||||
(defconst auto-load-project/project-file "project.el"
|
||||
"Project configuration file name.")
|
||||
|
||||
(defun auto-load-project-init ()
|
||||
"Initialize the autoload of project.el for projects."
|
||||
(defvar auto-load-project/loaded-projects (list)
|
||||
"Projects that have been loaded by `auto-load-project/load'.")
|
||||
|
||||
(with-eval-after-load 'projectile
|
||||
(defun auto-load-project/load ()
|
||||
"Loads the `auto-load-project/project-file' for a project.
|
||||
This is run once the project is loaded signifying project setup."
|
||||
(interactive)
|
||||
(when (projectile-project-p)
|
||||
(lexical-let* ((current-project-root (projectile-project-root))
|
||||
(project-init-file (expand-file-name auto-load-project/project-file current-project-root)))
|
||||
(when (and (not (member current-project-root auto-load-project/loaded-projects))
|
||||
(file-exists-p project-init-file)
|
||||
(auto-load-project/trusted-gpg-origin-p project-init-file))
|
||||
(message "Loading project init file for %s" (projectile-project-name))
|
||||
(condition-case ex
|
||||
(progn (load project-init-file)
|
||||
(add-to-list 'auto-load-project/loaded-projects current-project-root)
|
||||
(message "%s loaded successfully" project-init-file))
|
||||
('error
|
||||
(message
|
||||
"There was an error loading %s: %s"
|
||||
project-init-file
|
||||
(error-message-string ex))))))))
|
||||
|
||||
(defvar auto-load-project-loaded-projects (list)
|
||||
"Projects that have been loaded by `auto-load-project-load-project-file'.")
|
||||
|
||||
(defun auto-load-project-load-project-file ()
|
||||
"Loads the `auto-load-project-project-file' for a project. This is run once
|
||||
after the project is loaded signifying project setup."
|
||||
(interactive)
|
||||
(when (projectile-project-p)
|
||||
(lexical-let* ((current-project-root (projectile-project-root))
|
||||
(project-init-file (expand-file-name auto-load-project-project-file current-project-root)))
|
||||
(when (and (not (member current-project-root auto-load-project-loaded-projects))
|
||||
(file-exists-p project-init-file)
|
||||
(auto-load-project-trusted-gpg-origin-p project-init-file))
|
||||
(message "Loading project init file for %s" (projectile-project-name))
|
||||
(condition-case ex
|
||||
(progn (load project-init-file)
|
||||
(add-to-list 'auto-load-project-loaded-projects current-project-root)
|
||||
(message "%s loaded successfully" project-init-file))
|
||||
('error
|
||||
(message
|
||||
"There was an error loading %s: %s"
|
||||
project-init-file
|
||||
(error-message-string ex))))))))
|
||||
(add-hook 'find-file-hook #'auto-load-project-load-project-file t)
|
||||
(add-hook 'dired-mode-hook #'auto-load-project-load-project-file t)))
|
||||
(add-hook 'find-file-hook #'auto-load-project/load t)
|
||||
(add-hook 'dired-mode-hook #'auto-load-project/load t)
|
||||
|
||||
(provide 'auto-load-project)
|
||||
|
||||
|
|
Loading…
Reference in a new issue