* Indentation.
@ 2006-10-27 16:17 zombek
2006-10-27 16:53 ` Indentation Sam Peterson
0 siblings, 1 reply; 56+ messages in thread
From: zombek @ 2006-10-27 16:17 UTC (permalink / raw)
Hi.
I'm new to emacs and I'd like to set 2 things:
1) 4 space indentation (no mather which language) and it shouldn't care
about the syntax - when I say indent then indent
2)when I press RETURN when beeing on some indentation level i should
automatically go to the same indentation level in the new line without
the need to press TAB
Szymon
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-27 16:17 Indentation zombek
@ 2006-10-27 16:53 ` Sam Peterson
2006-10-27 18:58 ` Indentation Sam Peterson
0 siblings, 1 reply; 56+ messages in thread
From: Sam Peterson @ 2006-10-27 16:53 UTC (permalink / raw)
>>>>> "zombek" == zombek <zombek@gmail.com> writes:
> Hi. I'm new to emacs and I'd like to set 2 things: 1) 4 space
> indentation (no mather which language) and it shouldn't care
> about the syntax - when I say indent then indent 2)when I press
> RETURN when beeing on some indentation level i should
> automatically go to the same indentation level in the new line
> without the need to press TAB
(setq-default indent-tabs-mode nil)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\C-m" 'newline)
For cc-mode and modes derivative of cc-mode, the following will set
indentation to 4 spaces:
(setq c-basic-offset 4)
For the same modes, this will turn off syntactic indentation (electric
parens and braces).
(setq c-syntactic-indentation nil)
For other languages I'm not sure. I always saw syntactic indentation
as a useful feature. If you absolutely want TAB to indent 4-spaces
regardless, try this:
(fset 'four-space-indent "\C-u ")
(add-hook 'c-mode-hook
(lambda () (local-set-key [tab] 'four-space-indent)))
Use other hooks for other language modes.
HTH.
--
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-27 16:53 ` Indentation Sam Peterson
@ 2006-10-27 18:58 ` Sam Peterson
2006-10-28 16:25 ` Indentation jmg3000
0 siblings, 1 reply; 56+ messages in thread
From: Sam Peterson @ 2006-10-27 18:58 UTC (permalink / raw)
>>>>> "Sam" == Sam Peterson <skpeterson@nospam.please.ucdavis.edu> writes:
> (global-set-key "\C-m" 'newline-and-indent)
> (global-set-key "\C-m" 'newline)
Woops! That second line should be:
(global-set-key "\C-j" 'newline)
There.
--
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-27 18:58 ` Indentation Sam Peterson
@ 2006-10-28 16:25 ` jmg3000
2006-10-28 16:28 ` Indentation jmg3000
2006-10-28 16:54 ` Indentation don provan
0 siblings, 2 replies; 56+ messages in thread
From: jmg3000 @ 2006-10-28 16:25 UTC (permalink / raw)
Sam Peterson wrote:
> >>>>> "Sam" == Sam Peterson <skpeterson@nospam.please.ucdavis.edu> writes:
>
> > (global-set-key "\C-m" 'newline-and-indent)
> > (global-set-key "\C-m" 'newline)
>
> Woops! That second line should be:
>
> (global-set-key "\C-j" 'newline)
>
> There.
I've also seen that written
(global-set-key "\r" 'newline-and-indent)
and that seems to work also. So, Sam, that plus
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
should be just what you want.
---John
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-28 16:25 ` Indentation jmg3000
@ 2006-10-28 16:28 ` jmg3000
2006-10-28 16:54 ` Indentation don provan
1 sibling, 0 replies; 56+ messages in thread
From: jmg3000 @ 2006-10-28 16:28 UTC (permalink / raw)
jmg3...@gmail.com wrote:
> [snip]
> So, Sam, [snip ]
> should be just what you want.
Whoops. s/Sam/Szymon/.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-28 16:25 ` Indentation jmg3000
2006-10-28 16:28 ` Indentation jmg3000
@ 2006-10-28 16:54 ` don provan
2006-10-28 23:29 ` Indentation jmg3000
1 sibling, 1 reply; 56+ messages in thread
From: don provan @ 2006-10-28 16:54 UTC (permalink / raw)
jmg3000@gmail.com writes:
> (setq-default tab-width 4)
>
> should be just what you want.
Whoa! The original question quite correctly asked for four *space*
indentation. Changing the tab width to some non-standard value is
irrelevant, just typical confusion between the tab character in the
file (which, if other than 8 characters, can conflict with other
utilities) and the indent command that moves lines according to a
visual intentation scheme that has nothing at all to do with the tab
setting.
Also, there's no reason to suggest setting this value *globally*.
Let's just teach him to set it in the buffers he wants this special
indentation in: maybe as he gets used to normal "smart" indentation in
other modes, he'll loosen up about how he thinks indentation should
work.
-don
^ permalink raw reply [flat|nested] 56+ messages in thread
* Indentation
@ 2022-01-26 14:13 Pierre L. Nageoire
2022-01-26 21:18 ` Indentation Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 56+ messages in thread
From: Pierre L. Nageoire @ 2022-01-26 14:13 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
A few days ago with a macro of the form (define-something indentation
below was of two characters. I find it suitable ... But after installing
the last git version of emacs I got only one character : I dislike it !
There might be a variable to customize somewhere but don't know where !
Regards
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation
2022-01-26 14:13 Indentation Pierre L. Nageoire
@ 2022-01-26 21:18 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-27 3:30 ` Indentation Pierre L. Nageoire
0 siblings, 1 reply; 56+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-01-26 21:18 UTC (permalink / raw)
To: help-gnu-emacs
Pierre L. Nageoire wrote:
> A few days ago with a macro of the form (define-something
> indentation below was of two characters. I find it suitable
> ... But after installing the last git version of emacs I got
> only one character : I dislike it ! There might be
> a variable to customize somewhere but don't know where !
You mean this looks like this?
(define-error
nil nil)
Try `eval'ing this ...
(put 'define-error 'lisp-indent-function 0)
Then it looks like this, right?
(define-error
nil nil)
Don't know what happened or why tho ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation
2022-01-26 21:18 ` Indentation Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-01-27 3:30 ` Pierre L. Nageoire
2022-01-27 10:15 ` Indentation Robert Pluim
0 siblings, 1 reply; 56+ messages in thread
From: Pierre L. Nageoire @ 2022-01-27 3:30 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> Pierre L. Nageoire wrote:
>
>> A few days ago with a macro of the form (define-something
>> indentation below was of two characters. I find it suitable
>> ... But after installing the last git version of emacs I got
>> only one character : I dislike it ! There might be
>> a variable to customize somewhere but don't know where !
>
> You mean this looks like this?
>
> (define-error
> nil nil)
Exactly !
>
> Try `eval'ing this ...
>
> (put 'define-error 'lisp-indent-function 0)
I can actually do that for all my macros that start with define
>
> Then it looks like this, right?
>
> (define-error
> nil nil)
Yes exactly
>
> Don't know what happened or why tho ...
If someone could explain why the indent mechanism has soddenly been
changed I would be glad !
Regards
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation
2022-01-27 3:30 ` Indentation Pierre L. Nageoire
@ 2022-01-27 10:15 ` Robert Pluim
2022-01-28 6:31 ` Indentation Pierre L. Nageoire
0 siblings, 1 reply; 56+ messages in thread
From: Robert Pluim @ 2022-01-27 10:15 UTC (permalink / raw)
To: Pierre L. Nageoire; +Cc: help-gnu-emacs
>>>>> On Thu, 27 Jan 2022 04:30:36 +0100, "Pierre L. Nageoire" <devel@pollock-nageoire.net> said:
Pierre> If someone could explain why the indent mechanism has soddenly been
Pierre> changed I would be glad !
commit 32df2034234056bf24312ef5883671b59a387520
Author: Lars Ingebrigtsen <larsi@gnus.org>
Date: Mon Oct 18 10:00:20 2021 +0200
Remove the "def" indentation heuristic
* lisp/emacs-lisp/lisp-mode.el (lisp-indent-function): Don't
indent function calls with names that that start with "def"
specially (bug#43329).
and the corresponding etc/NEWS entry:
** 'def' indentation changes.
In 'emacs-lisp-mode', forms with a symbol with a name that start with
"def" have been automatically indented as if they were 'defun'-like
forms, for instance:
(defzot 1
2 3)
This heuristic has now been removed, and all functions/macros that
want to be indented this way have to be marked with
(declare (indent defun))
or the like. If the function/macro definition itself can't be
changed, the indentation can also be adjusted by saying something
like:
(put 'defzot 'lisp-indent-function 'defun)
Robert
--
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation
2022-01-27 10:15 ` Indentation Robert Pluim
@ 2022-01-28 6:31 ` Pierre L. Nageoire
0 siblings, 0 replies; 56+ messages in thread
From: Pierre L. Nageoire @ 2022-01-28 6:31 UTC (permalink / raw)
To: Robert Pluim; +Cc: help-gnu-emacs
Hi Robert,
Many thanks to have extracted this pertienent part of the emacs news !
First I now understand why the situation is so ; and secondly I know how
to custimize it for my own needs ! Perfect !
Regards
Robert Pluim <rpluim@gmail.com> writes:
>>>>>> On Thu, 27 Jan 2022 04:30:36 +0100, "Pierre L. Nageoire"
> <devel@pollock-nageoire.net> said:
>
> Pierre> If someone could explain why the indent mechanism has soddenly been
> Pierre> changed I would be glad !
>
> commit 32df2034234056bf24312ef5883671b59a387520
> Author: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon Oct 18 10:00:20 2021 +0200
>
> Remove the "def" indentation heuristic
>
> * lisp/emacs-lisp/lisp-mode.el (lisp-indent-function): Don't
> indent function calls with names that that start with "def"
> specially (bug#43329).
>
> and the corresponding etc/NEWS entry:
>
> ** 'def' indentation changes.
> In 'emacs-lisp-mode', forms with a symbol with a name that start with
> "def" have been automatically indented as if they were 'defun'-like
> forms, for instance:
>
> (defzot 1
> 2 3)
>
> This heuristic has now been removed, and all functions/macros that
> want to be indented this way have to be marked with
>
> (declare (indent defun))
>
> or the like. If the function/macro definition itself can't be
> changed, the indentation can also be adjusted by saying something
> like:
>
> (put 'defzot 'lisp-indent-function 'defun)
>
> Robert
^ permalink raw reply [flat|nested] 56+ messages in thread
* indentation
@ 2021-04-27 7:03 ptlo
2021-04-27 7:25 ` indentation Philip Kaludercic
` (2 more replies)
0 siblings, 3 replies; 56+ messages in thread
From: ptlo @ 2021-04-27 7:03 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
with never version of emacs (I have GNU Emacs 25.3.1 (x86_64-suse-linux-gnu, GTK+ Version 3.22.30)) I'm constantly annoyed by too aggressive automatic indentation when editing. Basically when I press enter, the cursor on the new line is automatically moved to the column of first character of the preceding line. This is in the Fundamental mode.
It gets even worse e.g. in the F90 mode. It e.g. moves a comment (starting with !) on preceding line to the column of first character of the next (really!) line when I add new line inside a code. This is crazy, why I couldn't have comment starting at column 1? The emacs simply can't know what I'm going to do on new empty line!!
In older emacs versions, when I presses enter, the cursor simply stayed at column 1 on new line. If I wanted a formatting, I pressed tab key. Please, please, how to return to this older setting? I went through all customizations containing indent, but nothing works.
Thank you!
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 7:03 indentation ptlo
@ 2021-04-27 7:25 ` Philip Kaludercic
2021-04-27 15:45 ` indentation ptlo
2021-04-27 9:30 ` indentation Gregory Heytings
2021-04-27 17:07 ` indentation Stefan Monnier
2 siblings, 1 reply; 56+ messages in thread
From: Philip Kaludercic @ 2021-04-27 7:25 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
<ptlo@centrum.cz> writes:
> Hello,
>
> with never version of emacs (I have GNU Emacs 25.3.1
> (x86_64-suse-linux-gnu, GTK+ Version 3.22.30)) I'm constantly annoyed
> by too aggressive automatic indentation when editing. Basically when I
> press enter, the cursor on the new line is automatically moved to the
> column of first character of the preceding line. This is in the
> Fundamental mode.
>
> It gets even worse e.g. in the F90 mode. It e.g. moves a comment
> (starting with !) on preceding line to the column of first character
> of the next (really!) line when I add new line inside a code. This is
> crazy, why I couldn't have comment starting at column 1? The emacs
> simply can't know what I'm going to do on new empty line!!
>
> In older emacs versions, when I presses enter, the cursor simply
> stayed at column 1 on new line. If I wanted a formatting, I pressed
> tab key. Please, please, how to return to this older setting? I went
> through all customizations containing indent, but nothing works.
>
> Thank you!
>
> Petr
Shouldn't this be disabled by deactivating electric-indent-mode?
--
Philip K.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 7:25 ` indentation Philip Kaludercic
@ 2021-04-27 15:45 ` ptlo
2021-04-27 16:06 ` indentation Colin Baxter
0 siblings, 1 reply; 56+ messages in thread
From: ptlo @ 2021-04-27 15:45 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: help-gnu-emacs
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.
Many thanks!
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 15:45 ` indentation ptlo
@ 2021-04-27 16:06 ` Colin Baxter
2021-04-27 18:43 ` indentation Thibaut Verron
0 siblings, 1 reply; 56+ messages in thread
From: Colin Baxter @ 2021-04-27 16:06 UTC (permalink / raw)
To: ptlo; +Cc: Philip Kaludercic, help-gnu-emacs
>>>>> <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
Best wishes,
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 16:06 ` indentation Colin Baxter
@ 2021-04-27 18:43 ` Thibaut Verron
2021-04-27 19:00 ` indentation Colin Baxter
0 siblings, 1 reply; 56+ messages in thread
From: Thibaut Verron @ 2021-04-27 18:43 UTC (permalink / raw)
To: Colin Baxter, ptlo; +Cc: Philip Kaludercic, help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 18:43 ` indentation Thibaut Verron
@ 2021-04-27 19:00 ` Colin Baxter
2021-04-27 19:20 ` indentation Thibaut Verron
0 siblings, 1 reply; 56+ messages in thread
From: Colin Baxter @ 2021-04-27 19:00 UTC (permalink / raw)
To: Thibaut Verron; +Cc: ptlo, Philip Kaludercic, help-gnu-emacs
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.
Best wishes,
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 19:00 ` indentation Colin Baxter
@ 2021-04-27 19:20 ` Thibaut Verron
2021-04-27 20:02 ` indentation Colin Baxter
0 siblings, 1 reply; 56+ messages in thread
From: Thibaut Verron @ 2021-04-27 19:20 UTC (permalink / raw)
To: Colin Baxter; +Cc: ptlo, Philip Kaludercic, help-gnu-emacs
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
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 19:20 ` indentation Thibaut Verron
@ 2021-04-27 20:02 ` Colin Baxter
2021-04-28 8:36 ` indentation Thibaut Verron
0 siblings, 1 reply; 56+ messages in thread
From: Colin Baxter @ 2021-04-27 20:02 UTC (permalink / raw)
To: Thibaut Verron; +Cc: ptlo, Philip Kaludercic, help-gnu-emacs
>>>>> 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.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 20:02 ` indentation Colin Baxter
@ 2021-04-28 8:36 ` Thibaut Verron
0 siblings, 0 replies; 56+ messages in thread
From: Thibaut Verron @ 2021-04-28 8:36 UTC (permalink / raw)
To: Colin Baxter; +Cc: ptlo, Philip Kaludercic, help-gnu-emacs
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
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 7:03 indentation ptlo
2021-04-27 7:25 ` indentation Philip Kaludercic
@ 2021-04-27 9:30 ` Gregory Heytings
2021-04-27 9:47 ` indentation Joost Kremers
2021-04-27 17:07 ` indentation Stefan Monnier
2 siblings, 1 reply; 56+ messages in thread
From: Gregory Heytings @ 2021-04-27 9:30 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
>
> with ne[w]er version of emacs (I have GNU Emacs 25.3.1
> (x86_64-suse-linux-gnu, GTK+ Version 3.22.30))
>
Note that Emacs 25.2 is not a "new" version of Emacs, the current stable
version is 27.2.
>
> I'm constantly annoyed by too aggressive automatic indentation when
> editing. Basically when I press enter, the cursor on the new line is
> automatically moved to the column of first character of the preceding
> line. This is in the Fundamental mode.
>
Yes, the default meaning of RET has changed in Emacs 24.4:
electric-indent-mode is enabled by default, which means that RET reindents
the current line and indents the next line. You can disable this by
adding (electric-indent-mode -1) to your init file.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 9:30 ` indentation Gregory Heytings
@ 2021-04-27 9:47 ` Joost Kremers
2021-04-27 16:55 ` indentation Stefan Monnier
0 siblings, 1 reply; 56+ messages in thread
From: Joost Kremers @ 2021-04-27 9:47 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
On Tue, Apr 27 2021, Gregory Heytings wrote:
>> I'm constantly annoyed by too aggressive automatic indentation when editing.
>> Basically when I press enter, the cursor on the new line is automatically
>> moved to the column of first character of the preceding line. This is in the
>> Fundamental mode.
>>
>
> Yes, the default meaning of RET has changed in Emacs 24.4: electric-indent-mode
> is enabled by default, which means that RET reindents the current line and
> indents the next line. You can disable this by adding (electric-indent-mode -1)
> to your init file.
Note that each new version of Emacs comes with a News file that describes all
the changes made in that version, esp. user-visible changes. There's usually
also information on how to get back the old behaviour (unless it's something
obvious, like disabling a minor mode, as is the case with indentation here).
So whenever you upgrade Emacs, it's always a good idea to check the News file,
which can be done easily in Emacs itself with `C-h n`. Keep in mind, though,
that if you skip a major version, the News file only contains changes for the
current major version, so anything that was changed in the version you skipped
won't be there. In that case, googling for "Emacs XX news" with XX being the
major version should get you the relevant News file.
I just thought I'd mention this because the change you encountered was made in
Emacs 24, while you say you upgraded to Emacs 25 (note, though, that Emacs 25.3
is already three and a half years old), so you wouldn't have found this change
by looking through the News file.
HTH
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 9:47 ` indentation Joost Kremers
@ 2021-04-27 16:55 ` Stefan Monnier
2021-04-27 22:12 ` indentation Gregory Heytings
0 siblings, 1 reply; 56+ messages in thread
From: Stefan Monnier @ 2021-04-27 16:55 UTC (permalink / raw)
To: help-gnu-emacs
> which can be done easily in Emacs itself with `C-h n`. Keep in mind, though,
> that if you skip a major version, the News file only contains changes for the
> current major version, so anything that was changed in the version you skipped
> won't be there. In that case, googling for "Emacs XX news" with XX being the
> major version should get you the relevant News file.
The news for the current version is in the file `.../etc/NEWS`, which is
what `C-h n` shows you. For older releases, you don't need to resort to
the internet: they're right there in `etc/NEWS.NN`.
I guess we could/should add a hyperlink at the end of `etc/NEWS` to the
previous files. You might want to suggest this improvement via `M-x
report-emacs-bug`.
Stefan
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 16:55 ` indentation Stefan Monnier
@ 2021-04-27 22:12 ` Gregory Heytings
0 siblings, 0 replies; 56+ messages in thread
From: Gregory Heytings @ 2021-04-27 22:12 UTC (permalink / raw)
To: help-gnu-emacs
>> which can be done easily in Emacs itself with `C-h n`. Keep in mind,
>> though, that if you skip a major version, the News file only contains
>> changes for the current major version, so anything that was changed in
>> the version you skipped won't be there. In that case, googling for
>> "Emacs XX news" with XX being the major version should get you the
>> relevant News file.
>
> The news for the current version is in the file `.../etc/NEWS`, which is
> what `C-h n` shows you. For older releases, you don't need to resort to
> the internet: they're right there in `etc/NEWS.NN`.
>
... and C-u NN C-h n opens the NEWS.NN file.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 7:03 indentation ptlo
2021-04-27 7:25 ` indentation Philip Kaludercic
2021-04-27 9:30 ` indentation Gregory Heytings
@ 2021-04-27 17:07 ` Stefan Monnier
2021-04-27 18:29 ` indentation ptlo
2 siblings, 1 reply; 56+ messages in thread
From: Stefan Monnier @ 2021-04-27 17:07 UTC (permalink / raw)
To: help-gnu-emacs
> It gets even worse e.g. in the F90 mode. It e.g. moves a comment (starting
> with !) on preceding line to the column of first character of the next
> (really!) line when I add new line inside a code. This is crazy, why
> I couldn't have comment starting at column 1? The emacs simply can't know
> what I'm going to do on new empty line!!
I'm not completely sure I understand the scenario you're describing
(and I'm not very familiar with F90's syntax either, my use of Fortran
dates back to the nineties but using F77), but it sounds like it might
simply be a bug.
Stefan
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 17:07 ` indentation Stefan Monnier
@ 2021-04-27 18:29 ` ptlo
2021-04-27 20:31 ` indentation Stefan Monnier
0 siblings, 1 reply; 56+ messages in thread
From: ptlo @ 2021-04-27 18:29 UTC (permalink / raw)
To: Stefan Monnier, help-gnu-emacs
I have a comment starting with ! in column 1, and a F90 code on next line starting around column 7. When I hit enter inside the comment, the rest of the comment is now on new line and aligned according to the *next* line (the F90 code). Moreover the start of the comment, instead of left alone -- is equally aligned too, i.e. the ! moved to around col. 7. This all happens even when above the comment was another comment starting e.g. in col. 1, not another F90 code, meaning that the indentation is governed by what follows not precedes. Crazines squared, isn't it?
Cheers
Petr
______________________________________________________________
> Od: "Stefan Monnier" <monnier@iro.umontreal.ca>
> Komu: help-gnu-emacs@gnu.org
> Datum: 27.04.2021 19:12
> Předmět: Re: indentation
>
>> It gets even worse e.g. in the F90 mode. It e.g. moves a comment (starting
>> with !) on preceding line to the column of first character of the next
>> (really!) line when I add new line inside a code. This is crazy, why
>> I couldn't have comment starting at column 1? The emacs simply can't know
>> what I'm going to do on new empty line!!
>
>I'm not completely sure I understand the scenario you're describing
>(and I'm not very familiar with F90's syntax either, my use of Fortran
>dates back to the nineties but using F77), but it sounds like it might
>simply be a bug.
>
>
> Stefan
>
>
>
>
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 18:29 ` indentation ptlo
@ 2021-04-27 20:31 ` Stefan Monnier
2021-04-28 6:32 ` indentation ptlo
0 siblings, 1 reply; 56+ messages in thread
From: Stefan Monnier @ 2021-04-27 20:31 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
> I have a comment starting with ! in column 1, and a F90 code on next line
> starting around column 7. When I hit enter inside the comment, the rest of
> the comment is now on new line and aligned according to the *next* line (the
> F90 code).
Without knowing more about the content of your code and comment (and
F90's syntax) I'm not sure if column 7 is the right choice for the
indentation of the new line, but it sounds reasonable.
> Moreover the start of the comment, instead of left alone -- is
> equally aligned too, i.e. the ! moved to around col. 7.
I expect the same happens if you just hit TAB instead of RET, right?
If so, the problem is not directly linked to the electric-indent-mode,
and is instead either a bug in f90-mode's indentation code or maybe it's
controlled by a config var in `f90-mode` (since it sounds to me that
comments in column 1 are an old F77 convention which you may or may not
want to follow in F90 code).
> This all happens even when above the comment was another comment
> starting e.g. in col. 1, not another F90 code, meaning that the
> indentation is governed by what follows not precedes.
It's probably neither: the indentation rules probably looks at preceding
*code* rather than preceding comments ;-)
> Crazines squared, isn't it?
There's always some twisted logic behind craziness.
Stefan
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-27 20:31 ` indentation Stefan Monnier
@ 2021-04-28 6:32 ` ptlo
2021-04-28 6:42 ` indentation Joost Kremers
2021-04-28 14:14 ` indentation Stefan Monnier
0 siblings, 2 replies; 56+ messages in thread
From: ptlo @ 2021-04-28 6:32 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Yes, it may be a bug/ feature of the F90 mode. But it got annoying only when the electric mode was active, otherwise the formatting was controlable (e.g. by tab key) and not disturbing. Look, when programming, one is often quite concentrated and not keen on seeing lines skipping unexpectedly here and there.
Cheers
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-28 6:32 ` indentation ptlo
@ 2021-04-28 6:42 ` Joost Kremers
2021-04-28 14:14 ` indentation Stefan Monnier
1 sibling, 0 replies; 56+ messages in thread
From: Joost Kremers @ 2021-04-28 6:42 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs, Stefan Monnier
On Wed, Apr 28 2021, ptlo@centrum.cz wrote:
> Yes, it may be a bug/ feature of the F90 mode. But it got annoying only when the
> electric mode was active, otherwise the formatting was controlable (e.g. by tab
> key) and not disturbing. Look, when programming, one is often quite concentrated
> and not keen on seeing lines skipping unexpectedly here and there.
The particular feature that the current line, i.e., the line on which one hits
RET, is re-indented, can be turned off by setting the variable
`electric-indent-inhibit` to `t`. (The name of this variable is somewhat
confusing, IMHO, because it suggests electric indent is inhibited altogether,
but in actual fact, as the doc string says, in inhibits *re*indentation).
With this feature turned off, which I find rather annoying myself,
electric-indent basically saves me from having to type TAB all the time. Even in
Python code, electric indent gets it right most of the time.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-28 6:32 ` indentation ptlo
2021-04-28 6:42 ` indentation Joost Kremers
@ 2021-04-28 14:14 ` Stefan Monnier
2021-04-29 7:14 ` indentation ptlo
2021-04-29 21:14 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
1 sibling, 2 replies; 56+ messages in thread
From: Stefan Monnier @ 2021-04-28 14:14 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
> Yes, it may be a bug/ feature of the F90 mode. But it got annoying only when
> the electric mode was active, otherwise the formatting was controlable
> (e.g. by tab key) and not disturbing.
Indeed. `electric-indent-mode` presumes that the indentation code
gets it right. If that's not the case, then you're better off disabling
it (or, as Joost points out, just disabling the reindentation by setting
`electric-indent-inhibit`).
But that doesn't mean we shouldn't try to make the indentation "do the
right thing" ;-)
Stefan
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-28 14:14 ` indentation Stefan Monnier
@ 2021-04-29 7:14 ` ptlo
2021-04-29 13:43 ` indentation Stefan Monnier
2021-04-29 21:14 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 56+ messages in thread
From: ptlo @ 2021-04-29 7:14 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
I admit I'm not a fan of gimmicks that are smarter than me... Now go for insert-programmer-infront-of-computer! Or for a start indent-programmer-looking-sideways? :-)
Cheers
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-29 7:14 ` indentation ptlo
@ 2021-04-29 13:43 ` Stefan Monnier
2021-04-29 14:23 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 7:05 ` indentation ptlo
0 siblings, 2 replies; 56+ messages in thread
From: Stefan Monnier @ 2021-04-29 13:43 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
> I admit I'm not a fan of gimmicks that are smarter than me...
I think you'll like (electric-indent-mode -1), then ;-)
More seriously, this does not necessarily require "smarts":
in some (many?) projects, the coding conventions says precisely
how indentation should be done, so there is no "smartness" involved and
if you don't like what the auto-indentation does, either it's because of
a bug in the code, or it's because you disagree with the conventions (and
overriding the conventions should be rare).
In those cases, typically the coders end up controlling the indentation
only indirectly, e.g. by carefully choosing where they cut the lines, or
by swapping arguments to commutative operations, or by other such means.
Stefan
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-29 13:43 ` indentation Stefan Monnier
@ 2021-04-29 14:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 7:05 ` indentation ptlo
1 sibling, 0 replies; 56+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-04-29 14:23 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier wrote:
> More seriously, this does not necessarily require "smarts":
> in some (many?) projects, the coding conventions says
> precisely how indentation should be done, so there is no
> "smartness" involved and if you don't like what the
> auto-indentation does, either it's because of a bug in the
> code, or it's because you disagree with the conventions (and
> overriding the conventions should be rare).
That's exactly right, set up the technology to do the routine
stuff and only where it matters you apply your own creativity
and brilliance so it will be put into just the right place :)
Some people say Emacs is all about automation, other say pro
programmers are so productive with Emacs it is amazing, yet
other say Emacs makes you so creative virtually nothing ever
gets done...
But actually I think one should instead think of all that as
positive entities that work _together_, and not at
all orthogonally. Or at the very least it doesn't HAVE to be
like that!
Like the Greek poets and drama writers of the ancient world,
they had tons of formal rules, methods, a whole scientific
approach to their craft and art, with terminology and
everything. But as it happens, knowing all that was not
a limitation, on the contrary it OPENED the doors of
inspiration and creativity. And made it more fun and
interesting while doing it, I'm sure!
So greetings from Sweden to all Emacs hackers all around the
world, I'll do my best to return to Elisp myself as soon as
possible God willing.
https://dataswamp.org/~incal/ut/ut.png
https://dataswamp.org/~incal/ut/ut.webp
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-29 13:43 ` indentation Stefan Monnier
2021-04-29 14:23 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-04-30 7:05 ` ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
` (2 more replies)
1 sibling, 3 replies; 56+ messages in thread
From: ptlo @ 2021-04-30 7:05 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Imposing conventions is of use when many and changing (and beginner) programmers work on same code. It's not my case. But the problem where it all started is, when I press enter, the new empty line got indented to first character of previous line. There is absolutely no reason to impose that the block shall continue. Instead, an END statement may follow which is indented differently. Also one can wish to insert an empty line and then an automated insertion of spaces for no reason is hard to justify. Indeed I always felt the urge to delete those spaces (still was thinking how to do it as fast as possible and get over without new indentation...)
Strange thing is that I didn't find the electric indent searching "indent" from menu in customization groups.
Cheers
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 7:05 ` indentation ptlo
@ 2021-04-30 7:58 ` Philip Kaludercic
2021-04-30 8:54 ` indentation ptlo
2021-04-30 19:05 ` indentation Jean Louis
2021-04-30 21:58 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 1 reply; 56+ messages in thread
From: Philip Kaludercic @ 2021-04-30 7:58 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs
<ptlo@centrum.cz> writes:
> But the problem where it all started is, when I press enter, the new
> empty line got indented to first character of previous line. There is
> absolutely no reason to impose that the block shall continue. Instead,
> an END statement may follow which is indented differently. Also one
> can wish to insert an empty line and then an automated insertion of
> spaces for no reason is hard to justify. Indeed I always felt the urge
> to delete those spaces (still was thinking how to do it as fast as
> possible and get over without new indentation...)
What language are we talking about? Maybe it is not clever enough,
ie. you haven't enabled electric-pair-mode? When working with C, that
automatically inserts the opening and closing parentheses, and when I
press enter
{|}
becomes
{
|
}
just as I would want it. And of course, all instructions should be
intended.
Even if I weren't to enable electric-pair-mode, electric-indent-mode
would do the right thing when closing a block, because it automatically
re-indents the '}', when it is on it's own.
--
Philip K.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 7:58 ` indentation Philip Kaludercic
@ 2021-04-30 8:54 ` ptlo
2021-04-30 9:09 ` indentation Thibaut Verron
0 siblings, 1 reply; 56+ messages in thread
From: ptlo @ 2021-04-30 8:54 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: help-gnu-emacs
I'm talking of Fortran, F90 mode. But the same indentation occurs in Fundamental mode too.
When I write parenthesis, I'm used to type both at once (they are one next to other on keyboard)cand then return by 1 character. I've seen the habit at one teacher years ago.
Petr
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 8:54 ` indentation ptlo
@ 2021-04-30 9:09 ` Thibaut Verron
2021-04-30 9:18 ` indentation ptlo
0 siblings, 1 reply; 56+ messages in thread
From: Thibaut Verron @ 2021-04-30 9:09 UTC (permalink / raw)
To: ptlo, Philip Kaludercic; +Cc: help-gnu-emacs
On 4/30/21 10:54 AM, ptlo@centrum.cz wrote:
> I'm talking of Fortran, F90 mode. But the same indentation occurs in Fundamental mode too.
> When I write parenthesis, I'm used to type both at once (they are one next to other on keyboard)cand then return by 1 character. I've seen the habit at one teacher years ago.
Have you tried electric-pair-mode or something similar? Those modes
automate the insertion of the closing pair, essentially saving you that
insertion and the C-b.
Some 3rd-party packages such as smartparens also help you switch from
manual insertion of the pairs to automatic, by silently ignoring the
closing pair insertion. That is: pressing '(' results in "([])" ([] is
the point), and pressing ')' then results in "()[]".
Thibaut
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 7:05 ` indentation ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
@ 2021-04-30 19:05 ` Jean Louis
2021-04-30 19:59 ` indentation Stefan Monnier
2021-04-30 21:58 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 1 reply; 56+ messages in thread
From: Jean Louis @ 2021-04-30 19:05 UTC (permalink / raw)
To: ptlo; +Cc: help-gnu-emacs, Stefan Monnier
* ptlo@centrum.cz <ptlo@centrum.cz> [2021-04-30 10:08]:
> Imposing conventions is of use when many and changing (and beginner)
> programmers work on same code. It's not my case. But the problem
> where it all started is, when I press enter, the new empty line got
> indented to first character of previous line. There is absolutely no
> reason to impose that the block shall continue.
I find that very handy when I am writing lists where list's text is
for 2-3 characters indented like this below:
- Something
and more
and one more line
For programming if you use programming mode, it will indent just
right. Which language is it?
To me it looks somehow weird if it is Fortran:
program hello
! This is a comment line, it is ignored by the compiler
print *, 'Hello, World!'
end program hello
As when I mark region and press TAB, somehow I expect different kind
of indentation. That looks weird now. I think it is bug in fortran-mode
Maybe you should M-x report-bug
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 7:05 ` indentation ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
2021-04-30 19:05 ` indentation Jean Louis
@ 2021-04-30 21:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 56+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-04-30 21:58 UTC (permalink / raw)
To: help-gnu-emacs
ptlo wrote:
> Imposing conventions is of use when many and changing (and
> beginner) programmers work on same code. It's not my case.
> [...]
OK, unless the word "imposing" makes this mean something that
I don't understand in this context, what you say isn't, to use
your word, the case!
Pro programmers use conventions even (especially) for code
only they work on.
Obey tradition!
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-28 14:14 ` indentation Stefan Monnier
2021-04-29 7:14 ` indentation ptlo
@ 2021-04-29 21:14 ` Wayne Harris via Users list for the GNU Emacs text editor
2021-04-30 20:17 ` indentation Tassilo Horn
1 sibling, 1 reply; 56+ messages in thread
From: Wayne Harris via Users list for the GNU Emacs text editor @ 2021-04-29 21:14 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Yes, it may be a bug/ feature of the F90 mode. But it got annoying
>> only when
>> the electric mode was active, otherwise the formatting was controlable
>> (e.g. by tab key) and not disturbing.
>
> Indeed. `electric-indent-mode` presumes that the indentation code
> gets it right. If that's not the case, then you're better off disabling
> it (or, as Joost points out, just disabling the reindentation by setting
> `electric-indent-inhibit`).
>
> But that doesn't mean we shouldn't try to make the indentation "do the
> right thing" ;-)
FWIW, I almost gave up from going from 24.3 to 27.1 precisely because of
electric-indent-mode
without knowing that was the cause of the new behavior (in my
perspective). Today I was writing some TeX and the following happened.
Let me use ``[]'' to represent the point.
--8<---------------cut here---------------start------------->8---
\noindent {\em Notation.} As we often write polynomials in
finite rings of characterisc 2, let's define
%v
\[\poly(x) = ...\]
%e
in the same way that it was used in the introduction. []%% Well...
--8<---------------cut here---------------end--------------->8---
When I pressed RET, I got this
--8<---------------cut here---------------start------------->8---
\noindent {\em Notation.} As we often write polynomials in
finite rings of characterisc 2, let's define
%v
\[\poly(x) = ...\]
%e
in the same way that it was used in the introduction.
[]%% Well...
--8<---------------cut here---------------end--------------->8---
I have been reading this thread, so I just turned it off for the first
time. I got used to it in other ways, but this behavior up there made
me turn it off and leave it off from now on. (And it scared the hell
out of me when I saw it first. Lol.)
Having said that, I recognize that many times I get to see new features
because they become the default. It takes a long while for me to
actually dig new features as an attempt to solve a problem. But you
know me by now --- I like stability a lot and so I stick to a version
for many, many years.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-29 21:14 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
@ 2021-04-30 20:17 ` Tassilo Horn
2021-05-01 13:43 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 56+ messages in thread
From: Tassilo Horn @ 2021-04-30 20:17 UTC (permalink / raw)
To: Wayne Harris; +Cc: help-gnu-emacs
Wayne Harris via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
Hi Wayne,
> Today I was writing some TeX and the following happened. Let me use
> ``[]'' to represent the point.
>
> \noindent {\em Notation.} As we often write polynomials in
> finite rings of characterisc 2, let's define
> %v
> \[\poly(x) = ...\]
> %e
> in the same way that it was used in the introduction. []%% Well...
>
> When I pressed RET, I got this
>
> \noindent {\em Notation.} As we often write polynomials in
> finite rings of characterisc 2, let's define
> %v
> \[\poly(x) = ...\]
> %e
> in the same way that it was used in the introduction.
> []%% Well...
Electric indent works well when you just let Emacs do the indentation.
In your example, Emacs wouldn't indent the inline math (hitting TAB in
that line makes it pop to column 0), and then the next sentence wouldn't
be indented as well. So basically you are fighting Emacs' LaTeX
indentation rules, and that becomes harder when `electric-indent-mode'
is enabled [1]. (At least with AUCTeX, `fill-paragraph' will also
adjust the indentation.)
FWIW, I'd write your example as
--8<---------------cut here---------------start------------->8---
\noindent {\em Notation.} As we often write polynomials in finite rings of
characterisc 2, let's define
\[
\poly(x) = ...
\]
in the same way that it was used in the introduction.
--8<---------------cut here---------------end--------------->8---
which is indented according to how AUCTeX would do it or the builtin
`latex-mode' if `latex-indent-within-escaped-parens' is t.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-04-30 20:17 ` indentation Tassilo Horn
@ 2021-05-01 13:43 ` Wayne Harris via Users list for the GNU Emacs text editor
2021-05-02 7:20 ` indentation Tassilo Horn
0 siblings, 1 reply; 56+ messages in thread
From: Wayne Harris via Users list for the GNU Emacs text editor @ 2021-05-01 13:43 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn <tsdh@gnu.org> writes:
> Wayne Harris via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
> Hi Wayne,
>
>> Today I was writing some TeX and the following happened. Let me use
>> ``[]'' to represent the point.
>>
>> \noindent {\em Notation.} As we often write polynomials in
>> finite rings of characterisc 2, let's define
>> %v
>> \[\poly(x) = ...\]
>> %e
>> in the same way that it was used in the introduction. []%% Well...
>>
>> When I pressed RET, I got this
>>
>> \noindent {\em Notation.} As we often write polynomials in
>> finite rings of characterisc 2, let's define
>> %v
>> \[\poly(x) = ...\]
>> %e
>> in the same way that it was used in the introduction.
>> []%% Well...
>
> Electric indent works well when you just let Emacs do the indentation.
> In your example, Emacs wouldn't indent the inline math (hitting TAB in
> that line makes it pop to column 0), and then the next sentence wouldn't
> be indented as well. So basically you are fighting Emacs' LaTeX
> indentation rules, and that becomes harder when `electric-indent-mode'
> is enabled [1]. (At least with AUCTeX, `fill-paragraph' will also
> adjust the indentation.)
>
> FWIW, I'd write your example as
>
> \noindent {\em Notation.} As we often write polynomials in finite rings of
> characterisc 2, let's define
> \[
> \poly(x) = ...
> \]
> in the same way that it was used in the introduction.
>
> which is indented according to how AUCTeX would do it or the builtin
> `latex-mode' if `latex-indent-within-escaped-parens' is t.
Thank you. I had no idea what was going on there. Clearly the root
cause of the problem is not understanding what is going on. That's
life: I took a while to begin using paredit-mode precisely for not being
able to minimially live with it, but it's been really worth it to try.
(I use it constantly now.) Maybe the same will happen with
electric-indent-mode.
Definitely consider this subthread a request for help, not a complaint.
But like the OP remarked, as these different behaviors appear after an
upgrade to a newer version, it's a bit scary to imagine we won't survive
with the new version.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-05-01 13:43 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
@ 2021-05-02 7:20 ` Tassilo Horn
2021-05-04 21:03 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 56+ messages in thread
From: Tassilo Horn @ 2021-05-02 7:20 UTC (permalink / raw)
To: help-gnu-emacs
Wayne Harris via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
Hey Wayne,
>> FWIW, I'd write your example as
>>
>> \noindent {\em Notation.} As we often write polynomials in finite rings of
>> characterisc 2, let's define
>> \[
>> \poly(x) = ...
>> \]
>> in the same way that it was used in the introduction.
>>
>> which is indented according to how AUCTeX would do it or the builtin
>> `latex-mode' if `latex-indent-within-escaped-parens' is t.
>
> Thank you. I had no idea what was going on there. Clearly the root
> cause of the problem is not understanding what is going on. That's
> life:
Absolutely!
> I took a while to begin using paredit-mode precisely for not being
> able to minimially live with it, but it's been really worth it to try.
> (I use it constantly now.) Maybe the same will happen with
> electric-indent-mode.
Possibly. If you want to, you might also want to try the
`aggressive-indent' package (from MELPA; its minor-mode is
`aggressive-indent-mode') which is essentially `electric-indent-mode' on
steroids, i.e., it indents the current function according to the mode's
rules on every edit which makes it completely impossible to fight
against the mode's indentation rules. (Of course, aggressive-indent is
mostly suited with programming modes; it works very well with lisp.)
Bye,
Tassilo
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: indentation
2021-05-02 7:20 ` indentation Tassilo Horn
@ 2021-05-04 21:03 ` Wayne Harris via Users list for the GNU Emacs text editor
2021-05-05 1:46 ` indentation Stefan Monnier via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 56+ messages in thread
From: Wayne Harris via Users list for the GNU Emacs text editor @ 2021-05-04 21:03 UTC (permalink / raw)
To: help-gnu-emacs
Tassilo Horn <tsdh@gnu.org> writes:
> Wayne Harris via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
> Hey Wayne,
>
>>> FWIW, I'd write your example as
>>>
>>> \noindent {\em Notation.} As we often write polynomials in finite rings of
>>> characterisc 2, let's define
>>> \[
>>> \poly(x) = ...
>>> \]
>>> in the same way that it was used in the introduction.
>>>
>>> which is indented according to how AUCTeX would do it or the builtin
>>> `latex-mode' if `latex-indent-within-escaped-parens' is t.
>>
>> Thank you. I had no idea what was going on there. Clearly the root
>> cause of the problem is not understanding what is going on. That's
>> life:
>
> Absolutely!
>
>> I took a while to begin using paredit-mode precisely for not being
>> able to minimially live with it, but it's been really worth it to try.
>> (I use it constantly now.) Maybe the same will happen with
>> electric-indent-mode.
>
> Possibly. If you want to, you might also want to try the
> `aggressive-indent' package (from MELPA; its minor-mode is
> `aggressive-indent-mode') which is essentially `electric-indent-mode' on
> steroids, i.e., it indents the current function according to the mode's
> rules on every edit which makes it completely impossible to fight
> against the mode's indentation rules. (Of course, aggressive-indent is
> mostly suited with programming modes; it works very well with lisp.)
Lol! I like that a lot, actually. It would show me what are the rules.
I didn't it in the previous message, but I almost wrote that I was going
against it because I didn't know what the rules were in the first
place. If software will do a reasonable job and all by itself, I'm
definitely willing to accept the reasonable result.
So, I'll report back if my experience is interesting wih the
aggressive-indent package. Thanks for pointing it out.
^ permalink raw reply [flat|nested] 56+ messages in thread
* Indentation.
@ 2006-10-27 16:17 zombek
2006-10-27 16:46 ` Indentation Markus Triska
0 siblings, 1 reply; 56+ messages in thread
From: zombek @ 2006-10-27 16:17 UTC (permalink / raw)
Hi.
I'm new to emacs and I'd like to set 2 things:
1) 4 space indentation (no mather which language) and it shouldn't care
about the syntax - when I say indent then indent
2)when I press RETURN when beeing on some indentation level i should
automatically go to the same indentation level in the new line without
the need to press TAB
Szymon
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-27 16:17 Indentation zombek
@ 2006-10-27 16:46 ` Markus Triska
2006-10-27 18:01 ` Indentation Malte Spiess
0 siblings, 1 reply; 56+ messages in thread
From: Markus Triska @ 2006-10-27 16:46 UTC (permalink / raw)
zombek@gmail.com writes:
> 1) 4 space indentation (no mather which language) and it shouldn't care
> about the syntax - when I say indent then indent
Add this to the modes in which you want 4 spaces when you press TAB:
(local-set-key "\t" (lambda () (interactive) (insert " ")))
> 2)when I press RETURN when beeing on some indentation level i should
> automatically go to the same indentation level in the new line without
> the need to press TAB
(global-set-key "\C-m" 'newline-and-indent)
Best wishes! -- Markus Triska
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation.
2006-10-27 16:46 ` Indentation Markus Triska
@ 2006-10-27 18:01 ` Malte Spiess
2006-11-01 20:41 ` Indentation Markus Triska
0 siblings, 1 reply; 56+ messages in thread
From: Malte Spiess @ 2006-10-27 18:01 UTC (permalink / raw)
Markus Triska <triska@gmx.at> writes:
> zombek@gmail.com writes:
>
>> 1) 4 space indentation (no mather which language) and it shouldn't care
>> about the syntax - when I say indent then indent
>
> Add this to the modes in which you want 4 spaces when you press TAB:
>
> (local-set-key "\t" (lambda () (interactive) (insert " ")))
I have to say that I don't think that this is a very good idea since
every other function that has to do with indentation will ruin your
setup. (indent-region,...)
You should stick to what Sam has recommended and maybe think your intend
over.
I guess that there are some modes in which an indentation of 4 is really
not a good idea, like LaTeX mode or html stuff (ymmv). Plus I don't
think that this is a easy to accomplish feature. I would recommend a
more precise setup for each mode. The modes for c-like-languages can be
changed all in one step.
>> 2)when I press RETURN when beeing on some indentation level i should
>> automatically go to the same indentation level in the new line without
>> the need to press TAB
>
> (global-set-key "\C-m" 'newline-and-indent)
This can be a good idea anyway. But keep in mind that C-j already does this.
Greetings
Malte
^ permalink raw reply [flat|nested] 56+ messages in thread
* Indentation
@ 2006-07-03 22:01 Ronny Mandal
2006-07-03 23:00 ` Indentation Colin S. Miller
0 siblings, 1 reply; 56+ messages in thread
From: Ronny Mandal @ 2006-07-03 22:01 UTC (permalink / raw)
Hi.
Does anyone know how I get rid of the annoying indentation after e.g.
if-statements (in multiple languages), i.e. (C-example):
if(condition)
{ /*Why?!*/
}
Thanks.
-RM
^ permalink raw reply [flat|nested] 56+ messages in thread
* Re: Indentation
2006-07-03 22:01 Indentation Ronny Mandal
@ 2006-07-03 23:00 ` Colin S. Miller
0 siblings, 0 replies; 56+ messages in thread
From: Colin S. Miller @ 2006-07-03 23:00 UTC (permalink / raw)
Ronny Mandal wrote:
> Hi.
>
> Does anyone know how I get rid of the annoying indentation after e.g.
> if-statements (in multiple languages), i.e. (C-example):
>
> if(condition)
> { /*Why?!*/
> }
>
>
> Thanks.
>
> -RM
That's the default indent style, its used for all GNU project code.
(c-add-style "myStyle" '("bsd"
(c-basic-offset . 4)))
(add-hook 'c-mode-common-hook '(lambda ()
(c-set-style "myStyle")))
should change it to a more-normal style.
NB,
This code is for XEmacs, it should work on GNU Emacs, but I haven't tested it.
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
^ permalink raw reply [flat|nested] 56+ messages in thread
[parent not found: <mailman.2266.1066871723.21628.help-gnu-emacs@gnu.org>]
* Re: indentation
[not found] <mailman.2266.1066871723.21628.help-gnu-emacs@gnu.org>
@ 2003-10-23 13:19 ` Gareth Rees
0 siblings, 0 replies; 56+ messages in thread
From: Gareth Rees @ 2003-10-23 13:19 UTC (permalink / raw)
Yen Tran wrote:
> How do I leave indentation mode unchanged? For example, if current
> *.c or *.cpp file is using 5 spaces as indentation, then use 5 spaces;
> if it's using 4-space tab, then use tab.
>
> By default, everything I edit with Emacs adds tab to file.
Emacs indentation behaviour in C mode is under the control of these
variables:
* 'indent-tabs-mode'
Indentation can insert tabs if this is non-nil.
* 'tab-width'
Distance between tab stops (for display of tab characters), in columns.
* 'c-basic-offset'
Amount of basic offset used by + and - symbols in 'c-offsets-alist'.
The best thing to do is to agree with all your colleagues to use spaces
for indentation (hence indent-tabs-mode should be nil) and how many of
them. Then you and they can set editor settings accordingly.
The next best thing to do is to specify behaviour for different files by
putting a local variables section into the file (see the Info node
(emacs)File Variables). For example, a file using indentation of 5
spaces should have the following somewhere near the end:
/* Local Variables: */
/* indent-tabs-mode: nil */
/* c-basic-offset: 5 */
/* End: */
while a file using tab characters for indent which you want to display
with tab stops every 4 characters should have the following:
/* Local Variables: */
/* indent-tabs-mode: t */
/* tab-width: 4 */
/* c-basic-offset: 4 */
/* End: */
If this is no good either, then you could write something that guesses
the settings for the file, and put that in c-mode-hook. For example,
you might do something like this:
(defun guess-indent-settings ()
(save-excursion
(goto-char (point-min))
;; Don't guess if local variables already set.
(when (and (not (search-forward "Local Variables:" nil t))
(re-search-forward "\\([\t ]*\\).*{\n\\1\\(\t\\| +\\)"
nil t))
(make-local-variable 'c-basic-offset)
(if (string= (match-string 2) "\t")
(setq indent-tabs-mode t
tab-width 4 ; See note below
c-basic-offset 4) ; Ditto
(setq indent-tabs-mode nil
c-basic-offset (length (match-string 2)))))))
(add-hook 'c-mode-hook 'guess-indent-settings)
Note that when code uses tab characters for indenting, there's no way to
automatically guess by reading the file how many columns are needed per
tab stop. A good reason not to use that indentation style!
As a last resort, I suppose you could look at the filename and apply
some rules based on what you know about the different projects you work
on, perhaps like this:
(setq indent-tabs-mode nil
c-basic-offset
(let ((f (buffer-file-name)))
(cond ((string-match "/projects/foo/" f) 5)
((string-match "/projects/bar/" f) 8)
(t 4))))
--
Gareth Rees http://www.garethrees.org/
^ permalink raw reply [flat|nested] 56+ messages in thread
* indentation
@ 2003-10-23 1:14 Yen Tran
0 siblings, 0 replies; 56+ messages in thread
From: Yen Tran @ 2003-10-23 1:14 UTC (permalink / raw)
Hi,
How do I leave indentation mode unchanged? For example, if current *.c or
*.cpp file is using 5 spaces as indentation, then use 5 spaces; if it's
using 4-space tab, then use tab.
By default, everything I edit with emacs adds tab to file.
Version I am using is GNU Emacs 21.2.1.
Thanks,
--yen
^ permalink raw reply [flat|nested] 56+ messages in thread
end of thread, other threads:[~2022-01-28 6:31 UTC | newest]
Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-27 16:17 Indentation zombek
2006-10-27 16:53 ` Indentation Sam Peterson
2006-10-27 18:58 ` Indentation Sam Peterson
2006-10-28 16:25 ` Indentation jmg3000
2006-10-28 16:28 ` Indentation jmg3000
2006-10-28 16:54 ` Indentation don provan
2006-10-28 23:29 ` Indentation jmg3000
-- strict thread matches above, loose matches on Subject: below --
2022-01-26 14:13 Indentation Pierre L. Nageoire
2022-01-26 21:18 ` Indentation Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-27 3:30 ` Indentation Pierre L. Nageoire
2022-01-27 10:15 ` Indentation Robert Pluim
2022-01-28 6:31 ` Indentation Pierre L. Nageoire
2021-04-27 7:03 indentation ptlo
2021-04-27 7:25 ` indentation Philip Kaludercic
2021-04-27 15:45 ` indentation ptlo
2021-04-27 16:06 ` indentation Colin Baxter
2021-04-27 18:43 ` indentation Thibaut Verron
2021-04-27 19:00 ` indentation Colin Baxter
2021-04-27 19:20 ` indentation Thibaut Verron
2021-04-27 20:02 ` indentation Colin Baxter
2021-04-28 8:36 ` indentation Thibaut Verron
2021-04-27 9:30 ` indentation Gregory Heytings
2021-04-27 9:47 ` indentation Joost Kremers
2021-04-27 16:55 ` indentation Stefan Monnier
2021-04-27 22:12 ` indentation Gregory Heytings
2021-04-27 17:07 ` indentation Stefan Monnier
2021-04-27 18:29 ` indentation ptlo
2021-04-27 20:31 ` indentation Stefan Monnier
2021-04-28 6:32 ` indentation ptlo
2021-04-28 6:42 ` indentation Joost Kremers
2021-04-28 14:14 ` indentation Stefan Monnier
2021-04-29 7:14 ` indentation ptlo
2021-04-29 13:43 ` indentation Stefan Monnier
2021-04-29 14:23 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-30 7:05 ` indentation ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
2021-04-30 8:54 ` indentation ptlo
2021-04-30 9:09 ` indentation Thibaut Verron
2021-04-30 9:18 ` indentation ptlo
2021-04-30 19:05 ` indentation Jean Louis
2021-04-30 19:59 ` indentation Stefan Monnier
2021-04-30 21:58 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
2021-04-29 21:14 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
2021-04-30 20:17 ` indentation Tassilo Horn
2021-05-01 13:43 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
2021-05-02 7:20 ` indentation Tassilo Horn
2021-05-04 21:03 ` indentation Wayne Harris via Users list for the GNU Emacs text editor
2021-05-05 1:46 ` indentation Stefan Monnier via Users list for the GNU Emacs text editor
2006-10-27 16:17 Indentation zombek
2006-10-27 16:46 ` Indentation Markus Triska
2006-10-27 18:01 ` Indentation Malte Spiess
2006-11-01 20:41 ` Indentation Markus Triska
2006-07-03 22:01 Indentation Ronny Mandal
2006-07-03 23:00 ` Indentation Colin S. Miller
[not found] <mailman.2266.1066871723.21628.help-gnu-emacs@gnu.org>
2003-10-23 13:19 ` indentation Gareth Rees
2003-10-23 1:14 indentation Yen Tran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).