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

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

[elpa] externals/dape 8cc8b262c1 059/123: Add custom formatting to dape-


From: ELPA Syncer
Subject: [elpa] externals/dape 8cc8b262c1 059/123: Add custom formatting to dape-info variables
Date: Tue, 5 Dec 2023 03:58:00 -0500 (EST)

branch: externals/dape
commit 8cc8b262c15a4168747b5f92fc4e2e3048f839f6
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>

    Add custom formatting to dape-info variables
    
    Multi line strings in the dape-info buffer looks off, add custom flag
    for turning it on again.
---
 dape.el | 66 +++++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 38 insertions(+), 28 deletions(-)

diff --git a/dape.el b/dape.el
index 235e265462..838a515f24 100644
--- a/dape.el
+++ b/dape.el
@@ -168,8 +168,12 @@ The hook is run with one argument, the compilation buffer."
   "Maximum length of inline variable overlays."
   :type 'natnum)
 
-(defcustom dape--debug-on
-  '(io info error std-server)
+(defcustom dape-info-buffer-variable-format 'line
+  "How variables are formatted in *dape-info* buffer."
+  :type '(choice (const :tag "Truncate string at new line" line)
+                 (const :tag "No formatting" nil)))
+
+(defcustom dape--debug-on '(io info error std-server)
   "Types of logs should be printed to *dape-debug*."
   :type '(set (const :tag "dap IO" io)
               (const :tag "info logging" info)
@@ -1900,32 +1904,38 @@ Depth is decided by `dape--info-variables-fetch-depth'."
 
 (defun dape--variable-to-widget (tree variable)
   "Create variable widget from VARIABLE under TREE."
-  (cond
-   ((zerop (plist-get variable :variablesReference))
-    (widget-convert
-     'item
-     :tag (dape--variable-string variable)))
-   (t
-    (widget-convert
-     'dape--tree-widget
-     :parent tree
-     :key (plist-get variable :name)
-     :default (equal (plist-get variable :presentationHint) "locals")
-     :tag (dape--variable-string variable)
-     :expander-p
-     (lambda (tree)
-       (if (plist-get variable :variables)
-           t
-         (dape--variables (dape--live-process)
-                          variable
-                          (dape--callback
-                           (when (plist-get variable :variables)
-                             (dape--info-update-widget tree))))
-         nil))
-     :expander
-     (lambda (tree)
-       (mapcar (apply-partially 'dape--variable-to-widget tree)
-               (plist-get variable :variables)))))))
+  (let ((variable-string (dape--variable-string variable)))
+    ;; Apply formatting
+    (when (eq dape-info-buffer-variable-format 'line)
+      (setq variable-string
+            (substring variable-string
+                       0 (string-match-p "\n" variable-string))))
+    (cond
+     ((zerop (plist-get variable :variablesReference))
+      (widget-convert
+       'item
+       :tag variable-string))
+     (t
+      (widget-convert
+       'dape--tree-widget
+       :parent tree
+       :key (plist-get variable :name)
+       :default (equal (plist-get variable :presentationHint) "locals")
+       :tag variable-string
+       :expander-p
+       (lambda (tree)
+         (if (plist-get variable :variables)
+             t
+           (dape--variables (dape--live-process)
+                            variable
+                            (dape--callback
+                             (when (plist-get variable :variables)
+                               (dape--info-update-widget tree))))
+           nil))
+       :expander
+       (lambda (tree)
+         (mapcar (apply-partially 'dape--variable-to-widget tree)
+                 (plist-get variable :variables))))))))
 
 (defun dape--expand-scopes-p (tree)
   "Expander predicate for `dape--scopes-widget'."



reply via email to

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