emacs-devel
[Top][All Lists]
Advanced

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

Standard check before creating large num of frames


From: Tino Calancha
Subject: Standard check before creating large num of frames
Date: Thu, 15 Sep 2016 15:26:43 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)


Dear all,

several functions might create new frames.  In particular when
`pop-up-frames' is non-nil, `display-buffer' creates a new frame.
Creating a lot of new frames might be expensive.

Some functions may ask for user confirmation before creating an
many frames.
For instance, see `ibuffer-do-view-1': this function ask for confirmation
before creating > 3 frames.
IMO, it's good if each function creating a large number of frames
do a similar check.
We might add a new option, for instance 'max-number-of-frames'
or 'frame-max-number':

(defcustom max-number-of-frames 3
  "Maximum number of frames to create before asking user confirmation."
    :version "25.2"
    :type 'integer
    :group 'convenience)

We might want to standarize the check as well:
(defun frame-create-many-frames-p (nframes &optional prompt)
  "Return non-nil if it's OK to create NFRAMES.
If NFRAMES + current number of frames is > `max-number-of-frames',
ask for user confirmation.
An optional arg is the prompt to ask the user."
  (let* ((tot (+ nframes (length (frame-list))))
         (str (or prompt (format "Really create %s frames? " nframes)))
         (res (or (<= tot max-number-of-frames)
                  (y-or-n-p str))))
    res))

Please, let me know your opinions/suggestions about this proposal.
In case we want to add these things: where should they live?

Regards,
Tino



reply via email to

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