-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
#49 Don't flyspell links #50
Conversation
TobiasZawada
commented
Feb 8, 2024
- Let font-lock put the adoc-flyspell-ignore property on links
- use this in adoc-flyspell-p to decide to check word at point or not
- adoc-flyspell-p is the flyspell-mode-predicate property of adoc-mode
…ore and use it in adoc-flyspell-p
The prefix for the commit should be This needs a changelog entry, as it can be considered a bug-fix. |
(defun adoc-flyspell-p () | ||
"Function for `flyspell-mode-predicate' property of `adoc-mode'. | ||
Returns t if word at point should be checked, nil otherwise." | ||
(font-lock-ensure (line-beginning-position) (line-end-position)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Seems kind of redundant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Jit-Lock version of Font-lock is free to fontify only the visible part of the buffer if large yanks of text are inserted. flycheck-buffer
on the other hand does not care about visibility. So we ensure that the adoc-flycheck-ignore
property is correctly applied by font-lock-ensure
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would come with a performance hit, though, that's why I was wondering if it's really needed. I'm also not sure how often people use flyspell-buffer
- e.g. I never use it myself.
I think at the very least we should add some note explaining the need for this, as I don't think that's obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance hit is minimized by that junk of jit-lock-fontify-now
:
(setq next (or (text-property-any start end 'fontified t)
end))
;; Avoid unnecessary work if the chunk is empty (bug#23278).
(when (> next start)
adoc-mode.el
Outdated
"Function for `flyspell-mode-predicate' property of `adoc-mode'. | ||
Returns t if word at point should be checked, nil otherwise." | ||
(font-lock-ensure (line-beginning-position) (line-end-position)) | ||
(null (get-text-property (point) 'adoc-flyspell-ignore))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null
check also seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I assume this will work just fine without explicit conversion into boolean, given that Elisp doesn't have a real boolean type anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that you know that null
is the internal command for negation. (You can interpret it as predicate, nullp
would be a more appropriate name.)
The flyspell-mode-predicate
should return t if the word is to be checked. We mark the words that should not be checked with adoc-flyspell-ignore
.
subr.el
has a alias not
for it if this is more to your liking.
By the way, I already added 1-
to check really the inside of the word for adoc-flyspell-ignore
. The new version is (null (get-text-property (1- (point)) 'adoc-flyspell-ignore))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be it be t
specifically or just something truthy (anything that's not nil
)? I'm asking mostly because I've rarely seen APIs that rely specifically on t
as the return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null
returns t on nil. But, that does not really matter. Any non-nil value would do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misread the intention of adoc-flyspell-p
- thought this was the things to ignore, but it's actually the things to check. That being said my initial remark was also because of some style conventions in Elisp:
null
is the same asnot
; both functions are included for the sake of clarity. As a matter of style, it is customary to usenull
to check whether something is the empty list and to usenot
to invert the sense of a logical value.
That's why I called null
a predicate, despite its name. Anyways, not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... my initial remark was also because of some style conventions in Elisp:
null
is the same asnot
; both functions are included for the sake of clarity. As a matter of style, it is customary to usenull
to check whether something is the empty list and to usenot
to invert the sense of a logical value.
Good point. I've changed it.
Btw, did you compare your approach with this one https://github.com/jrblevin/markdown-mode/blob/master/markdown-mode.el#L2330 ? I'm wondering why |
I checked only after your remark. |
Fair enough. Let's go with your approach then. Just mention it in the changelog and we can merge this. |
@bbatsov In our company we were told just to write the issue title in the "Bugs fixed" section. This is also reasonable, when one considers that this section lists the fixed things. Do you agree? Another remark: There will be certainly more things that shouldn't be checked by Flyspell. These are new issues which we handle when we cross them. |