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

syntax entry for dollar sign #320

Closed
mallt opened this issue Sep 9, 2016 · 7 comments
Closed

syntax entry for dollar sign #320

mallt opened this issue Sep 9, 2016 · 7 comments

Comments

@mallt
Copy link
Contributor

mallt commented Sep 9, 2016

While using avy-goto-word-1 (https://github.com/abo-abo/avy) I noticed I couldn't jump to the first letter of php variables. After setting the dollar sign as symbol constituent with

(modify-syntax-entry ?$ "_" php-mode-syntax-table)

avy-goto-word-1 starting working as expected.

Would this be a correct addition to the php-mode-syntax-table?

@syohex
Copy link
Collaborator

syohex commented Sep 9, 2016

[Note] shell-script-mode sets $ as expression prefix class, while perl-mode sets $ as escape class.

I'll check other programming languages modes.

@syohex
Copy link
Collaborator

syohex commented Sep 10, 2016

ruby-mode sets $ as prefix class.

@mallt
Copy link
Contributor Author

mallt commented Sep 10, 2016

Thank you @syohex! I checked your modification with avy-goto-word-1 and it works as expected now.

@syohex
Copy link
Collaborator

syohex commented Sep 11, 2016

I have merged

@syohex syohex closed this as completed Sep 11, 2016
@mallt
Copy link
Contributor Author

mallt commented Jan 18, 2017

@syohex I noticed this change causes (thing-at-point 'symbol) to drop the dollar sign from variables. Reading https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html, wouldn't it be better to classify the dollar sign as a symbol constituent?

Thanks!

@zonuexe
Copy link
Member

zonuexe commented Jan 18, 2017

@mallt
I do not agree with confusing users by changing syntax-table.
As an alternative, I implemented (thing-at-point 'php-token).
(zonuexe/php-util.el@218ad43 is in my private package, but if this function is seems to stabilize, I propose to integrate it into php-mode.)

Is this what you expected?

@mallt
Copy link
Contributor Author

mallt commented Jan 18, 2017

I was just thinking that if (thing-at-point 'symbol) doesn't return the expected result the syntax table might not be correct. To me it seems the dollar in php is rather a symbol constituent than an expression prefix, but I guess there are no strict rules to follow here.

zonuexe added a commit that referenced this issue Aug 24, 2019
In practice, $ is just part of the variable name, which is more
advantageous than considering it as “Expression prefixes”.

If you want to be compatible with older syntax tables, add the
following code to your own .emacs file (init.el):

    (with-eval-after-load "php-mode"
      (modify-syntax-entry ?$  "'"   php-mode-syntax-table))

Past discussions are in the following issues:
#320
#564
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

3 participants