emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is it somehow possible to meaningfully use window-start during a 'redisp


From: dalanicolai
Subject: Is it somehow possible to meaningfully use window-start during a 'redisplay'?
Date: Mon, 6 Nov 2023 14:59:41 +0100

Hi all!

I am trying to use the functions window-start and window-end, within a
function that gets called from the window-configuration-change-hook as
follows:

(defun test ()
  (interactive)
  (let ((inhibit-read-only t))
    (dotimes (i 9)
      (let ((o (make-overlay (point) (progn (insert " ") (point)))))
(insert "\n")
(overlay-put o 'face `(:background ,(pcase (% i 3)
     (0 "red")
     (1 "green")
     (2 "blue"))))
(overlay-put o 'display '(space . (:width (600) :height (800))))
(overlay-put o 'window (selected-window))))
    (when (looking-back "\n")
      (delete-char -1)))
  (goto-char 7)

  (print (current-buffer) #'external-debugging-output)
  (print (window-buffer (selected-window)) #'external-debugging-output)
  (print (point) #'external-debugging-output)

  (force-window-update (selected-window))
  (redisplay t)

  (print (window-start) #'external-debugging-output)
  (print (window-end nil t) #'external-debugging-output))


(define-derived-mode test-mode special-mode "Test"
  "Debug"
  (add-hook 'window-configuration-change-hook #'test nil t))

(add-to-list 'auto-mode-alist '("\\.debug\\'" . test-mode))

The above test function creates some 'space overlays' after which it
tries to determine the actual 'displayed' overlays by using
window-start and window-end. It prints debugging output to the
terminal (it is printing to the terminal because printing elsewhere
makes debugging redisplay issues more complicated).

Now when invoking the command manually in some buffer, the functions
window-start and window-end, work correctly, i.e. window-start returns
the same value as point (both 7, after the goto-char 7). Actually
using a simple '(redisplay)' before window-start is sufficient.

However, when triggering the function from the
'window-configuration-change-hook' (for that simply 'visit a new file'
ending with a '.debug' extension), the window-start and window-end
functions seem unusable; i.e even after adding

  (force-window-update (selected-window))
  (redisplay t)

before using them, window-start still returns 1 while point is at 7.

I conclude that I can not redisplay during a redisplay this way.
Would it be possible to get the 'correct' values using window-start
and window-end during a redisplay/from the
'window-configuration-change-hook'?

Thanks
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]