3

I have a bash shell script that has a fairly sizable amount of perl code in it. Is there a why to get perl syntax highlighting instead of the normal here doc coloring? Thank you for any help, I'm new to emacs and still getting the hang of elisp and the terminology

2
  • 1
    Try the solutions for multiple modes. Commented Sep 7, 2016 at 21:22
  • thanks, mmm-mode seems to work well. I'm having a hard time getting to automatically recognize the perl code. As i said i have perl script in a bash here doc. parse region seems to get it when i do it manually
    – Gary Ash
    Commented Sep 8, 2016 at 16:03

1 Answer 1

-2

You can just M-x perl-mode to activate perl mode.

Or, set a easy key to perl-mode. For example,

(global-set-key (kbd "<f8>") 'perl-mode)

Or, you can put add this comment to the first line in the bash file

# -*- mode: perl -*-

then, it'll open with perl mode.

Or, you can put the following at the bottom

# Local Variables:
# eval: (perl-mode 1)
# End:

Does that answer your question?

2
  • I wanted this in shell highlight #!/usr/bin/env bash for file in $(find $HOME -depth 1 -name ".*"); do echo $file done sudo perl <<-'PERL' #&> /dev/null # this in perl highlighting #!/usr/bin/env perl #**************************************************************************************** # libraries used #**************************************************************************************** use strict; use warnings;
    – Gary Ash
    Commented Jul 9, 2016 at 20:50
  • @GaryAsh See emacswiki.org/emacs/MultipleModes but i don't think they'll be smooth, as emacs is designed for just 1 major mode per buffer.
    – Xah Lee
    Commented Jul 10, 2016 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.