From b7eb76647395eac256602bdecaab4aea3ffbe68c Mon Sep 17 00:00:00 2001 Message-ID: From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:37:28 +0900 Subject: [PATCH v2] org-do-remove-indentation: Ignore invisible text * lisp/org-macs.el (org-do-remove-indentation): Set `buffer-invisibility-spec' to nil before detecting the column or moving to a column. This fixes src_block indentation removal for org-modern-mode but will also correct other cases of hidden indentation. TINYCHANGE --- lisp/org-macs.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 8def5cbb2..fc4fd7975 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -388,6 +388,8 @@ (defmacro org-current-text-indentation () (defun org-do-remove-indentation (&optional n skip-fl) "Remove the maximum common indentation from the buffer. +Do not consider invisible text when calculating indentation. + When optional argument N is a positive integer, remove exactly that much characters from indentation, if possible. When optional argument SKIP-FL is non-nil, skip the first @@ -408,7 +410,8 @@ (defun org-do-remove-indentation (&optional n skip-fl) ;; Remove exactly N indentation, but give up if not possible. (when skip-fl (forward-line)) (while (not (eobp)) - (let ((ind (progn (skip-chars-forward " \t") (current-column)))) + (let* ((buffer-invisibility-spec nil) ; do not treat invisible text specially + (ind (progn (skip-chars-forward " \t") (current-column)))) (cond ((< ind n) (if (eolp) (delete-region (line-beginning-position) (point)) (throw :exit nil))) -- 2.43.0