Skip to content

Added: elixir-quoted-minor-mode #103

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

Merged
merged 2 commits into from
Aug 27, 2014

Conversation

sviridov
Copy link
Contributor

Hi!

I'm a fan of macros and I really miss some slime or cider features about macro expansions in emacs-elixir.

So, this commit adds some interactivity for quoted expressions. Now, one can see a popup window with elixir highlighting and indentation instead of text message and close it with q.

screen1

@mattdeboard
Copy link
Contributor

You are a man after my own heart.

Unfortunately this uses font-lock-ensure, which is not available in the latest stable release (24.4.50).

In order to check out the functionality (which is really cool!) I added the following to elixir-mode.el:

(defvar font-lock-ensure-function
  (lambda (_beg _end)
    (unless font-lock-fontified (font-lock-default-fontify-buffer)))
  "Function to make sure a region has been fontified.
Called with two arguments BEG and END.")

(defun font-lock-ensure (&optional beg end)
  "Make sure the region BEG...END has been fontified.
If the region is not specified, it defaults to the whole buffer."
  (font-lock-set-defaults)
  (funcall font-lock-ensure-function
           (or beg (point-min)) (or end (point-max))))

I also added the following line to the elixir-mode definition:

  (set (make-local-variable 'font-lock-ensure-function)
       'jit-lock-fontify-now)

Adding those made it work flawlessly.

I will be more than happy to merge this pull request if you can add a guard so that it's only activated if the user's emacs has font-lock-ensure available. Or perhaps adding e.g. elixir-compat.el with all the necessary additions to make this work.

I'm really excited about this (I am a fan of Clojure's emacs tooling as well) but can't merge it without guarantees for users that it will either work or be unavailable.

Thanks

Matt

@mattdeboard
Copy link
Contributor

This could probably be accomplished through the use of functionp, e.g.

(when (functionp 'font-lock-ensure)
  (define-minor-mode elixir-quoted-minor-mode
  "Minor mode for displaying elixir quoted expressions"
  :group 'elixir-quoted :lighter " quoted"
  :keymap '(("q" . quit-window))
  (setq buffer-read-only t)))

@mattdeboard
Copy link
Contributor

How does this look? 415dc6e...mdeboard-elixir-quoted-minor-mode

If that looks right, merge it into your branch and I'll merge the PR.

@mattdeboard mattdeboard added this to the v1.5.0 milestone Aug 26, 2014
@sviridov
Copy link
Contributor Author

Hi, Matt!

It's seems that there is no need in this call at all 😄. Looks like elixir-mode call already take care about fontification. So.. I just remove it.

@sviridov
Copy link
Contributor Author

I took this idea of font-lock-<something> call from slime (here). But I didn't notice that they change font-lock-keywords-case-fold-search variable after setting major mode. So they really need to fontify buffer again, but we don't need it.

@mattdeboard
Copy link
Contributor

👍

mattdeboard added a commit that referenced this pull request Aug 27, 2014
@mattdeboard mattdeboard merged commit 7376654 into elixir-editors:master Aug 27, 2014
@sviridov sviridov deleted the elixir-quoted-minor-mode branch September 2, 2014 06:36
J3RN pushed a commit to J3RN/emacs-elixir that referenced this pull request Apr 24, 2021
New feature: Suggest specs based on Dialyzer's success typings using code lenses
J3RN pushed a commit to J3RN/emacs-elixir that referenced this pull request Apr 24, 2021
* :cwd option expects a charlist

* Signature Help Request should return null instead of empty array when no signature found

see https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_signatureHelp

* ElixirSense.docs never returns nil

instead return null when no subject is found
see https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_hover
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants