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

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

Re: indentation


From: Thibaut Verron
Subject: Re: indentation
Date: Wed, 28 Apr 2021 10:36:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

On 4/27/21 10:02 PM, Colin Baxter wrote:
Thibaut Verron <thibaut.verron@gmail.com> writes:
     > On 4/27/21 9:00 PM, Colin Baxter wrote:
     >> Hi Thibaut,
     >>
     >>>>>>> Thibaut Verron <thibaut.verron@gmail.com> writes:
     >> > On 4/27/21 6:06 PM, Colin Baxter wrote:
     >> >>>>>>> <ptlo@centrum.cz> writes: >> > Philip, this is it! I
     >> disabled the electric-indent-mode and >> emacs > is again sane. I
     >> didn't find this option before, looking >> in the > customization
     >> groups from the menu.
     >> >>
     >> >> In F-90 I switch off electric-indent-mode via a
     >> .dir-locals.el, >> viz
     >> >>
     >> >> #+begin_src elisp ((nil . ((f90-if-indent . 4) (f90-do-indent
     >> >> . 4) (f90-program-indent . 4) (f90-associate-indent . 4) >>
     >> (f90-critical-indent . 4) (f90-type-indent . 4) (eval add-hook >>
     >> 'f90-mode-hook (lambda () (electric-indent-local-mode -1)))))) >>
     >> #+end_src
     >>
     >> > Do you use a .dir-locals because you sometimes want to use >
     >> electric-indent-mode in fortran?
     >>
     >> > If yes, I don't think this will do what you want, as the eval
     >> form > will modify the global value of the hook.
     >>
     >> > However, if all you want is to never have electric-indent-mode
     >> in > fortran, you can just have the add-hook form in your .emacs.
     >>
     >> The latter. I use a dir-local and do not put the hook in ~/.emacs
     >> for the simple reason that I have other fortran (different
     >> versions) directories where I want the electric-indent-mode.

     > Oh, I see. Then something like the following should work, without
     > touching the hook for those other directories:

     > ((f90-mode . ((f90-if-indent . 4) (f90-do-indent . 4)
     > (f90-program-indent . 4) (f90-associate-indent . 4)
     > (f90-critical-indent . 4) (f90-type-indent . 4) (eval
     > . (electric-indent-local-mode -1))))

     > Best wishes, Thibaut

Right - that's what I wrote except I don't need no f90-mode since there ain't
no non-fortran files in the directory.

Ok, then the f90-mode bit is not necessary (but it doesn't hurt either). But the important change is the last line, setting the mode without modifying the hook.

You can test it yourself: with what you wrote, open a file in the directory with the dir-locals, re-open it to make sure the hook is run (maybe not necessary if the variables are set for all modes), and indeed electric-indent-mode is off.

But if you open another f90 file in one of your other directories, electric-indent-mode will be off there too.

Best wishes,

Thibaut




reply via email to

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