Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ I stumbled upon weird behavior when using `org-toggle-link-display', and I finally checked what that is about. Observation: - use `org-toggle-link-display' in org buffer A, and (coming from the defaults) links are now shown in full (not just the description), but only in buffer A - switch to org buffer B, still only showing the description part, and again use `o-t-l-d' --- nothing changes - the state for new org buffers is as before, onle link descriptions are shown. This behavior is very confusing, IMO. The reason is simple. The display hiding comes from changing the `buffer-invisibility-spec', which is automatically buffer-local. But the state of the org toggle is kept in `org-link-descriptive', which is global! I suggest a simple fix that I just tested: make `org-link-descriptive' automatically buffer-local, by adding ":local t" to the defcustom. NB: This also fixes a related bug that eval: (org-toggle-link-display) in the file-local works properly --- it did not work for me before. Thanks. Emacs : GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-27 Package: Org mode version 9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)
Ingo Lohmar writes: > I stumbled upon weird behavior when using `org-toggle-link-display', and > I finally checked what that is about. > > Observation: > - use `org-toggle-link-display' in org buffer A, and (coming > from the defaults) links are now shown in full (not just the > description), but only in buffer A > - switch to org buffer B, still only showing the description part, and > again use `o-t-l-d' --- nothing changes > - the state for new org buffers is as before, onle link descriptions are > shown. > > This behavior is very confusing, IMO. The reason is simple. The > display hiding comes from changing the `buffer-invisibility-spec', which > is automatically buffer-local. But the state of the org toggle is kept > in `org-link-descriptive', which is global! Thanks for the clear problem description and analysis. I agree that this is a bug and don't suspect that anyone is relying on org-toggle-link-display to toggling the global value. Gustavo reported the same issue at <https://orgmode.org/list/87lfeqzm3a.fsf@gmail.com>, but unfortunately it didn't get any attention back then. > I suggest a simple fix that I just tested: make `org-link-descriptive' > automatically buffer-local, by adding ":local t" to the defcustom. Hmm, I think a problem with `:local t' (or, equivalently, make-variable-buffer-local for backward compatibility reasons) is that then you'd interfere with user customization that directly sets this after ol.el is loaded. You could also still get into a mismatched state like you described above if you load an Org buffer, set the value through the customization interface, and then call org-toggle-link-display in that buffer. Instead I've updated the body of `org-mode' to make org-link-descriptive buffer-local (702e782cb).
On Mon, Apr 05 2021 22:36 (-0400), Kyle Meyer wrote:
>> I suggest a simple fix that I just tested: make `org-link-descriptive'
>> automatically buffer-local, by adding ":local t" to the defcustom.
>
> Hmm, I think a problem with `:local t' (or, equivalently,
> make-variable-buffer-local for backward compatibility reasons) is that
> then you'd interfere with user customization that directly sets this
> after ol.el is loaded. You could also still get into a mismatched state
> like you described above if you load an Org buffer, set the value
> through the customization interface, and then call
> org-toggle-link-display in that buffer.
>
> Instead I've updated the body of `org-mode' to make org-link-descriptive
> buffer-local (702e782cb).
I am not sure that I understand the problem you're describing.. Maybe
it's because I don't use the customize interface myself, but I think any
such customization would only set the default value, wouldn't it?
But in any case, I am (of course) perfectly fine with your fix, thanks a
lot for the quick response!
Ingo Lohmar writes: > On Mon, Apr 05 2021 22:36 (-0400), Kyle Meyer wrote: >> Hmm, I think a problem with `:local t' (or, equivalently, >> make-variable-buffer-local for backward compatibility reasons) is that >> then you'd interfere with user customization that directly sets this >> after ol.el is loaded. You could also still get into a mismatched state >> like you described above if you load an Org buffer, set the value >> through the customization interface, and then call >> org-toggle-link-display in that buffer. [...] > I am not sure that I understand the problem you're describing.. Maybe > it's because I don't use the customize interface myself, but I think any > such customization would only set the default value, wouldn't it? Yes. Here are expanded descriptions for the two problems I'm referring to above. This is based on testing with the `:local t' diff below (on top of bcfe6f985, before the commit I mentioned in my last message). * Breaks customization of direct setq callers if ol.el is already loaded. If (setq org-link-descriptive nil) is executed after ol.el is loaded, links in a visited Org buffer will be displayed according to the default org-link-descriptive value of t. * Setting org-link-descriptive via the customization interface can get into a mismatched state. - Visit an Org file with a link and description. org-link-descriptive is at its global value of t. - Set org-link-descriptive to nil via the customization interface, changing the global value to nil. This value is in effect in the Org buffer because org-link-descriptive isn't yet buffer-local. The description is still hidden because buffer-invisibility-spec hasn't been changed. - Calling org-toggle-link-display sets org-link-descriptive to t, making org-link-descriptive a buffer-local variable. The appearance of the description doesn't change due to the mismatch (like described in your original report). Calling it again aligns the buffer-local value and buffer-invisibility-spec. diff --git a/lisp/ol.el b/lisp/ol.el index d1db1683b..0e225ce4e 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -193,6 +193,7 @@ (defcustom org-link-descriptive t `org-toggle-link-display' or from the \"Org > Hyperlinks\" menu." :group 'org-link :type 'boolean + :local t :safe #'booleanp) (defcustom org-link-make-description-function nil