unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Turning electric-indent-mode off, for a specific buffer
@ 2022-06-12 21:20 goncholden via Users list for the GNU Emacs text editor
  2022-06-13  0:26 ` Po Lu
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden via Users list for the GNU Emacs text editor @ 2022-06-12 21:20 UTC (permalink / raw)
  To: goncholden via Users list for the GNU Emacs text editor

I thought that for Emacs >= 24.4 there is "electric-indent-local-mode" so one can turn it off in a specific buffer.

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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-12 21:20 Turning electric-indent-mode off, for a specific buffer goncholden via Users list for the GNU Emacs text editor
@ 2022-06-13  0:26 ` Po Lu
  2022-06-13  1:31   ` goncholden
  0 siblings, 1 reply; 11+ messages in thread
From: Po Lu @ 2022-06-13  0:26 UTC (permalink / raw)
  To: goncholden via Users list for the GNU Emacs text editor; +Cc: goncholden

goncholden via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> I thought that for Emacs >= 24.4 there is "electric-indent-local-mode"
> so one can turn it off in a specific buffer.

There is?



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  0:26 ` Po Lu
@ 2022-06-13  1:31   ` goncholden
  2022-06-13  2:25     ` Po Lu
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden @ 2022-06-13  1:31 UTC (permalink / raw)
  To: Po Lu; +Cc: goncholden via Users list for the GNU Emacs text editor


------- Original Message -------
On Monday, June 13th, 2022 at 12:26 PM, Po Lu <luangruo@yahoo.com> wrote:


> goncholden via Users list for the GNU Emacs text editor
> help-gnu-emacs@gnu.org writes:
>
> > I thought that for Emacs >= 24.4 there is "electric-indent-local-mode"
> > so one can turn it off in a specific buffer.
>
>
> There is?

What is the way to disable `electric-indent-mode` in a buffer?

There is `setq-default` which only changes the mode if the buffer does not have a defined local value for `electric-indent-mode`.  Using `setq` would be considered a global change.

Thusly, `setq-local` could be the appropriate one to use.

(setq-local electric-indent-mode nil)

Whereas for the specific language I could use

(defun myindent ()
  (setq-local electric-indent-mode nil))

(add-hook 'fortran-mode 'myindent)

Any critique about all this?






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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  1:31   ` goncholden
@ 2022-06-13  2:25     ` Po Lu
  2022-06-13  5:21       ` goncholden
  0 siblings, 1 reply; 11+ messages in thread
From: Po Lu @ 2022-06-13  2:25 UTC (permalink / raw)
  To: goncholden; +Cc: goncholden via Users list for the GNU Emacs text editor

goncholden <goncholden@protonmail.com> writes:

> What is the way to disable `electric-indent-mode` in a buffer?

To turn off electric-indent-local-mode, just as you would any other
minor mode.



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  2:25     ` Po Lu
@ 2022-06-13  5:21       ` goncholden
  2022-06-13  5:42         ` Po Lu
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden @ 2022-06-13  5:21 UTC (permalink / raw)
  To: Po Lu; +Cc: goncholden via Users list for the GNU Emacs text editor


------- Original Message -------
On Monday, June 13th, 2022 at 2:25 PM, Po Lu <luangruo@yahoo.com> wrote:


> goncholden goncholden@protonmail.com writes:
>
> > What is the way to disable `electric-indent-mode` in a buffer?
>
>
> To turn off electric-indent-local-mode, just as you would any other
> minor mode.

Those are functions with usage

(electric-indent-mode 0)  ; turn mode off buffer-local
(electric-indent-local-mode 0)

But I also found the variable `electric-indent-mode`, and was using

(setq electric-indent-mode nil)

I do not know if the variable is buffer-local.

What's the recommended way to do this, disabling `electric-indent-mode`?









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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  5:21       ` goncholden
@ 2022-06-13  5:42         ` Po Lu
  2022-06-13  6:07           ` goncholden
  0 siblings, 1 reply; 11+ messages in thread
From: Po Lu @ 2022-06-13  5:42 UTC (permalink / raw)
  To: goncholden; +Cc: goncholden via Users list for the GNU Emacs text editor

goncholden <goncholden@protonmail.com> writes:

> What's the recommended way to do this, disabling `electric-indent-mode`?

I (and the doc string of `electric-indent-mode') already told you: just
disable `electric-indent-local-mode' in the buffer where you want it
off.



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  5:42         ` Po Lu
@ 2022-06-13  6:07           ` goncholden
  2022-06-13 10:53             ` goncholden
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden @ 2022-06-13  6:07 UTC (permalink / raw)
  To: Po Lu; +Cc: goncholden via Users list for the GNU Emacs text editor

------- Original Message -------
On Monday, June 13th, 2022 at 5:42 PM, Po Lu <luangruo@yahoo.com> wrote:


> goncholden goncholden@protonmail.com writes:
>
> > What's the recommended way to do this, disabling `electric-indent-mode`?
>
>
> I (and the doc string of `electric-indent-mode') already told you: just disable` electric-indent-local-mode' in the buffer where you want it
> off.

Ok



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13  6:07           ` goncholden
@ 2022-06-13 10:53             ` goncholden
  2022-06-13 11:39               ` Po Lu
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden @ 2022-06-13 10:53 UTC (permalink / raw)
  To: goncholden; +Cc: Po Lu, goncholden via Users list for the GNU Emacs text editor


------- Original Message -------
On Monday, June 13th, 2022 at 6:07 PM, goncholden <goncholden@protonmail.com> wrote:


> ------- Original Message -------
> On Monday, June 13th, 2022 at 5:42 PM, Po Lu luangruo@yahoo.com wrote:
>
>
>
> > goncholden goncholden@protonmail.com writes:
> >
> > > What's the recommended way to do this, disabling `electric-indent-mode`?
> >
> > I (and the doc string of `electric-indent-mode') already told you: just disable` electric-indent-local-mode' in the buffer where you want it
> > off.
>
>
> Ok


Doing "C-h v electric-indent-mode" says that setting this variable directly does not take effect, but one can customize it.  It is very confusing.  How is it ok to customize it and what happens when you do?

Perhaps this needs change so one does not customize it?



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13 10:53             ` goncholden
@ 2022-06-13 11:39               ` Po Lu
  2022-06-13 12:01                 ` goncholden
  0 siblings, 1 reply; 11+ messages in thread
From: Po Lu @ 2022-06-13 11:39 UTC (permalink / raw)
  To: goncholden; +Cc: goncholden via Users list for the GNU Emacs text editor

goncholden <goncholden@protonmail.com> writes:

> Doing "C-h v electric-indent-mode" says that setting this variable
> directly does not take effect, but one can customize it.  It is very
> confusing.  How is it ok to customize it and what happens when you do?
>
> Perhaps this needs change so one does not customize it?

electric-indent-mode is a global minor mode.
Customizing it turns the mode on or off, while setting the variable
itself has no effect.



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13 11:39               ` Po Lu
@ 2022-06-13 12:01                 ` goncholden
  2022-06-13 12:15                   ` Po Lu
  0 siblings, 1 reply; 11+ messages in thread
From: goncholden @ 2022-06-13 12:01 UTC (permalink / raw)
  To: Po Lu; +Cc: goncholden via Users list for the GNU Emacs text editor


------- Original Message -------
On Monday, June 13th, 2022 at 11:39 PM, Po Lu <luangruo@yahoo.com> wrote:


> goncholden goncholden@protonmail.com writes:
>
> > Doing "C-h v electric-indent-mode" says that setting this variable
> > directly does not take effect, but one can customize it. It is very
> > confusing. How is it ok to customize it and what happens when you do?
> >
> > Perhaps this needs change so one does not customize it?
>
>
> electric-indent-mode is a global minor mode.
> Customizing it turns the mode on or off, while setting the variable
> itself has no effect.

Then customizing electric-indent-mode does not customize the variable but the minor-mode?  If I remember correctly, when defining a minor-mode, a variable is also created automatically.  From your discussion, it seems that there would also exist a function with the same name.



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

* Re: Turning electric-indent-mode off, for a specific buffer
  2022-06-13 12:01                 ` goncholden
@ 2022-06-13 12:15                   ` Po Lu
  0 siblings, 0 replies; 11+ messages in thread
From: Po Lu @ 2022-06-13 12:15 UTC (permalink / raw)
  To: goncholden; +Cc: goncholden via Users list for the GNU Emacs text editor

goncholden <goncholden@protonmail.com> writes:

> Then customizing electric-indent-mode does not customize the variable
> but the minor-mode?

Yes.

> If I remember correctly, when defining a minor-mode, a variable is
> also created automatically.  From your discussion, it seems that there
> would also exist a function with the same name.

Both a command that serves to switch a minor mode on or off and a
variable is created when defining a minor mode.

They share the same name, because Emacs Lisp, being a Lisp-2, has
separate cells for functions and variables.

All of this information is trivially available in the doc string of the
function `electric-indent-mode', that of the macro `define-minor-mode',
and the Emacs Lisp reference manual.  I suggest you read them.



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

end of thread, other threads:[~2022-06-13 12:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-12 21:20 Turning electric-indent-mode off, for a specific buffer goncholden via Users list for the GNU Emacs text editor
2022-06-13  0:26 ` Po Lu
2022-06-13  1:31   ` goncholden
2022-06-13  2:25     ` Po Lu
2022-06-13  5:21       ` goncholden
2022-06-13  5:42         ` Po Lu
2022-06-13  6:07           ` goncholden
2022-06-13 10:53             ` goncholden
2022-06-13 11:39               ` Po Lu
2022-06-13 12:01                 ` goncholden
2022-06-13 12:15                   ` Po Lu

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).