[Top][All Lists]

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

Re: Freezing frameset-restore

From: Juanma Barranquero
Subject: Re: Freezing frameset-restore
Date: Sat, 8 Mar 2014 02:42:16 +0100

On Sat, Mar 8, 2014 at 1:34 AM, Stefan Monnier <address@hidden> 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

> 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.


reply via email to

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