emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/buffer-env 2b3d95eb57 1/2: Rename buffer-env-inspect to


From: ELPA Syncer
Subject: [elpa] externals/buffer-env 2b3d95eb57 1/2: Rename buffer-env-inspect to buffer-env-describe, use help-mode
Date: Wed, 16 Mar 2022 16:57:18 -0400 (EDT)

branch: externals/buffer-env
commit 2b3d95eb57dafd0ae9c6462b2e31b3fad19d2812
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Rename buffer-env-inspect to buffer-env-describe, use help-mode
---
 buffer-env.el | 56 +++++++++++++++++++++++++-------------------------------
 1 file changed, 25 insertions(+), 31 deletions(-)

diff --git a/buffer-env.el b/buffer-env.el
index b8657095c9..63b6fbe2fb 100644
--- a/buffer-env.el
+++ b/buffer-env.el
@@ -103,11 +103,11 @@ In this case, this is the name of the script used to 
generate it.")
          buffer-env-mode-line
          help-echo "\
 Process environment is buffer local\n\
-mouse-1: Inspect process environment\n\
+mouse-1: Describe 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-1 . buffer-env-describe)
                                       (mouse-2 . buffer-env-reset))))))
 
 (defun buffer-env--authorize (file)
@@ -197,38 +197,32 @@ When called interactively, ask for a FILE."
                                   (match-string 0 y))))))
     (sort (seq-uniq vars testfn) 'string<)))
 
-(defun buffer-env-inspect ()
+(defun buffer-env-describe (&optional buffer)
   "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)
+  (setq buffer (or buffer (current-buffer)))
+  (with-current-buffer buffer
+    (let ((script (or 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))))
+          (global (buffer-env--sorted (default-toplevel-value 
'process-environment))))
+      (help-setup-xref (list #'buffer-env-describe buffer)
+                      (called-interactively-p 'interactive))
+      (with-help-window (help-buffer)
+        (with-current-buffer standard-output
+          (insert "The process environment of buffer ‘" (buffer-name buffer)
+                  "’ was generated by the script ‘" script "’.")
+          (fill-paragraph)
+          (insert "\n\nOnly in the local process environment:\n")
+          (if-let ((vars (seq-difference local global)))
+              (dolist (var vars) (insert "    " var ?\n))
+            (insert "    (None)\n"))
+          (insert "\nOnly in the global process environment:\n")
+          (if-let ((vars (seq-difference global local)))
+              (dolist (var vars) (insert "    " var ?\n))
+            (insert "    (None)\n"))
+          (insert "\nComplete process environment of the buffer:\n")
+          (dolist (var local) (insert "    " var ?\n))
+          (goto-char (point-min)))))))
 
 (provide 'buffer-env)
 ;;; buffer-env.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]