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

ethan-wspace detetes trailing minuses (dashes) in auctex math formulas #38

Open
sewkokot opened this issue Apr 12, 2020 · 2 comments
Open

Comments

@sewkokot
Copy link

I have ethan-wspace installed for more than a year with the following configuration:
(use-package ethan-wspace
:diminish
:config
(setq mode-require-final-newline nil)
(setq ethan-wspace-face-customized nil)
(global-ethan-wspace-mode 1))
I'm using current emacs from git (compiled and built every two days or so)

For a week or two I have found that the function ethan-wspace-clean-before-save-hook in before-save-hook deletes trailing dashes (minuses) in math formulas of auctex mode. I have also noticed that strings of trailing dashes in comments of other modes are also removed.
How this happens and how to prevent it (delete only trailing spaces not dashes)?

Thank you in advance!

@sewkokot
Copy link
Author

This is a really nasty bug - many equations in auctex mode and comments composed of trailing dashes/hyphens in other files were deleted. Fortunately I could identify and revert these changes under git version control.

I suspect that this is related to
https://gitlab.com/ideasman42/emacs-spell-fu/-/blob/master/spell-fu.el
which has this line: (modify-syntax-entry ?- "-" table)
and in fact dashes in the affected files had the syntax of whitespace and not symbol.

In fact I played with spell-fu these days so it can the the reason. Anyway, I removed loading spell-fu and now the dashes are not removed anymore and the syntax of '---' is symbol.

Can you confirm that this could be the reason that the syntax table is related to this trailing dash removal?

@glasserc
Copy link
Owner

Sorry for the delayed reply!

This sounds like it's related to the eol cleanup code. However, this code doesn't itself do any of the deleting -- it just calls to the builtin emacs function delete-trailing-whitespace (shown here). You could see if the problem is there by just calling delete-trailing-whitespace explicitly instead of saving the file. I suspect that it will still delete your hyphen characters because of the code here -- it's going backwards until it finds a character that isn't of the syntax -, and then deleting it.

It seems that the syntax - is the syntax category of "whitespace". I see that spell-fu describes this as trying to make the hyphen character a "word boundary". Maybe setting it to syntax class _, meaning "symbol constitutent", would work instead, or ., for "punctuation character? However, I think the code in spell-fu is not trying to use this modified syntax table globally, but just in a few functions. Maybe the bug is that the syntax table is getting used too broadly somehow?

I do think that this interaction is the cause of the bug. I'm not 100% sure what to do about it. Maybe you could open a bug on the spell-fu repository. I'm happy to help more if I can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants