* indentation @ 2021-04-27 7:03 ptlo 2021-04-27 7:25 ` indentation Philip Kaludercic ` (3 more replies) 0 siblings, 4 replies; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: indentation 2021-04-27 20:02 ` indentation Colin Baxter @ 2021-04-28 8:36 ` Thibaut Verron 0 siblings, 0 replies; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: indentation 2021-04-27 16:55 ` indentation Stefan Monnier @ 2021-04-27 22:12 ` Gregory Heytings 0 siblings, 0 replies; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: [External] : indentation 2021-04-27 20:23 ` Stefan Monnier @ 2021-04-27 22:28 ` Stefan Monnier 0 siblings, 0 replies; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: indentation 2021-04-30 9:09 ` indentation Thibaut Verron @ 2021-04-30 9:18 ` ptlo 0 siblings, 0 replies; 45+ messages in thread From: ptlo @ 2021-04-30 9:18 UTC (permalink / raw) To: Thibaut Verron, Philip Kaludercic; +Cc: help-gnu-emacs No, for now I stay away from electric gimmicks :-) But the described manual insertion costs nearly nothing. I mostly try to stick with default modes, because on another computer any customization is lost. But electric indent which became default I couldn't stand. Cheers Petr ^ permalink raw reply [flat|nested] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: indentation 2021-04-30 19:05 ` indentation Jean Louis @ 2021-04-30 19:59 ` Stefan Monnier 0 siblings, 0 replies; 45+ messages in thread From: Stefan Monnier @ 2021-04-30 19:59 UTC (permalink / raw) To: ptlo; +Cc: help-gnu-emacs > 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 He's not using `fortran-mode` but `f90-mode`. Stefan ^ permalink raw reply [flat|nested] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ 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; 45+ 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] 45+ messages in thread
* Re: indentation 2021-05-04 21:03 ` indentation Wayne Harris via Users list for the GNU Emacs text editor @ 2021-05-05 1:46 ` Stefan Monnier via Users list for the GNU Emacs text editor 0 siblings, 0 replies; 45+ messages in thread From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-05-05 1:46 UTC (permalink / raw) To: help-gnu-emacs >> Possibly. If you want to, you might also want to try the >> `aggressive-indent' package (from MELPA; its minor-mode is >> `aggressive-indent-mode') It's also on GNU ELPA, BTW. Stefan ^ permalink raw reply [flat|nested] 45+ messages in thread
end of thread, other threads:[~2021-05-05 1:46 UTC | newest] Thread overview: 45+ 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
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).