all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tab completion and electric-indent-mode
@ 2022-06-17 11:59 carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-17 14:10 ` [External] : " Drew Adams
  0 siblings, 1 reply; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-17 11:59 UTC (permalink / raw)
  To: Help Gnu Emacs


Have been delving into tab completion and encountered the variable `tab-always-indent` where I can use the tab key for completion at point.    Does there exist any relationship between the variable `tab-always-indent` and `electric-indent-mode`?

Would `(setq tab-always-indent 'complete)` interfere with any functionality that one would usually want to have?
 
`electric-indent-mode` says that in does "On-the-fly Reindentation".  What does that mean, and how is it different to normal indentation?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [External] : Tab completion and electric-indent-mode
  2022-06-17 11:59 Tab completion and electric-indent-mode carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-17 14:10 ` Drew Adams
  2022-06-17 14:14   ` carlmarcos--- via Users list for the GNU Emacs text editor
                     ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Drew Adams @ 2022-06-17 14:10 UTC (permalink / raw)
  To: carlmarcos@tutanota.com; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

> `electric-indent-mode` says that in does "On-the-fly
> Reindentation".  What does that mean, and how is it
> different to normal indentation?

(What's "normal indentation"?)

The doc string says that the mode does this, which
is presumably what it means by hand-waving with
"on-the-fly reindentation":

  this reindents whenever the hook `electric-indent-functions'
  returns non-nil, or if you insert a character from
  `electric-indent-chars'.

The Emacs manual, node `Indent Convenience' says:

  Electric Indent mode is a global minor mode that
  automatically indents the line after every <RET>
  you type.

If you feel that these explanations aren't clear
enough then please consider filing an enhancement
request to clarify further: `M-x report-emacs-bug'.


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13801 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [External] : Tab completion and electric-indent-mode
  2022-06-17 14:10 ` [External] : " Drew Adams
@ 2022-06-17 14:14   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-17 15:33   ` Eli Zaretskii
  2022-06-17 17:41   ` Emanuel Berg
  2 siblings, 0 replies; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-17 14:14 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'




Jun 17, 2022, 14:10 by drew.adams@oracle.com:

>> `electric-indent-mode` says that in does "On-the-fly
>> Reindentation".  What does that mean, and how is it
>> different to normal indentation?
>>
>
> (What's "normal indentation"?)
>
Indentation that is not on-the-fly.  I would think that all indentation is on-the-fly,
but I am not sure.  Reading indicates that it is some indentation enhancement.


> The doc string says that the mode does this, which
> is presumably what it means by hand-waving with
> "on-the-fly reindentation":
>
>  this reindents whenever the hook `electric-indent-functions'
>  returns non-nil, or if you insert a character from
>  `electric-indent-chars'.
>
> The Emacs manual, node `Indent Convenience' says:
>
>  Electric Indent mode is a global minor mode that
>  automatically indents the line after every <RET>
>  you type.
>
> If you feel that these explanations aren't clear
> enough then please consider filing an enhancement
> request to clarify further: `M-x report-emacs-bug'.
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-17 14:10 ` [External] : " Drew Adams
  2022-06-17 14:14   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-17 15:33   ` Eli Zaretskii
  2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-17 17:41   ` Emanuel Berg
  2 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-06-17 15:33 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Drew Adams <drew.adams@oracle.com>
> CC: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" <help-gnu-emacs@gnu.org>
> Date: Fri, 17 Jun 2022 14:10:00 +0000
> 
> > `electric-indent-mode` says that in does "On-the-fly
> > Reindentation".  What does that mean, and how is it
> > different to normal indentation?
> 
> (What's "normal indentation"?)
> 
> The doc string says that the mode does this, which
> is presumably what it means by hand-waving with
> "on-the-fly reindentation":
> 
>   this reindents whenever the hook `electric-indent-functions'
>   returns non-nil, or if you insert a character from
>   `electric-indent-chars'.
> 
> The Emacs manual, node `Indent Convenience' says:
> 
>   Electric Indent mode is a global minor mode that
>   automatically indents the line after every <RET>
>   you type.
> 
> If you feel that these explanations aren't clear
> enough then please consider filing an enhancement
> request to clarify further: `M-x report-emacs-bug'.

But before you do, I suggest to check the latest code, because the
above quotations are obsolete.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-17 14:10 ` [External] : " Drew Adams
  2022-06-17 14:14   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-17 15:33   ` Eli Zaretskii
@ 2022-06-17 17:41   ` Emanuel Berg
  2022-06-18  4:20     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2022-06-17 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> `electric-indent-mode` says that in does "On-the-fly
>> Reindentation". What does that mean, and how is it
>> different to normal indentation?
>
> What's "normal indentation"?

I was thinking the same! Capable programmers think the
same ...

Isn't there a PhD thesis in CS on this where they have
subdivided it into categories with pros and cons?

In this thread we have encountered

0. languages that demand indentation to be a certain way (e.g. Python)

0. situations where TABs are mandatory (e.g. a Makefile for
   GNU make), i.e. SPC doesn't work

0. indentation that is done "on the fly" (I agree with whoever
   just said it isn't clear what that's supposed to mean?)

Note 0:
  Indenting the code your way, which often is just one or two
  cases, the rest is the same as everyone else does it - this
  can be a way to "get into" a bunch of code you originally
  didn't write, rather it was handed over to you, be it from
  some intelligence agency, maybe Mossad or the FSB ...

Note 0:
  "May I indent your code?", one should be careful saying to
  a fellow programmer, perhaps.

Note 0:
  With some languages (e.g. Haskell) you often get stuck doing
  indentation manually for ages, and after changing some
  thing, it "has to" be adjusted for that, all of it; I don't
  know if that is because of Haskell's formal approach and
  style that resembles math, or Haskell's inherent
  neuroticism, or if it is some feature of the language, be it
  the support for and focus on pattern matching often and
  a lot, the function arguments not the least ...

- HEY, why aren't the digits increasing?!

Because ... these are technical details,
implementation-specific solutions, as well as general hacker
lore & legend, what I look for is rather styles of the
indentation itself. Like "this indentation style is called
'leap-and-return' and what characterizes it is its focus on
[etc etc]"

- Ah, there you go. Thanks for the answer!

np :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-17 15:33   ` Eli Zaretskii
@ 2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18  6:44       ` Eli Zaretskii
                         ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-18  3:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs



Jun 17, 2022, 15:33 by eliz@gnu.org:

>> From: Drew Adams <drew.adams@oracle.com>
>> CC: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" <help-gnu-emacs@gnu.org>
>> Date: Fri, 17 Jun 2022 14:10:00 +0000
>>
>> > `electric-indent-mode` says that in does "On-the-fly
>> > Reindentation".  What does that mean, and how is it
>> > different to normal indentation?
>>
>> (What's "normal indentation"?)
>>
>> The doc string says that the mode does this, which
>> is presumably what it means by hand-waving with
>> "on-the-fly reindentation":
>>
>>  this reindents whenever the hook `electric-indent-functions'
>>  returns non-nil, or if you insert a character from
>>  `electric-indent-chars'.
>>
>> The Emacs manual, node `Indent Convenience' says:
>>
>>  Electric Indent mode is a global minor mode that
>>  automatically indents the line after every <RET>
>>  you type.
>>
>> If you feel that these explanations aren't clear
>> enough then please consider filing an enhancement
>> request to clarify further: `M-x report-emacs-bug'.
>>
>
> But before you do, I suggest to check the latest code, because the
> above quotations are obsolete.
>
Have looked /emacs/lisp/electric.el which now describes command loop for `electric' modes.

Still think there should be clear explanations on the level of indentations emacs does.
This is because reindentation typically refers to an indentation enhancement compared to
some basic indentation method.  "On-the-Fly Reindentation" also has difficulty of interpretation.
Does there exist indentation that is "Not On-the-Fly"?  What would that do?

Have viewed the main repository

define-minor-mode electric-indent-mode

says

When enabled, this reindents whenever the hook `electric-indent-functions'
returns non-nil,  I do not find the comment informative regarding the types of
reindents.  

electric-indent-functions states that it is a special hook run to decide whether to auto-indent.

Additionally, reindent means that an indentation scheme would have been applied
already, supposedly composed of a simpler indent scheme.

Can information be introduced on how indentation and re-indentation works and the conditions
by which indentation is applied?

There needs to be clear explanations of what indentation and reindentation do and under what 
conditions as the current information is developer targeted but not user targeted.
 








^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-17 17:41   ` Emanuel Berg
@ 2022-06-18  4:20     ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-18  4:20 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


Jun 17, 2022, 17:41 by incal@dataswamp.org:

> Drew Adams wrote:
>
>>> `electric-indent-mode` says that in does "On-the-fly
>>> Reindentation". What does that mean, and how is it
>>> different to normal indentation?
>>>
>>
>> What's "normal indentation"?
>>
>
> I was thinking the same! Capable programmers think the
> same ...
>

There seems to be some basic initial indentation (call it normal).  This could be followed be
a subsequent reindent.

> Isn't there a PhD thesis in CS on this where they have
> subdivided it into categories with pros and cons?
>
> In this thread we have encountered
>
> 0. languages that demand indentation to be a certain way (e.g. Python)
>
> 0. situations where TABs are mandatory (e.g. a Makefile for
>  GNU make), i.e. SPC doesn't work
>
> 0. indentation that is done "on the fly" (I agree with whoever
>  just said it isn't clear what that's supposed to mean?)
>

Right.  Confusing what it is doing.

> Note 0:
>  Indenting the code your way, which often is just one or two
>  cases, the rest is the same as everyone else does it - this
>  can be a way to "get into" a bunch of code you originally
>  didn't write, rather it was handed over to you, be it from
>  some intelligence agency, maybe Mossad or the FSB ...
>

Isn't working with the code your way a basic premise of free software?
When emacs is the flagship of the Gnu System, working with the code
your way should actually be supported.


> Note 0:
>  "May I indent your code?", one should be careful saying to
>  a fellow programmer, perhaps.
>
> Note 0:
>  With some languages (e.g. Haskell) you often get stuck doing
>  indentation manually for ages, and after changing some
>  thing, it "has to" be adjusted for that, all of it; I don't
>  know if that is because of Haskell's formal approach and
>  style that resembles math, or Haskell's inherent
>  neuroticism, or if it is some feature of the language, be it
>  the support for and focus on pattern matching often and
>  a lot, the function arguments not the least ...
>
> - HEY, why aren't the digits increasing?!
>
> Because ... these are technical details,
> implementation-specific solutions, as well as general hacker
> lore & legend, what I look for is rather styles of the
> indentation itself. Like "this indentation style is called
> 'leap-and-return' and what characterizes it is its focus on
> [etc etc]"
>
> - Ah, there you go. Thanks for the answer!
>
> np :)
>
> -- 
> underground experts united
> https://dataswamp.org/~incal
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-18  6:44       ` Eli Zaretskii
  2022-06-18  8:05         ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18  9:15       ` Eric S Fraga
  2022-06-18 23:10       ` Drew Adams
  2 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-06-18  6:44 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 18 Jun 2022 05:45:06 +0200 (CEST)
> From: carlmarcos@tutanota.com
> Cc: help-gnu-emacs@gnu.org
> 
>  But before you do, I suggest to check the latest code, because the
>  above quotations are obsolete.
> 
> Have looked /emacs/lisp/electric.el which now describes command loop for `electric' modes.
> 
> Still think there should be clear explanations on the level of indentations emacs does.
> This is because reindentation typically refers to an indentation enhancement compared to
> some basic indentation method.  "On-the-Fly Reindentation" also has difficulty of interpretation.
> Does there exist indentation that is "Not On-the-Fly"?  What would that do?
> 
> Have viewed the main repository
> 
> define-minor-mode electric-indent-mode
> 
> says
> 
> When enabled, this reindents whenever the hook `electric-indent-functions'
> returns non-nil,  I do not find the comment informative regarding the types of
> reindents.  

I don't know in which place you looked, but the above is just a small
part of what the doc string says.  You omitted the parts that are
supposed to answer your questions.  In particular, the doc string does
attempt to explain what "reindent" means.

> electric-indent-functions states that it is a special hook run to decide whether to auto-indent.

Why are you focusing on electric-indent-functions?  In most cases, the
cause of electric reindentation is not that function, but what the
rest of the sentence says:

  ...or if you insert one of the "electric characters".

> Additionally, reindent means that an indentation scheme would have been applied
> already, supposedly composed of a simpler indent scheme.
> 
> Can information be introduced on how indentation and re-indentation works and the conditions
> by which indentation is applied?

What exactly indentation and reindentation do depends on the current
major mode.  electric-indent-mode just makes the mode-specific
indentation to happen automatically in certain situations, where Emacs
thinks the user expects reindentation.

If you want to know how a specific major mode indents text, you need
to look for answers in that mode, not in electric-indent-mode, because
the latter simply cannot give you the answer.

> There needs to be clear explanations of what indentation and reindentation do and under what 
> conditions as the current information is developer targeted but not user targeted.

Here's the full doc string of electric-indent-mode in the current
development version of Emacs:

  Toggle on-the-fly reindentation of text lines (Electric Indent mode).

  When enabled, this reindents whenever the hook `electric-indent-functions'
  returns non-nil, or if you insert one of the "electric characters".
  The electric characters normally include the newline, but can
  also include other characters as needed by the major mode; see
  `electric-indent-chars' for the actual list.

  By "reindent" we mean remove any existing indentation, and then
  indent the line according to context and rules of the major mode.

  This is a global minor mode.  To toggle the mode in a single buffer,
  use `electric-indent-local-mode'.

Given that electric-indent-mode doesn't know (and doesn't care) about
the major-mode's specific indentation rules, the above explains what
the minor mode itself does, including what is meant by
"reindentation".  The rest of the details are in the documentation of
the major modes, and you should look there for more information.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  6:44       ` Eli Zaretskii
@ 2022-06-18  8:05         ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18  8:17           ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-18  8:05 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs


Jun 18, 2022, 06:44 by eliz@gnu.org:

>> Date: Sat, 18 Jun 2022 05:45:06 +0200 (CEST)
>> From: carlmarcos@tutanota.com
>> Cc: help-gnu-emacs@gnu.org
>>
>>  But before you do, I suggest to check the latest code, because the
>>  above quotations are obsolete.
>>
>> Have looked /emacs/lisp/electric.el which now describes command loop for `electric' modes.
>>
>> Still think there should be clear explanations on the level of indentations emacs does.
>> This is because reindentation typically refers to an indentation enhancement compared to
>> some basic indentation method.  "On-the-Fly Reindentation" also has difficulty of interpretation.
>> Does there exist indentation that is "Not On-the-Fly"?  What would that do?
>>
>> Have viewed the main repository
>>
>> define-minor-mode electric-indent-mode
>>
>> says
>>
>> When enabled, this reindents whenever the hook `electric-indent-functions'
>> returns non-nil,  I do not find the comment informative regarding the types of
>> reindents.
>>
>
> I don't know in which place you looked, but the above is just a small
> part of what the doc string says.  You omitted the parts that are
> supposed to answer your questions.  In particular, the doc string does
> attempt to explain what "reindent" means.
>
>> electric-indent-functions states that it is a special hook run to decide whether to auto-indent.
>>
>
> Why are you focusing on electric-indent-functions?  In most cases, the
> cause of electric reindentation is not that function, but what the
> rest of the sentence says:
>
>  ...or if you insert one of the "electric characters".
>
Ok


>> Additionally, reindent means that an indentation scheme would have been applied
>> already, supposedly composed of a simpler indent scheme.
>>
>> Can information be introduced on how indentation and re-indentation works and the conditions
>> by which indentation is applied?
>>
>
> What exactly indentation and reindentation do depends on the current
> major mode.  electric-indent-mode just makes the mode-specific
> indentation to happen automatically in certain situations, where Emacs
> thinks the user expects reindentation.
>
> If you want to know how a specific major mode indents text, you need
> to look for answers in that mode, not in electric-indent-mode, because
> the latter simply cannot give you the answer.
>

How can a user get that information, are there commands for that?

>> There needs to be clear explanations of what indentation and reindentation do and under what 
>> conditions as the current information is developer targeted but not user targeted.
>>
>
> Here's the full doc string of electric-indent-mode in the current
> development version of Emacs:
>
>  Toggle on-the-fly reindentation of text lines (Electric Indent mode).
>
>  When enabled, this reindents whenever the hook `electric-indent-functions'
>  returns non-nil, or if you insert one of the "electric characters".
>  The electric characters normally include the newline, but can
>  also include other characters as needed by the major mode; see
>  `electric-indent-chars' for the actual list.
>
>  By "reindent" we mean remove any existing indentation, and then
>  indent the line according to context and rules of the major mode.
>
Can there be a clarification that reindentation removes the existing indentation
with new indentation rules applied?


>  This is a global minor mode.  To toggle the mode in a single buffer,
>  use `electric-indent-local-mode'.
>
> Given that electric-indent-mode doesn't know (and doesn't care) about
> the major-mode's specific indentation rules, the above explains what
> the minor mode itself does, including what is meant by
> "reindentation".  The rest of the details are in the documentation of
> the major modes, and you should look there for more information.
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  8:05         ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-18  8:17           ` Eli Zaretskii
  2022-06-18 15:35             ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-06-18  8:17 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 18 Jun 2022 10:05:54 +0200 (CEST)
> From: carlmarcos@tutanota.com
> Cc: help-gnu-emacs@gnu.org
> 
>  What exactly indentation and reindentation do depends on the current
>  major mode. electric-indent-mode just makes the mode-specific
>  indentation to happen automatically in certain situations, where Emacs
>  thinks the user expects reindentation.
> 
>  If you want to know how a specific major mode indents text, you need
>  to look for answers in that mode, not in electric-indent-mode, because
>  the latter simply cannot give you the answer.
> 
> How can a user get that information, are there commands for that?

The commands for that are the usual Help commands, but you need to
apply them to the major mode you are interested in.

>  Toggle on-the-fly reindentation of text lines (Electric Indent mode).
> 
>  When enabled, this reindents whenever the hook `electric-indent-functions'
>  returns non-nil, or if you insert one of the "electric characters".
>  The electric characters normally include the newline, but can
>  also include other characters as needed by the major mode; see
>  `electric-indent-chars' for the actual list.
> 
>  By "reindent" we mean remove any existing indentation, and then
>  indent the line according to context and rules of the major mode.
> 
> Can there be a clarification that reindentation removes the existing indentation
> with new indentation rules applied?

??? Isn't the above saying precisely that?  Or maybe I don't understand
what you need clarified?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18  6:44       ` Eli Zaretskii
@ 2022-06-18  9:15       ` Eric S Fraga
  2022-06-19  2:26         ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18 23:10       ` Drew Adams
  2 siblings, 1 reply; 17+ messages in thread
From: Eric S Fraga @ 2022-06-18  9:15 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, 18 Jun 2022 at 05:45, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> Does there exist indentation that is "Not On-the-Fly"?  What would that do?

Maybe, for instance,

,----[ C-h f indent-region RET ]
| indent-region is an interactive native compiled Lisp function in
| ‘indent.el’.
| 
| It is bound to C-M-\.
| 
| (indent-region START END &optional COLUMN)
| 
| Indent each nonblank line in the region.
| A numeric prefix argument specifies a column: indent each line to that column.
| [...]
| 
`----

which does this once when invoked explicitly, i.e. not on-the-fly.

The other extreme, by the way, is aggresive-indent-mode which on-the-fly
indents not just the line you are one but others around it as things
change.  I use it all the time.

-- 
Eric S Fraga via gnus (Emacs 29.0.50 2022-06-17) on Debian 11.3




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  8:17           ` Eli Zaretskii
@ 2022-06-18 15:35             ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18 16:20               ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-18 15:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs


Jun 18, 2022, 08:17 by eliz@gnu.org:

>> Date: Sat, 18 Jun 2022 10:05:54 +0200 (CEST)
>> From: carlmarcos@tutanota.com
>> Cc: help-gnu-emacs@gnu.org
>>
>>  What exactly indentation and reindentation do depends on the current
>>  major mode. electric-indent-mode just makes the mode-specific
>>  indentation to happen automatically in certain situations, where Emacs
>>  thinks the user expects reindentation.
>>
>>  If you want to know how a specific major mode indents text, you need
>>  to look for answers in that mode, not in electric-indent-mode, because
>>  the latter simply cannot give you the answer.
>>
>> How can a user get that information, are there commands for that?
>>
>
> The commands for that are the usual Help commands, but you need to
> apply them to the major mode you are interested in.
>

Can you provide an example?  I could not find a list of all the
programming major-modes in emacs manual.

Called "C-h f mhtml-mode" for instance, which never discusses any
indentation rules.  For embedded JS, the documentation says that
code elements are indented using the rules from ‘js-mode’.  But
then, doing "M-h f js-mode" does not describe any indentation
rules.


>> Toggle on-the-fly reindentation of text lines (Electric Indent mode).
>>
>>  When enabled, this reindents whenever the hook `electric-indent-functions'
>>  returns non-nil, or if you insert one of the "electric characters".
>>  The electric characters normally include the newline, but can
>>  also include other characters as needed by the major mode; see
>>  `electric-indent-chars' for the actual list.
>>
>>  By "reindent" we mean remove any existing indentation, and then
>>  indent the line according to context and rules of the major mode.
>>
>> Can there be a clarification that reindentation removes the existing indentation
>> with new indentation rules applied?
>>
>
> ??? Isn't the above saying precisely that?  Or maybe I don't understand
> what you need clarified?
>
By the definition of "re-" meaning "again"?  Thus re-indent
corresponds to indent again.  Ok



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18 15:35             ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-18 16:20               ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2022-06-18 16:20 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 18 Jun 2022 17:35:45 +0200 (CEST)
> From: carlmarcos@tutanota.com
> Cc: help-gnu-emacs@gnu.org
> 
>  If you want to know how a specific major mode indents text, you need
>  to look for answers in that mode, not in electric-indent-mode, because
>  the latter simply cannot give you the answer.
> 
>  How can a user get that information, are there commands for that?
> 
>  The commands for that are the usual Help commands, but you need to
>  apply them to the major mode you are interested in.
> 
> Can you provide an example?  I could not find a list of all the
> programming major-modes in emacs manual.
> 
> Called "C-h f mhtml-mode" for instance, which never discusses any
> indentation rules.

The doc string of mhtml-mode says:

  Code inside a <script> element is indented using the rules from
  ‘js-mode’; and code inside a <style> element is indented using
  the rules from ‘css-mode’.

> For embedded JS, the documentation says that
> code elements are indented using the rules from ‘js-mode’.  But
> then, doing "M-h f js-mode" does not describe any indentation
> rules.

Maybe you should tell what exactly do you mean by "indentation rules",
then.  What kind of explanations do you expect to see about
indentation rules in some arbitrary major mode?

In general, indentation provided by any major mode is "as expected by
the user", and Emacs gives you customizable options to control the
various parameters of the indentation.  For example, for  css-mode
type "M-x customize-group RET css RET" and review the options.  Two
options there seem to be relevant to the issue being discussed:
css-electric-keys and css-indent-offset.  That's about all users need
to know about "indentation rules" in css-mode; if you want to know
more detail, read the source.

>  By "reindent" we mean remove any existing indentation, and then
>  indent the line according to context and rules of the major mode.
> 
>  Can there be a clarification that reindentation removes the existing indentation
>  with new indentation rules applied?
> 
>  ??? Isn't the above saying precisely that? Or maybe I don't understand
>  what you need clarified?
> 
> By the definition of "re-" meaning "again"?  Thus re-indent
> corresponds to indent again.  Ok

Yes.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [External] : Tab completion and electric-indent-mode
  2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-18  6:44       ` Eli Zaretskii
  2022-06-18  9:15       ` Eric S Fraga
@ 2022-06-18 23:10       ` Drew Adams
  2022-06-18 23:19         ` Drew Adams
  2 siblings, 1 reply; 17+ messages in thread
From: Drew Adams @ 2022-06-18 23:10 UTC (permalink / raw)
  To: carlmarcos@tutanota.com; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]

> "On-the-Fly Reindentation" also has difficulty of interpretation.
> Does there exist indentation that is "Not On-the-Fly"?  What would that
> do?

Yes, the behavior should be described clearly.
"On-the-fly" can mean different things.  What's
important is just what the behavior is.

A guess is that "on-the-fly" here means that
indentation happens in an automatic or partly
automatic way, as you edit/type normally.
E.g., hit `RET' to get a new line, and you also
get that new line indented.

"On the fly" means any old time, in particular,
while you are doing something else.

It can mean that while doing something else you
can hit a key to do something else, and then
continue with what you were doing.  Or it can
mean that something happens automatically
while you are doing something else.  My guess
is that the latter is what's meant here: hit
`RET' to enter text on a new line (main action),
and get also the extra action of indenting the
text on that new line.

Indenting that's not "on-the-fly"?

You can manually, explicitly indent a block of
text, using command `indent-rigidly', bound by
default to `C-x TAB'.  It indents lines that are
at least partially in the region.

See the doc string.  You can incrementally
increase and decrease the amount of indentation.
And a prefix arg indents to exactly that number
of columns.

There can be any number of kinds of indenting.
Some, like `indent-rigidly, can be initiated
manually - just to indent.  Others can be
initiated automatically, in combination with
some other activity or depending on the context.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14509 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [External] : Tab completion and electric-indent-mode
  2022-06-18 23:10       ` Drew Adams
@ 2022-06-18 23:19         ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2022-06-18 23:19 UTC (permalink / raw)
  To: carlmarcos@tutanota.com; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

> It can mean that while doing something else
                                          ^
                                          |
                          remove "else" --+
> you can hit a key to do something else, and
> then continue with what you were doing.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-18  9:15       ` Eric S Fraga
@ 2022-06-19  2:26         ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-22 10:46           ` Eric S Fraga
  0 siblings, 1 reply; 17+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-19  2:26 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: help-gnu-emacs


Jun 18, 2022, 09:15 by e.fraga@ucl.ac.uk:

> On Saturday, 18 Jun 2022 at 05:45, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
>> Does there exist indentation that is "Not On-the-Fly"?  What would that do?
>>
>
> Maybe, for instance,
>
> ,----[ C-h f indent-region RET ]
> | indent-region is an interactive native compiled Lisp function in
> | ‘indent.el’.
> | 
> | It is bound to C-M-\.
> | 
> | (indent-region START END &optional COLUMN)
> | 
> | Indent each nonblank line in the region.
> | A numeric prefix argument specifies a column: indent each line to that column.
> | [...]
> | 
> `----
>
> which does this once when invoked explicitly, i.e. not on-the-fly.
>
> The other extreme, by the way, is aggresive-indent-mode which on-the-fly
> indents not just the line you are one but others around it as things
> change.  I use it all the time.
>

Interesting.  Will try it.  Does `aggresive-indent-mode` conflict with `electric-indent-mode`?
Would I need to turn `electric-indent-mode` off?


> -- 
> Eric S Fraga via gnus (Emacs 29.0.50 2022-06-17) on Debian 11.3
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [External] : Tab completion and electric-indent-mode
  2022-06-19  2:26         ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-22 10:46           ` Eric S Fraga
  0 siblings, 0 replies; 17+ messages in thread
From: Eric S Fraga @ 2022-06-22 10:46 UTC (permalink / raw)
  To: help-gnu-emacs

On Sunday, 19 Jun 2022 at 04:26, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> Interesting.  Will try it.  Does `aggresive-indent-mode` conflict with
> `electric-indent-mode`?
> Would I need to turn `electric-indent-mode` off?

No idea. Sorry. Try it!

-- 
Eric S Fraga via gnus (Emacs 29.0.50 2022-05-19) on Debian 11.3




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-06-22 10:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-17 11:59 Tab completion and electric-indent-mode carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-17 14:10 ` [External] : " Drew Adams
2022-06-17 14:14   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-17 15:33   ` Eli Zaretskii
2022-06-18  3:45     ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-18  6:44       ` Eli Zaretskii
2022-06-18  8:05         ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-18  8:17           ` Eli Zaretskii
2022-06-18 15:35             ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-18 16:20               ` Eli Zaretskii
2022-06-18  9:15       ` Eric S Fraga
2022-06-19  2:26         ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-22 10:46           ` Eric S Fraga
2022-06-18 23:10       ` Drew Adams
2022-06-18 23:19         ` Drew Adams
2022-06-17 17:41   ` Emanuel Berg
2022-06-18  4:20     ` carlmarcos--- via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.