[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/buffer-env 564c3679c8 11/12: Add mode line indicator an
From: |
ELPA Syncer |
Subject: |
[elpa] externals/buffer-env 564c3679c8 11/12: Add mode line indicator and make messages optional |
Date: |
Mon, 28 Feb 2022 15:57:26 -0500 (EST) |
branch: externals/buffer-env
commit 564c3679c8ed56894b005c3027b2a34a20c9c2c0
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Add mode line indicator and make messages optional
---
buffer-env.el | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
diff --git a/buffer-env.el b/buffer-env.el
index 87299fe4ac..acb10a090d 100644
--- a/buffer-env.el
+++ b/buffer-env.el
@@ -79,12 +79,36 @@ content."
(defcustom buffer-env-ignored-variables
'("_=" "PS1=" "SHLVL=" "DISPLAY=" "PWD=")
"List of environment variables to ignore."
- :type '(string))
+ :type '(repeat string))
(defcustom buffer-env-extra-variables
'("TERM=dumb")
"List of additional environment variables."
- :type '(string))
+ :type '(repeat string))
+
+(defcustom buffer-env-verbose nil
+ "Whether to display a message every time `buffer-env-update' runs
successfully."
+ :type 'boolean)
+
+(defcustom buffer-env-mode-line " Env"
+ "Mode line indicator for buffers affected by buffer-env."
+ :type '(choice string (const :tag "No indicator" nil)))
+
+(defvar-local buffer-env-active nil
+ "Non-nil if a buffer-local process environment has been set.
+In this case, this is the name of the script used to generate it.")
+
+(setf (alist-get 'buffer-env-active minor-mode-alist)
+ '((:propertize
+ buffer-env-mode-line
+ help-echo "\
+Process environment is buffer local\n\
+mouse-1: Inspect process environment\n\
+mouse-2: Reset to default process environment"
+ mouse-face mode-line-highlight
+ local-map (keymap (mode-line keymap
+ (mouse-1 . buffer-env-inspect)
+ (mouse-2 . buffer-env-reset))))))
(defun buffer-env--authorize (file)
"Check if FILE is safe to execute, or ask for permission.
@@ -150,17 +174,19 @@ When called interactively, ask for a FILE."
(when-let* ((path (getenv "PATH")))
(setq-local exec-path (nconc (split-string path path-separator)
(list exec-directory))))
- (unless (string-prefix-p " " (buffer-name (current-buffer)))
+ (when buffer-env-verbose
(message "[buffer-env] Environment of `%s' set from `%s'"
- (current-buffer)
- file))))
+ (current-buffer) file))
+ (setq buffer-env-active file)))
;;;###autoload
(defun buffer-env-reset ()
- "Reset this buffer's process environment to the global values."
+ "Reset the process environment of this buffer to the default values."
(interactive)
+ (kill-local-variable 'buffer-env-active)
(kill-local-variable 'process-environment)
- (kill-local-variable 'exec-path))
+ (kill-local-variable 'exec-path)
+ (force-mode-line-update))
(defun buffer-env--sorted (vars)
"Sort and remove duplicates in the list of environment VARS."
- [elpa] branch externals/buffer-env created (now dc7342277f), ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env a12a914cd5 05/12: No message for hidden buffers, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env 32c1cfdf06 08/12: Add a Readme, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env 564c3679c8 11/12: Add mode line indicator and make messages optional,
ELPA Syncer <=
- [elpa] externals/buffer-env 4ed60c9fee 03/12: Add a separate buffer-env--locate-script function, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env eb4cf91f7b 02/12: Refinements in defcustoms, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env 3568a9f426 01/12: Initial commit, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env 5f4e2258ff 04/12: Add buffer-env-reset, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env f05d5bd1e7 07/12: Fix checkdoc and package-lint issues, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env 033f04fd27 10/12: Command to display the process environment, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env ed0a4b31ce 06/12: Some simplifications, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env f3781a628a 09/12: Update README, ELPA Syncer, 2022/02/28
- [elpa] externals/buffer-env dc7342277f 12/12: Release on ELPA, ELPA Syncer, 2022/02/28