tmalsburg / guess-language.el

Emacs minor mode that detects the language you're typing in. Automatically switches spell checker. Supports multiple languages per document.
115 stars 14 forks source link

Possiblity to ignore certain lines #38

Open Thaodan opened 10 months ago

Thaodan commented 10 months ago

Some modes post content in the buffer that is read-only and not related to the actual content that the user writes.

For example in have or ERC/Circe the messages sent by other users or for Mastodon the same and the keybinds shown.

tmalsburg commented 10 months ago

I don't have much experience with such modes. Any suggestions as to how this could be implemented? Is it safe to assume that read-only content should always be ignored?

Thaodan commented 10 months ago

Titus von der Malsburg @.***> writes:

I don't have much experience with such modes. Any suggestions as to how this could be implemented?

What about a regex? E.g. ignore everything after ^#.*

Is it safe to assume that read-only content should always be ignored?

I'd assume so?

tmalsburg commented 10 months ago

What about a regex? E.g. ignore everything after ^#.*

I don't think it's that simple. Content after # is not necessarily read-only and should not generally be ignored. In Python, for instance, I'd want to do the opposite: ignore everything that does not follow # because we would like to do language guessing based on the comments, not based on the code.

Thaodan commented 10 months ago

Having the ability to set this per buffer and thous per mode would help enough at first.

I'd be fine if read-only content can be ignored. Since depending on the mode the read-only content might indicate the buffer language e.g. the prior messages inside a chat mode.

tmalsburg commented 10 months ago

Tbh, this sounds like a difficult-to-implement feature and it would have to be implemented for different modes separately.

Alternative proposal: How about a way to guess the language only based on the current paragraph, not the entire buffer? Wouldn't this also solve your use case?

Thaodan commented 10 months ago

Titus von der Malsburg @.***> writes:

Tbh, this sounds like a difficult-to-implement feature and it would have to be implemented for different modes separately.

That's why I think a pattern that should be ignore is the simplest solution. The user can set a pattern per mode for themselves.

While read-only content could be ignored if so choosen e.g. global or per make-local-variable.

tmalsburg commented 9 months ago

I won't have time to work on this myself, but feel free to sketch an PR.