Emacs Pretty Symbols in cperl mode: :: must be surrounded my spaces

120 Views Asked by At

I'm using Emacs with PDE and cperl-mode. I really want prettify-symbols-mode to work with it. When just using perl-mode this happens:

Mod::thing->new( {c => 'sea'} );

becomes

Mod∷thing→new( {c ⇒ 'sea'} );

however when using cperl same expression becomes

Mod::thing→new( {c ⇒ 'sea'} );

in cperl-mode the :: only becomes when it is separated by spaces on both sides.

I have tried adding to the cperl--pretty-symbols-alist and pretty-symbols-alist. and still only the -> and => work.

I thought it might be how cperl defines characters as symbols or words, but the -> and => work just fine without being surrounded by spaces.

2

There are 2 best solutions below

0
On BEST ANSWER

I got it. I went to /usr/share/emacs/26.1/lisp/progmodes and deleted a file called cperl-mode.elc. then I went into an archinve here /usr/share/emacs/26.1/lisp/progmodes/cperl-mode.el.gz. I edited line 1498 of cperl-mode.el to be (modify-syntax-entry ?: "." cperl-mode-syntax-table) instead of (modify-syntax-entry ?: "_" cperl-mode-syntax-table). Then I byte-compiled the file and put it back in /usr/share/emacs/26.1/lisp/progmodes.

0
On

You can also do this in your init file so you don't have to edit any files that are shipped with Emacs. If you edit files that are part of Emacs, you'll need to update them every time you install or upgrade.

(with-eval-after-load "cperl-mode"
  (modify-syntax-entry ?: "." cperl-mode-syntax-table))