From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: Freezing frameset-restore Date: Sat, 8 Mar 2014 02:42:16 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1394242973 24677 80.91.229.3 (8 Mar 2014 01:42:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Mar 2014 01:42:53 +0000 (UTC) Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 08 02:43:02 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WM6I2-0001eU-B0 for ged-emacs-devel@m.gmane.org; Sat, 08 Mar 2014 02:43:02 +0100 Original-Received: from localhost ([::1]:39023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WM6I1-0000td-WC for ged-emacs-devel@m.gmane.org; Fri, 07 Mar 2014 20:43:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WM6Hy-0000tX-RG for emacs-devel@gnu.org; Fri, 07 Mar 2014 20:42:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WM6Hx-0002OH-OS for emacs-devel@gnu.org; Fri, 07 Mar 2014 20:42:58 -0500 Original-Received: from mail-yh0-x232.google.com ([2607:f8b0:4002:c01::232]:54901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WM6Hx-0002OB-Js for emacs-devel@gnu.org; Fri, 07 Mar 2014 20:42:57 -0500 Original-Received: by mail-yh0-f50.google.com with SMTP id t59so5168937yho.9 for ; Fri, 07 Mar 2014 17:42:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=h7SUxDhHjJAj04ngrA8p9SSloV5swvAIuT7XOxVURyI=; b=bguif72gxfcOcvQdMNaUKA8uR0FdRPQvcO5gA4bv/LU0WWRseZaQP48O0NlEqocKt4 OIq7T5sb+ZdmXVRT2UdzvNcwuO9kDUiGpZ8qpzzKBSdtt6cACktgY5IAFH/Zb3SUCeKf hL6UAkD27+bBPH5wczUtTftJxKwiCZ8V/EYBnWUXVvSYLigVFHYKXQ3Y7r8CjcOMYHJd 5oz+2tQN0bm3q9JGzfctaZMWFq02Rs7EH0H/z8nJtSxFVBaK/FsW2+AIHZEijxvG8002 +J7xVYMGt8J080jM0LYDxJUwWYMTGDtbdFz6+DgGCfRUZBsCk6xBnfr1uKKBF/Mv8bxh jUPA== X-Received: by 10.236.149.2 with SMTP id w2mr450122yhj.114.1394242976917; Fri, 07 Mar 2014 17:42:56 -0800 (PST) Original-Received: by 10.170.163.3 with HTTP; Fri, 7 Mar 2014 17:42:16 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c01::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:170216 Archived-At: On Sat, Mar 8, 2014 at 1:34 AM, Stefan Monnier wrote: > Right. But we're simplifying the "interface". Hm. On one hand, the interface is already complex; on the other hand, it's not more complex than make-network-process or defcustom ;-) > And we can provide > a frameset-restore-cleanup function which does the default thing. I don't understand what you mean, i.e, a function for the common case? (defun frameset-restore-cleanup (frame-action) "Delete frame from FRAME-ACTION if it was not restored upon. FRAME-ACTION is a pair (FRAME . ACTION) as returned by `frameset-restore' (which see)." (when (memq (cdr action) '(:ignored :rejected)) (delete-frame (car frame)))) (mapc 'frameset-restore-cleanup (frameset-restore fs)) Or a generic one (defun frameset-restore-cleanup (frame-action action-map) "Clean up frame from FRAME-ACTION according to ACTION-MAP. FRAME-ACTION is a pair (FRAME . ACTION) as returned by `frameset-restore' (which see). ACTION-MAP is an alist \((ACTIONn . FUNCTIONn)...) mapping actions to their cleanup functions. ACTIONn can be an action, or a list of actions. Each FUNCTIONn, if called, gets a single argument FRAME, and its return value is ignored." (let* ((action (cdr frame-action)) (func (cl-find-if (lambda (item) (if (consp item) (memq action item) (eq action item))) action-map :key #'car))) (when func (funcall (cdr func) (car frame-action))))) (dolist (frame-action (frameset-restore fs)) (frameset-restore-cleanup frame-action '((:rejected :ignored) . #'delete-frame))) I'm not sure we gain anything with this. As a net loss, we must construct (and sort) the return list even if it is not going to be used, while in the CLEANUP argument case, no list is constructed; in fact, if CLEANUP = :keep, not even (frame-list) is called at that point. > Tho the main question is: how many callers are we talking about? > So far I see 2 calls to this function in Emacs's trunk Well, yes, of course. This is an un-released feature. I imagine that once it is released in 24.4, some other uses will be found, but not that many; it is a specialized feature anyway, and its main use case (and the reason it was implemented) is already covered by desktop.el. > so moving some > complexity to the caller doesn't sound so terrible. I don't find it terrible, but neither do I find it cleaner. Anyway, it's your call. J