enhanced-ruby-mode
enhanced-ruby-mode copied to clipboard
No fontification when used on a narrowed buffer
I have some ruby code in a notes file with org-mode
on, so I've narrowed to a region and enabled enh-ruby-mode
. This did result in no fontification at all. Any idea what's going wrong here?
This is just a guess... but it relies on sending the code out to a ruby server to parse it and it probably sends the whole thing and gets confused.
When I try this with a bash script w/ embedded ruby I get this in *Messages*
:
Not enabling jit-lock: it does not work in indirect buffer [2 times]
Not sure what jit-lock
is.
;;; jit-lock.el --- just-in-time fontification -*- lexical-binding: t -*-
So... maybe not my fault? Should try with a different language too.
Nope... doesn't seem to work with any language in an indirect buffer.
@wasamasa any feedback? I think this is more of a problem with emacs.
I think this is more of a problem with enh-ruby-mode
as I cannot reproduce this with a shell script embedding Scheme code.
cat << END > ~/.csirc
(load-verbose #f)
(unless (get-environment-variable "INSIDE_EMACS")
(use (prefix readline "rl-"))
(current-input-port (rl-make-readline-port))
(rl-install-history-file
#f (format "/.csi_history" (get-environment-variable "HOME"))))
END
echo 123
I can't repro with your file.
- Create file "bug086.sh" and paste in your output.
- Select inner scheme code
- Run
narrow-to-region-indirect
- In new narrowed buffer, try to activate
scheme-mode
I get an error and the following in *Messages*
:
Indentation setup for shell type bash
Mark set
Not enabling jit-lock: it does not work in indirect buffer [2 times]
Why narrow-to-region-indirect
(I don't have it as command here)? I'm speaking of regular narrow-to-region
. If I replace step 3 with "Run M-x narrow-to-region
", syntax highlighting works fine.
Here are the contents of an Org file for the Ruby case:
Foo
#+BEGIN_SRC
(0..10).each do |i|
puts i
end
#+END_SRC
Bar
narrow-to-region-indirect
probably comes from here: https://demonastery.org/2013/04/emacs-narrow-to-region-indirect/
Correct. And it uses narrow-to-region
underneath so it should be roughly equivalent. Since I have the problem there too, I think the difference is probably fine.
i'm experiencing something similar without explicitly using narrowing. source blocks in an org file do not get fontified properly with enh-ruby-mode
. to recreate:
- disable
enh-ruby-mode
from taking ruby buffers -
org-src-lang-modes
should either not have an entry for ruby or have("ruby" . ruby)
- create an org file and insert a ruby source block with some code
- you should see fontified source
- push or
(add-to-list 'org-src-lang-modes '("ruby" . enh-ruby))
- toggle org mode / reopen file / or rewrite the src lang (delete the
y
fromruby
and put it back) - you should see improper fontification
I've tried to trace down what is going wrong, but I haven't made much progress. I have a guess that its related to the font lock keywords in enh-ruby-mode. I do see some keywords being highlighted and right now I have a string highlighted properly, but things like class
def
etc do not. They end up with the default org-block
face. Running with plain ruby-mode
they get the expected font lock faces.
Hopefully this is helpful! Thanks for the work on the package!
This potentially could be a separate issue, but seemed similar.
EDIT
you can recreate without pushing things to the org-src-lang-modes
by changing the source block to use enh-ruby
rather than ruby
@gcentauri I have the same problem.
GNU Emacs 27.2 macos monterey 12.0.1 enh-ruby-mode 20210120.201