reddit / emacs
dap-mode doesn't work as expected
EmilySeville7cfg · 2022-09-07 04:53
My goal is to configure debugging for Python and Java. I have the following `~/.emacs` config:
```
;;; .emacs --- My custom .emacs config.
;;; Commentary:
;;; Installs different packages for code linting and formatting to enable user feel Emacs like an IDE.
;;; All language servers and linters can be installed separately.
;;; Code:
(require 'package)
(defun general-settings()
"Settings accessible without any plugins setup."
(defvar bookmark-save-flag 1)
(menu-bar-mode -1)
(setq-default tab-width 4)
(setq-default display-line-numbers 'relative))
(defun look-settings()
"Theme settings."
(package-install 'spacemacs-theme)
(load-theme 'spacemacs-light t))
(defun general-lsp-setup()
"General LSP settings setup."
(package-install 'lsp-mode)
(package-install 'company)
(require 'lsp-mode))
(defun lisp-setup()
"Lisp plugin setup."
(add-hook 'emacs-lisp-mode-hook #'company-mode))
(defun yaml-setup()
"YAML plugin setup."
(package-install 'yaml-mode)
(let ((hook 'yaml-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)))
(defun json-setup()
"JSON plugin setup."
(package-install 'json-mode)
(let ((hook 'json-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)))
(defun bash-setup()
"Bash plugin setup."
(let ((hook 'sh-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)))
(defun python-setup()
"Python plugin setup."
(package-install 'lsp-pyright)
(require 'dap-python)
(let ((hook 'python-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'dap-mode)))
(defun java-setup()
"Java plugin setup."
(package-install 'lsp-java)
(require 'dap-java)
(let ((hook 'java-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'dap-mode)))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(general-settings)
(look-settings)
(general-lsp-setup)
(lisp-setup)
(yaml-setup)
(json-setup)
(bash-setup)
(python-setup)
(java-setup)
(provide '.emacs)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(json-mode yaml-mode lsp-mode spacemacs-theme)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;; .emacs ends here
```
My test Python file is:
```
class Point2D:
def __init__(self, x: float, y: float) -> None:
self.x, self.y = x, y
def __str__(self) -> str:
return f"{self.x}, {self.y}"
print(Point2D(1, 2))
print(Point2D(3, 4))
```
1. When I go to `print(Point2D(1, 2))` line and execute `M-x dap-breakpoint-toggle RET` I obtain no visible breakpoint in the left editor side. I ran emacs with `-nw` flag. Is it normal? In GUI mode breakpoint is visible.
2. When I execute `M-x dap-debug RET` and press `Tab` I obtain the following completion list:
```
1 In this buffer, type RET to select the completion near point.
1
2 Possible completions are:
3 Java Attach Java Run Configuration Java Run Configuration (compile/attach)
4 Python :: Run file (buffer) Python :: Run file from project directory Python :: Run pytest (at point)
5 Python :: Run pytest (buffer)
```
When I chose `Python :: Run file (buffer)` I obtain the weird error `Wrong type argument: arrayp, nil `. What should I do?...
7890yuiop · 2022-09-07 08:38
The only code formatting method which works for all of reddit is to switch the reddit editor to markdown mode and indent the code by 4 spaces (you can use `M-4 C-x C-i` on a region followed by `M-x untabify` to achieve this in Emacs); and you need to use empty lines to separate the indented lines from the other text. Otherwise for lots of readers your message looks like this: https://old.reddit.com/r/emacs/comments/x7w1kh/dapmode_doesnt_work_as_expected/
Be sure to remove any different syntax intended for formatting (such as triple backticks) at the same time.
arthurno1 · 2022-09-07 10:43
Reddit uses four backticks, before and after the text, for the shorter (inline) code markup. For longer text, we can put four spaces on each line before the code. You can mark text and press the button with '<>' to format it as code (it will be indented with four spaces).
````
(defun foo ())
````
On the same line works too: ````(defun foo ())````
Or with spaces:
(defun foo())
See the [screenshot of the raw comment,](https://imgur.com/a/EQjtvqI) for clarification.
Edit: clarified bactics and short code. (Screenshot is still old text :)).
arthurno1 · 2022-09-07 11:02
@ /u/7890yuiop
> The only code formatting method which works for all of reddit is to switch the reddit editor to markdown mode and indent the code by 4 spaces
There is no reason to switch to markdown editor nor to alter your indentation in Emacs just for posting a snippet on Reddit. He just used three backticks. GitHub uses three backticks for the code mark up and Op perhaps don't know the markup on Reddit differ, or just copy-pasted or simply just forgot to change it.
I never switch to markdown editor and have posted tons of code here on Reddit; the fancypancy editor works just fine in this regard, actually :).
PS. I can't answer under your comment for some reason, but this works as well :).
7890yuiop · 2022-09-07 11:18
I don't know what to tell you which isn't a word-for-word repeat of my original comment. I don't dispute that the backticks work for you (and the OP and plenty of other people), but the markdown approach is the *only* method which works for *all* readers of reddit, and the link I provided *should* demonstrate this clearly. If it doesn't, try opening it as a new private browser window (and if that changes how the code is being formatted for you vs a non-private window for the same URL, please let me know so that I can update my standard text accordingly).
> I never switch to markdown editor and have posted tons of code here on Reddit
And all of it will look awful for some proportion of the readers.
arthurno1 · 2022-09-07 12:36
> I don't know what to tell you which isn't a word-for-word repeat of my original comment.
You could tell me that you haven't checked your facts before you posted a personal opinion worded as a fact? Just as you do every time there is a discussion about native compiler too.
> the markdown approach is the only method which works for all readers of reddit
Reddit serves the same HTML regardless of how I input spaces; with fancypancy button or convoluted, manual way as you do.
> the link I provided should demonstrate this clearly
??? You provided the link to the same post with old Reddit theme. I use the old Reddit theme all the time. :) Your link really proves nothing. Even less opening in private window should prove anything. Seriously, what should that prove? :)
The rendering of HTML is not changed in private window. It is just how it deals with your data during and afterwards the browsing session; but the renderer used is the same one. What do you think, with the complexity of HTML rendering today, that any browser would implement a different renderer just for private rendering? But since you will probably claim something different, [I have taken a screenshot as you requested](https://imgur.com/a/ukZuuiq), so please stop spreading disinformation to less informed users as if it was an absolute fact.
> > I never switch to markdown editor and have posted tons of code here on Reddit
> And all of it will look awful for some proportion of the readers.
How come no one from that proportion ever complained? Can you take a screenshot of some of my posts that does not work for that proportion of readers?
7890yuiop · 2022-09-07 13:06
> But since you will probably claim something different, [I have taken a screenshot as you requested](https://imgur.com/a/ukZuuiq)
Thank you for the screenshot. It demonstrates precisely the bad code rendering that I am referring to, and so I am thoroughly mystified that you seem to believe that this code (in the question text) is being displayed the way the author had intended. I can only suppose you are trolling (or alternatively that you have never used the newer reddit UI and have no clue that it supports different formatting capabilities for code blocks).
> The rendering of HTML is not changed in private window.
A private window ensures that reddit is not taking any of your cookies into account, which can in turn have a bearing on what it decides to send to your web browser. (But no doubt that's just another personal opinion that I haven't fact-checked.)
I suggested it only because you had implied you were seeing nicely-rendered code blocks in this question via old reddit; but as I can now see from your screenshot that you are actually seeing exactly the same rubbish rendering of that code as myself, you may safely disregard the suggestion; it transpires that cookies are not the problem after all.
arthurno1 · 2022-09-07 15:00
> Thank you for the screenshot. It demonstrates precisely the bad code rendering that I am referring to
It precisely does not :D. You are confusing things here, seems like.
What are you looking at: the rendering of the original posting by Op which erroneously used three backticks and comes out as ordinary text, as *already explained to you earlier*, or do you look at my comment below, **which you should look at**, which uses both backticks and spaces and is formatted by the fancypancy editor and not markdown, and renders as it should. There is no bad code there.
> A private window ensures that reddit is not taking any of your cookies into account, which can in turn have a bearing on what it decides to send to your web browser.
Reddit, and probably any big website, might (and probably will) send different data to different clients. That will depend on the client that requests data, its rendering capabilities, and probably some other criteria based on the OS, client etc; but certainly not on how you or other users have input data into some web form :D. Furthermore, Reddit is probably not even aware that you are browsing it in a private session. It is handled by your browser.
There might have been a bug in the past that made Reddit save user form from the wysiwyg editor badly, but I haven't seen anything about it in years.
> I suggested it only because you had implied you were seeing nicely-rendered code blocks in this question via old reddit
I have not *implied* this before your so-called suggestion; I have told you that **after** your so-called suggestion.
You also seem to have misunderstood that some people see correctly the original posting by the Op. It comes out as garbage in my browser too, but not because they're using the wysiwyg editor, a.k.a fancypancy editor, but by erroneously using three backticks instead of four. I have told you that in the first comment already, you seem to have missed that somehow. As well, have you missed that I have posted a screenshot of correctly formatted code as an answer to him before I sent you an answer, just as you are missing the correctly formatted code from the fancypancy editor in the private window at your request too.
7890yuiop · 2022-09-07 21:40
Well I don't think we should see each other any more. As *truly* amazing as it's been, this really isn't working out for either of us. It's not you, it's me (it's you), yada, yada. If you should happen to take issue with any of my baseless opinions in future (and I'm sure that you will), I'd appreciate it if you could refrain from talking to me about them.
Edit: Ah screw it, let's take one final shot at this.
1. Four backticks in old reddit is 99.9% identical to one backtick in reddit, and renders as **inline code** rather than code blocks. The sole difference between one backtick and *any other* number of backticks is the number of backticks in a row you can include *in your code*. Inline code formatting is *not* intended for use with large code blocks -- that does not look good.
2. What they have written at present looks *totally fine* in new reddit. I still can't tell if you've even looked, or realise that three backticks produces *good* block formatting in new reddit. You appear to believe that's *only* for other sites. Four backticks *also* works as a code block in new reddit (in order to allow you to show code containing three backticks), but produces inline code in old reddit which does not look good.
3. Indented markdown code blocks render *as code blocks* in both old and new reddit. As I said at the very beginning, it is the *only* thing which does.
4. Read https://reddithelp.com/hc/en-us/articles/360043033952-Formatting-Guide#wiki_code_blocks_and_inline_code please. I'll even quote it for you: "New Reddit note: Indented code blocks are the only form of code block that works on Old Reddit. Use them for compatibility." It also covers all of the above. (In my baseless personal opinion.)
arthurno1 · 2022-09-07 22:15
> Well I don't think we should see each other any more.
See each other? :D Wtf dude, we are not dating.
> It's not you, it's me (it's you), yada, yada.
What yada yada, "not me not you". There are f-n photos demanding your baseless opinion, as you at least correctly call that one. Take a look at them and be at least that much grown up to recognize when you are not correct. Don't come up with "let's agree to disagree", it is not a subjective opinion we are talking about, but an easily checked fact.
> If you should happen to take issue with any of my baseless opinions
Whenever you post other baseless opinion; just as much as others and you yourself are taking issue if I do an error somewhere. You yourself are quite keen to take issue on the smallest error by others if you just can. Anyway, that is OK for me, if I do an error, I am grateful to learn about it; even if it comes with d_ck comments such as yours, but I usually don't pick on yours comments to others, unless you are recommending them something unnecessary convoluted and based on false premise like you do here.
> I'd appreciate it if you could refrain from talking to me about them
I don't think you appreciate anything from me; at least I don't see why you would block me some long time ago without having any issue with me. Merely than me pointing out your aggressiveness towards Andrea's work about native compiler.
7890yuiop · 2022-09-07 22:33
I think Andrea's work on the native compiler is *amazing*. If by "aggressiveness" you mean "pointing out the fact that it doesn't benefit all users" then I don't know what to tell you. It's incredible work which helps a lot of people, and I do not believe that I have *ever* claimed otherwise. That it doesn't improve Emacs for *all* people (and *depending on circumstances* could even be a net loss) doesn't change that; it's nothing more than evidence of trade-offs and "YMMV".
p.s. I also edited the thing you've replied to with some information you may find illuminating. (Or maybe not; it really doesn't matter at this point, but I tried...)
thoomfish · 2022-09-07 23:14
> Reddit uses four backticks, before and after the text, for the code markup.
Please don't use backticks. It doesn't work on old.reddit, the only humane interface to reddit.
arthurno1 · 2022-09-07 23:15
Yeah, it just works for short inlined code; I just learned that too.
arthurno1 · 2022-09-07 23:38
> I think Andrea's work on the native compiler is amazing.
Maybe you do; but you have sounded much different some time ago. Once, you were being quite passive-aggressive towards it; and removed two comments I pointed out to you as such. At that time, you were commenting on each post here quite negatively about native compiler. Even now you often claim, without showing us benchmarks, that it didn't leave up to speed expectations and what not. That is much more than just "pointing out the fact that it doesn't benefit all users". Please. By the way, many things in Emacs do not benefit all users.
> I also edited the thing you've replied to with some information you may find illuminating.
You could have as well posted it in the last comment and skipped the sarcastic d_ck comment too.
Yes, I haven't looked in the new Reddit because I don't use it and I remember I can use 4 backticks, albeit I never do it myself; I just mark text and press code button. But you are correct, it is only for short code.
Anyway; why didn't you express yourself clearly, as you often advise everyone here? Why talking about switching to markdown editor, or indenting the code in Emacs, when you could just tell the guy to precede the code with four spaces?
Then, when I point out there is no need to switch editors, because I was clearly misstaking *what you see as a problem* you reply that it will make everything look awful:
>> I never switch to markdown editor and have posted tons of code here on Reddit
>
> And all of it will look awful for some proportion of the readers.
Which just leaves me in belief that you actually believe that it is the *editor* that is the problem, not the markup.
I am sorry, I have mistaken your original comment, but you didn't make it easy for me to realize that either, to be honest. You could have just told me it is spaces only for longer code, instead of taking detours through private window and what not.
7890yuiop · 2022-09-07 23:53
In general when I've commented on native-compilation not necessarily improving things, it has been in *response* to someone else's comment suggesting that it is a guaranteed improvement with no down-sides. To my recollection I have only ever tried to balance those kinds of comments by pointing out that actually YMMV.
I do exactly the same in reverse if I see someone suggesting the opposite extreme:
* https://old.reddit.com/r/emacs/comments/wmcdup/could_one_compile_elisp_to_common_lisp/ik908fa/
* https://old.reddit.com/r/emacs/comments/uv49ix/i_am_curious_how_many_of_you_are_using_native/i9k1k84/
> You could have as well posted it in the last comment
I was writing that edit while you were writing your reply; I didn't intentionally add the info after you had replied (that would be weird). It was just slightly easier to point it out than to move it.
> Anyway; why didn't you express yourself clearly, as you often advise everyone here? Why talking about switching to markdown editor, or indenting the code in Emacs, when you could just tell the guy to precede the code with four spaces?
That piece of text is something that has evolved over time, based upon feedback from other users who have pointed out to me ways in which the process I had been suggesting previously was insufficient. One of these tips (which I was able to confirm at the time) was that trying to use the fancy editor to add markdown code block indentation didn't work well, so since then I have recommended switching to the markdown editor for this process, which is reliable. (So yes, the editor *is* part of the problem; or it certainly used to be, at minimum.) I am also not telling people that they *must* indent in Emacs; I am telling them that they *can* (easily) perform this indentation in Emacs (eliminating what might otherwise be a cumbersome task for some users. The process is as clear and easy to follow as I have been able to make it, whilst still being succinct and *reliably* covering off the requirements as I know them. (I may review it again after this, though.)
> You could have just told me it is spaces only for longer code, instead of taking detours through private window and what not.
Trust me, I am no less bewildered by this conversation than you. I've been making an effort to help people format their code in a compatible fashion in this subreddit for quite a while now, and no one has ever reacted to it like this before.
arthurno1 · 2022-09-08 11:53
> I am also not telling people that they must indent in Emacs
For the "must", I was referring to the markdown editor tip; I was just trying to say that there is no reason to do the switch at all.
> the editor is part of the problem; or it certainly used to be
I think there was a bug with formatting when they just released the new editor, but it was a long time ago. I have been using it for years without any issues. It works to either paste-in formatted code from Emacs, or to M-w region, paste in here, select and press the code button.
> Trust me, I am no less bewildered by this conversation than you. I've been making an effort to help people format their code in a compatible fashion in this subreddit for quite a while now, and no one has ever reacted to it like this before.
Well, sorry, I have misunderstood your very first post, partly because I myself thought that four backticks and spaces were interchangeable. But as said, you took some strange detours and claims, instead of telling me the backticks are for inline code only. I never used them myself, to be honest; and you yourself didn't understand I am talking about the new editor being OK when it comes to formatting. You probably didn't look at the screenshot to the Op where it shows new editor and formatting coming out as intended. Anyway, confusion solved; I have learned something about things I don't use :), and you don't need to tell the people to shift over to markdown editor. :).
plm314 · 2022-09-10 16:43
Can someone please address the original question now that the formatting concern was addressed?
I don’t use dap mode, so I am not sure if the behavior in 1 is normal (and therefore warrants a feature request). If nobody here answers your question, please try to submit a bug report to the maintainers of the package. It could help with both questions. And once you get an answer, please update this thread.