Browse Source

Add a command to list and jump to breakpoints

workspaces
Nicolas Petton 3 years ago
parent
commit
07c3d444de
3 changed files with 31 additions and 2 deletions
  1. +4
    -1
      doc/Indium.texi
  2. +26
    -1
      indium-interaction.el
  3. +1
    -0
      sphinx-doc/code-evaluation.rst

+ 4
- 1
doc/Indium.texi View File

@ -21,7 +21,7 @@
@copying
@quotation
Indium 0.5.0, May 23, 2017
Indium 0.5.0, May 24, 2017
Nicolas Petton
@ -630,6 +630,9 @@ You need to first make sure that Indium is set up correctly to use local files
@item
@code{C-c b K}: Remove all breakpoints from the current buffer
@item
@code{C-c b l}: List all breakpoints and easily jump to any breakpoint
@item
@code{C-c b d}: Deactivate all breakpoints (the runtime won't pause when hitting a breakpoint)


+ 26
- 1
indium-interaction.el View File

@ -29,6 +29,7 @@
(require 'map)
(require 'seq)
(require 'subr-x)
(require 'xref)
(require 'easymenu)
(require 'indium-backend)
@ -153,6 +154,28 @@ hitting a breakpoint."
(indium-backend-activate-breakpoints (indium-backend))
(message "Breakpoints activated"))
(defun indium-list-breakpoints ()
"List all breakpoints in the current connection."
(interactive)
(xref--show-xrefs (indium--make-xrefs-from-breakpoints) nil))
(defun indium--make-xrefs-from-breakpoints ()
"Return a list of xref objects from all breakpoints."
(seq-map (lambda (breakpoint)
(xref-make (indium--get-breakpoint-xref-match breakpoint)
(xref-make-file-location (map-elt breakpoint 'file)
(1+ (map-elt breakpoint 'line))
0)))
(indium-backend-get-breakpoints)))
(defun indium--get-breakpoint-xref-match (breakpoint)
"Return the source line where BREAKPOINT is set."
(with-current-buffer (find-file-noselect (map-elt breakpoint 'file))
(save-excursion
(goto-char (point-min))
(forward-line (map-elt breakpoint 'line))
(buffer-substring (point-at-bol) (point-at-eol)))))
(defun indium-interaction-node-before-point ()
"Return the node before point to be evaluated."
(save-excursion
@ -201,6 +224,7 @@ hitting a breakpoint."
(define-key map (kbd "C-c b K") #'indium-remove-all-breakpoints-from-buffer)
(define-key map (kbd "C-c b a") #'indium-activate-breakpoints)
(define-key map (kbd "C-c b d") #'indium-deactivate-breakpoints)
(define-key map (kbd "C-c b l") #'indium-list-breakpoints)
(easy-menu-define indium-interaction-mode-menu map
"Menu for Indium interaction mode"
'("Indium interaction"
@ -217,7 +241,8 @@ hitting a breakpoint."
["Remove breakpoint" indium-remove-breakpoint]
["Remove all breakpoints" indium-remove-all-breakpoints-from-buffer]
["Deactivate breakpoints" indium-deactivate-breakpoints]
["Activate breakpoints" indium-activate-breakpoints])))
["Activate breakpoints" indium-activate-breakpoints]
["List all breakpoints" indium-list-breakpoints])))
map))
(define-minor-mode indium-interaction-mode


+ 1
- 0
sphinx-doc/code-evaluation.rst View File

@ -40,6 +40,7 @@ You need to first make sure that Indium is set up correctly to use local files
- ``C-c b c``: Add a conditional breakpoint
- ``C-c b k``: Remove a breakpoint
- ``C-c b K``: Remove all breakpoints from the current buffer
- ``C-c b l``: List all breakpoints and easily jump to any breakpoint
- ``C-c b d``: Deactivate all breakpoints (the runtime won't pause when hitting a breakpoint)
- ``C-c b a``: Activate all breakpoints (it has no effect if breakpoints have not been deactivated)


Loading…
Cancel
Save