New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disable org-superstar in org source code block #34
Conversation
This has the potential to adversely impact performance, so it should probably be thoroughly benchmarked. As well:
|
Thanks for your advice! I just updated the code to improve the performance a bit:
How did you benchmark this package? I mostly used with small org files (< 1k lines each file) and don't see any bad impact on the performance. |
Those seem like good changes. It would also be good to fix the indentation of that function.
I haven't. @integral-dw can probably speak to how he handles that. In the meantime, see these macros for what I generally use: https://github.com/alphapapa/emacs-package-dev-handbook#bench-multi-macros
I'm afraid such small files can't provide a meaningful benchmark. I have some Org files with over 50,000 lines, and there are users who have even larger ones. |
Hi,
That is very strange, unless I am mistaken the current version should already catch such cases on default settings. Sounds like there is a bug/regression then. I'll look into it (and your patch) and report back when I figured out what is going on. |
@alphapapa @integral-dw : Thanks for looking into it. I just tested again and confirm that in these two code blocks, the symbol
and #+begin_src scala
(all letters)
|
^
&
< >
= !
:
+ -
* / %
(all other special characters)
#+end_src |
(org-element-lineage (org-element-at-point) | ||
'(plain-list) t)) | ||
t))) | ||
'(plain-list) t))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to keep the t
at the end, see the comment above the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK that's not idiomatic Lisp. Any value can be treated as nil or non-nil, so it's not necessary to explicitly return t unless the calling function expects t to have a different meaning than any other non-nil value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience predicates often merely guarantee to return some non-nil value, absolutely. Often their docstrings state "Return non-nil if..." or some variation for that reason. Although I have seen plenty of predicates explicitly state to return t specifically ("Return t if.." being actually used as an example for a predicate docstring in the Elisp reference manual), in which case I'd argue the function should ensure that to be the case. In my mind it's a case where coding style is influenced by documentation style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those "return t if" predicates in Elisp are core functions implemented as C subrs, and there would be no reason for them to return anything other than t.
In a function like this, there's no special meaning to t as opposed to another non-nil value, and AFAIK there's no advantage to returning t explicitly, so the code would be simpler without explicitly returning t.
Not that it really matters here, but simpler is usually better. :)
@integral-dw Hi, I justed with |
Very odd. I suppose |
Can you try with this minimal org content? I just tested and the bug still occurs
|
I managed to reproduce your bug! The missing piece was that the src-block is embedded within a list, which I didn't consider at all when writing the function. I think I'll kick out org-element-lineage completely since checking if the region is in an src block should be good enough. |
Since SRC blocks are the only case (I'm aware of) where Org syntax fundamentally changes it is clearer to use org-in-src-block-p anyway. See PR #34 for context.
@integral-dw Great! Thanks for the update! :) |
Hi,
I created this PR to disable org-superstar from transforming the symbol
-, +, *
in org source code block.Currently, for the following code block, org-superstar will transform the
+
symbol into the right-arrow symbol.This PR will prevent this situation from happening.
Can you advise if this feature is reasonable?
Thank you!