"J.D. Smith" <[email protected]> writes:
>> While testing, I found how I managed to reproduce the problem last time.
>> It is a bout the order of invocation.
>> If I do M-x org-inside-mode and *then* M-x org-toggle-pretty-entities,
>> the sub/superscripts do not get highlighted.
>
> True. The list of entities to search for is set at mode start (per
> buffer):
>
> (defun org-inside--setup-hidden-contents-types ()
> "Setup entity types with hidden contents."
> (setq org-inside--hidden-contents-types
> `(,@(and org-hide-emphasis-markers
> '(bold code italic verbatim underline strike-through))
> ,@(and org-link-descriptive '(link))
> ,@(and org-pretty-entities
> org-pretty-entities-include-sub-superscripts
> '(subscript superscript latex-fragment)))))
>
> If you need to change these settings "live", you'll want to restart the
> mode. I suppose I could compute this list dynamically during
> `org-inside--elems-at-point', but your existing font-locking will be
> invalid anyway if you do this.
I think we can do it simpler and plug org-inside into `org-restart-font-lock'.
>> My thinking is to have highlighting/cursor change even when there is
>> nothing hidden, in bare links/sub/superscripts as an option. It is
>> somewhat different from what you propose as I understand.
>
> I can't see how a completely bare link (your first element) is related
> here, other than the fact that org applies similar styling to bare and
> "real" links. If we change the appearance inside such an entity, we are
> misrepresenting the case: there are no hidden contents, and thus no
> ambiguity about the position of point. There is no "inside"
> vs. "outside".
> At least for the case of a bare subscript, there is "something" hidden
> (the `_'/`^' chars), and therefore there is an inside/outside
> distinction at one end (the front of the super/sub-scripted text).
Makes sense.
But "inside" is not defined in that case wither.
> BTW, have you had a look at the manual entries? I just cleaned that up
> a bit.
Sure. Let me look. Several minor comments below.
> :DESCRIPTION: When in doubt, press @kbd{C-c C-c}.
> +:ID: ACEBFD46-09A6-43E5-A868-A4B3CF1F56AF
Stray ID :)
> +The visibility of hidden text can always toggled using {{{kbd(C-c
* be always toggled
or
* can be toggled
> +inside an entity with hidden contents. Hidden text can also be made
> +visible automatically upon entry, with an optional delay. Text is
Probably a good idea to describe org-inside-unhide-delay in the manual.
> +;; and added to the context-dependent ctrl-c ctrl-c hook; see
> +;; `org-inside-toggle-hidden'.
`org-ctrl-c-ctrl-c-hook'
> (defcustom org-inside-appearance '(:cursor bar :face org-inside-face)
For all the defcustoms, please add :package-version and :safe settings.
> + (get-text-property (org-element-begin el) 'invisible))
Why not `invisible-p'?
> + (setq org-inside--states (cl-delete state org-inside--states))))
Any particular reason you are not using simple delete?
> + (cl-callf2 push state org-inside--states))
Why not just (push state org-inside--states)?
> + (let* ((sec-p (and face with-secondary-p (>= emacs-major-version 31)))
I think it is worth explaining why we need this minimal version
requirement somewhere in the top commentary.
> + (let ((beg (org-element-begin elem))
> + (end (- (org-element-end elem) (org-element-post-blank elem))))
This is not accurate when the post-blank lines contain tabs/spaces.
> + (when (get-text-property beg 'invisible)
> + (setq beg (next-single-property-change beg 'invisible nil end)
> + end (previous-single-property-change end 'invisible nil beg))
> + (and (> end beg) (cons beg end)))))
Considering that you are sometimes putting 'invisible 'totally-visible,
invisible-p would be more reliable.
> + (unless (minibuffer-window-active-p win)
Why is it necessary?
> + ;; for proper point adjustment
> + (when (memq type '(emphasis raise))
> + (org-rear-nonsticky-at visible-beg)
> + (when (< emacs-major-version 31)
> + (org-rear-nonsticky-at visible-end)))
Why do you need to do it in org-inside? Maybe we can already apply
rear-nonsticky as a part of fontification?
> +;; Starting in v31, buffer-local change functions are run in
> +;; windows a buffer left as well those it entered.
> +(unless (>= emacs-major-version 31)
> + (add-hook 'window-buffer-change-functions #'org-inside--frame-changed))
Why is this not a part of org-inside-mode setup?
Side effects when merely loading a library should be avoided.
> +(defvar org-hidden-text-functions nil
We should probably announce this in news.
Or declare it as internal hook with "--" in name.
> +(defvar org-extra-unfontify-properties nil
Should be internal as well.
> @@ -6434,21 +6465,19 @@ (defun org-raise-scripts (limit)
> ;; Handle a_b^c
> (when (member (char-after) '(?_ ?^)) (goto-char (1- pos)))
> (unless (or comment-p emph-p link-p keyw-p)
> - (put-text-property (match-beginning 3) (match-end 0)
> - 'display
> + (put-text-property (match-beginning 2) vend 'org-emphasis t)
> + (add-text-properties (match-beginning 2) (match-end 2) props)
> + (when (and (eq (char-after vbeg) ?{)
> + (eq (char-before vend) ?}))
> + (add-text-properties vbeg (1+ vbeg) props)
> + (add-text-properties (1- vend) vend props)
> + (setq vbeg (1+ vbeg) vend (1- vend)))
> + (put-text-property vbeg vend 'display
> (if (equal (char-after (match-beginning 2)) ?^)
> (nth (if table-p 3 1) org-script-display)
> (nth (if table-p 2 0) org-script-display)))
> - (put-text-property (match-beginning 2) (match-end 3)
> - 'org-emphasis t)
> - (add-text-properties (match-beginning 2) (match-end 2)
> - (list 'invisible t))
> - (when (and (eq (char-after (match-beginning 3)) ?{)
> - (eq (char-before (match-end 3)) ?}))
> - (add-text-properties (match-beginning 3) (1+ (match-beginning 3))
> - (list 'invisible t))
> - (add-text-properties (1- (match-end 3)) (match-end 3)
> - (list 'invisible t))))
> + (run-hook-with-args 'org-hidden-text-functions 'raise
> + (match-beginning 0) (match-end 0) vbeg vend))
> t)))
Do we have to change where 'org-emphasis property is applied? AFAIR,
some third-party packages depend on the current behavior.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>