help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to change Perl mode indentation to two spaces and no tabs?


From: Dan Espen
Subject: Re: How to change Perl mode indentation to two spaces and no tabs?
Date: Mon, 15 Jun 2015 16:10:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Kenneth Wolcott <kennethwolcott@gmail.com> writes:

R> On Mon, Jun 15, 2015 at 12:47 PM, John Mastro <john.b.mastro@gmail.com> 
wrote:
>>>   I like the syntax highlighting and the formatting (in general) of
>>> the perl mode, I just want multiples of two spaces for indentation
>>> rather than multiples of  four.
>>
>> Then it looks like you'll want something like:
>>
>>     (defun my-init-perl-mode ()
>>       (setq perl-indent-level 2
>>             perl-continued-statement-offset 2
>>             perl-continued-brace-offset -2))
>>
>>     (eval-after-load 'perl-mode
>>       '(add-hook 'perl-mode-hook #'my-init-perl-mode))
>>
>> See `C-h f perl-mode RET' for more information on those, and other,
>> options. I based the above on the "LW" style (the default) with every 4
>> replaced by a 2.
>>
>> --
>> john
>
> Thanks, John!
>
> I did as you suggested, looking at the built-in help for perl-mode.
>
> I'm now experimenting with these lines in my ~/.emacs file.
>
> Well, initial experiments still show that the default perl-mode still
> seems to override what I have in the ~/.emacs file, as the four-space
> indentation is still occurring.
>
> I'm still googling for this as well; haven't found the right info yet.

Make sure you are in perl-mode.
You could be in cperl-mode.

(Look at your mode line while editing a Perl file.)

Then set either perl-indent-level or cperl-indent-level in a hook as
shown above.

The technique above is going to require an Emacs restart to take effect.

Stilll having issues?
Add a message to the defun to verify that the defun is being run:

(message "defun has run")

-- 
Dan Espen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]