unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: dalanicolai <dalanicolai@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: displaying margins leads to Emacs hanging
Date: Sat, 25 Feb 2023 12:51:28 +0200	[thread overview]
Message-ID: <83bklikogf.fsf@gnu.org> (raw)
In-Reply-To: <CACJP=3ntnfYcaSZmOR5HTa_+mE3N9cD_16xQOm5nGcvgn+mdRw@mail.gmail.com> (message from dalanicolai on Fri, 24 Feb 2023 21:53:35 +0100)

> From: dalanicolai <dalanicolai@gmail.com>
> Date: Fri, 24 Feb 2023 21:53:35 +0100
> Cc: emacs-devel@gnu.org
> 
> B.t.w if someone want to have a look, I'll attach a smaller file here where
> I have just removed about 200 pages of the book text data, so that it is
> the file is much smaller, but there is still enough date to clearly show the
> 'undesired' behavior.
> 
> So now, Emacs will not 'hang', but there will still be a clear difference in time it
> takes to update the buffer (between when window margins are displayed,
> and when they are not).

Your code overwhelms redisplay with an inconceivably huge number of
overlays that are left from the previous iteration.  This one-line
change makes the code work reasonably fast:

(defun baleen-update2 ()
  ;; (let ((query (minibuffer-contents)))
  ;;   (with-current-buffer (get-buffer-create "*baleen*")
  ;;     (erase-buffer)
  ;;     (baleen-render (baleen-filter test2 query)))))
  (let* ((query (minibuffer-contents))
         (query-length (length query)))
    (if (> (length previous-query) query-length)
        (with-current-buffer (get-buffer-create "*baleen*")
          (erase-buffer)
          (baleen-render (cdr (alist-get query baleen-results nil nil #'string=))))
      (let* ((parent-results (unless (< query-length 2)
                               (alist-get (substring query 0 -1) baleen-results nil nil #'string=)))
             (current-results (if parent-results
                                  (baleen-filter parent-results query)
                                (unless (string-empty-p query) (baleen-filter test2 query)))))
        (when current-results
          (with-current-buffer (get-buffer-create "*baleen*")
	    (remove-overlays) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            (erase-buffer)
            (baleen-render current-results))
          (cl-pushnew (cons query current-results) baleen-results :test #'string= :key #'car))

        (setq previous-query query)))))



  parent reply	other threads:[~2023-02-25 10:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 19:29 displaying margins leads to Emacs hanging dalanicolai
2023-02-24 19:41 ` Eli Zaretskii
2023-02-24 20:26   ` dalanicolai
2023-02-24 20:29     ` Eli Zaretskii
2023-02-24 20:41       ` dalanicolai
2023-02-24 20:53         ` dalanicolai
2023-02-24 21:19           ` dalanicolai
2023-02-24 21:43             ` dalanicolai
2023-02-25 10:51           ` Eli Zaretskii [this message]
2023-02-25 13:17             ` dalanicolai
2023-02-25 13:42               ` Eli Zaretskii
2023-03-06 22:51                 ` dalanicolai
2023-02-24 21:25         ` Eli Zaretskii
2023-02-24 21:41           ` dalanicolai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bklikogf.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=dalanicolai@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).