简体   繁体   English

cperl 模式下的 Emacs Pretty Symbols::: 必须包围我的空间

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

I'm using Emacs with PDE and cperl-mode.我将 Emacs 与 PDE 和 cperl 模式结合使用。 I really want prettify-symbols-mode to work with it.我真的想让 prettify-symbols-mode 与它一起工作。 When just using perl-mode this happens:仅使用 perl-mode 时会发生这种情况:

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

becomes成为

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

however when using cperl same expression becomes然而,当使用 cperl 时,相同的表达式变为

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

in cperl-mode the :: only becomes when it is separated by spaces on both sides.在 cperl 模式下, ::只有在两边被空格分隔时才会变成

I have tried adding to the cperl--pretty-symbols-alist and pretty-symbols-alist.我已经尝试添加到 cperl--pretty-symbols-alist 和 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.我认为这可能是 cperl 将字符定义为符号或单词的方式,但是->=>工作得很好,没有被空格包围。

I got it.我知道了。 I went to /usr/share/emacs/26.1/lisp/progmodes and deleted a file called cperl-mode.elc.我去了/usr/share/emacs/26.1/lisp/progmodes并删除了一个名为 cperl-mode.elc 的文件。 then I went into an archinve here /usr/share/emacs/26.1/lisp/progmodes/cperl-mode.el.gz .然后我在这里/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) .我将 cperl-mode.el 的第 1498 行编辑为(modify-syntax-entry?: "." cperl-mode-syntax-table)而不是(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 .然后我对文件进行字节编译并将其放回/usr/share/emacs/26.1/lisp/progmodes中。

You can also do this in your init file so you don't have to edit any files that are shipped with Emacs.您也可以在 init 文件中执行此操作,这样您就不必编辑 Emacs 附带的任何文件。 If you edit files that are part of Emacs, you'll need to update them every time you install or upgrade.如果您编辑的文件是 Emacs 的一部分,则每次安装或升级时都需要更新它们。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM