-
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
Highlight @doc as comment #355
Comments
I would have to use this for a while to be able to tell for sure if I like it or not, but I think I like the idea. 👍 |
@pdilyard @whatyouhide I'll make a PR so you guys could work with this variate for a bit. |
@tonini thanks, I'd appreciate that! |
Hmm, at Python we have a docstring face for that. As comments and strings are syntactically different, should they get the same face? |
We could use
From the Gnu/Emacs page on font lock faces I think it is fitting. Some themes might not implement a specific color for this face, and it will fallback to the string face (as it is now), but the semantics would be right; and the themes that has defined the face would be spot on. |
@gausby awesome catch, I say #justdoit with a PR 😃 |
@whatyouhide I would love to know how to do it, but it would require me to be able to distinct between multiline strings and actual docstrings so I can apply the font face to them. Perhaps I should pair with Tonini on this at some point. |
Another possibility to consider here would be using markdown indentation rules within docstrings, so you wouldn't have to enter visual mode to manually move code blocks to the correct level. |
I think that would be hard to implement; essentially it would require us to redo the stuff markdown mode does. It would probably be better to have a mode like mmm-mode (multi-major-mode) handle this, but the individual would have to set this up for themselves—an article on how to do this would be nice. |
@gausby we should try your solution. 👍 |
Yes, an article on how to set it up would be very helpful |
Has anyone attempted this yet? I'd love to look at grey docstrings 😄 I'd also be willing to try this myself if someone could point me in the right direction in the code. |
@pdilyard I suck at elisp. Anyway, I tried using polymode to create a mode for only docstrings and then have a meta-mode that uses elixir-mode and this new mode at the same time. But then I ran into problems because font-lock-mode seems to come with default highlighting for strings and it took precenden over what I did. Anyway, I failed, just wanted to share the approach I tried. |
(I want to apologize first to those who do know elisp. Hopefully what I've found is helpful) OK, I had some time and researched this a bit. I looked at how python-mode achieves this. Elixir mode sets the value of font-lock-defaults the simpler way. There is a more verbose way to set that variable that allows more customization. (set (make-local-variable 'font-lock-defaults)
'(elixir-font-lock-keywords)) Python sets this variable in a more complex way: (set (make-local-variable 'font-lock-defaults)
'(python-font-lock-keywords
nil nil nil nil
(font-lock-syntactic-face-function
. python-font-lock-syntactic-face-function))) By doing it this way, it is able to specify a function for Syntactic font locking allows:
This is, I think, ideal for this case. The function that does this in python-mode is: (defun python-font-lock-syntactic-face-function (state)
"Return syntactic face given STATE."
(if (nth 3 state)
(if (python-info-docstring-p state)
font-lock-doc-face
font-lock-string-face)
font-lock-comment-face)) That function has to decide the type of expression it is looking at. We could basically copy this and just implement the equivalent Hopefully this helps other more knowledgeable people find a solution to this. I will dump here some relevant links I found along the way: https://www.gnu.org/software/emacs/manual/html_node/elisp/Font-Lock-Basics.html |
@pdilyard hopefully what I found ^^ helps you |
@andreas-roehler man, I want to cry! 😆 |
Woah! Thanks @edmz and @andreas-roehler |
Having difficulty getting this to work. When I run
However my |
@wpcarro did you update from package.el? You might try closing the file and opening it again. Or change mode to fundamental then back again to elixir mode. |
@edmz Just tried How can I update from package.el? I may have already done so, but I'm unsure. Do you mind sharing your output from |
You are running the latest tagged version which is 9 months old or so which
means you are installing the package from melpa-stable.
This repo has pretty much stopped relying on melpa-stable, and just using
melpa.
…On Thu, Jan 12, 2017 at 10:16 AM, William Carroll ***@***.***> wrote:
Just tried M-x fundamental-mode then M-x elixir-mode. No difference made.
Repeated these steps after killing all Elixir buffers -- nothing. I've also
restarted Emacs, without success.
How can I update from package.el? I may have already done so, but I'm
unsure. Do you mind sharing your output from M-x elixir-mode-version?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#355 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASti22qtdUKNxxcC5JB9oPtRUsTuLBnks5rRlHcgaJpZM4IbVp4>
.
|
@mattdeboard switched to Melpa (nonstable). Uninstalled |
I can confirm that my |
I take that back, it works, it just isn't customized by the theme I was using. The following applies to spacemacs users (and may also apply to pure emacs users, but I can't guarantee that): For anyone who is having problems, try executing If you place your cursor over the documentation and run If you want to customize that part of your theme, you can place the following code (adjusted for your theme and the color you want) in your (custom-theme-set-faces
'molokai
'(font-lock-doc-face ((t (:foreground "#465457"))))) |
Things look a lot cleaner if you highlight the following blocks as if they were comments:
Most other Elixir syntax highlighters handle things this way (including the Github one, as shown above). It tends to make things look a bit cleaner in larger modules.
If people agree, I could try to work on a PR for this.
The text was updated successfully, but these errors were encountered: