lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;;; frameset.el --- save and restore frame and window setup -*- lexical-binding: t -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
;; Author: Juanma Barranquero <lekktu@gmail.com>
|
|
|
|
|
;; Keywords: convenience
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This file provides a set of operations to save a frameset (the state
|
|
|
|
|
;; of all or a subset of the existing frames and windows), both
|
|
|
|
|
;; in-session and persistently, and restore it at some point in the
|
|
|
|
|
;; future.
|
|
|
|
|
;;
|
|
|
|
|
;; It should be noted that restoring the frames' windows depends on
|
|
|
|
|
;; the buffers they are displaying, but this package does not provide
|
|
|
|
|
;; any way to save and restore sets of buffers (see desktop.el for
|
|
|
|
|
;; that). So, it's up to the user of frameset.el to make sure that
|
|
|
|
|
;; any relevant buffer is loaded before trying to restore a frameset.
|
|
|
|
|
;; When a window is restored and a buffer is missing, the window will
|
|
|
|
|
;; be deleted unless it is the last one in the frame, in which case
|
|
|
|
|
;; some previous buffer will be shown instead.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'cl-lib)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(cl-defstruct (frameset (:type list) :named
|
|
|
|
|
(:copier nil)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(:predicate nil)
|
|
|
|
|
;; A BOA constructor, not the default "keywordy" one.
|
|
|
|
|
(:constructor make-frameset (properties states)))
|
|
|
|
|
|
|
|
|
|
"A frameset encapsulates a serializable view of a set of frames and windows.
|
|
|
|
|
|
|
|
|
|
It contains the following slots, which can be accessed with
|
|
|
|
|
\(frameset-SLOT fs) and set with (setf (frameset-SLOT fs) VALUE):
|
|
|
|
|
|
|
|
|
|
version A non-modifiable version number, identifying the format
|
|
|
|
|
of the frameset struct. Currently its value is 1.
|
|
|
|
|
properties A property list, to store both frameset-specific and
|
|
|
|
|
user-defined serializable data (some suggested properties
|
|
|
|
|
are described below).
|
|
|
|
|
states An alist of items (FRAME-PARAMETERS . WINDOW-STATE), in no
|
|
|
|
|
particular order. Each item represents a frame to be
|
|
|
|
|
restored. FRAME-PARAMETERS is a frame's parameter list,
|
|
|
|
|
extracted with (frame-parameters FRAME) and filtered through
|
|
|
|
|
`frame-parameters-alist' or a similar filter alist.
|
|
|
|
|
WINDOW-STATE is the output of `window-state-get', when
|
|
|
|
|
applied to the root window of the frame.
|
|
|
|
|
|
|
|
|
|
Some suggested properties:
|
|
|
|
|
|
|
|
|
|
:app APPINFO Can be used by applications and packages to indicate the
|
|
|
|
|
intended (but by no means exclusive) use of the frameset.
|
|
|
|
|
Freeform. For example, currently desktop.el framesets set
|
|
|
|
|
:app to `(desktop . ,desktop-file-version).
|
|
|
|
|
:name NAME The name of the frameset instance; a string.
|
|
|
|
|
:desc TEXT A description for user consumption (to show in a menu to
|
|
|
|
|
choose among framesets, etc.); a string.
|
|
|
|
|
|
|
|
|
|
A frameset is intended to be used through the following simple API:
|
|
|
|
|
|
|
|
|
|
- `frameset-save' captures all or a subset of the live frames, and returns
|
|
|
|
|
a serializable snapshot of them (a frameset).
|
|
|
|
|
- `frameset-restore' takes a frameset, and restores the frames and windows
|
|
|
|
|
it describes, as faithfully as possible.
|
|
|
|
|
- `frameset-p' is the predicate for the frameset type. It returns nil
|
|
|
|
|
for non-frameset objects, and the frameset version number (see below)
|
|
|
|
|
for frameset objects.
|
|
|
|
|
- `frameset-copy' returns a deep copy of a frameset.
|
|
|
|
|
- `frameset-prop' is a `setf'able accessor for the contents of the
|
|
|
|
|
`properties' slot.
|
|
|
|
|
- The `frameset-SLOT' accessors described above."
|
|
|
|
|
|
|
|
|
|
(version 1 :read-only t)
|
|
|
|
|
properties states)
|
|
|
|
|
|
|
|
|
|
(defun frameset-copy (frameset)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"Return a copy of FRAMESET.
|
|
|
|
|
This is a deep copy done with `copy-tree'."
|
|
|
|
|
(copy-tree frameset t))
|
|
|
|
|
|
2013-08-04 00:58:32 +00:00
|
|
|
|
;;;###autoload
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(defun frameset-p (frameset)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
"If FRAMESET is a frameset, return its version number.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
Else return nil."
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(and (eq (car-safe frameset) 'frameset) ; is a list
|
|
|
|
|
(integerp (nth 1 frameset)) ; version is an int
|
|
|
|
|
(nth 3 frameset) ; states is non-null
|
|
|
|
|
(nth 1 frameset))) ; return version
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
2013-08-03 09:57:07 +00:00
|
|
|
|
;; A setf'able accessor to the frameset's properties
|
|
|
|
|
(defun frameset-prop (frameset prop)
|
|
|
|
|
"Return the value of the PROP property of FRAMESET.
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
Properties can be set with
|
2013-08-03 09:57:07 +00:00
|
|
|
|
|
|
|
|
|
(setf (frameset-prop FRAMESET PROP) NEW-VALUE)"
|
|
|
|
|
(plist-get (frameset-properties frameset) prop))
|
|
|
|
|
|
2013-08-03 13:33:22 +00:00
|
|
|
|
(gv-define-setter frameset-prop (val fs prop)
|
|
|
|
|
(macroexp-let2 nil v val
|
|
|
|
|
`(progn
|
|
|
|
|
(setf (frameset-properties ,fs)
|
|
|
|
|
(plist-put (frameset-properties ,fs) ,prop ,v))
|
|
|
|
|
,v)))
|
2013-08-03 09:57:07 +00:00
|
|
|
|
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
;; Filtering
|
|
|
|
|
|
2013-08-04 22:12:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defvar frameset-live-filter-alist
|
2013-08-05 04:45:17 +00:00
|
|
|
|
'((name . :never)
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(left . frameset-filter-iconified)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(minibuffer . frameset-filter-minibuffer)
|
|
|
|
|
(top . frameset-filter-iconified))
|
|
|
|
|
"Minimum set of parameters to filter for live (on-session) framesets.
|
|
|
|
|
See `frameset-filter-alist' for a full description.")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defvar frameset-persistent-filter-alist
|
|
|
|
|
(nconc
|
|
|
|
|
'((background-color . frameset-filter-sanitize-color)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(buffer-list . :never)
|
|
|
|
|
(buffer-predicate . :never)
|
|
|
|
|
(buried-buffer-list . :never)
|
|
|
|
|
(font . frameset-filter-save-param)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(foreground-color . frameset-filter-sanitize-color)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(fullscreen . frameset-filter-save-param)
|
|
|
|
|
(GUI:font . frameset-filter-restore-param)
|
|
|
|
|
(GUI:fullscreen . frameset-filter-restore-param)
|
|
|
|
|
(GUI:height . frameset-filter-restore-param)
|
|
|
|
|
(GUI:width . frameset-filter-restore-param)
|
|
|
|
|
(height . frameset-filter-save-param)
|
|
|
|
|
(outer-window-id . :never)
|
|
|
|
|
(parent-id . :never)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(tty . frameset-filter-tty-to-GUI)
|
|
|
|
|
(tty-type . frameset-filter-tty-to-GUI)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(width . frameset-filter-save-param)
|
|
|
|
|
(window-id . :never)
|
|
|
|
|
(window-system . :never))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
frameset-live-filter-alist)
|
|
|
|
|
"Recommended set of parameters to filter for persistent framesets.
|
|
|
|
|
See `frameset-filter-alist' for a full description.")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defvar frameset-filter-alist frameset-persistent-filter-alist
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"Alist of frame parameters and filtering functions.
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
This alist is the default value of the :filters arguments of
|
|
|
|
|
`frameset-save' and `frameset-restore' (which see). On saving,
|
|
|
|
|
PARAMETERS is the parameter list of each frame processed, and
|
|
|
|
|
FILTERED is the parameter list that gets saved to the frameset.
|
|
|
|
|
On restoring, PARAMETERS is the parameter list extracted from the
|
|
|
|
|
frameset, and FILTERED is the resulting frame parameter list used
|
|
|
|
|
to restore the frame.
|
|
|
|
|
|
|
|
|
|
Elements of this alist are conses (PARAM . ACTION), where PARAM
|
|
|
|
|
is a parameter name (a symbol identifying a frame parameter), and
|
|
|
|
|
ACTION can be:
|
|
|
|
|
|
|
|
|
|
nil The parameter is copied to FILTERED.
|
|
|
|
|
:never The parameter is never copied to FILTERED.
|
|
|
|
|
:save The parameter is copied only when saving the frame.
|
|
|
|
|
:restore The parameter is copied only when restoring the frame.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
FILTER A filter function.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
FILTER can be a symbol FILTER-FUN, or a list (FILTER-FUN ARGS...).
|
2013-08-05 04:45:17 +00:00
|
|
|
|
FILTER-FUN is called with four arguments CURRENT, FILTERED, PARAMETERS and
|
|
|
|
|
SAVING, plus any additional ARGS:
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
CURRENT A cons (PARAM . VALUE), where PARAM is the one being
|
2013-08-04 22:12:18 +00:00
|
|
|
|
filtered and VALUE is its current value.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
FILTERED The resulting alist (so far).
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
PARAMETERS The complete alist of parameters being filtered,
|
2013-08-05 04:45:17 +00:00
|
|
|
|
SAVING Non-nil if filtering before saving state, nil if filtering
|
|
|
|
|
before restoring it.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
2013-08-06 01:26:29 +00:00
|
|
|
|
FILTER-FUN is allowed to modify items in FILTERED, but no other arguments.
|
|
|
|
|
It must return:
|
2013-08-05 04:45:17 +00:00
|
|
|
|
nil Skip CURRENT (do not add it to FILTERED).
|
|
|
|
|
t Add CURRENT to FILTERED as is.
|
|
|
|
|
(NEW-PARAM . NEW-VALUE) Add this to FILTERED instead of CURRENT.
|
|
|
|
|
|
|
|
|
|
Frame parameters not on this alist are passed intact, as if they were
|
|
|
|
|
defined with ACTION = nil.")
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defvar frameset--target-display nil
|
|
|
|
|
;; Either (minibuffer . VALUE) or nil.
|
|
|
|
|
;; This refers to the current frame config being processed inside
|
2013-08-05 04:45:17 +00:00
|
|
|
|
;; `frameset-restore' and its auxiliary functions (like filtering).
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; If nil, there is no need to change the display.
|
|
|
|
|
;; If non-nil, display parameter to use when creating the frame.
|
|
|
|
|
"Internal use only.")
|
|
|
|
|
|
|
|
|
|
(defun frameset-switch-to-gui-p (parameters)
|
|
|
|
|
"True when switching to a graphic display.
|
|
|
|
|
Return t if PARAMETERS describes a text-only terminal and
|
|
|
|
|
the target is a graphic display; otherwise return nil.
|
|
|
|
|
Only meaningful when called from a filtering function in
|
|
|
|
|
`frameset-filter-alist'."
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(and frameset--target-display ; we're switching
|
|
|
|
|
(null (cdr (assq 'display parameters))) ; from a tty
|
|
|
|
|
(cdr frameset--target-display))) ; to a GUI display
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
(defun frameset-switch-to-tty-p (parameters)
|
|
|
|
|
"True when switching to a text-only terminal.
|
|
|
|
|
Return t if PARAMETERS describes a graphic display and
|
|
|
|
|
the target is a text-only terminal; otherwise return nil.
|
|
|
|
|
Only meaningful when called from a filtering function in
|
|
|
|
|
`frameset-filter-alist'."
|
|
|
|
|
(and frameset--target-display ; we're switching
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(cdr (assq 'display parameters)) ; from a GUI display
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(null (cdr frameset--target-display)))) ; to a tty
|
|
|
|
|
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(defun frameset-filter-tty-to-GUI (_current _filtered parameters saving)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
"Remove CURRENT when switching from tty to a graphic display.
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(or saving
|
|
|
|
|
(not (frameset-switch-to-gui-p parameters))))
|
|
|
|
|
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(defun frameset-filter-sanitize-color (current _filtered parameters saving)
|
|
|
|
|
"When switching to a GUI frame, remove \"unspecified\" colors.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
Useful as a filter function for tty-specific parameters.
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(or saving
|
|
|
|
|
(not (frameset-switch-to-gui-p parameters))
|
|
|
|
|
(not (stringp (cdr current)))
|
|
|
|
|
(not (string-match-p "^unspecified-[fb]g$" (cdr current)))))
|
|
|
|
|
|
|
|
|
|
(defun frameset-filter-minibuffer (current _filtered _parameters saving)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
"When saving, convert (minibuffer . #<window>) parameter to (minibuffer . t).
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(or (not saving)
|
|
|
|
|
(if (windowp (cdr current))
|
|
|
|
|
'(minibuffer . t)
|
|
|
|
|
t)))
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(defun frameset-filter-save-param (current _filtered parameters saving
|
|
|
|
|
&optional prefix)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"When switching to a tty frame, save parameter P as PREFIX:P.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
The parameter can be later restored with `frameset-filter-restore-param'.
|
|
|
|
|
PREFIX defaults to `GUI'.
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(unless prefix (setq prefix 'GUI))
|
|
|
|
|
(cond (saving t)
|
|
|
|
|
((frameset-switch-to-tty-p parameters)
|
|
|
|
|
(let ((prefix:p (intern (format "%s:%s" prefix (car current)))))
|
|
|
|
|
(if (assq prefix:p parameters)
|
|
|
|
|
nil
|
|
|
|
|
(cons prefix:p (cdr current)))))
|
|
|
|
|
((frameset-switch-to-gui-p parameters)
|
|
|
|
|
(not (assq (intern (format "%s:%s" prefix (car current))) parameters)))
|
|
|
|
|
(t t)))
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(defun frameset-filter-restore-param (current filtered parameters saving)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"When switching to a GUI frame, restore PREFIX:P parameter as P.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
CURRENT must be of the form (PREFIX:P . value).
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(or saving
|
|
|
|
|
(not (frameset-switch-to-gui-p parameters))
|
|
|
|
|
(let* ((prefix:p (symbol-name (car current)))
|
|
|
|
|
(p (intern (substring prefix:p
|
|
|
|
|
(1+ (string-match-p ":" prefix:p)))))
|
|
|
|
|
(val (cdr current))
|
|
|
|
|
(found (assq p filtered)))
|
|
|
|
|
(if (not found)
|
|
|
|
|
(cons p val)
|
|
|
|
|
(setcdr found val)
|
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
|
|
(defun frameset-filter-iconified (_current _filtered parameters saving)
|
|
|
|
|
"Remove CURRENT when saving an iconified frame.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
This is used for positional parameters `left' and `top', which are
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
meaningless in an iconified frame, so the frame is restored in a
|
2013-08-05 04:45:17 +00:00
|
|
|
|
default position.
|
|
|
|
|
|
|
|
|
|
For the meaning of CURRENT, FILTERED, PARAMETERS and SAVING,
|
|
|
|
|
see the docstring of `frameset-filter-alist'."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(not (and saving (eq (cdr (assq 'visibility parameters)) 'icon))))
|
|
|
|
|
|
|
|
|
|
(defun frameset-filter-params (parameters filter-alist saving)
|
|
|
|
|
"Filter parameter list PARAMETERS and return a filtered list.
|
|
|
|
|
FILTER-ALIST is an alist of parameter filters, in the format of
|
|
|
|
|
`frameset-filter-alist' (which see).
|
|
|
|
|
SAVING is non-nil while filtering parameters to save a frameset,
|
|
|
|
|
nil while the filtering is done to restore it."
|
|
|
|
|
(let ((filtered nil))
|
|
|
|
|
(dolist (current parameters)
|
2013-08-06 01:26:29 +00:00
|
|
|
|
;; When saving, the parameter list is temporary, so modifying it
|
|
|
|
|
;; is not a problem. When restoring, the parameter list is part
|
|
|
|
|
;; of a frameset, so we must copy parameters to avoid inadvertent
|
|
|
|
|
;; modifications.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(pcase (cdr (assq (car current) filter-alist))
|
|
|
|
|
(`nil
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(push (if saving current (copy-tree current)) filtered))
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(:never
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
nil)
|
|
|
|
|
(:restore
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(unless saving (push (copy-tree current) filtered)))
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(:save
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(when saving (push current filtered)))
|
|
|
|
|
((or `(,fun . ,args) (and fun (pred fboundp)))
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(let* ((this (apply fun current filtered parameters saving args))
|
|
|
|
|
(val (if (eq this t) current this)))
|
|
|
|
|
(when val
|
|
|
|
|
(push (if saving val (copy-tree val)) filtered))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(other
|
|
|
|
|
(delay-warning 'frameset (format "Unknown filter %S" other) :error))))
|
|
|
|
|
;; Set the display parameter after filtering, so that filter functions
|
|
|
|
|
;; have access to its original value.
|
|
|
|
|
(when frameset--target-display
|
|
|
|
|
(let ((display (assq 'display filtered)))
|
|
|
|
|
(if display
|
|
|
|
|
(setcdr display (cdr frameset--target-display))
|
|
|
|
|
(push frameset--target-display filtered))))
|
|
|
|
|
filtered))
|
|
|
|
|
|
|
|
|
|
|
2013-08-05 13:06:29 +00:00
|
|
|
|
;; Frame ids
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
(defun frameset--set-id (frame)
|
2013-08-05 13:06:29 +00:00
|
|
|
|
"Set FRAME's id if not yet set.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
Internal use only."
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(unless (frame-parameter frame 'frameset--id)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(set-frame-parameter frame
|
2013-08-04 22:12:18 +00:00
|
|
|
|
'frameset--id
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(mapconcat (lambda (n) (format "%04X" n))
|
|
|
|
|
(cl-loop repeat 4 collect (random 65536))
|
|
|
|
|
"-"))))
|
2013-08-05 13:06:29 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun frameset-frame-id (frame)
|
|
|
|
|
"Return the frame id of FRAME, if it has one; else, return nil.
|
|
|
|
|
A frame id is a string that uniquely identifies a frame.
|
|
|
|
|
It is persistent across `frameset-save' / `frameset-restore'
|
|
|
|
|
invocations, and once assigned is never changed unless the same
|
|
|
|
|
frame is duplicated (via `frameset-restore'), in which case the
|
|
|
|
|
newest frame keeps the id and the old frame's is set to nil."
|
|
|
|
|
(frame-parameter frame 'frameset--id))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun frameset-frame-id-equal-p (frame id)
|
|
|
|
|
"Return non-nil if FRAME's id matches ID."
|
|
|
|
|
(string= (frameset-frame-id frame) id))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun frameset-locate-frame-id (id &optional frame-list)
|
|
|
|
|
"Return the live frame with id ID, if exists; else nil.
|
|
|
|
|
If FRAME-LIST is a list of frames, check these frames only.
|
|
|
|
|
If nil, check all live frames."
|
|
|
|
|
(cl-find-if (lambda (f)
|
|
|
|
|
(and (frame-live-p f)
|
|
|
|
|
(frameset-frame-id-equal-p f id)))
|
|
|
|
|
(or frame-list (frame-list))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Saving framesets
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
(defun frameset--process-minibuffer-frames (frame-list)
|
|
|
|
|
"Process FRAME-LIST and record minibuffer relationships.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
FRAME-LIST is a list of frames. Internal use only."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; Record frames with their own minibuffer
|
|
|
|
|
(dolist (frame (minibuffer-frame-list))
|
|
|
|
|
(when (memq frame frame-list)
|
|
|
|
|
(frameset--set-id frame)
|
|
|
|
|
;; For minibuffer-owning frames, frameset--mini is a cons
|
|
|
|
|
;; (t . DEFAULT?), where DEFAULT? is a boolean indicating whether
|
|
|
|
|
;; the frame is the one pointed out by `default-minibuffer-frame'.
|
|
|
|
|
(set-frame-parameter frame
|
|
|
|
|
'frameset--mini
|
|
|
|
|
(cons t (eq frame default-minibuffer-frame)))))
|
|
|
|
|
;; Now link minibufferless frames with their minibuffer frames
|
|
|
|
|
(dolist (frame frame-list)
|
|
|
|
|
(unless (frame-parameter frame 'frameset--mini)
|
|
|
|
|
(frameset--set-id frame)
|
|
|
|
|
(let* ((mb-frame (window-frame (minibuffer-window frame)))
|
2013-08-05 13:06:29 +00:00
|
|
|
|
(id (and mb-frame (frameset-frame-id mb-frame))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(if (null id)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(error "Minibuffer frame %S for %S is not being saved" mb-frame frame)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; For minibufferless frames, frameset--mini is a cons
|
2013-08-04 22:12:18 +00:00
|
|
|
|
;; (nil . FRAME-ID), where FRAME-ID is the frameset--id
|
|
|
|
|
;; of the frame containing its minibuffer window.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(set-frame-parameter frame
|
|
|
|
|
'frameset--mini
|
|
|
|
|
(cons nil id)))))))
|
|
|
|
|
|
2013-08-04 00:58:32 +00:00
|
|
|
|
;;;###autoload
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(cl-defun frameset-save (frame-list &key filters predicate properties)
|
|
|
|
|
"Return the frameset of FRAME-LIST, a list of frames.
|
2013-08-06 01:26:29 +00:00
|
|
|
|
Dead frames and non-frame objects are silently removed from the list.
|
|
|
|
|
If nil, FRAME-LIST defaults to the output of `frame-list' (all live frames).
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
FILTERS is an alist of parameter filters; defaults to `frameset-filter-alist'.
|
|
|
|
|
PREDICATE is a predicate function, which must return non-nil for frames that
|
|
|
|
|
should be saved; it defaults to saving all frames from FRAME-LIST.
|
|
|
|
|
PROPERTIES is a user-defined property list to add to the frameset."
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(let* ((list (or (copy-sequence frame-list) (frame-list)))
|
|
|
|
|
(frames (cl-delete-if-not #'frame-live-p
|
|
|
|
|
(if predicate
|
|
|
|
|
(cl-delete-if-not predicate list)
|
|
|
|
|
list))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(frameset--process-minibuffer-frames frames)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(make-frameset properties
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (frame)
|
|
|
|
|
(cons
|
|
|
|
|
(frameset-filter-params (frame-parameters frame)
|
|
|
|
|
(or filters frameset-filter-alist)
|
|
|
|
|
t)
|
|
|
|
|
(window-state-get (frame-root-window frame) t)))
|
|
|
|
|
frames))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Restoring framesets
|
|
|
|
|
|
|
|
|
|
(defvar frameset--reuse-list nil
|
2013-08-05 04:45:17 +00:00
|
|
|
|
"The list of frames potentially reusable.
|
|
|
|
|
Its value is only meaningful during execution of `frameset-restore'.
|
|
|
|
|
Internal use only.")
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
(defun frameset--compute-pos (value left/top right/bottom)
|
|
|
|
|
(pcase value
|
|
|
|
|
(`(+ ,val) (+ left/top val))
|
|
|
|
|
(`(- ,val) (+ right/bottom val))
|
|
|
|
|
(val val)))
|
|
|
|
|
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(defun frameset-move-onscreen (frame force-onscreen)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"If FRAME is offscreen, move it back onscreen and, if necessary, resize it.
|
|
|
|
|
For the description of FORCE-ONSCREEN, see `frameset-restore'.
|
|
|
|
|
When forced onscreen, frames wider than the monitor's workarea are converted
|
|
|
|
|
to fullwidth, and frames taller than the workarea are converted to fullheight.
|
2013-08-06 01:26:29 +00:00
|
|
|
|
NOTE: This only works for non-iconified frames."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(pcase-let* ((`(,left ,top ,width ,height) (cl-cdadr (frame-monitor-attributes frame)))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(right (+ left width -1))
|
|
|
|
|
(bottom (+ top height -1))
|
|
|
|
|
(fr-left (frameset--compute-pos (frame-parameter frame 'left) left right))
|
|
|
|
|
(fr-top (frameset--compute-pos (frame-parameter frame 'top) top bottom))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(ch-width (frame-char-width frame))
|
|
|
|
|
(ch-height (frame-char-height frame))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(fr-width (max (frame-pixel-width frame) (* ch-width (frame-width frame))))
|
|
|
|
|
(fr-height (max (frame-pixel-height frame) (* ch-height (frame-height frame))))
|
|
|
|
|
(fr-right (+ fr-left fr-width -1))
|
|
|
|
|
(fr-bottom (+ fr-top fr-height -1)))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(when (pcase force-onscreen
|
2013-08-04 22:12:18 +00:00
|
|
|
|
;; A predicate.
|
|
|
|
|
((pred functionp)
|
|
|
|
|
(funcall force-onscreen
|
|
|
|
|
frame
|
|
|
|
|
(list fr-left fr-top fr-width fr-height)
|
|
|
|
|
(list left top width height)))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; Any corner is outside the screen.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(:all (or (< fr-bottom top) (> fr-bottom bottom)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(< fr-left left) (> fr-left right)
|
|
|
|
|
(< fr-right left) (> fr-right right)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(< fr-top top) (> fr-top bottom)))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; Displaced to the left, right, above or below the screen.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(`t (or (> fr-left right)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(< fr-right left)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(> fr-top bottom)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(< fr-bottom top)))
|
|
|
|
|
;; Fully inside, no need to do anything.
|
|
|
|
|
(_ nil))
|
|
|
|
|
(let ((fullwidth (> fr-width width))
|
|
|
|
|
(fullheight (> fr-height height))
|
|
|
|
|
(params nil))
|
|
|
|
|
;; Position frame horizontally.
|
|
|
|
|
(cond (fullwidth
|
|
|
|
|
(push `(left . ,left) params))
|
|
|
|
|
((> fr-right right)
|
|
|
|
|
(push `(left . ,(+ left (- width fr-width))) params))
|
|
|
|
|
((< fr-left left)
|
|
|
|
|
(push `(left . ,left) params)))
|
|
|
|
|
;; Position frame vertically.
|
|
|
|
|
(cond (fullheight
|
|
|
|
|
(push `(top . ,top) params))
|
|
|
|
|
((> fr-bottom bottom)
|
|
|
|
|
(push `(top . ,(+ top (- height fr-height))) params))
|
|
|
|
|
((< fr-top top)
|
|
|
|
|
(push `(top . ,top) params)))
|
|
|
|
|
;; Compute fullscreen state, if required.
|
|
|
|
|
(when (or fullwidth fullheight)
|
|
|
|
|
(push (cons 'fullscreen
|
|
|
|
|
(cond ((not fullwidth) 'fullheight)
|
|
|
|
|
((not fullheight) 'fullwidth)
|
|
|
|
|
(t 'maximized)))
|
|
|
|
|
params))
|
|
|
|
|
;; Finally, move the frame back onscreen.
|
|
|
|
|
(when params
|
|
|
|
|
(modify-frame-parameters frame params))))))
|
|
|
|
|
|
|
|
|
|
(defun frameset--find-frame (predicate display &rest args)
|
|
|
|
|
"Find a frame in `frameset--reuse-list' satisfying PREDICATE.
|
|
|
|
|
Look through available frames whose display property matches DISPLAY
|
|
|
|
|
and return the first one for which (PREDICATE frame ARGS) returns t.
|
|
|
|
|
If PREDICATE is nil, it is always satisfied. Internal use only."
|
|
|
|
|
(cl-find-if (lambda (frame)
|
|
|
|
|
(and (equal (frame-parameter frame 'display) display)
|
|
|
|
|
(or (null predicate)
|
|
|
|
|
(apply predicate frame args))))
|
|
|
|
|
frameset--reuse-list))
|
|
|
|
|
|
|
|
|
|
(defun frameset--reuse-frame (display frame-cfg)
|
|
|
|
|
"Look for an existing frame to reuse.
|
|
|
|
|
DISPLAY is the display where the frame will be shown, and FRAME-CFG
|
|
|
|
|
is the parameter list of the frame being restored. Internal use only."
|
|
|
|
|
(let ((frame nil)
|
|
|
|
|
mini)
|
|
|
|
|
;; There are no fancy heuristics there. We could implement some
|
|
|
|
|
;; based on frame size and/or position, etc., but it is not clear
|
|
|
|
|
;; that any "gain" (in the sense of reduced flickering, etc.) is
|
|
|
|
|
;; worth the added complexity. In fact, the code below mainly
|
|
|
|
|
;; tries to work nicely when M-x desktop-read is used after a
|
|
|
|
|
;; desktop session has already been loaded. The other main use
|
|
|
|
|
;; case, which is the initial desktop-read upon starting Emacs,
|
|
|
|
|
;; will usually have only one frame, and should already work.
|
|
|
|
|
(cond ((null display)
|
|
|
|
|
;; When the target is tty, every existing frame is reusable.
|
|
|
|
|
(setq frame (frameset--find-frame nil display)))
|
|
|
|
|
((car (setq mini (cdr (assq 'frameset--mini frame-cfg))))
|
|
|
|
|
;; If the frame has its own minibuffer, let's see whether
|
|
|
|
|
;; that frame has already been loaded (which can happen after
|
|
|
|
|
;; M-x desktop-read).
|
|
|
|
|
(setq frame (frameset--find-frame
|
|
|
|
|
(lambda (f id)
|
2013-08-05 13:06:29 +00:00
|
|
|
|
(frameset-frame-id-equal-p f id))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
display (cdr (assq 'frameset--id frame-cfg))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; If it has not been loaded, and it is not a minibuffer-only frame,
|
|
|
|
|
;; let's look for an existing non-minibuffer-only frame to reuse.
|
|
|
|
|
(unless (or frame (eq (cdr (assq 'minibuffer frame-cfg)) 'only))
|
|
|
|
|
(setq frame (frameset--find-frame
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(let ((w (frame-parameter f 'minibuffer)))
|
|
|
|
|
(and (window-live-p w)
|
|
|
|
|
(window-minibuffer-p w)
|
|
|
|
|
(eq (window-frame w) f))))
|
|
|
|
|
display))))
|
|
|
|
|
(mini
|
|
|
|
|
;; For minibufferless frames, check whether they already exist,
|
|
|
|
|
;; and that they are linked to the right minibuffer frame.
|
|
|
|
|
(setq frame (frameset--find-frame
|
2013-08-04 02:57:45 +00:00
|
|
|
|
(lambda (f id mini-id)
|
2013-08-05 13:06:29 +00:00
|
|
|
|
(and (frameset-frame-id-equal-p f id)
|
|
|
|
|
(frameset-frame-id-equal-p (window-frame
|
|
|
|
|
(minibuffer-window f))
|
|
|
|
|
mini-id)))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
display (cdr (assq 'frameset--id frame-cfg)) (cdr mini))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(t
|
|
|
|
|
;; Default to just finding a frame in the same display.
|
|
|
|
|
(setq frame (frameset--find-frame nil display))))
|
|
|
|
|
;; If found, remove from the list.
|
|
|
|
|
(when frame
|
|
|
|
|
(setq frameset--reuse-list (delq frame frameset--reuse-list)))
|
|
|
|
|
frame))
|
|
|
|
|
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(defun frameset--initial-params (frame-cfg)
|
|
|
|
|
"Return parameters from FRAME-CFG that should not be changed later.
|
|
|
|
|
Setting position and size parameters as soon as possible helps reducing
|
|
|
|
|
flickering; other parameters, like `minibuffer' and `border-width', must
|
|
|
|
|
be set when creating the frame because they can not be changed later.
|
|
|
|
|
Internal use only."
|
|
|
|
|
(cl-loop for param in '(left top with height border-width minibuffer)
|
|
|
|
|
collect (assq param frame-cfg)))
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(defun frameset--restore-frame (frame-cfg window-cfg filters force-onscreen)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"Set up and return a frame according to its saved state.
|
|
|
|
|
That means either reusing an existing frame or creating one anew.
|
|
|
|
|
FRAME-CFG is the frame's parameter list; WINDOW-CFG is its window state.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
For the meaning of FILTERS and FORCE-ONSCREEN, see `frameset-restore'.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
Internal use only."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(let* ((fullscreen (cdr (assq 'fullscreen frame-cfg)))
|
|
|
|
|
(lines (assq 'tool-bar-lines frame-cfg))
|
|
|
|
|
(filtered-cfg (frameset-filter-params frame-cfg filters nil))
|
|
|
|
|
(display (cdr (assq 'display filtered-cfg))) ;; post-filtering
|
|
|
|
|
alt-cfg frame)
|
|
|
|
|
|
|
|
|
|
;; This works around bug#14795 (or feature#14795, if not a bug :-)
|
|
|
|
|
(setq filtered-cfg (assq-delete-all 'tool-bar-lines filtered-cfg))
|
|
|
|
|
(push '(tool-bar-lines . 0) filtered-cfg)
|
|
|
|
|
|
|
|
|
|
(when fullscreen
|
|
|
|
|
;; Currently Emacs has the limitation that it does not record the size
|
|
|
|
|
;; and position of a frame before maximizing it, so we cannot save &
|
|
|
|
|
;; restore that info. Instead, when restoring, we resort to creating
|
|
|
|
|
;; invisible "fullscreen" frames of default size and then maximizing them
|
|
|
|
|
;; (and making them visible) which at least is somewhat user-friendly
|
|
|
|
|
;; when these frames are later de-maximized.
|
|
|
|
|
(let ((width (and (eq fullscreen 'fullheight) (cdr (assq 'width filtered-cfg))))
|
|
|
|
|
(height (and (eq fullscreen 'fullwidth) (cdr (assq 'height filtered-cfg))))
|
|
|
|
|
(visible (assq 'visibility filtered-cfg)))
|
|
|
|
|
(setq filtered-cfg (cl-delete-if (lambda (p)
|
|
|
|
|
(memq p '(visibility fullscreen width height)))
|
|
|
|
|
filtered-cfg :key #'car))
|
|
|
|
|
(when width
|
|
|
|
|
(setq filtered-cfg (append `((user-size . t) (width . ,width))
|
|
|
|
|
filtered-cfg)))
|
|
|
|
|
(when height
|
|
|
|
|
(setq filtered-cfg (append `((user-size . t) (height . ,height))
|
|
|
|
|
filtered-cfg)))
|
|
|
|
|
;; These are parameters to apply after creating/setting the frame.
|
|
|
|
|
(push visible alt-cfg)
|
|
|
|
|
(push (cons 'fullscreen fullscreen) alt-cfg)))
|
|
|
|
|
|
|
|
|
|
;; Time to find or create a frame an apply the big bunch of parameters.
|
|
|
|
|
;; If a frame needs to be created and it falls partially or fully offscreen,
|
|
|
|
|
;; sometimes it gets "pushed back" onscreen; however, moving it afterwards is
|
|
|
|
|
;; allowed. So we create the frame as invisible and then reapply the full
|
|
|
|
|
;; parameter list (including position and size parameters).
|
|
|
|
|
(setq frame (or (and frameset--reuse-list
|
|
|
|
|
(frameset--reuse-frame display filtered-cfg))
|
|
|
|
|
(make-frame-on-display display
|
|
|
|
|
(cons '(visibility)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(frameset--initial-params filtered-cfg)))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(modify-frame-parameters frame
|
|
|
|
|
(if (eq (frame-parameter frame 'fullscreen) fullscreen)
|
|
|
|
|
;; Workaround for bug#14949
|
|
|
|
|
(assq-delete-all 'fullscreen filtered-cfg)
|
|
|
|
|
filtered-cfg))
|
|
|
|
|
|
|
|
|
|
;; If requested, force frames to be onscreen.
|
|
|
|
|
(when (and force-onscreen
|
|
|
|
|
;; FIXME: iconified frames should be checked too,
|
|
|
|
|
;; but it is impossible without deiconifying them.
|
|
|
|
|
(not (eq (frame-parameter frame 'visibility) 'icon)))
|
2013-08-06 01:26:29 +00:00
|
|
|
|
(frameset-move-onscreen frame force-onscreen))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
;; Let's give the finishing touches (visibility, tool-bar, maximization).
|
|
|
|
|
(when lines (push lines alt-cfg))
|
|
|
|
|
(when alt-cfg (modify-frame-parameters frame alt-cfg))
|
|
|
|
|
;; Now restore window state.
|
|
|
|
|
(window-state-put window-cfg (frame-root-window frame) 'safe)
|
|
|
|
|
frame))
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(defun frameset--minibufferless-last-p (state1 state2)
|
2013-08-06 01:26:29 +00:00
|
|
|
|
"Predicate to sort frame states in an order suitable for creating frames.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
It sorts minibuffer-owning frames before minibufferless ones."
|
|
|
|
|
(pcase-let ((`(,hasmini1 ,id-def1) (assq 'frameset--mini (car state1)))
|
|
|
|
|
(`(,hasmini2 ,id-def2) (assq 'frameset--mini (car state2))))
|
|
|
|
|
(cond ((eq id-def1 t) t)
|
|
|
|
|
((eq id-def2 t) nil)
|
|
|
|
|
((not (eq hasmini1 hasmini2)) (eq hasmini1 t))
|
|
|
|
|
((eq hasmini1 nil) (string< id-def1 id-def2))
|
|
|
|
|
(t t))))
|
|
|
|
|
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(defun frameset-keep-original-display-p (force-display)
|
|
|
|
|
"True if saved frames' displays should be honored."
|
|
|
|
|
(cond ((daemonp) t)
|
2013-08-06 01:26:29 +00:00
|
|
|
|
((eq system-type 'windows-nt) nil) ;; Does ns support more than one display?
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(t (not force-display))))
|
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(defun frameset-minibufferless-first-p (frame1 _frame2)
|
|
|
|
|
"Predicate to sort minibufferless frames before other frames."
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(not (frame-parameter frame1 'minibuffer)))
|
|
|
|
|
|
2013-08-04 00:58:32 +00:00
|
|
|
|
;;;###autoload
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(cl-defun frameset-restore (frameset
|
|
|
|
|
&key filters reuse-frames force-display force-onscreen)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
"Restore a FRAMESET into the current display(s).
|
|
|
|
|
|
2013-08-04 00:58:32 +00:00
|
|
|
|
FILTERS is an alist of parameter filters; defaults to `frameset-filter-alist'.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
2013-08-05 04:45:17 +00:00
|
|
|
|
REUSE-FRAMES selects the policy to use to reuse frames when restoring:
|
2013-08-04 22:12:18 +00:00
|
|
|
|
t Reuse any existing frame if possible; delete leftover frames.
|
|
|
|
|
nil Restore frameset in new frames and delete existing frames.
|
|
|
|
|
:keep Restore frameset in new frames and keep the existing ones.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
LIST A list of frames to reuse; only these are reused (if possible),
|
|
|
|
|
and any leftover ones are deleted; other frames not on this
|
|
|
|
|
list are left untouched.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
FORCE-DISPLAY can be:
|
2013-08-05 04:45:17 +00:00
|
|
|
|
t Frames are restored in the current display.
|
|
|
|
|
nil Frames are restored, if possible, in their original displays.
|
|
|
|
|
:delete Frames in other displays are deleted instead of restored.
|
|
|
|
|
PRED A function called with one argument, the parameter list;
|
|
|
|
|
it must return t, nil or `:delete', as above but affecting
|
2013-08-04 22:12:18 +00:00
|
|
|
|
only the frame that will be created from that parameter list.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
FORCE-ONSCREEN can be:
|
2013-08-04 22:12:18 +00:00
|
|
|
|
t Force onscreen only those frames that are fully offscreen.
|
|
|
|
|
nil Do not force any frame back onscreen.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
:all Force onscreen any frame fully or partially offscreen.
|
|
|
|
|
PRED A function called with three arguments,
|
2013-08-04 22:12:18 +00:00
|
|
|
|
- the live frame just restored,
|
|
|
|
|
- a list (LEFT TOP WIDTH HEIGHT), describing the frame,
|
2013-08-05 04:45:17 +00:00
|
|
|
|
- a list (LEFT TOP WIDTH HEIGHT), describing the workarea.
|
|
|
|
|
It must return non-nil to force the frame onscreen, nil otherwise.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
|
|
|
|
|
Note the timing and scope of the operations described above: REUSE-FRAMES
|
|
|
|
|
affects existing frames, FILTERS and FORCE-DISPLAY affect the frame being
|
|
|
|
|
restored before that happens, and FORCE-ONSCREEN affects the frame once
|
|
|
|
|
it has been restored.
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
All keywords default to nil."
|
|
|
|
|
|
|
|
|
|
(cl-assert (frameset-p frameset))
|
|
|
|
|
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(let (other-frames)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
|
|
|
|
|
;; frameset--reuse-list is a list of frames potentially reusable. Later we
|
|
|
|
|
;; will decide which ones can be reused, and how to deal with any leftover.
|
|
|
|
|
(pcase reuse-frames
|
2013-08-04 22:12:18 +00:00
|
|
|
|
((or `nil `:keep)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(setq frameset--reuse-list nil
|
|
|
|
|
other-frames (frame-list)))
|
|
|
|
|
((pred consp)
|
|
|
|
|
(setq frameset--reuse-list (copy-sequence reuse-frames)
|
|
|
|
|
other-frames (cl-delete-if (lambda (frame)
|
|
|
|
|
(memq frame frameset--reuse-list))
|
|
|
|
|
(frame-list))))
|
|
|
|
|
(_
|
|
|
|
|
(setq frameset--reuse-list (frame-list)
|
|
|
|
|
other-frames nil)))
|
|
|
|
|
|
|
|
|
|
;; Sort saved states to guarantee that minibufferless frames will be created
|
|
|
|
|
;; after the frames that contain their minibuffer windows.
|
|
|
|
|
(dolist (state (sort (copy-sequence (frameset-states frameset))
|
2013-08-05 04:45:17 +00:00
|
|
|
|
#'frameset--minibufferless-last-p))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(condition-case-unless-debug err
|
|
|
|
|
(pcase-let* ((`(,frame-cfg . ,window-cfg) state)
|
|
|
|
|
((and d-mini `(,hasmini . ,mb-id))
|
|
|
|
|
(cdr (assq 'frameset--mini frame-cfg)))
|
|
|
|
|
(default (and (booleanp mb-id) mb-id))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(force-display (if (functionp force-display)
|
|
|
|
|
(funcall force-display frame-cfg)
|
|
|
|
|
force-display))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(frame nil) (to-tty nil))
|
|
|
|
|
;; Only set target if forcing displays and the target display is different.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(cond ((frameset-keep-original-display-p force-display)
|
|
|
|
|
(setq frameset--target-display nil))
|
|
|
|
|
((eq (frame-parameter nil 'display) (cdr (assq 'display frame-cfg)))
|
|
|
|
|
(setq frameset--target-display nil))
|
|
|
|
|
(t
|
|
|
|
|
(setq frameset--target-display (cons 'display
|
|
|
|
|
(frame-parameter nil 'display))
|
|
|
|
|
to-tty (null (cdr frameset--target-display)))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; Time to restore frames and set up their minibuffers as they were.
|
|
|
|
|
;; We only skip a frame (thus deleting it) if either:
|
|
|
|
|
;; - we're switching displays, and the user chose the option to delete, or
|
|
|
|
|
;; - we're switching to tty, and the frame to restore is minibuffer-only.
|
|
|
|
|
(unless (and frameset--target-display
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(or (eq force-display :delete)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(and to-tty
|
|
|
|
|
(eq (cdr (assq 'minibuffer frame-cfg)) 'only))))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
;; If keeping non-reusable frames, and the frameset--id of one of them
|
|
|
|
|
;; matches the id of a frame being restored (because, for example, the
|
|
|
|
|
;; frameset has already been read in the same session), remove the
|
|
|
|
|
;; frameset--id from the non-reusable frame, which is not useful anymore.
|
|
|
|
|
(when (and other-frames
|
|
|
|
|
(or (eq reuse-frames :keep) (consp reuse-frames)))
|
2013-08-05 13:06:29 +00:00
|
|
|
|
(let ((dup (frameset-locate-frame-id (cdr (assq 'frameset--id frame-cfg))
|
|
|
|
|
other-frames)))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(when dup
|
|
|
|
|
(set-frame-parameter dup 'frameset--id nil))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
;; Restore minibuffers. Some of this stuff could be done in a filter
|
|
|
|
|
;; function, but it would be messy because restoring minibuffers affects
|
|
|
|
|
;; global state; it's best to do it here than add a bunch of global
|
|
|
|
|
;; variables to pass info back-and-forth to/from the filter function.
|
|
|
|
|
(cond
|
|
|
|
|
((null d-mini)) ;; No frameset--mini. Process as normal frame.
|
|
|
|
|
(to-tty) ;; Ignore minibuffer stuff and process as normal frame.
|
|
|
|
|
(hasmini ;; Frame has minibuffer (or it is minibuffer-only).
|
|
|
|
|
(when (eq (cdr (assq 'minibuffer frame-cfg)) 'only)
|
|
|
|
|
(setq frame-cfg (append '((tool-bar-lines . 0) (menu-bar-lines . 0))
|
|
|
|
|
frame-cfg))))
|
|
|
|
|
(t ;; Frame depends on other frame's minibuffer window.
|
2013-08-05 13:06:29 +00:00
|
|
|
|
(let* ((mb-frame (or (frameset-locate-frame-id mb-id)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(error "Minibuffer frame %S not found" mb-id)))
|
|
|
|
|
(mb-param (assq 'minibuffer frame-cfg))
|
|
|
|
|
(mb-window (minibuffer-window mb-frame)))
|
|
|
|
|
(unless (and (window-live-p mb-window)
|
|
|
|
|
(window-minibuffer-p mb-window))
|
|
|
|
|
(error "Not a minibuffer window %s" mb-window))
|
|
|
|
|
(if mb-param
|
|
|
|
|
(setcdr mb-param mb-window)
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(push (cons 'minibuffer mb-window) frame-cfg)))))
|
|
|
|
|
;; OK, we're ready at last to create (or reuse) a frame and
|
|
|
|
|
;; restore the window config.
|
2013-08-05 04:45:17 +00:00
|
|
|
|
(setq frame (frameset--restore-frame frame-cfg window-cfg
|
|
|
|
|
(or filters frameset-filter-alist)
|
|
|
|
|
force-onscreen))
|
2013-08-04 22:12:18 +00:00
|
|
|
|
;; Set default-minibuffer if required.
|
|
|
|
|
(when default (setq default-minibuffer-frame frame))))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(error
|
|
|
|
|
(delay-warning 'frameset (error-message-string err) :error))))
|
|
|
|
|
|
|
|
|
|
;; In case we try to delete the initial frame, we want to make sure that
|
|
|
|
|
;; other frames are already visible (discussed in thread for bug#14841).
|
|
|
|
|
(sit-for 0 t)
|
|
|
|
|
|
|
|
|
|
;; Delete remaining frames, but do not fail if some resist being deleted.
|
2013-08-04 22:12:18 +00:00
|
|
|
|
(unless (eq reuse-frames :keep)
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(dolist (frame (sort (nconc (if (listp reuse-frames) nil other-frames)
|
|
|
|
|
frameset--reuse-list)
|
2013-08-05 04:45:17 +00:00
|
|
|
|
;; Minibufferless frames must go first to avoid
|
|
|
|
|
;; errors when attempting to delete a frame whose
|
|
|
|
|
;; minibuffer window is used by another frame.
|
|
|
|
|
#'frameset-minibufferless-first-p))
|
lisp/desktop.el: Move code related to saving frames to frameset.el.
Require frameset.
(desktop-restore-frames): Doc fix.
(desktop-restore-reuses-frames): Rename from
desktop-restoring-reuses-frames.
(desktop-saved-frameset): Rename from desktop-saved-frame-states.
(desktop-clear): Clear frames too.
(desktop-filter-parameters-alist): Set from frameset-filter-alist.
(desktop--filter-tty*, desktop-save, desktop-read):
Use frameset functions.
(desktop-before-saving-frames-functions, desktop--filter-*-color)
(desktop--filter-minibuffer, desktop--filter-restore-desktop-parm)
(desktop--filter-save-desktop-parm, desktop--filter-iconified-position)
(desktop-restore-in-original-display-p, desktop--filter-frame-parms)
(desktop--process-minibuffer-frames, desktop-save-frames)
(desktop--reuse-list, desktop--compute-pos, desktop--move-onscreen)
(desktop--find-frame, desktop--select-frame, desktop--make-frame)
(desktop--sort-states, desktop-restoring-frames-p)
(desktop-restore-frames): Remove. Most code moved to frameset.el.
(desktop-restoring-frameset-p, desktop-restore-frameset)
(desktop--check-dont-save, desktop-save-frameset): New functions.
(desktop--app-id): New constant.
(desktop-first-buffer, desktop-buffer-ok-count)
(desktop-buffer-fail-count): Move before first use.
lisp/frameset.el: New file.
2013-08-02 04:33:58 +00:00
|
|
|
|
(condition-case err
|
|
|
|
|
(delete-frame frame)
|
|
|
|
|
(error
|
|
|
|
|
(delay-warning 'frameset (error-message-string err))))))
|
|
|
|
|
(setq frameset--reuse-list nil)
|
|
|
|
|
|
|
|
|
|
;; Make sure there's at least one visible frame.
|
|
|
|
|
(unless (or (daemonp) (visible-frame-list))
|
|
|
|
|
(make-frame-visible (car (frame-list))))))
|
|
|
|
|
|
|
|
|
|
(provide 'frameset)
|
|
|
|
|
|
|
|
|
|
;;; frameset.el ends here
|