unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Process:  Determining the origin of a command loop.
@ 2018-12-20  4:11 Keith David Bershatsky
  2018-12-20 14:11 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Keith David Bershatsky @ 2018-12-20  4:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Thank you, Eli, for taking the time to review this particular thread.

Whereas an individual cursor (the real cursor) has very little overhead, an average of approximately 200 fake cursors are indeed semi-costly and merit optimization.  The current draft of crosshairs/visible-fill-column/multiple-fake-cursors relies upon display_and_set_cursor to determine when to generate the goodies.  I would like to optimize/suppress the goodies so that they are erased/redrawn only when absolutely necessary.  Let us assume that we make the following modifications to the Emacs master branch and evaluate the following Lisp code after launching the newly built Emacs from the terminal so that we can see the STDERR trace-redisplay output.  As to the current buffer in this situation, there is no need to erase and redraw the goodies (200 fake cursors) because the cursor is in the
  same location and the buffer is unmodified in all respects.  The only changes are occurring in the *compilation* buffer, which is not the current buffer.  The hallmarks of this situation are "redis
 play_preserve_echo_area (12)".

In a nutshell, I am looking for a way to programmatically detect this situation and suppress redrawing the cursor(s) in the unmodified windows.

(progn
  (trace-redisplay 1)
  (when global-eldoc-mode
    (global-eldoc-mode -1))
  (when jit-lock-context-timer
    (cancel-timer jit-lock-context-timer))
  (setq jit-lock-context-timer nil)
  (when (timerp undo-auto-current-boundary-timer)
    (cancel-timer undo-auto-current-boundary-timer))
  (fset 'undo-auto--undoable-change
        (lambda () (add-to-list 'undo-auto--undoably-changed-buffers (current-buffer))))
  (fset 'undo-auto-amalgamate 'ignore)
  (when blink-cursor-mode
    (blink-cursor-mode -1)
    (when (memq 'blink-cursor-check post-command-hook)
      (remove-hook 'post-command-hook 'blink-cursor-check)))
  (setq compilation-scroll-output t)
  (compile "while :; do echo \"Hello-World\"; sleep 1; done"))

diff --git a/src/xdisp.c b/src/xdisp.c
index 4201bdc..9ed03d3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -29775,6 +29775,16 @@ display_and_set_cursor (struct window *w, bool on,
   FRAME_RIF (f)->draw_window_cursor (w, glyph_row, x, y,
                                      new_cursor_type, new_cursor_width,
                                      on, active_cursor);
+
+  if (trace_redisplay_p)
+    {
+      Lisp_Object window;
+      XSETWINDOW (window, w);
+      Lisp_Object window_string = Fprin1_to_string (window, Qnil);
+      char *window_char = SSDATA (window_string);
+      fprintf (stderr, "\ndisplay_and_set_cursor (%s):  on (%d) | active (%d)\n",
+                       window_char, on, active_cursor);
+    }
 }

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [12-19-2018 07:24:50] <19 Dec 2018 17:24:50 +0200>
> From: Eli Zaretskii <eliz@gnu.org>
> 
> * * *
> >
> > I am unaware of any reason why the cursor in the active window needs updating in this situation.
> 
> The way the code is written, we might move the cursor as part of
> updating the window, and the code doesn't record the fact whether it
> did or didn't move the cursor, or turned it off.  So it always
> redisplays the cursor on the correct place at the end.
> 
> > Q:  How can I determine the origin of the command loop in this situation so that I can suppress the cursor from being updated in the active window?
> 
> I don't really understand the question ("origin of the command loop"?
> what's that?), and more generally, don't see why you would want to
> suppress the cursor update.



^ permalink raw reply related	[flat|nested] 19+ messages in thread
* Re: Process:  Determining the origin of a command loop.
@ 2018-12-20 23:54 Keith David Bershatsky
  0 siblings, 0 replies; 19+ messages in thread
From: Keith David Bershatsky @ 2018-12-20 23:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Thank you, Eli, for the helpful guidance -- greatly appreciated!

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [12-20-2018 06:11:20] <20 Dec 2018 16:11:20 +0200>
> From: Eli Zaretskii <eliz@gnu.org>
> 
> * * *
> 
> I understand, but I think you will have to come up with your own
> mechanism to check when the
> crosshairs/visible-fill-column/multiple-fake-cursors need to be
> updated, because I don't think that can be established from the
> physical cursor's position or the need to redraw it.  Since those fake
> cursors can be anywhere in the window, and the conditions for updating
> them are independent of the conditions for moving point, the logic for
> that must be independently designed and implemented, using the data
> you maintain for drawing those fake cursors.  If you already track
> that data, then all you need is determine whether any of it changed
> since the last time.



^ permalink raw reply	[flat|nested] 19+ messages in thread
* Process:  Determining the origin of a command loop.
@ 2018-12-19  4:34 Keith David Bershatsky
  2018-12-19 15:24 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Keith David Bershatsky @ 2018-12-19  4:34 UTC (permalink / raw)
  To: Emacs Devel

One of the items on my todo list for developing feature requests #22873 (multiple fake cursors) and #17684 (crosshairs and visible fill column) is the suppression of redrawing the cursor(s) in certain windows due to output from an ongoing process in one of many visible window.

Let us assume that a user has an _inactive_ window that has ongoing activity; e.g., an *Eshell* buffer is compiling an application and output necessitates that its window be updated.  The user is viewing source code in another window, which may or may not be a different frame all together.  The frame with the *Eshell* buffer may even be hidden behind the active frame.  As output arrives to the *Eshell* buffer, redisplay is updating the cursor in that window and also the active window.

I am unaware of any reason why the cursor in the active window needs updating in this situation.

Q:  How can I determine the origin of the command loop in this situation so that I can suppress the cursor from being updated in the active window?

BACKGROUND:  In general (with some exceptions), multiple fake cursors, crosshairs and the visible fill column are redrawn whenever the real cursor gets updated.

Thanks,

Keith



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-12-22 17:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20  4:11 Process: Determining the origin of a command loop Keith David Bershatsky
2018-12-20 14:11 ` Eli Zaretskii
2018-12-20 15:39   ` Cursor drawing (was: Process: Determining the origin of a command loop) Stefan Monnier
2018-12-20 19:07     ` Cursor drawing Eli Zaretskii
2018-12-20 19:18       ` Stefan Monnier
2018-12-20 19:35         ` Eli Zaretskii
2018-12-20 19:58           ` Stefan Monnier
2018-12-21  4:03             ` Elias Mårtenson
2018-12-21  7:09               ` Eli Zaretskii
2018-12-21 16:36                 ` Elias Mårtenson
2018-12-21 20:05                   ` Eli Zaretskii
2018-12-21 20:27                     ` Clément Pit-Claudel
2018-12-21 20:37                       ` Eli Zaretskii
2018-12-21 20:41                         ` Eli Zaretskii
2018-12-22 16:43                         ` Stefan Monnier
2018-12-22 17:03                           ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2018-12-20 23:54 Process: Determining the origin of a command loop Keith David Bershatsky
2018-12-19  4:34 Keith David Bershatsky
2018-12-19 15:24 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).