Snippet to browse dap-breakpoints with completing-read
This snippet shows the line the breakpoint is on in the selection, and if you enter it you will be taken to the breakpoint in the code.
(defun my/browse-breakpoints ()
(interactive)
(let* ((entries (-map (lambda (item)
(let* ((filename (nth 0 (alist-get 'file-name item)))
(linenumber (alist-get 'line item))
(line-content
(save-window-excursion
(find-file filename)
(goto-char (point-min))
(forward-line (1- linenumber))
(buffer-substring (line-beginning-position) (line-end-position)))))
(format "%s: %s: %s" filename linenumber line-content)))
(bui-get-entries 'dap-ui-breakpoints-ui 'list)))
(choice
(split-string
(completing-read "Select breakpoint: " entries)
":"))
(file-name (car choice))
(line-number (string-to-number (nth 1 choice))))
(find-file file-name)
(goto-char (point-min))
(forward-line (1- line-number))))
My site is free of ads and trackers. Was this post helpful to you? Why not
Disqus is great for comments/feedback but I had no idea it came with these gaudy ads.