Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commenting a line starting with a link inserts the comment into the link #11

Closed
mohkale opened this issue Oct 7, 2021 · 4 comments
Closed
Labels

Comments

@mohkale
Copy link

mohkale commented Oct 7, 2021

When you have (setq orglink-match-anywhere t) enabled and try to comment a line beginning with an org-link, the inside of the link description ends up commented instead of the link itself.

For example say I have a scratch buffer like this:

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with SPC f f and enter text in its buffer.

[[file:foo.html][blarg]]

On the last line if I run M-: (comment-region (line-beginning-position) (line-end-position)) I end up with

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with SPC f f and enter text in its buffer.

[[file:foo.html][;; blarg]]

Is there a way to fix this?

@mohkale
Copy link
Author

mohkale commented Oct 7, 2021

Also you can't uncomment (as one would expect, trying to just continually comments the description. :/.

@tarsius
Copy link
Owner

tarsius commented Oct 7, 2021

I can reproduce this issue also when using a mode such as text-mode. It appears that the orglink implementation has a bug that the org implementation doesn't have. I noticed that the org implementation has significantly changed since I copied and adjusted it, likely also to fix this bug. I should copy and adjust again to take advantage of the improvements. Doing that might take a little bit longer.

@tarsius
Copy link
Owner

tarsius commented Oct 9, 2021

I have switched to the new code from org but that didn't fix it. (I haven't pushed that yet.)

The problem clearly is that the commenting functionality does not properly deal with invisible text at the beginning of the line and my hope was that org had figured out how to counter that.

In a way it has. It comes with its own commenting functionality by setting comment-region-function and others. It doesn't do this to deal with this particular issue but because it has special needs. From org.el:

;; Org comments syntax is quite complex.  It requires the entire line
;; to be just a comment.  Also, even with the right syntax at the
;; beginning of line, some elements (e.g., verse-block or
;; example-block) don't accept comments.  Usual Emacs comment commands
;; cannot cope with those requirements.  Therefore, Org replaces them.

;; Org still relies on 'comment-dwim', but cannot trust
;; 'comment-only-p'.  So, 'comment-region-function' and
;; 'uncomment-region-function' both point
;; to 'org-comment-or-uncomment-region'.  Eventually,
;; 'org-insert-comment' takes care of insertion of comments at the
;; beginning of line.

;; 'org-setup-comments-handling' install comments related variables
;; during 'org-mode' initialization.

So this implementation doesn't have the issue of the default implementation, but it is highly specialized and not suitable for use in non-org buffers.

I am afraid I am going to have to close this as wontfix. If you cannot live with this, then I suggest that you bring it up with the emacs maintainers as you should be able to reproduce this with any invisible (and/or intangible) text at the beginning of a line.

@tarsius tarsius added the wontfix label Oct 9, 2021
@mohkale
Copy link
Author

mohkale commented Oct 9, 2021

@tarsius

Thanks for looking into the issue. Truth be told while annoying I don't think its a major issue. I checked after installing this plugin but org-link-minor-mode has the same issue and in all my time using it I'd never encountered it before experimenting with this plugin. I think its safe to say this isn't a deal braker, so I'm fine with a wontfix resolution for now. I might send an issue on the mailing list if I encounter it more or run into a similair situation with another plugin.

Once again, thank you.

@mohkale mohkale closed this as completed Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants