reddit / emacs

Exclude a character from "symbol"

reliktary · 2022-05-10 16:21
Hi, I'm migrating from Vim and configuring my Emacs config (I use Doom). I use PHP and I need to exclude `$` from symbol definition, if that make sense. In PHP class properties are defined like so `private $propertyName = 'something'`. And then used like so `$this->propertyName`. The issue is that when I use `*` to search for a symbol at point (assume my point is on the property definition, the one with `$` sign) the "symbol" to search for is `$propertyName` hence things like `$this->propertyName` aren't going to be found in the buffer. I'm not sure exactly where I should look for the fix. I tried to set `evil-symbol-word-search` to `nil` which will force evil to search for "word" at point but that's not that great and doesn't work for variables with underscore. That's maybe could be fixed with `modify-syntax-entry` function but it's all looks like a wrong path to do it. What can I do to tell Emacs (or evil) that a "symbol" excludes "$" sign? Thanks
reliktary · 2022-05-10 16:51
ok, answering my own question it seems like `modify-syntax-entry` can help me here. I inspected php-mode source code and found that it does `(modify-syntax-entry ?$ "_" table)` which makes that `$` sign to be `symbol constituent`. I need opposite of that so I did `(modify-syntax-entry ?$ "." php-mode-syntax-table)` and it fixed the issue with `*` key and with some others that looks for a symbol at point.