There is a built in way to do this with font-lock (thank you sanityinc)
This answer has all the details about how this style of font-lock-keywords work: https://stackoverflow.com/a/14675550
(defun pod-comment-highlighter (limit)
"If looking after __END__ or __END__ is before LIMIT, set match-data to a the location of the pod comment."
The answer is that you can't do it "right".
But you can do the following:
(syntax-propertize-rules ("\\('\\)[bh]" (1 "."))))
(add-function :before (local 'syntax-propertize-function)
Using the recommendations of @Constantine, here is an improved version of the function:
(defun get-perl-id-at-point ()
(let ((beg nil) (end nil))
(if (looking-at "[A-Za-z0-9:_]*?(")
(setq end (- (match-end 0) 1)))
(if (looking-back "[-+=*/;[:space:]][A-Za-z0-9:_]*?" (- (line-beginning-position) 1))
(setq beg (+ (...
You can always turn syntax highlighting back on using M-x font-lock-mode. Using the same command a second time will turn it back off. If you've got it bound to a key that you've inadvertently pressed, use Ctrl+h w font-lock-mode to find which key it's bound to.
If you want to set font-lock-mode permanently for cperl, you can do so by setting either cperl-...
So I did some more digging and I was able to find a solution, but not a very clean one. I copied the perl-syntax-propertize-function from perl-mode.el. I then added this to my .emacs and changed the name to my/perl-syntax-propertize-function and added the following code after syntax-propertize-rules
("\\('\\)b[^'a-z]" (1 "."))
I then added a perl-mode-hook ...
cperl creates abbreviations for perl keywords into ~/.emacs.d/abbrev_defs that trigger function cperl-electric-keyword that does the expansion.
To remove the offending entries, call M-x edit-abbrevs,
remove the lines you want, save, and press C-c C-c to activate the changes.
The package highlight-refontification visualizes how font-lock refontifies a buffer. In this case, it starts at the line where the point is.
One way to handle this is to add a function to font-lock-extend-region-functions to expand the region to include the full heredoc comment.
One thing that is curious is that the highlighting becomes correct when ...
Try setting perl-continued-statement-offset.
(setq perl-continued-statement-offset 0)
See it's documentation (via Ctrl-H v):
perl-continued-statement-offset is a variable defined in ‘perl-mode.el’.
Its value is 4
This variable is safe as a file local variable if its value
satisfies the predicate ‘integerp’.
Extra indent for lines not ...
You can also set include paths per project or directory.
Add a directory local variable flycheck-perl-include-path with a list of directory strings. Or just create a .dir-locals.el file with
(flycheck-perl-include-path . ("../lib/" "path/to/you/lib"))))
;; Enable/disable perlcritic-mode
(setq perlcritic-mode (if (null arg)
;; Nothing! Just toggle it.
perlcritic-mode toggles itself when you pass it no arguments, but you really just want to enable, so you could do something like this in your .emacs:
(defun turn-on-perlcritic-mode ()
Since it looks like cperl-mode always rewrites its abbreviations, my previous answer is not a long term solution.
A better solution is to run a hook after cperl has been loaded and redefine the cperl-mode-abbrev-table. Add it to your emacs configuration file after other commands modifying cperl. I've removed the loop abbreviations from the redefined table, ...
It seems like this behavior is related to the newest version of cperl-mode. I am using Emacs 24.4 on Ubuntu 14.04, and the cperl-mode that came with the installation (/opt/emacs24.4/share/emacs/24.4/lisp/progmodes/cperl-mode.el.gz) is version 6.1 of cperl-mode.
I then tried to install cperl-mode from ELPA using Emacs 24.4 package manager (list-packages), ...