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

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

[elpa] externals/inspector d374a56c8c 2/3: Add prefix argument commands


From: ELPA Syncer
Subject: [elpa] externals/inspector d374a56c8c 2/3: Add prefix argument commands as recipe to the README
Date: Fri, 5 May 2023 09:58:47 -0400 (EDT)

branch: externals/inspector
commit d374a56c8c04905c88fa2550802a197e7d753b88
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>

    Add prefix argument commands as recipe to the README
---
 README.md | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/README.md b/README.md
index 187e4f8dd9..ebc87ba78c 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,38 @@ Works together with the "normal" inspector when it is 
loaded; when an object lab
 
 Then start the inspector with either `M-x tree-inspector-inspect-expression` 
or `M-x tree-inspector-inspect-last-sexp`.
 
+### Setup evaluation commands using prefix arguments
+
+Instead of bothering setting up different key bindings for elisp evaluation 
and inspection, it can be handy to have both in the same command, and use 
prefix arguments to differenciate, like this:
+
+```emacs-lisp
+
+;;;###autoload
+(defun inspector-eval-expression (arg)
+  "Like `eval-expression', but also inspect when called with prefix ARG."
+  (interactive "P")
+  (pcase arg
+    ('(4) (let ((current-prefix-arg nil))
+           (call-interactively #'inspector-inspect-expression)))
+    (_ (call-interactively #'eval-expression))))
+       
+;;;###autoload
+(defun inspector-eval-last-sexp (arg)
+  "Like `eval-last-sexp', but also inspect when called with prefix ARG."
+  (interactive "P")
+  (pcase arg
+    ('(4) (inspector-inspect-last-sexp))
+    (_ (call-interactively #'eval-last-sexp))))
+```
+
+Setup key bindings:
+
+```emacs-lisp
+(define-key global-map [remap eval-last-sexp] #'inspector-eval-last-sexp)
+(define-key global-map [remap eval-expression] #'inspector-eval-expression)
+```
+and then use `C-u C-x C-e` and `C-u M-:` as alternatives to `eval-last-sexp` 
and `eval-expression`.
+
 ### For `evil/vim` user
 
 - Add this to your config file



reply via email to

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