enhanced-ruby-mode icon indicating copy to clipboard operation
enhanced-ruby-mode copied to clipboard

No fontification when used on a narrowed buffer

Open wasamasa opened this issue 9 years ago • 12 comments

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?

wasamasa avatar Jul 29 '15 12:07 wasamasa

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.

zenspider avatar Aug 07 '15 07:08 zenspider

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.

zenspider avatar Aug 07 '15 07:08 zenspider

;;; jit-lock.el --- just-in-time fontification  -*- lexical-binding: t -*-

So... maybe not my fault? Should try with a different language too.

zenspider avatar Aug 07 '15 07:08 zenspider

Nope... doesn't seem to work with any language in an indirect buffer.

zenspider avatar Aug 07 '15 07:08 zenspider

@wasamasa any feedback? I think this is more of a problem with emacs.

zenspider avatar Sep 15 '16 23:09 zenspider

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

wasamasa avatar Sep 16 '16 06:09 wasamasa

I can't repro with your file.

  1. Create file "bug086.sh" and paste in your output.
  2. Select inner scheme code
  3. Run narrow-to-region-indirect
  4. 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]

zenspider avatar Jan 24 '18 04:01 zenspider

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

wasamasa avatar Jan 24 '18 18:01 wasamasa

narrow-to-region-indirect probably comes from here: https://demonastery.org/2013/04/emacs-narrow-to-region-indirect/

Silex avatar Jun 18 '19 15:06 Silex

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.

zenspider avatar Jun 21 '19 18:06 zenspider

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 from ruby 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 avatar Jun 01 '21 04:06 gcentauri

@gcentauri I have the same problem.

GNU Emacs 27.2 macos monterey 12.0.1 enh-ruby-mode 20210120.201

Andsbf avatar Dec 24 '21 04:12 Andsbf