@@ -433,15 +433,12 @@ This is in contrast to merely setting it to 0."
433433 (lsp-workspace-set-metadata " Breakpoints" breakpoints)
434434 breakpoints)))
435435
436- (defun dap--persist (file-name to-persist )
437- " Persist TO-PERSIST.
438-
439- FILE-NAME the file name.
440- WORKSPACE will be used to calculate root folder."
436+ (defun dap--persist (file to-persist )
437+ " Serialize TO-PERSIST to FILE."
441438 (with-demoted-errors
442439 " Failed to persist file: %S"
443- (make-directory (file-name-directory file-name ) t )
444- (with-temp-file file-name
440+ (make-directory (file-name-directory file) t )
441+ (with-temp-file file
445442 (erase-buffer )
446443 (insert (prin1-to-string to-persist)))))
447444
@@ -454,7 +451,7 @@ WORKSPACE will be used to calculate root folder."
454451 " Persist BREAKPOINTS."
455452 ; ; filter markers before persisting the breakpoints (markers are not
456453 ; ; writeable) and update the point based on the marker.
457- (- let [ filtered-breakpoints (make-hash-table :test 'equal )]
454+ (let (( filtered-breakpoints (make-hash-table :test 'equal )))
458455 (maphash (lambda (k v )
459456 (puthash k (-map (-lambda ((bkp &as &plist :marker :point ))
460457 (-> bkp
@@ -991,7 +988,7 @@ PARAMS are the event params.")
991988 (or
992989 (when (string= kind " external" )
993990 (let* ((name (or title (concat (dap--debug-session-name debug-session)
994- " - terminal" )))
991+ " - terminal" )))
995992 (terminal-argv
996993 (cl-loop for part in dap-external-terminal collect
997994 (->> part (s-replace " {display}" name)
@@ -1366,65 +1363,6 @@ DEBUG-SESSIONS - list of the currently active sessions."
13661363 (get-buffer-window-list ))))
13671364 (current-buffer )))
13681365
1369- (defun dap-start-debugging-noexpand (launch-args )
1370- " Start debug session with LAUNCH-ARGS.
1371- Special arguments:
1372-
1373- :wait-for-port - boolean defines whether the debug configuration
1374- should be started after the :port argument is taken.
1375-
1376- :program-to-start - when set it will be started using `compilation-start'
1377- before starting the debug process."
1378- (-let* (((&plist :name :skip-debug-session :cwd :program-to-start
1379- :wait-for-port :type :request :port
1380- :startup-function :environment-variables :hostName host) launch-args)
1381- (session-name (dap--calculate-unique-name name (dap--get-sessions)))
1382- (default-directory (or cwd default-directory))
1383- program-process)
1384- (mapc (-lambda ((env . value)) (setenv env value)) environment-variables)
1385- (plist-put launch-args :name session-name)
1386-
1387- (when program-to-start
1388- (setf program-process
1389- (get-buffer-process
1390- (compilation-start program-to-start 'dap-server-log-mode
1391- (lambda (_ ) (concat " *" session-name " server log*" ))))))
1392- (when wait-for-port
1393- (dap--wait-for-port host port dap-connect-retry-count dap-connect-retry-interval))
1394-
1395- (when startup-function (funcall startup-function launch-args))
1396-
1397- (unless skip-debug-session
1398- (let ((debug-session (dap--create-session launch-args)))
1399- (setf (dap--debug-session-program-proc debug-session) program-process)
1400- (dap--send-message
1401- (dap--initialize-message type)
1402- (dap--session-init-resp-handler
1403- debug-session
1404- (lambda (initialize-result )
1405- (-let [debug-sessions (dap--get-sessions)]
1406-
1407- (setf (dap--debug-session-initialize-result debug-session) initialize-result)
1408-
1409- (dap--set-sessions (cons debug-session debug-sessions)))
1410- (dap--send-message
1411- (dap--make-request request (-> launch-args
1412- (cl-copy-list )
1413- (dap--plist-delete :cleanup-function )
1414- (dap--plist-delete :startup-function )
1415- (dap--plist-delete :dap-server-path )
1416- (dap--plist-delete :environment-variables )
1417- (dap--plist-delete :wait-for-port )
1418- (dap--plist-delete :skip-debug-session )
1419- (dap--plist-delete :program-to-start )))
1420- (dap--session-init-resp-handler debug-session)
1421- debug-session)))
1422- debug-session)
1423-
1424- (dap--set-cur-session debug-session)
1425- (push (cons session-name launch-args) dap--debug-configuration)
1426- (run-hook-with-args 'dap-session-created-hook debug-session)))))
1427-
14281366(declare-function dap-variables-expand " dap-variables" (plist))
14291367(defvar dap-variables-project-root-function )
14301368(defun dap-variables-expand-in-launch-configuration (conf )
@@ -1433,13 +1371,6 @@ before starting the debug process."
14331371 (let ((dap-variables-project-root-function #'lsp-workspace-root ))
14341372 (dap-variables-expand conf)))
14351373
1436- (defun dap-start-debugging (conf )
1437- " Like `dap-start-debugging-noexpand' , but expand variables.
1438- CONF's variables are expanded before being passed to
1439- `dap-start-debugging' ."
1440- (dap-start-debugging-noexpand
1441- (dap-variables-expand-in-launch-configuration conf)))
1442-
14431374(defun dap--set-breakpoints-in-file (file file-breakpoints )
14441375 " Establish markers for FILE-BREAKPOINTS in FILE."
14451376 (-when-let (buffer (get-file-buffer file))
@@ -1452,7 +1383,7 @@ CONF's variables are expanded before being passed to
14521383 (run-hooks 'dap-breakpoints-changed-hook ))))
14531384
14541385(defun dap--read-from-file (file )
1455- " Read FILE content ."
1386+ " Read a lisp expression from FILE ."
14561387 (with-temp-buffer
14571388 (insert-file-contents file)
14581389 (cl-first (read-from-string
@@ -1641,6 +1572,72 @@ list are called and their results (which must be lists) are
16411572concatenated. The user can then choose one of them from the
16421573resulting list." )
16431574
1575+ (defun dap-start-debugging (conf )
1576+ " Like `dap-start-debugging-noexpand' , but expand variables.
1577+ CONF's variables are expanded before being passed to
1578+ `dap-start-debugging' ."
1579+ (dap-start-debugging-noexpand
1580+ (dap-variables-expand-in-launch-configuration conf)))
1581+
1582+ (defun dap-start-debugging-noexpand (launch-args )
1583+ " Start debug session with LAUNCH-ARGS.
1584+ Special arguments:
1585+
1586+ :wait-for-port - boolean defines whether the debug configuration
1587+ should be started after the :port argument is taken.
1588+
1589+ :program-to-start - when set it will be started using `compilation-start'
1590+ before starting the debug process."
1591+ (-let* (((&plist :name :skip-debug-session :cwd :program-to-start
1592+ :wait-for-port :type :request :port
1593+ :startup-function :environment-variables :hostName host) launch-args)
1594+ (session-name (dap--calculate-unique-name name (dap--get-sessions)))
1595+ (default-directory (or cwd default-directory))
1596+ program-process)
1597+ (mapc (-lambda ((env . value)) (setenv env value)) environment-variables)
1598+ (plist-put launch-args :name session-name)
1599+
1600+ (when program-to-start
1601+ (setf program-process
1602+ (get-buffer-process
1603+ (compilation-start program-to-start 'dap-server-log-mode
1604+ (lambda (_ ) (concat " *" session-name " server log*" ))))))
1605+ (when wait-for-port
1606+ (dap--wait-for-port host port dap-connect-retry-count dap-connect-retry-interval))
1607+
1608+ (when startup-function (funcall startup-function launch-args))
1609+
1610+ (unless skip-debug-session
1611+ (let ((debug-session (dap--create-session launch-args)))
1612+ (setf (dap--debug-session-program-proc debug-session) program-process)
1613+ (dap--send-message
1614+ (dap--initialize-message type)
1615+ (dap--session-init-resp-handler
1616+ debug-session
1617+ (lambda (initialize-result )
1618+ (-let [debug-sessions (dap--get-sessions)]
1619+
1620+ (setf (dap--debug-session-initialize-result debug-session) initialize-result)
1621+
1622+ (dap--set-sessions (cons debug-session debug-sessions)))
1623+ (dap--send-message
1624+ (dap--make-request request (-> launch-args
1625+ (cl-copy-list )
1626+ (dap--plist-delete :cleanup-function )
1627+ (dap--plist-delete :startup-function )
1628+ (dap--plist-delete :dap-server-path )
1629+ (dap--plist-delete :environment-variables )
1630+ (dap--plist-delete :wait-for-port )
1631+ (dap--plist-delete :skip-debug-session )
1632+ (dap--plist-delete :program-to-start )))
1633+ (dap--session-init-resp-handler debug-session)
1634+ debug-session)))
1635+ debug-session)
1636+
1637+ (dap--set-cur-session debug-session)
1638+ (push (cons session-name launch-args) dap--debug-configuration)
1639+ (run-hook-with-args 'dap-session-created-hook debug-session)))))
1640+
16441641;;;### autoload
16451642(defun dap-debug (debug-args )
16461643 " Run debug configuration DEBUG-ARGS.
0 commit comments