[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape 2376cf5400 010/123: Resolve symbols in config eval
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape 2376cf5400 010/123: Resolve symbols in config evaluation |
Date: |
Tue, 5 Dec 2023 03:57:56 -0500 (EST) |
branch: externals/dape
commit 2376cf5400fd72259b1b1510b0ae6b1c8b9f57bf
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>
Resolve symbols in config evaluation
---
README.org | 35 +++++++++++++++++-----------------
dape.el | 64 +++++++++++++++++++++++++++++++++++---------------------------
2 files changed, 54 insertions(+), 45 deletions(-)
diff --git a/README.org b/README.org
index a99382e3df..3b0b271854 100644
--- a/README.org
+++ b/README.org
@@ -44,16 +44,17 @@ Currently =Dape= does not come with any debug adapter
configuration.
#+end_src
* Differences with dap-mode
-~dap-mode~ is the most popular alternative and of course much more mature and
probably more feature rich (have not used ~dap-mode~ extensively).
+[[https://github.com/emacs-lsp/dap-mode][dap-mode]] is the most popular
alternative and is of course much more mature and probably more feature rich
(have not used ~dap-mode~ extensively).
Dape has no dependencies outside of packages included in emacs, and tries to
use get as much out of them possible.
Dape takes a slightly different approach to configuration.
+ Dape does not support ~launch.json~ files, if per project configuration is
needed use ~dir-locals~.
+ Tries to simplify configuration, by having just a plist.
-+ No magic, no special variables.
-+ Dape tries to improve config ergonomics in ~dape~ completing-read by
allowing to change and add plist entries in an already existing config,
example: ~adapter-config :port 5555~.
-+ No batteries included.
++ Dape tries to improve config ergonomics in ~dape~ completing-read by
allowing to change/add plist entries in an already existing config, example:
~adapter-config :program "/home/user/b.out" :compile "gcc -g -o b.out main.c "~.
++ No magic, no special variables. Instead, functions and variables are
resolved before starting a new session.
++ No batteries included. Many, suffer from a significant drawback: they're
tightly coupled with the vscode extension they're bundled with. This tight
coupling results in launch/attach requests being specific to each adapter,
devoid of reasonable defaults as they are stored within the extension itself,
leading to an ever-changing and unstable API. Consequently, attempting to
include default configurations for each adapter seems like a losing proposition.
++ Tries to be envision to how debug adapter configuration would be implemented
in emacs if vscode never existed.
Some might say that Dape has a nicer UI others might not.
@@ -78,8 +79,8 @@ Example launch configuration for ~node~.
command-args ("src/dapDebugServer.js" "8123")
:type "pwa-node"
:request "launch"
- :cwd ,dape-cwd-fn
- :program dape-find-file
+ :cwd dape-cwd-fn
+ :program dape-find-file-buffer-default
:outputCapture "console"
:sourceMapRenames t
:pauseForSourceMap nil
@@ -100,13 +101,13 @@ See
[[https://github.com/go-delve/delve/tree/master/Documentation/installation][
modes (go-mode go-ts-mode)
command "dlv"
command-args ("dap" "--listen" "127.0.0.1:55878")
- command-cwd ,dape-cwd-fn
+ command-cwd dape-cwd-fn
host "127.0.0.1"
port 55878
:type "debug"
:request "launch"
- :cwd ,dape-cwd-fn
- :program ,dape-cwd-fn)
+ :cwd dape-cwd-fn
+ :program dape-cwd-fn)
dape-configs)
#+end_src
@@ -118,16 +119,16 @@ Download latest
[[https://github.com/vadimcn/codelldb/releases][release]] and un
#+begin_src emacs-lisp
(add-to-list `(codelldb
modes (c-mode c-ts-mode
- c++-mode c++-ts-mode
- rust-ts-mode rust-mode)
+ c++-mode c++-ts-mode
+ rust-ts-mode rust-mode)
;; Replace vadimcn.vscode-lldb with the vsix directory you
just extracted
- command ,"vadimcn.vscode-lldb/adapter/codelldb"
+ command "vadimcn.vscode-lldb/adapter/codelldb"
host "localhost"
port 5818
command-args ("--port" "5818")
:type "lldb"
:request "launch"
- :cwd ,dape-cwd-fn
+ :cwd dape-cwd-fn
:program dape-find-file)
dape-configs)
#+end_src
@@ -145,10 +146,10 @@ Then ~chmod +x debugAdapters/bin/OpenDebugAD7~.
modes (c-mode c-ts-mode c++-mode c++-ts-mode)
command-cwd ,(file-name-directory
dape--cppdbg-command)
- command ,cppdbg-command
+ command cppdbg-command
:type "cppdbg"
:request "launch"
- :cwd ,dape-cwd-fn
+ :cwd dape-cwd-fn
:program dape-find-file
:MIMode ,(cond
((executable-find "gdb") "gdb")
@@ -168,8 +169,8 @@ Install debugpy with pip ~pip install debugpy~
command-args ("-m" "debugpy.adapter")
:type "executable"
:request "launch"
- :cwd ,dape-cwd-fn
- :program dape-find-file)
+ :cwd dape-cwd-fn
+ :program dape-find-file-buffer-default)
dape-configs)
#+end_src
diff --git a/dape.el b/dape.el
index c089b68749..edcb6d5bf5 100644
--- a/dape.el
+++ b/dape.el
@@ -71,7 +71,7 @@ Symbol Keys (Used by Dape):
Debug adapter connection in configuration:
- If only command is specified (without host and port), Dape
will communicate with the debug adapter through stdin/stdout.
-- If both host'and port are specified, Dape will connect to the
+- If both host and port are specified, Dape will connect to the
debug adapter. If `command is specified, Dape will wait until the
command is initiated before it connects with host and port.
@@ -81,9 +81,11 @@ Keywords in configuration:
information on how Dape serializes these keyword elements. Dape
uses nil as false.
-Functions in configuration:
+Functions and symbols in configuration:
If a value in a key is a function, the function's return value will
- replace the key's value before execution."
+ replace the key's value before execution.
+ If a value in a key is a symbol, the symbol will recursively resolve
+ at runtime."
:type '(alist :key-type (symbol :tag "Name")
:value-type
(plist :options
@@ -104,7 +106,6 @@ Functions in configuration:
"Dape buffers to open when debugging starts."
:type '(list (const dape-info) (const dape-repl)))
-
(defcustom dape-main-functions '("main")
"Functions to set breakpoints at startup if no other breakpoints are set."
:type '(list string))
@@ -143,7 +144,7 @@ Functions in configuration:
"Function to run compile with."
:type 'function)
-(defcustom dape-cwd-fn 'dape--default-cwd
+(defcustom dape-cwd-fn #'dape--default-cwd
"Function to get current working directory."
:type 'function)
@@ -310,11 +311,18 @@ The hook is run with one argument, the compilation
buffer."
(project-root project))
default-directory)))
-(defun dape-find-file ()
+(defun dape-find-file (&optional default)
(let* ((completion-ignored-extensions nil)
(default-directory (funcall dape-cwd-fn)))
(expand-file-name
- (read-file-name "Program: " default-directory nil t))))
+ (read-file-name (if default
+ (format "Program (default %s): " default)
+ "Program : ")
+ default-directory
+ default t))))
+
+(defun dape-find-file-buffer-default ()
+ (dape-find-file (buffer-file-name)))
(defun dape--overlay-region (&optional extended)
(list (line-beginning-position)
@@ -342,8 +350,6 @@ The hook is run with one argument, the compilation buffer."
'face 'font-lock-type-face))))))
-
-
;;; Process and parsing
(defconst dape--content-length-re
@@ -1085,7 +1091,7 @@ string is read as NAME and rest as element in CONFIG.
Interactive example:
launch :program \"bin\"
-Executes launch `dape-config' with :program as \"bin\"."
+Executes launch `dape-configs' with :program as \"bin\"."
(interactive (dape--read-config))
(unless (plist-get config 'start-debugging)
(dape-kill))
@@ -1096,8 +1102,8 @@ Executes launch `dape-config' with :program as \"bin\"."
(setq evaled-config
(dape--config-eval
(seq-reduce (apply-partially 'apply 'plist-put)
- (seq-partition config 2)
- (copy-tree base-config))))
+ (seq-partition config 2)
+ (copy-tree base-config))))
(when (called-interactively-p)
(push (dape--config-to-string name
base-config
@@ -1982,23 +1988,26 @@ Buffer contains debug session information."
((functionp value) (funcall-interactively value))
((plistp value) (dape--config-eval value))
((vectorp value) (cl-map 'vector #'eval-value value))
+ ((and (symbolp value)
+ (not (eq (symbol-value value) value)))
+ (funcall #'eval-value (symbol-value value)))
(t value))))
(cl-loop for (key value) on config by 'cddr
append (cond
((memq key '(modes)) (list key value))
- (t (list key (funcall #'eval-value value)))))))
+ (t (list key (funcall #'eval-value value)))))))
(defun dape--config-from-string (str)
(let (name read-config base-config)
(when (string-empty-p str)
- (user-error "Expected `dape-config' name."))
+ (user-error "Expected config name."))
(setq name (read str)
base-config (copy-tree (alist-get name dape-configs))
str (substring str (length (symbol-name name))))
(unless (string-empty-p str)
(setq read-config (read (format "(%s)" str))))
(unless (plistp read-config)
- (user-error "Unexpected `dape-config' format, see `dape'."))
+ (user-error "Unexpected config format, see `dape-configs'."))
(cl-loop for (key value) on read-config by 'cddr
do (setq base-config (plist-put base-config key value)))
(list name base-config)))
@@ -2010,7 +2019,7 @@ Buffer contains debug session information."
(defun dape--config-to-string (name pre-eval-config post-eval-config)
(let ((config-diff (dape--config-diff pre-eval-config
- post-eval-config)))
+ post-eval-config)))
(concat (format "%s" name)
(when-let ((config-str (and config-diff
(prin1-to-string config-diff))))
@@ -2021,18 +2030,17 @@ Buffer contains debug session information."
(defun dape--read-config ()
(let ((candidate
- (completing-read
- "Dape config: "
- (append
- (mapcan
- (lambda (name-config)
- (let* ((config (cdr name-config))
- (modes (plist-get config 'modes)))
- (when (apply 'provided-mode-derived-p major-mode modes)
- (list (car name-config)))))
- dape-configs)
- dape--config-history)
- nil nil nil 'dape-history)))
+ (completing-read "Dape config: "
+ (append
+ (mapcan
+ (lambda (name-config)
+ (let* ((config (cdr name-config))
+ (modes (plist-get config 'modes)))
+ (when (apply 'provided-mode-derived-p
major-mode modes)
+ (list (car name-config)))))
+ dape-configs)
+ dape--config-history)
+ nil nil nil 'dape-history)))
(if-let ((config
(alist-get (intern candidate) dape-configs)))
(list (intern candidate) config)
- [elpa] branch externals/dape created (now b52882f627), ELPA Syncer, 2023/12/05
- [elpa] externals/dape 3e15266d78 030/123: Remove function symbols from config options diff, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 813ace9e69 033/123: Fix vector options eval, ELPA Syncer, 2023/12/05
- [elpa] externals/dape e804aca510 008/123: Readme fixups, ELPA Syncer, 2023/12/05
- [elpa] externals/dape b7f68f1b96 021/123: Update readme with a bit more helpful path example, ELPA Syncer, 2023/12/05
- [elpa] externals/dape c7c085a94a 012/123: Added roadmap, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2376cf5400 010/123: Resolve symbols in config evaluation,
ELPA Syncer <=
- [elpa] externals/dape ed37a0cd5b 025/123: Add exception breakpoints, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 8418a68442 026/123: Fix repl faces, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 815a880f48 027/123: Rename dape input vars, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 4eb75e39b2 031/123: Small readme fixup, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 04aabf1862 041/123: Update screenshots, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 95d52ea585 044/123: Fix parsing of codelldb adapter output on windows #1, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 3d800b349e 045/123: Add godot example config, ELPA Syncer, 2023/12/05
- [elpa] externals/dape b42b7def86 046/123: Fix timers when repl buffer is not available, ELPA Syncer, 2023/12/05
- [elpa] externals/dape efcfc93003 047/123: Fix duplicate variable overlays, ELPA Syncer, 2023/12/05
- [elpa] externals/dape cacddbb8e7 057/123: Improve error printout and do a better job of validating config, ELPA Syncer, 2023/12/05