help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Spaces rather than tabs by a major mode hook


From: goncholden
Subject: Re: Spaces rather than tabs by a major mode hook
Date: Thu, 09 Jun 2022 18:13:44 +0000

------- Original Message -------
On Friday, June 10th, 2022 at 3:30 AM, goncholden <goncholden@protonmail.com> 
wrote:


> ------- Original Message -------
> On Friday, June 10th, 2022 at 3:12 AM, Yuri Khan yuri.v.khan@gmail.com wrote:
>
>
>
> > On Thu, 9 Jun 2022 at 21:39, goncholden via Users list for the GNU
> > Emacs text editor help-gnu-emacs@gnu.org wrote:
> >
> > > I want to use spaces rather than tabs, but need to do this setting by a 
> > > major mode hook?
> > >
> > > How can this be done exactly?
> >
> > (defun my-indent-with-spaces ()
> > (setq-local indent-tabs-mode nil))
> > (add-hook 'emacs-lisp-mode 'my-indent-with-spaces)
> > (add-hook 'js-mode 'my-indent-with-spaces)
> >
> > Alternatively, use spaces by default and only use tabs for specific modes:
> >
> > (setq-default indent-tabs-mode nil)
> > (defun my-indent-with-tabs ()
> > (setq-local indent-tabs-mode t))
> > (add-hook 'c++-mode 'my-indent-with-tabs)
> > (add-hook 'c-mode 'my-indent-with-tabs)
> >
> > Or use spaces everywhere by default and only use tabs for specific
> > modes in specific projects where prescribed by coding convention:
> >
> > (setq-default indent-tabs-mode nil)
> >
> > In your project’s root directory, put a .dir-locals.el:
> >
> > ((c++-mode
> > (indent-tabs-mode . t)
> > (c-mode
> > (indent-tabs-mode . t)))

Suppose I have a file with tabs, would the change show the tabs as spaces?  I 
would rather have the file show as it is.  If there are tabs in the file, would 
(setq-default indent-tabs-mode nil) show them as spaces?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]