* indentation
@ 2021-04-27 7:03 ptlo
2021-04-27 7:25 ` indentation Philip Kaludercic
` (3 more replies)
0 siblings, 4 replies; 65+ 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] 65+ 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
` (2 subsequent siblings)
3 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* Re: indentation
2021-04-27 20:02 ` indentation Colin Baxter
@ 2021-04-28 8:36 ` Thibaut Verron
0 siblings, 0 replies; 65+ 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] 65+ 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 15:01 ` [External] : indentation Drew Adams
2021-04-27 17:07 ` indentation Stefan Monnier
3 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* Re: indentation
2021-04-27 16:55 ` indentation Stefan Monnier
@ 2021-04-27 22:12 ` Gregory Heytings
0 siblings, 0 replies; 65+ 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] 65+ messages in thread
* RE: [External] : 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 15:01 ` Drew Adams
2021-04-27 17:04 ` Stefan Monnier
2021-04-27 17:07 ` indentation Stefan Monnier
3 siblings, 1 reply; 65+ messages in thread
From: Drew Adams @ 2021-04-27 15:01 UTC (permalink / raw)
To: ptlo@centrum.cz, help-gnu-emacs@gnu.org
> 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.
Yes, as others have said, turn off `electric-indent-mode',
to restore the sane behavior you're used to and love. ;-)
This "modernization" was yet another attempt to make Emacs
seem more like other apps some people might be used to.
On n'arrete pas let progres...
"The emacs simply can't know", indeed. Fortunately, there's
a way to let it know, in this case.
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: [External] : indentation
2021-04-27 15:01 ` [External] : indentation Drew Adams
@ 2021-04-27 17:04 ` Stefan Monnier
2021-04-27 17:54 ` Drew Adams
0 siblings, 1 reply; 65+ messages in thread
From: Stefan Monnier @ 2021-04-27 17:04 UTC (permalink / raw)
To: help-gnu-emacs
> This "modernization" was yet another attempt to make Emacs
> seem more like other apps some people might be used to.
Huh? This modernization was pretty much a unilateral choice made by
yours truly, and I have no idea what "other apps" do in this regard, so
the intention was definitely not what you state.
Instead, it was based on a mix of my personal preference, a look at the
behavior of existing major modes (many of the most popular programming
modes having explicit rebindings of RET to some kind of "newline+indent"
command), and a desire to promote this new mode in the hope to speed up
the elimination of those mode-specific RET keybindings which really
aren't mode-specific at all in most cases but just reflect the
personal preference of their author.
I know full well that it disagrees with some users, but there has been
surprisingly few complaints over this change, so in retrospect I think
I made the right call (something which is always pretty hard to know
beforehand).
Stefan
^ permalink raw reply [flat|nested] 65+ messages in thread
* RE: [External] : indentation
2021-04-27 17:04 ` Stefan Monnier
@ 2021-04-27 17:54 ` Drew Adams
2021-04-27 20:23 ` Stefan Monnier
0 siblings, 1 reply; 65+ messages in thread
From: Drew Adams @ 2021-04-27 17:54 UTC (permalink / raw)
To: Stefan Monnier, help-gnu-emacs@gnu.org
> > This "modernization" was yet another attempt to make Emacs
> > seem more like other apps some people might be used to.
>
> Huh? This modernization was pretty much a unilateral choice made by
> yours truly, and I have no idea what "other apps" do in this regard, so
> the intention was definitely not what you state.
And yet you said things like this, as motivation for the change:
"because most people don't use C-j but use RET instead"
and
"I'm obviously not the only, because it's very common for
text editors to 'auto-indent on RET' (either by default,
or via a config setting).
And others who supported the change gave similar reasons:
"Every IDE does that [what `newline-and-indent' does] when
the user presses RET." (Dmitry)
"The days when keyboards had an LFD key that produced C-j
are long gone. Nowadays, keyboards have only the RET key,
and users expect it to indent in programming modes, at
least by default. As things are now, I need to customize
every programming mode I use to do that. I think it's
time for a change." (Eli)
The main argument in favor of this default change was, IMO,
modernization ("time for a change"), to align Emacs default
behavior with what users of other apps had come to expect.
I say that after reviewing the various discussions about
making such a change.
And no, it was not a unilateral choice by you. There was
quite a long discussion (more than one), with many voices
pro and con before a decision was made.
> I know full well that it disagrees with some users, but
> there has been surprisingly few complaints over this change,
It's easy enough to turn it off - that's the point. The
default doesn't matter a lot. But to say that few people
complained about the change is wrong - misleading, IMHO.
Once _changed_, few complain about most default changes
that are easy for an individual user to remedy/reverse.
That was the case here.
Just turn it off by default and Bob's your uncle, if you
don't want electric indenting by default. That's the
answer for Petr.
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: [External] : indentation
2021-04-27 17:54 ` Drew Adams
@ 2021-04-27 20:23 ` Stefan Monnier
2021-04-27 22:28 ` Stefan Monnier
0 siblings, 1 reply; 65+ messages in thread
From: Stefan Monnier @ 2021-04-27 20:23 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs@gnu.org
>> I know full well that it disagrees with some users, but
>> there has been surprisingly few complaints over this change,
> It's easy enough to turn it off - that's the point. The
> default doesn't matter a lot. But to say that few people
> complained about the change is wrong - misleading, IMHO.
AFAIK there are 3 types of users: those who want it ON, those who want it
OFF and those who don't care. I'm not sure how those are spread
statistically, but the number of complaints I've seen since the feature
was turned ON suggests that the first type is a small minority.
> Just turn it off by default and Bob's your uncle, if you
> don't want electric indenting by default. That's the
> answer for Petr.
Yes, like I do for many other Emacs features that are enabled
by default ;-)
Stefan
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: [External] : indentation
2021-04-27 20:23 ` Stefan Monnier
@ 2021-04-27 22:28 ` Stefan Monnier
0 siblings, 0 replies; 65+ messages in thread
From: Stefan Monnier @ 2021-04-27 22:28 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs@gnu.org
>>> I know full well that it disagrees with some users, but
>>> there has been surprisingly few complaints over this change,
>> It's easy enough to turn it off - that's the point. The
>> default doesn't matter a lot. But to say that few people
>> complained about the change is wrong - misleading, IMHO.
>
> AFAIK there are 3 types of users: those who want it ON, those who want it
> OFF and those who don't care. I'm not sure how those are spread
> statistically, but the number of complaints I've seen since the feature
> was turned ON suggests that the first type is a small minority.
Hmm... I think this came out wrong ;-)
I meant the second type is a small minority.
It might still be the case that the first type is an even smaller
minority, of course, but I find it hard to believe that the 3rd type
would be such an overwhelming majority of Emacs users.
Stefan
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: indentation
2021-04-27 7:03 indentation ptlo
` (2 preceding siblings ...)
2021-04-27 15:01 ` [External] : indentation Drew Adams
@ 2021-04-27 17:07 ` Stefan Monnier
2021-04-27 18:29 ` indentation ptlo
3 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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-29 21:38 ` on interface and behavior (Was: Re: indentation) Wayne Harris via Users list for the GNU Emacs text editor
2021-04-30 7:05 ` indentation ptlo
1 sibling, 1 reply; 65+ 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] 65+ messages in thread
* on interface and behavior (Was: Re: indentation)
2021-04-29 14:23 ` indentation Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-04-29 21:38 ` Wayne Harris via Users list for the GNU Emacs text editor
2021-04-30 7:53 ` Eli Zaretskii
0 siblings, 1 reply; 65+ messages in thread
From: Wayne Harris via Users list for the GNU Emacs text editor @ 2021-04-29 21:38 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> 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.
I'm for all that. However, I think in terms of user interface and
software behavior we should consider the following conjecture.
--8<---------------cut here---------------start------------->8---
Conjecture. Computer systems should pleasurable to use. In the work
and programming context, a pleasure-to-use system is one where the users
gets a sense of precise control. The user should be able to predict
where a window will show up and what's gonna happen to the text once
s/he presses RET, say.
--8<---------------cut here---------------end--------------->8---
(*) The case of frames in Windows
Speaking of which, FWIW, I have gone through extra lengths to try to get
frames to show up more consistently on Windows. Windows has no
reasonable window manager, so that's left for the applications
themselves. Most windows programs save their window sizes and position
before quitting and restore when they come back alive. The GNU Emacs
does not.
I was constantly moving my initial frame to the right and I often create
new frames and they insist on showing up more towards the left side of
the my screen, so I like the initial frame on the right. I'm happy now
with command-line --geometry -0 -fh -fn my-favorite-font. However, I
must still
(add-to-list 'initial-frame-alist '(height . fullheight))
(add-to-list 'default-frame-alist '(height . 0.91))
or new frames are larger than the initial frame because of the font I
choose. (Due to fonts, the problem doesn't seem trivial.)
I would appreciate --- as a default behavior --- the GNU Emacs on
Windows remembering the size and position of the window before shuting
down.
(*) The documentation of initial-frame-alist could mention --geometry
Elsewhere I learned about the full syntax of --geometry. The
documentation of initial-frame-alist misses an opportunity to mention
--geometry:
--8<---------------cut here---------------start------------->8---
initial-frame-alist is a variable defined in ‘frame.el’.
[...]
Documentation:
Alist of parameters for the initial X window frame.
You can set this in your init file; for example,
(setq initial-frame-alist
'((top . 1) (left . 1) (width . 80) (height . 55)))
Parameters specified here supersede the values given in
‘default-frame-alist’.
[...]
You can specify geometry-related options for just the initial
frame by setting this variable in your init file; however, they
won’t take effect until Emacs reads your init file, which happens
after creating the initial frame. If you want the initial frame
to have the proper geometry as soon as it appears, you need to
use this three-step process:
* Specify X resources to give the geometry you want.
* Set ‘default-frame-alist’ to override these options so that they
don’t affect subsequent frames.
* Set ‘initial-frame-alist’ in a way that matches the X resources,
to override what you put in ‘default-frame-alist’.
[back]
--8<---------------cut here---------------end--------------->8---
One last bullet could mention the full syntax of --geometry. Maybe
--help could as well: it doesn't.
(*) A suggested approach for Windows
I believe the problem could be solved for Windows specifically by
restoring the size and position of the initial-frame in w32-win.el. Of
course, the size and position should be saved before exit.
--8<---------------cut here---------------start------------->8---
(cl-defmethod window-system-initialization (&context (window-system w32)
&optional _display)
"Initialize Emacs for W32 GUI frames."
(cl-assert (not w32-initialized))
;; Do the actual Windows setup here; the above code just defines
;; functions and variables that we use now.
(setq command-line-args (x-handle-args command-line-args))
[...]
(x-open-connection "w32" x-command-line-resources
;; Exit with a fatal error if this fails and we
;; are the initial display
(eq initial-window-system 'w32))
[...]
;; Apply a geometry resource to the initial frame. Put it at the end
;; of the alist, so that anything specified on the command line takes
;; precedence.
(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
parsed)
(if res-geometry
(progn
(setq parsed (x-parse-geometry res-geometry))
;; If the resource specifies a position,
;; call the position and size "user-specified".
(if (or (assq 'top parsed) (assq 'left parsed))
(setq parsed (cons '(user-position . t)
(cons '(user-size . t) parsed))))
;; All geometry parms apply to the initial frame.
(setq initial-frame-alist (append initial-frame-alist parsed))
;; The size parms apply to all frames.
(if (and (assq 'height parsed)
(not (assq 'height default-frame-alist)))
(setq default-frame-alist
(cons (cons 'height (cdr (assq 'height parsed)))
default-frame-alist))
(if (and (assq 'width parsed)
(not (assq 'width default-frame-alist)))
(setq default-frame-alist
(cons (cons 'width (cdr (assq 'width parsed)))
default-frame-alist)))))))
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: on interface and behavior (Was: Re: indentation)
2021-04-29 21:38 ` on interface and behavior (Was: Re: indentation) Wayne Harris via Users list for the GNU Emacs text editor
@ 2021-04-30 7:53 ` Eli Zaretskii
2021-05-01 13:30 ` on interface and behavior Wayne Harris via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 65+ messages in thread
From: Eli Zaretskii @ 2021-04-30 7:53 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 29 Apr 2021 18:38:08 -0300
> From: Wayne Harris via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
>
> (*) The case of frames in Windows
>
> Speaking of which, FWIW, I have gone through extra lengths to try to get
> frames to show up more consistently on Windows. Windows has no
> reasonable window manager, so that's left for the applications
> themselves. Most windows programs save their window sizes and position
> before quitting and restore when they come back alive. The GNU Emacs
> does not.
Emacs can save and restore the frame geometry if you use the
desktop.el package to resume your sessions. This is in the manual.
> I would appreciate --- as a default behavior --- the GNU Emacs on
> Windows remembering the size and position of the window before shuting
> down.
We have that as an optional feature, see above.
> You can specify geometry-related options for just the initial
> frame by setting this variable in your init file; however, they
> won’t take effect until Emacs reads your init file, which happens
> after creating the initial frame. If you want the initial frame
> to have the proper geometry as soon as it appears, you need to
> use this three-step process:
> * Specify X resources to give the geometry you want.
> * Set ‘default-frame-alist’ to override these options so that they
> don’t affect subsequent frames.
> * Set ‘initial-frame-alist’ in a way that matches the X resources,
> to override what you put in ‘default-frame-alist’.
>
> [back]
> --8<---------------cut here---------------end--------------->8---
>
> One last bullet could mention the full syntax of --geometry. Maybe
> --help could as well: it doesn't.
>
> (*) A suggested approach for Windows
>
> I believe the problem could be solved for Windows specifically by
> restoring the size and position of the initial-frame in w32-win.el. Of
> course, the size and position should be saved before exit.
Emacs on MS-Windows emulates X resources by storing them in the
Registry. This is also described in the user manual, which see. So
you can have this feature even without desktop.el, if you want.
P.S. One thing I learned about Emacs a long time ago is that for any
issue that might worry you, it is likely that someone already solved
it in Emacs. So the first thing I do when U bump into such annoyances
is to search the manual and the built-in documentation for similar
features. Usually, I find a solution that is ready to be used; I
stopped being amazed by that long time ago.
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: on interface and behavior
2021-04-30 7:53 ` Eli Zaretskii
@ 2021-05-01 13:30 ` Wayne Harris via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 65+ messages in thread
From: Wayne Harris via Users list for the GNU Emacs text editor @ 2021-05-01 13:30 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Thu, 29 Apr 2021 18:38:08 -0300
>> From: Wayne Harris via Users list for the GNU Emacs text editor
>> <help-gnu-emacs@gnu.org>
>>
>> (*) The case of frames in Windows
>>
>> Speaking of which, FWIW, I have gone through extra lengths to try to get
>> frames to show up more consistently on Windows. Windows has no
>> reasonable window manager, so that's left for the applications
>> themselves. Most windows programs save their window sizes and position
>> before quitting and restore when they come back alive. The GNU Emacs
>> does not.
>
> Emacs can save and restore the frame geometry if you use the
> desktop.el package to resume your sessions. This is in the manual.
Desktop.el isn't a very satisfactory solution because of flickering.
The GNU Emacs initial frame shows up in a certain place and position and
then resizes and move somewhere else. But maybe the registry --- which
you mentioned below --- would be a nice solution.
[...]
>> You can specify geometry-related options for just the initial
>> frame by setting this variable in your init file; however, they
>> won’t take effect until Emacs reads your init file, which happens
>> after creating the initial frame. If you want the initial frame
>> to have the proper geometry as soon as it appears, you need to
>> use this three-step process:
>> * Specify X resources to give the geometry you want.
>> * Set ‘default-frame-alist’ to override these options so that they
>> don’t affect subsequent frames.
>> * Set ‘initial-frame-alist’ in a way that matches the X resources,
>> to override what you put in ‘default-frame-alist’.
>>
>> [back]
>> --8<---------------cut here---------------end--------------->8---
>>
>> One last bullet could mention the full syntax of --geometry. Maybe
>> --help could as well: it doesn't.
>>
>> (*) A suggested approach for Windows
>>
>> I believe the problem could be solved for Windows specifically by
>> restoring the size and position of the initial-frame in w32-win.el. Of
>> course, the size and position should be saved before exit.
>
> Emacs on MS-Windows emulates X resources by storing them in the
> Registry. This is also described in the user manual, which see. So
> you can have this feature even without desktop.el, if you want.
Thanks. I will check that.
> P.S. One thing I learned about Emacs a long time ago is that for any
> issue that might worry you, it is likely that someone already solved
> it in Emacs. So the first thing I do when U bump into such annoyances
> is to search the manual and the built-in documentation for similar
> features. Usually, I find a solution that is ready to be used; I
> stopped being amazed by that long time ago.
You're totally right. That has always been my experience too, but it
evidently didn't change my bad habits yet. :-)
^ permalink raw reply [flat|nested] 65+ 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
` (3 more replies)
1 sibling, 4 replies; 65+ 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] 65+ 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 16:49 ` [External] : indentation Drew Adams
` (2 subsequent siblings)
3 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* RE: [External] : Re: indentation
2021-04-30 7:05 ` indentation ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
@ 2021-04-30 16:49 ` Drew Adams
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
3 siblings, 0 replies; 65+ messages in thread
From: Drew Adams @ 2021-04-30 16:49 UTC (permalink / raw)
To: ptlo@centrum.cz, Stefan Monnier; +Cc: help-gnu-emacs@gnu.org
> Strange thing is that I didn't find the electric indent
> searching "indent" from menu in customization groups.
M-x customize-apropos is your friend.
It finds `electric-indent-mode' with no problem.
^ permalink raw reply [flat|nested] 65+ messages in thread
* Re: indentation
2021-04-30 7:05 ` indentation ptlo
2021-04-30 7:58 ` indentation Philip Kaludercic
2021-04-30 16:49 ` [External] : indentation Drew Adams
@ 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
3 siblings, 1 reply; 65+ 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] 65+ messages in thread
* Re: indentation
2021-04-30 7:05 ` indentation ptlo
` (2 preceding siblings ...)
2021-04-30 19:05 ` indentation Jean Louis
@ 2021-04-30 21:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
3 siblings, 0 replies; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* Indentation.
@ 2006-10-27 16:17 zombek
2006-10-27 16:46 ` Indentation Markus Triska
0 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* Indentation.
@ 2006-10-27 16:17 zombek
2006-10-27 16:53 ` Indentation Sam Peterson
0 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* Indentation
@ 2006-07-03 22:01 Ronny Mandal
2006-07-03 23:00 ` Indentation Colin S. Miller
0 siblings, 1 reply; 65+ 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] 65+ 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; 65+ 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] 65+ 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; 65+ 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] 65+ messages in thread
* indentation
@ 2003-10-23 1:14 Yen Tran
0 siblings, 0 replies; 65+ 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] 65+ messages in thread
end of thread, other threads:[~2022-01-28 6:31 UTC | newest]
Thread overview: 65+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 15:01 ` [External] : indentation Drew Adams
2021-04-27 17:04 ` Stefan Monnier
2021-04-27 17:54 ` Drew Adams
2021-04-27 20:23 ` Stefan Monnier
2021-04-27 22:28 ` Stefan Monnier
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-29 21:38 ` on interface and behavior (Was: Re: indentation) Wayne Harris via Users list for the GNU Emacs text editor
2021-04-30 7:53 ` Eli Zaretskii
2021-05-01 13:30 ` on interface and behavior Wayne Harris 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 16:49 ` [External] : indentation Drew Adams
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
-- 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
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-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
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).