Subject: bug#77981: 30.1; kill-ring-deindent-mode replaces spaces with tabs even when indent-tabs-mode is nil

From: Eli Zaretskii <[email-masked]>
Date: Sat, 26 Apr 2025 16:13:13 +0300

> From: spl3g <[email-masked]>
> Date: Tue, 22 Apr 2025 11:22:26 +0300
> 
> When enabling kill-ring-deindent-mode, it would replace spaces with tabs
> in modes with indent-tabs-mode turned off.
> It breaks some languages, that do not support tabs for example elm and
> yaml.
> 
> I think it is because the temp buffer it creates has indent-tabs-mode
> turned on by default.

Thank you for your report.  Does the patch below give good results?

diff --git a/lisp/indent-aux.el b/lisp/indent-aux.el
index 27d5875..ce98944 100644
--- a/lisp/indent-aux.el
+++ b/lisp/indent-aux.el
@@ -45,10 +45,14 @@ kill-ring-deindent-buffer-substring-function
           end (max a b)))
   (let ((indentation (save-excursion (goto-char beg)
                                      (current-column)))
+        (i-t-m indent-tabs-mode)
         (text (if delete
                   (delete-and-extract-region beg end)
                 (buffer-substring beg end))))
     (with-temp-buffer
+      ;; Indent/deindent the same as the major mode in the original
+      ;; buffer.
+      (setq indent-tabs-mode i-t-m)
       (insert text)
       (indent-rigidly (point-min) (point-max)
                       (- indentation))