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
Extended support for function shorthand notation #1282
Conversation
using the backslash shorthand notation. Ensure extensibility by creating variables `ess-R-keystrings' and `ess-r--non-fn-kstrs' as complements to `ess-R-keywords' and `ess-r--non-fn-kwds'. Adjust `ess-r--find-fl-keyword' accordingly. Fixes emacs-ess#1278. Add question mark (shortcut to help) to both `ess-R-keystrings' and `ess-r--non-fn-kstrs'.
`ess--r-s-function-pattern'. Allows function defined with the shorthand notation to be recognized as functions by e.g. `ess-r-beginning-of-function'.
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.
Would you mind taking a look and add to the existing unit tests for font-locking in https://github.com/emacs-ess/ESS/blob/master/test/ess-test-r-fontification.el? If you run into trouble please let me know.
lisp/ess-custom.el
Outdated
@@ -2088,7 +2098,7 @@ See also function `ess-create-object-name-db'.") | |||
(defvar ess-R-function-name-regexp | |||
(concat "\\(" "\\sw+" "\\)" | |||
"[ \t]*" "\\(<-\\)" | |||
"[ \t\n]*" "function\\b")) | |||
"[ \t\n]*" "\\(function\\b\\|\\\\\\)")) |
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'm not sure we want to encourage such usage but I guess it makes sense to have a baseline support and let linters/reformatters correct this usage.
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.
Personally I only use the shorthand notation for lambdas, and I agree with you but since the options has been made available by R Core, I think it is a good thing to have it supported by ESS. I see your point concerning the 'encouragement', but I do not consider this as a real one (including snippet templates would have been a different story^^)
Hi @lionel- , sorry for the delay before answer. I will add to the existing unit tests for font-locking end of this week. I will get back to you. Thanks for the great work with ESS ! |
…hens' convention and remove reference made to it from the docstring of `ess-R-keywords'. Set it to lowercase.
… tests, excluding test related to backquoted function definition fontification.
Hi @lionel- , your feedback would be welcome concerning the two following issues I encountered when adding to the unit tests:
Concerning (1), at first My first guess was that the problem comes from the way ERT, based on the Thanks. |
@maxecharel I will try to find time to take a look this week. |
…R function shorthand notation. Allows e.g. backquoted function names to be font-locked.
@lionel- some updates (to keep you posted and as notes for myself):
One question remains, and one has been added (this one will certainly require your feedback at some point, sorry for that)
|
Sorry I don't have any bandwidth for this :/ Let's just merge your work. |
Adds font-locking support for R function shorthand notation
\()
and for names of functions defined using this shorthand notation. Also makes the shorthand notation a recognized function pattern.