Search code examples
emacscygwinelispindentationcperl-mode

Turn off auto-indent in perl-mode emacs


When I use Emacs, I turn of any auto indentation and use a custom indentation scheme (keep indentation of previous line, only using spaces).

In c-mode I just used C-c C-l to turn off electric mode.

But in perl-mode I'm not sure how to achieve the same.

Looking at http://mirror.fraunhofer.de/CPAN/misc/emacs/perl-mode.el . I can see

(defvar perl-mode-map ()
  "Keymap used in Perl mode.")
(if perl-mode-map
    ()
  (setq perl-mode-map (make-sparse-keymap))
  (define-key perl-mode-map "{" 'electric-perl-terminator)
  (define-key perl-mode-map "}" 'electric-perl-terminator)
  (define-key perl-mode-map ";" 'electric-perl-terminator)
  ...

So I tried M-x set-variable perl-mode-map, but I only get [No match].

Is this because my perl-mode.el is precompiled? When I try to M-x find-function perl-mode it complains that it can't find it perl-mode.el . I do however have a perl-mode.elc file though.

I am running emacs through a console on cygwin.


Solution

  • My bad.I didn't realise there were normal variables and user option variables in emacs.

    Running (setq perl-mode-map (make-sparse-keymap)) in the scratch buffer then reloading perl-mode disabled the electric indentation for me.

    Also, thanks for the answer syohex.

    EDIT: It is important to reload perl-mode for this to work.