-
Notifications
You must be signed in to change notification settings - Fork 94
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
suite.rc syntax lexers: improve emacs support #2784
suite.rc syntax lexers: improve emacs support #2784
Conversation
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 all for fair treatment of the downtrodden and the disadvantaged. 🙌 so I'm approving this in principle.
However, I don't use emacs - so I'm going to have to delegate the proper review to someone who does!
Neither does @oliver-sanders, but I would think one would simply need to check the syntax highlighting looks correct, which simply requires opening, eyeballing & closing the file, which is trivial unlike for vim! But if you would like to feel free to delegate. |
Ha 😁 fair enough. Personally I think typing "[esc]:q" is vastly easier than "[ctrl-X][ctr-C]" (see I do remember some emacs, from back when it was better than vim ... 25 years ago! I'll try to take a look... |
@sadielbartholomew - what do you mean by "multi-line statements"? Multi-line strings or continuation-lines, in suite.rc syntax? or multi-line Jinja2 statements? ... Also note that Jinja2 |
Sorry if this did not work with your set-up @hjoliver! I am trying to think why we could be getting different results, as with mine & Oliver's set-up there were definitely issues with the emacs syntax highlighting & my code definitely fixed them to some extent (see detail below). Any ideas why we get different outputs, as it shouldn't depend on the Linux environment? The issues we see:
Up-to-date master branch:This (PR) branch:However as can be seen the |
1b48440
to
360371e
Compare
Update: the I think it best if we both show what we get on master & on this branch with default emacs styling etc., & determine & share our versions, so any differences are explicit. I'll do that tomorrow morning. If you could too when you get a chance that would be appreciated, thanks. |
Okay, so I am using the same (hacked-together & with imperfect suite design, but capturing everything wanted for testing) example as above. Could you please copy & paste it to show what you get for the same code, as below,
with nothing in your ;; Cylc syntax
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'cylc-mode)
(setq auto-mode-alist (append auto-mode-alist
(list '("\\.rc$" . cylc-mode)))) With that example & that init file, I now (after fixing the Up-to-date master branch:This (PR) branch: |
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.
@sadielbartholomew - thanks for the extra work on this. I won't bother posting screenshots because my results now agree with yours. I therefore re-affirm my approval of this PR 👍
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.
Nearly there, just a couple niggles:
Multiline blocks ({%
) now work great with punctuation, can we extend this to comments ({#
):
{# foo
"bar"
baz #}
Pipe characters through a spanner into the works:
{{ x|upper() }}
@oliver-sanders ah I wasn't aware of multi-line comments, thanks for raising that, & well-spotted RE the pipe. I'll get this amended accordingly. |
I've been working on this, but I am not quite finished & will comment when ready for final re-review. It seems there are further inconsistencies with gvim, which we can take as the standard for Cylc syntax highlighting. New more comprehensive test:
|
5515b95
to
3ca5037
Compare
After discussions with Oliver, we think it is best to break consistency with vim for something that seems more intuitive, namely for Jinja2 comments to appear in the 'comment face' as for regular comments, not as standard Jinja2 face. Other than that this should be consistent with the vim screenshot above. For the same example text, after the latest commit I get: I still have no idea why there is a lone Jinja2 comment that does not seem to play ball wherever I place it in the text & whether or not its contents includes quotes! I have spent hours trying to uncover the reason (via tweaking all the regexes, using an online debugger, etc.) for this to no avail. Anyone have any ideas? Otherwise, I have spotted that sections with punctuation are also broken on master for emacs. I still need to fix that (too), & it isn't trivial as there are inter-cycle offsets to distinguish from in square brackets. Will return to this Monday. |
Sounds difficult! I wonder if it is worth asking emacs experts (on some support mailing list) about this (font-lock mode and the "lone Jinja2 comment..." bit above)? |
@cylc/core - if the final problem above proves too hard to solve, I think we should consider merging this as-is - it is still a significant improvement on current emacs support - in order to get the release out. It can then be tweaked in a later PR. |
@hjoliver: sorry I was focusing on other work previously, but I know this is now urgent to finalise to some extent for the next release. I'm consulting an emacs 'expert' (not sure whether quoting this is appropriate 😄) who may be able to detect the remaining issue, as described above. If we can't debug it today I agree we should merge as-is (with any simple possible further feedback addressed). |
@stevewardle if you have some spare time for this today, could you please see if you can see any reason for the following:
There should be sufficient info in the PR comments & code to comprehend the problem, but I am happy to summarise it for you in-person, or show the strange behaviour as it appears on my monitor, if that would make it easier? Thank in advance. |
Hmm... this all feels fairly familiar as I recall running into a lot of similar oddities when writing the syntax file for Rose... but there are a few other things about this Cylc mode that I think are worth fixing too:
As for a fix I think perhaps it might be worth copying the Rose syntax file (but strip out the mode-specific parts and replace them with the regex's from this change)? At a glance there are a few bits in the Rose one which might fix the issue above (I recall having a similar problem trying to get the trigger-ignored sections to turn grey) |
Thanks for having a look @stevewardle, that is very helpful. Admittedly I based my solution on the syntax highlighting file as it was before, so assumed the use of e.g. Using your Rose syntax file as a template sounds like the way to, I agree. I'll give that a shot this afternoon. |
UpdateI can't thank you enough @stevewardle (:star:); after I copied all the regular expressions I had adapted so far into the Rose syntax template as you suggested and amended it for Cylc / From there it was really easy to simplify the regular expressions I already had. I think the reason they had become so convoluted was because I was trying to manipulate the oddness incorporated somewhere within the original approach. Had I begun with that template I feel I could have done this is a tenth of the time 😑. But it was a learning process, that's for sure. I can't seem to add you as a reviewer, as you aren't in the All: this is open for (hopefully final) reviewing. Reviewing aidesIt's perhaps overkill, but I'll provide up-to-date screenshots since there are a few more domain cases I didn't cover with my previous mock (bad but illustrative) suite.rc file, namely punctuation within section headers and inter-cycle dependencies. I added in After the latest commit, I now (with the minimal |
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.
Re-approving, after the new implementation (disclaimer, again: I haven't been an emacs user for 20 years).
Also looks good to me - glad to see you got it all working in the end 😌 |
Looks good and has some big improvements, I especially like the highlighting of I've found a few new niggles, some of which should be quick to fix:
|
Very thorough reviewing @oliver-sanders! I wasn't even aware Jinja2 could be used inside sections. I'll get those fixed now.
No, I used the template from the Rose syntax but created the regular expressions from scratch myself. So the actual highlighting behaviour is largely custom, & hopefully I can adapt it easily. I will check with you about multi-line string 'quoting' behaviour in person as I am not sure what is best to implement there. |
@oliver-sanders I have now as far as I can tell covered the issues you spotted. For testing I used:
For multiline strings, I went for the simple solution of highlighting any occurence of the pattern |
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
emacs
editor is lacking the basic level of syntax highlighting all-inclusive support provided for the other editors supported to some extent (see first 7 rows of the table given in #2752). In particular, Jinja2{% ... %}
& multi-line statements should at least be fully supported & this is implemented here.Equality for emacs:heavy_exclamation_mark: