From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Spaces rather than tabs by a major mode hook Date: Thu, 9 Jun 2022 22:12:07 +0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16578"; mail-complaints-to="usenet@ciao.gmane.io" Cc: goncholden via Users list for the GNU Emacs text editor To: goncholden Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 09 17:22:56 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzJzs-0004AS-3J for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 09 Jun 2022 17:22:56 +0200 Original-Received: from localhost ([::1]:50168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJzq-000629-VL for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 09 Jun 2022 11:22:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzJpd-0008E3-Tv for help-gnu-emacs@gnu.org; Thu, 09 Jun 2022 11:12:24 -0400 Original-Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:35625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzJpc-00064L-Di for help-gnu-emacs@gnu.org; Thu, 09 Jun 2022 11:12:21 -0400 Original-Received: by mail-qt1-x82f.google.com with SMTP id fu17so1465249qtb.2 for ; Thu, 09 Jun 2022 08:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=J2RMkHQxjCcMKVsK8t+6lDFJAPP4sMi6cuJZDxrqB8I=; b=iI8Sd/kupaRfCR7ef7/8FNxdSO0emVR2zrPv3OEMgH+LyqpYdS2UFbfA6CCQjb7QJ/ R1N2hIvXA71+EGc/qKI8u09C01Dq/zq3qoBRwHY8r31vPt2iL9+OWchgNQJRHwE2zNNi KDTgw06dantIbuTNx8YPvVVDxAeGv/yFgoiXWs96ZSvkHmLysCuL1boXzLz0i9x0AcqO asBkCuK41slmtFl2IKY+J6OkR8YSe7E7YMkLbFO2Sbcnt3Q+wBiwdx66EVDxgrjP/Ca7 pChQaXylU2Ym6k7k1LWarVpy6Qfite7jKGymrknMeAjO2yqVN66SetpMUnK4ALtj/BW/ T2iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=J2RMkHQxjCcMKVsK8t+6lDFJAPP4sMi6cuJZDxrqB8I=; b=m/vpT/eqUbPQAPxBJDUQmjJODp3ocwGP9qKGsHU1vH18zDYf8T6lB0W7FHPmzxwV4i YcSMFrjJ6XhKXBkJFqolyQFu4GphoF/wnzHEte6bU2YFJgeZCzN7cxtegNk4vwyl0s/7 gKQtyCiLX9YqML/HxLjBhhH/u6lGPhiY2lqBwdnzjPgHbXWU0gJTnKsJy7zS13SjkYVi xl2T/UxrlZY5y6OyH2t8UM2uCacg9de6KawJXyUU+Th3/6tcxuFep7+VSHtW2uM8ct7G O/WvSwtSozydl5WJIezM0ymUcEVsLYJnK+aXK/Q5efuodHhTl6ZU4dCH0BvcB875/wu5 FmLg== X-Gm-Message-State: AOAM532jzMIQ+VTQBmXrCRvfDMttubLVa4DLETyf4C9nNJlXaMXtnjJf VSSOCmoVn4zARk1QtNoploV8/EwsQa9Vm4o6XUwqDnlcjeg= X-Google-Smtp-Source: ABdhPJy2UNcATT35a/KckaU12kTvIDm1GFzRJR0lpP9qNO4fyCO8O59GKxYTz4q+8Zk5ttPox+R6FvRLKXOwzaNcO7c= X-Received: by 2002:a05:622a:50b:b0:2f3:e227:628a with SMTP id l11-20020a05622a050b00b002f3e227628amr31150361qtx.533.1654787538996; Thu, 09 Jun 2022 08:12:18 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=yurivkhan@gmail.com; helo=mail-qt1-x82f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137559 Archived-At: On Thu, 9 Jun 2022 at 21:39, goncholden via Users list for the GNU Emacs text editor wrote: > > I want to use spaces rather than tabs, but need to do this setting by a m= ajor 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=E2=80=99s root directory, put a .dir-locals.el: ((c++-mode (indent-tabs-mode . t) (c-mode (indent-tabs-mode . t)))