Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.82k stars 195 forks source link

Review all usages of `char-syntax` #1195

Closed Fuco1 closed 6 months ago

Fuco1 commented 6 months ago

There is about 20 uses of this function. However, it can introduce subtle bugs, such as #851 because some modes use syntax-table property to annotate characters/points in special situations (to override the general syntax assigned to the character)

If you’re trying to determine the syntax of characters in the buffer, this is probably the wrong function to use, because it can’t take ‘syntax-table’ text properties into account. Consider using ‘syntax-after’ instead.

So that in ruby foo? has the ? as part of the symbol with the syntax _ (symbol), but when it is somewhere on its own, it has syntax . (punctuation). Then if we test the character itself in isolation with char-syntax it always gives punctuation instead of what it should give based on the context.

See also https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Table-Internals.html