4

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.

rhlee
  • 3,857
  • 5
  • 33
  • 38

3 Answers3

2

Add following code your configuration file(.emacs or ~/.emacs.d/init.el)

(defun perl-mode-disable-auto-indent ()
  (local-unset-key (kbd "{"))
  (local-unset-key (kbd "}"))
  (local-unset-key (kbd ";"))
  (local-unset-key (kbd ":")))

(add-hook 'perl-mode-hook 'perl-mode-disable-auto-indent)
syohex
  • 2,293
  • 17
  • 16
0

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.

rhlee
  • 3,857
  • 5
  • 33
  • 38
0

Turn off electric-indent-mode for perl-mode is how I do it. I add the following in my ~/.emacs.d/init.el

(defun perl-mode-disable-auto-indent()
    (electric-indent-mode -1))
(add-hook 'perl-mode-hook 'perl-mode-disable-auto-indent)

You can find similar posts here, here, and here

Community
  • 1
  • 1
xxks-kkk
  • 2,336
  • 3
  • 28
  • 48