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
This commit is contained in:
Psionik K 2024-01-10 22:37:28 +09:00 committed by Ihor Radchenko
parent a1b8554f6f
commit b6f8078ab4
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 1 deletions

View File

@ -377,6 +377,8 @@ in target-prerequisite files relation."
(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
@ -397,7 +399,8 @@ line. Return nil if it fails."
;; 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)))