2

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.

Drew
  • 29,895
  • 7
  • 74
  • 104
CharJe
  • 41
  • 6
  • 1
    That's because `cperl-mode` gives syntax "symbol constituent" to the `:` character in its syntax-tables, whereas `perl-mode` gives it syntax "punctuation". – Stefan Apr 24 '19 at 15:15
  • Could I change it to something else? What would be the elisp code to do that? – CharJe Apr 24 '19 at 15:28

2 Answers2

1

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.

CharJe
  • 41
  • 6
1

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))
jpkotta
  • 9,237
  • 3
  • 29
  • 34