[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/buffer-env 033f04fd27 10/12: Command to display the pro
From: |
ELPA Syncer |
Subject: |
[elpa] externals/buffer-env 033f04fd27 10/12: Command to display the process environment |
Date: |
Mon, 28 Feb 2022 15:57:26 -0500 (EST) |
branch: externals/buffer-env
commit 033f04fd27ae3207c851b23a797a2a718763b0a4
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Command to display the process environment
---
buffer-env.el | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/buffer-env.el b/buffer-env.el
index 808114d1bf..87299fe4ac 100644
--- a/buffer-env.el
+++ b/buffer-env.el
@@ -162,5 +162,47 @@ When called interactively, ask for a FILE."
(kill-local-variable 'process-environment)
(kill-local-variable 'exec-path))
+(defun buffer-env--sorted (vars)
+ "Sort and remove duplicates in the list of environment VARS."
+ (let ((testfn (lambda (x y)
+ (string= (progn (string-match "[^=]*" x)
+ (match-string 0 x))
+ (progn (string-match "[^=]*" y)
+ (match-string 0 y))))))
+ (sort (seq-uniq vars testfn) 'string<)))
+
+(defun buffer-env-inspect ()
+ "Compare buffer-local and global process environments."
+ (interactive)
+ (if (not (local-variable-p 'process-environment))
+ (message "Buffer has the default process environment")
+ (let ((name (buffer-name (current-buffer)))
+ (script buffer-env-active)
+ (local (buffer-env--sorted process-environment))
+ (global (buffer-env--sorted (default-toplevel-value
'process-environment)))
+ (buffer (get-buffer-create "*buffer-env*"))
+ (inhibit-read-only t))
+ (with-current-buffer buffer
+ (special-mode)
+ (erase-buffer)
+ (insert "The process environment of buffer ‘" name
+ "’ was generated by the script ‘" (or script "??") "’.")
+ (fill-paragraph)
+ (insert "\n\nOnly in the local process environment:\n\n")
+ (add-face-text-property (line-beginning-position -2) (point) 'bold)
+ (if-let ((vars (seq-difference local global)))
+ (dolist (var vars) (insert var ?\n))
+ (insert "(None)"))
+ (insert "\nOnly in the global process environment:\n\n")
+ (add-face-text-property (line-beginning-position -2) (point) 'bold)
+ (if-let ((vars (seq-difference global local)))
+ (dolist (var vars) (insert var ?\n))
+ (insert "(None)"))
+ (insert "\nComplete process environment of the buffer:\n\n")
+ (add-face-text-property (line-beginning-position -2) (point) 'bold)
+ (dolist (var local) (insert var ?\n))
+ (goto-char (point-min)))
+ (display-buffer buffer))))
+
(provide 'buffer-env)
;;; buffer-env.el ends here
- [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, 2022/02/28
- [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 <=
- [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