[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56837: 28.1.90; `current-indentation' sometimes returns zero inside
From: |
Ihor Radchenko |
Subject: |
bug#56837: 28.1.90; `current-indentation' sometimes returns zero inside invisible text |
Date: |
Sat, 30 Jul 2022 19:27:09 +0800 |
Eli Zaretskii <eliz@gnu.org> writes:
> I guess you should temporarily remove the invisible property? Like
> this:
>
> (let ((invis-spec buffer-invisibility-spec)
> indent)
> (remove-from-invisibility-spec '(outline . t))
> (setq indent
> (save-excursion (search-forward " a") (current-indentation)))
> (setq buffer-invisibility-spec invis-spec) indent)
A simpler version would be let-binding buffer-invisibility-spec.
Note that there is similar issue with current-column, though
current-column is much less likely to be used without considering
display properties.
Would it be possible to include the "text" versions of
current-indentation and current-column into Emacs?
Something like
(defmacro org-current-text-indentation ()
"Like `current-indentation', but ignore display/invisible properties."
`(let ((buffer-invisibility-spec nil))
(current-indentation)))
(defmacro org-current-text-column ()
"Like `current-column', but ignore display/invisible properties."
`(string-width (buffer-substring-no-properties
(line-beginning-position) (point))))
If not, could you at least mention the invisible text issues in
`current-indentation' docstring? The current undefined behaviour is very
hard to debug.
Best,
Ihor