On 2026-05-17  13:40, J.D. Smith wrote:

> Replied separately. I /think/ I'm caught up on your review and
> suggestions; let me know if I missed something.  Biggest thing now is to
> text v30 vs. v31 (which I haven't yet done), for functionality:
> 
> - Enter/exit at correct locations for both (modulo the small difference
>   I pointed out w.r.t. the end).
> 
> - Editing text near boundaries (just inside, just outside) does what's
>   expected for both.
> 
> - Changing buffer in windows works as expected for both.
> 
> Thanks for the thorough tests and good suggestions!

Thanks for your work, tests continue.  Sorry for not focusing on what
you would like to have tested, but I just still keep finding other
issues.


General remarks:

- All following tests done with Emacs 31.

- I have done my copyright assignment to the FSF, so you don't need to
  worry about using any patches provided be me.

- Of course, all my patches are strictly noncommittal.

- The reference test document is still:

  #+begin_src org
  Foo =bar0 bar1 bar2= baz.
  #+end_src


Here is a patch, advantages listed below:

@@ -273,14 +273,20 @@ portion."
 Operates only when inside an entity wrapped by hidden text and
 `org-inside-mode' is enabled.  Text will be re-hidden when point leaves
 the entity.  See `org-inside-appearance' to enable automatic unhiding or
-configure other appearance settings."
+configure other appearance settings.
+This function returns a non-nil value if it has toggled visibilty, nil
+otherwise.  This makes it suitable as an entry in `org-ctrl-c-ctrl-c-hook',
+for example."
   (interactive)
-  (when-let* ((ov (window-parameter nil 'org-inside-overlay))
-              (_ (and (> (overlay-start ov) 0)
-                      (> (overlay-end ov) 0))))
+  (and-let* ((ov (window-parameter nil 'org-inside-overlay))
+             (_ (<= (point-min) (overlay-start ov)))
+             (_ (<= (overlay-start ov) (point)))
+             (_ (<  (point) (overlay-end ov)))
+             (_ (<  (overlay-end ov) (point-max))))
     (let ((inv (overlay-get ov 'invisible)))
       (overlay-put ov 'invisible
-                   (if inv nil 'org-inside--not-hidden)))))
+                   (if inv nil 'org-inside--not-hidden))
+      t)))

 ;;;###autoload
 (define-minor-mode org-inside-mode

[ Not sure whether I got all the "<" vs "<=" right - I just hacked
  that together rather quickly. ]

- It makes `o-i-t-v' suitable for addition to some abnormal hooks,
  which I in particular would be keen to have.

- It avoids touching markers outside of a narrowed region.  Not
  sure whether you consider this an issue.

- It fixes a bug like this:

  + "make repro"
  + M-: (setq org-hide-emphasis-markers t) RET
  + M-: (setq org-inside-appearance nil) RET
  + open reference Org mode document
  + M-x org-inside-mode RET
  + M->
  + M-x org-inside-toggle-hidden RET (*outside* of the emph text)
  + C-b a couple of times

  => This shows the emph markers when moving into the emph text,
  since the call to `o-i-t-h' has "primed" the overlay already to
  be visible, IIUC.


That window-vs-buffer thingy will surely be good for more surprises.
Here is one:

  + make repro
  + (setq org-hide-emphasis-markers t)
  + open reference Org mode document
  + M-x org-inside-mode RET
  + Move into emph text and let cursor turn bar
  + C-x 2
  + C-x o
  + M-x org-inside-mode RET
  + C-x o

  => Cursor stays bar in upper window.

I guess whenever the visibility or appearance changes for whatever
reason, you'd need to walk all windows.


BTW, when walking windows (regardless for above issue or for
`org-inside--reset-all'), probably consider walking with

  (walk-windows ... nil t)

Otherwise, e.g., *customize*-in-one-frame-org-mode-buffer-in-other
scenarios still can lead to dangling bar shaped cursors when
customizing o-i-a.  These operations should be rather infrequent,
so more walking shouldn't be a problem.


The custom spec has issues.  Well, at least one, and only in an
exotic (?) Emacs session where cus-start.el has not been loaded
yet and `(get 'cursor-type 'custom-type)' can equal nil:

  + "make repro"
  + M-x load-library org-inside RET
  + M-x customize-variable org-inside-appearance RET

  => Getting stack trace

  #+begin_example
  Debugger entered--Lisp error: (void-function nil)
    nil((nil) bar)
    widget-apply((nil) :match bar)
    widget-match-inline((nil) (bar))
    widget-group-match-inline((group :format "Key: %v" :inline t :args ((const 
:args nil :value :cursor) (nil))) (:cursor bar))
    widget-apply((group :format "Key: %v" :inline t :args ((const :args nil 
:value :cursor) (nil))) :match-inline (:cursor bar))
    widget-match-inline((group :format "Key: %v" :inline t :args ((const :args 
nil :value :cursor) (nil))) (:cursor bar))
  #+end_example

The following crude hack has helped:

@@ -75,7 +75,8 @@ still be used to unhide hidden markers for the entity you are 
inside."
           (plist
            :tag "Specific appearance options"
           :options
-          ((:cursor ,(get 'cursor-type 'custom-type)
+          ((:cursor ,(progn (require 'cus-start)
+                             (get 'cursor-type 'custom-type))
                     :tag "Cursor Type")
            (:face (choice (face :tag "Face Name")
                           (plist :tag "Attribute List"))

A more fundamental approach probably would be to ask for an
"official" constant providing what the top-level `let' form in
cus-start.el provides as `cursor-type-types'.

[ It can be that I have been seeing pink elephants again here,
  caused by test fatigue.  At some time I couldn't reproduce the
  stack trace shown above, but then it happened again ... ]


I've noticed trailing whitespace in org-inside.el, not sure
whether you or anybody else bothers.


The story will probably continue ...


Reply via email to