dape icon indicating copy to clipboard operation
dape copied to clipboard

dape-repl with debugpy doesn't run dape commands?

Open glyph opened this issue 8 months ago • 2 comments

Thanks for dape! This is the first emacs debugger I have ever used that actually worked out of the box without a bunch of configuration (although I did already know that I needed to pip install debugpy before I tried it). Kudos!

As I would expect, the dape repl runs Python code if I'm debugging a Python process.

However, it begins with the message:

* Welcome to Dape REPL! *
Available Dape commands: debug, next, continue, pause, step, out, up, down, threads, stack, modules, sources, breakpoints, scope, watch, restart, kill, disconnect, quit
Empty input will rerun last command.

with prefixes of the commands highlighted.

I would therefore expect that if I type, e.g. s and hit enter, dape would single-step, but instead, I get

Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 's' is not defined. Did you mean: 'os'?

glyph avatar Apr 03 '25 06:04 glyph

Hey and thank you for your bug report!

This is what I would expect as well, dape is looking for an exact match so if there is any space before or after it sends it through to the adapter. This behavior is more or less a hack to be able to evaluate stuff that collides with the "Dape commands".

If you M-x trace-function dape--repl-input-sender all calls to dape--repl-input-sender which handles all that stuff should be displayed in *trace-output* buffer.

It should be something like the following after s + enter in the repl?

======================================================================
1 -> (dape--repl-input-sender #<process dape repl> #("s" 0 1 (fontified t)))
1 <- dape--repl-input-sender: t

What is the contents of that buffer on your machine?

And also do you have any special customization to comint-mode?

Run M-x untrace-all to get rid of the tracing.

svaante avatar Apr 08 '25 20:04 svaante

Thanks for your response!

I followed your directions and I suspected it might be something like this:

======================================================================
1 -> (dape--repl-input-sender #<process dape-repl> #("s\n" 0 1 (fontified t) 1 2 (fontified t)))
1 <- dape--repl-input-sender: nil

Note the \n. The only customization I could find in my personal setup related to comint was (global-set-key (kbd "C-M-/") 'comint-dynamic-complete-filename) but I doubt very much that has anything to do with this. I do have some packages installed; here's a full list if it helps:

  ac-helm                        20160319.233   installed             Helm interface for auto-complete.
  achievements                   20240703.318   installed             Achievements for emacs usage.
  actionscript-mode              20180527.1701  installed             A simple mode for editing Actionscript 3 files.
  ag                             20201031.2202  installed             A front-end for ag ('the silver searcher'), the C ack replacement.
  alect-themes                   20211022.1651  installed             Configurable light, dark and black themes for Emacs 24 or later.
  apples-mode                    20110121.418   installed             Major mode for editing and executing AppleScript code.
  auto-complete                  20250101.843   installed             Auto Completion for GNU Emacs.
  blacken                        20231129.654   installed             Reformat python buffers using the "black" formatter.
  bubbleberry-theme              20141017.944   installed             A theme based on LightTable for Emacs24.
  color-theme-sanityinc-tomorrow 20250401.1320  installed             A version of Chris Kempson's "tomorrow" themes.
  column-enforce-mode            20200605.1933  installed             Highlight text that extends beyond a  column.
  corral                         20160502.948   installed             Quickly surround text with delimiters.
  cython-mode                    20221130.1257  installed             Major mode for editing Cython files.
  dape                           0.23.0         installed             Debug Adapter Protocol for Emacs
  diff-hl                        20250407.34    installed             Highlight uncommitted changes using VC.
  dockerfile-mode                20250315.1426  installed             Major mode for editing Docker's Dockerfiles.
  dsvn                           20221102.1416  installed             Subversion interface.
  ecb                            20170728.1921  installed             A code browser for Emacs.
  ein                            20250307.1731  installed             Jupyter notebook client.
  eterm-256color                 20210224.2241  installed             Customizable 256 colors for term
  evil                           20250318.1816  installed             Extensible vi layer.
  evil-surround                  20240325.852   installed             Emulate surround.vim from Vim.
  exec-path-from-shell           20240411.859   installed             Get environment variables such as $PATH from the shell.
  fliptext                       20171124.2056  installed             Input method for flipping characters upside down.
  flycheck                       20250226.1541  installed             On-the-fly syntax checking.
  flycheck-pyflakes              20240124.101   installed             Support pyflakes in flycheck.
  graphviz-dot-mode              20230325.1050  installed             Mode for the dot-language used by graphviz (att).
  haste                          20141030.2034  installed             Emacs client for hastebin (http://hastebin.com/about.md).
  helm                           20250412.550   installed             Helm is an Emacs incremental and narrowing framework.
  helm-core                      20250411.545   installed             Development files for Helm.
  helm-git-grep                  20170614.1411  installed             Helm for git grep, an incremental git-grep(1).
  helm-ls-git                    20250405.1006  installed             The git project manager for helm.
  highlight-indentation          20210221.1418  installed             Minor modes for highlighting indentation.
  imenu-anywhere                 20210201.1704  installed             Ido/ivy/helm imenu across same mode/project/etc buffers.
  importmagic                    20180520.303   installed             Fix Python imports using importmagic.
  isortify                       20230821.1632  installed             (automatically) format python buffers using isort.
  jedi                           20191011.1750  installed             A Python auto-completion for Emacs.
  js2-mode                       20241205.140   installed             Improved JavaScript editing mode.
  json-mode                      20240427.1245  installed             Major mode for editing JSON files.
  magit                          20250401.1753  installed             A Git porcelain inside Emacs.
  magit-section                  20250401.1753  installed             Sections for read-only buffers.
  markdown-mode                  20250403.1127  installed             Major mode for Markdown-formatted text.
  mmm-mode                       20240222.428   installed             Allow Multiple Major Modes in a buffer.
  monokai-theme                  20240911.1046  installed             A fruity color theme for Emacs.
  nyan-mode                      20220408.2334  installed             Nyan Cat shows position in current buffer in mode-line.
  pelican-mode                   20190124.2336  installed             Minor mode for editing Pelican sites.
  popwin                         20240925.752   installed             Popup Window Manager.
  pov-mode                       20161115.743   installed             Major mode for editing POV-Ray scene files.
  powerline                      20221110.1956  installed             Rewrite of Powerline.
  prettier-js                    20180109.726   installed             Minor mode to format JS code on file save.
  python-environment             20150310.853   installed             Virtualenv API for Emacs Lisp.
  rainbow-delimiters             20210515.1254  installed             Highlight brackets according to their depth.
  rainbow-identifiers            20141102.1526  installed             Highlight identifiers according to their names.
  rust-mode                      20241112.438   installed             A major-mode for editing Rust source code.
  scss-mode                      20180123.1708  installed             Major mode for editing SCSS files.
  spaceline                      20230922.1127  installed             Modeline configuration library for powerline.
  sql-indent                     1.7            installed             Support for indenting code in SQL files.
  ssass-mode                     20200211.132   installed             Edit Sass without a Turing Machine.
  string-inflection              20240816.523   installed             Underscore -> UPCASE -> CamelCase -> lowerCamelCase conversion of names.
  swift-mode                     20250412.624   installed             Major-mode for Apple's Swift programming language.
  tabbar-ruler                   20160802.307   installed             Pretty tabbar, autohide, use both tabbar/ruler.
  tabula-rasa                    20141216.547   installed             Distraction free writing mode.
  taskpaper-mode                 20241231.1206  installed             Major mode for working with TaskPaper files.
  terraform-mode                 20241217.1628  installed             Major mode for terraform configuration file.
  tracwiki-mode                  20150119.1621  installed             Emacs Major mode for working with Trac.
  undo-tree                      0.8.2          installed             Treat undo history as a tree
  virtualenvwrapper              20190223.1919  installed             A featureful virtualenv tool for Emacs.
  visual-fill-column             20250323.1529  installed             Fill-column for visual-line-mode.
  vue-html-mode                  20180428.2035  installed             Major mode for editing Vue.js templates.
  vue-mode                       20240101.333   installed             Major mode for vue component based on mmm-mode.
  wc-goal-mode                   20140829.1359  installed             Running word count with goals (minor mode).
  wc-mode                        20210418.47    installed             Running word count with goals (minor mode).
  web-mode                       20241227.530   installed             Major mode for editing web templates.
  writeroom-mode                 20250204.2335  installed             Minor mode for distraction-free writing.
  xterm-color                    20230321.3     installed             ANSI, XTERM 256 and Truecolor support.
  yaml-mode                      20241003.153   installed             Major mode for editing YAML files.

My personal suggestion here would be to add some kind of dape-command prefix, like "!", something that would be a syntax error in normal Python, which would avoid collision with things like a variable named s existing in a relevant scope.

(Also I really want a buffer I can put the focus on that would allow these commands to be single keys by themselves, so I can hit s s s s s to single-step a function rather than putting an enter between each one :)

glyph avatar Apr 14 '25 19:04 glyph

I assume that the above commit solved your issue feel free to reopen if it didn't.

If you want to use s s activate repeat-mode then C-x C-a s s s ...

svaante avatar May 29 '25 08:05 svaante