From 58b7d5dd55f9f401c41b9dda8291a2f98186cfd7 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 21 Oct 2024 15:05:17 +0200 Subject: emacs: Fixes for ‘python-mode’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/emacs/modules/mm-editing.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index e6b3801..5811e25 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -70,10 +70,15 @@ The indentation settings are set based on the configured values in (spaces (plist-member plist :spaces)) (width (plist-member plist :width)) (extras (plist-member plist :extras))) - (when spaces - (indent-tabs-mode (and (cadr spaces) -1))) - (when width - (setq-local tab-width (cadr width))) + ;; Some modes like ‘python-mode’ explicitly set ‘tab-width’ and + ;; ‘indent-tabs-mode’ so we must override them explicitly. + (setq-local + indent-tabs-mode (if spaces + (and (cadr spaces) -1) + (default-value 'indent-tabs-mode)) + tab-width (if width + (cadr width) + (default-value 'tab-width))) (when extras (setq extras (cadr extras)) (when (symbolp extras) -- cgit v1.2.3