From 06cf887f5eb8e8715628deba7771397661879062 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 9 Nov 2020 08:00:43 -0600 Subject: Use tabs instead of spaces; install smart-tabs-mode --- config.org | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'config.org') diff --git a/config.org b/config.org index 3b17ff4..c1b868a 100644 --- a/config.org +++ b/config.org @@ -527,8 +527,45 @@ I was using company, but I think it might've been causing issues with ~awk-mode~ #+END_SRC ** Tabs & Spaces #+BEGIN_SRC emacs-lisp - (cuss indent-tabs-mode nil) (cuss sentence-end-double-space t) + + ;; cf https://dougie.io/emacs/indentation/ + ;; Create a variable for our preferred tab width + (setq custom-tab-width 4) + + ;; Two callable functions for enabling/disabling tabs in Emacs + (defun disable-tabs () (setq indent-tabs-mode nil)) + (defun enable-tabs () + (setq indent-tabs-mode t) + (setq tab-width custom-tab-width)) + + ;; Hooks to Enable Tabs + (add-hook 'prog-mode-hook 'enable-tabs) + ;; Hooks to Disable Tabs + (add-hook 'lisp-mode-hook 'disable-tabs) + (add-hook 'emacs-lisp-mode-hook 'disable-tabs) + + ;; Language-Specific Tweaks + (setq-default python-indent-offset custom-tab-width) ;; Python + (setq-default js-indent-level custom-tab-width) ;; Javascript + + ;; Make the backspace properly erase the tab instead of + ;; removing 1 space at a time. + (setq backward-delete-char-untabify-method 'hungry) + + ;; WARNING: This will change your life + ;; (OPTIONAL) Visualize tabs as a pipe character - "|" + ;; This will also show trailing characters as they are useful to spot. + (setq whitespace-style '(face tabs tab-mark trailing)) + (custom-set-faces + '(whitespace-tab ((t (:foreground "#636363"))))) + (setq whitespace-display-mappings + '((tab-mark 9 [124 9] [92 9]))) ; 124 is the ascii ID for '\|' + (global-whitespace-mode) ; Enable whitespace mode everywhere + + (use-package smart-tabs-mode + :init + (smart-tabs-insinuate 'c 'javascript)) #+END_SRC * Programming ** Git -- cgit 1.4.1-21-gabe81