From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Standard check before creating large num of frames Date: Thu, 15 Sep 2016 17:58:18 +0300 Message-ID: <838tut6whh.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1473952568 31414 195.159.176.226 (15 Sep 2016 15:16:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Sep 2016 15:16:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 15 17:15:59 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkYO9-0005oA-Tx for ged-emacs-devel@m.gmane.org; Thu, 15 Sep 2016 17:15:46 +0200 Original-Received: from localhost ([::1]:35407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkYO7-0007bY-Ug for ged-emacs-devel@m.gmane.org; Thu, 15 Sep 2016 11:15:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkY7F-0002AQ-J0 for emacs-devel@gnu.org; Thu, 15 Sep 2016 10:58:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkY79-0005W9-Lb for emacs-devel@gnu.org; Thu, 15 Sep 2016 10:58:16 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkY79-0005Vn-Hk; Thu, 15 Sep 2016 10:58:11 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1345 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bkY77-00006O-Lg; Thu, 15 Sep 2016 10:58:10 -0400 In-reply-to: (message from Tino Calancha on Thu, 15 Sep 2016 15:26:43 +0900 (JST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207445 Archived-At: > From: Tino Calancha > Date: Thu, 15 Sep 2016 15:26:43 +0900 (JST) > Cc: tino.calancha@gmail.com > > 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) FWIW, I don't like nagging users like that. It could be an optional feature, off by default, I guess. Did you really hear from someone complaining about too many frames open without their consent? A couple of minor comments: > (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)) First, the message text is confusing: when the user asked for creating a single additional frame, we are asking them Really create 4 frames? The user didn't ask for 4 frames, she only asked for one. A better text would be You already have 3 frames; really create another one? In addition, I think you should also allow the user to tell Emacs never ask this question again in the current session, not just yes/no for this one frame.