[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e5f23d1 05/11: Only deal with window configurations now, u
From: |
Ingo Lohmar |
Subject: |
[elpa] master e5f23d1 05/11: Only deal with window configurations now, update doc |
Date: |
Sun, 02 Aug 2015 14:43:04 +0000 |
branch: master
commit e5f23d1a8286c5dd330f26e1b86d9ee30feced2e
Author: Ingo Lohmar <address@hidden>
Commit: Ingo Lohmar <address@hidden>
Only deal with window configurations now, update doc
---
README.org | 40 ++++++++++++++++++----------
wconf.el | 84 ++++++++++++++++++++++-------------------------------------
2 files changed, 57 insertions(+), 67 deletions(-)
diff --git a/README.org b/README.org
index ce43ec7..2a99752 100644
--- a/README.org
+++ b/README.org
@@ -1,6 +1,6 @@
* wconf
** About
-=wconf= is a minimal window/frame layout manager for
[[http://www.gnu.org/software/emacs/][GNU Emacs]]. Its
+=wconf= is a minimal window configuration manager for
[[http://www.gnu.org/software/emacs/][GNU Emacs]]. Its
goal is to have several window configurations easily available, to
switch between them, and to save them to disk and later restore them.
@@ -80,17 +80,29 @@ it did not provide a lot of benefit for my personal needs,
but added
still more complexity. The functionality that I want should not require
179k of elisp.
-Nowadays (at least since the GNU Emacs 24.4 release), there is a proper
-lisp-reader (de)serialization for frame and window configurations, and
-=frameset.el= provides functions to deal with them (relatively)
-comfortably. Desktop already (re)stores a single configuration. That's
-when I decided that it's time to roll my own: build something light on
-top of what's already there, in order to provide persistent switchable
-configurations.
+Nowadays (at least since the GNU Emacs 24.4 release), there are proper
+lisp-reader (de)serializations for both frame and window configurations,
+and =window.el= and =frameset.el= provide functions to deal with them
+(relatively) comfortably. Desktop already (re)stores a single
+configuration. That's when I decided that it's time to roll my own:
+build something light on top of what's already there, in order to
+provide persistent switchable configurations.
** Notes, TODO
-I only use a single fullscreen frame all the time. While =frameset=
-deals with all frames and =wconf= acknowledges that, there has been zero
-effort (so far) to have =wconf= do something reasonable in that case. I
-am open to suggestions/pull requests, if they do not substantially
-increase the complexity of the package. =workgroups= is clever in that
-respect, but it is unlikely that I will follow that way.
+I only use a single fullscreen frame all the time. An earlier version
+of this package stored configurations as whole framesets, without any
+effort to deal with the multiple-frames case. It has now changed to
+deal with window configurations in a single frame only. This is
+much better defined, simpler, and no longer suffers from annoying
+flickering effects.
+
+Calling the package commands from different frames inside a single
+session may or may not result in the behavior you want. In the latter
+case, feel free to open an issue and describe what happens and what you
+expected/wanted to happen. I explicitly do /not/ guarantee that the
+code will change to suit your wishes --- but if minor changes could
+render it more generally useful, I am all ears.
+
+I am thinking about some rescaling options to deal with restoring on
+frames of different sizes (possible due to a different screen size).
+Filtering options for what is generally (re)stored (and how) might be a
+pleasant side effect. Don't hold your breath.
diff --git a/wconf.el b/wconf.el
index 7012285..ce39cb1 100644
--- a/wconf.el
+++ b/wconf.el
@@ -1,4 +1,4 @@
-;;; wconf.el --- Minimal window/frame layout manager -*- lexical-binding: t;
-*-
+;;; wconf.el --- Minimal window layout manager -*- lexical-binding: t; -*-
;; Copyright (C) 2014 Free Software Foundation, Inc.
@@ -29,8 +29,6 @@
;;; Code:
-(require 'frameset)
-
(defgroup wconf nil
"Easily use several window configurations."
:group 'convenience)
@@ -55,10 +53,10 @@
"String to use for the empty window configuration."
:group 'wconf)
-
+;; internal variables and helper functions
(defvar wc--configs nil
- "List of configurations; each item a cons (active . stored).")
+ "List of configurations; each item a list (active stored name).")
(defvar wc--index nil
"Index of currently shown configuration. After clean and load
@@ -71,10 +69,9 @@ this can be nil although wc--configs is not empty.")
(unless wc--configs
(error "No window configurations")))
-(defun wc--current-config (&optional name)
- (frameset-save nil
- :app 'wconf
- :name name))
+(defun wc--current-config ()
+ (window-state-get (frame-root-window (selected-frame))
+ 'writable))
(defun wc- (index)
(nth index wc--configs))
@@ -83,7 +80,7 @@ this can be nil although wc--configs is not empty.")
(if index
(format "%s:%s"
(number-to-string index)
- (frameset-name (car (wc- index))))
+ (caddr (wc- index)))
(concat "-:" wc-no-config-name)))
(defun wc--update-info ()
@@ -94,34 +91,15 @@ this can be nil although wc--configs is not empty.")
(and wc--index
(car (wc- wc--index))))))
-(defun wc--wrapped-config (new wc)
- "Returns configuration NEW, with metadata replaced by that of WC."
- (let ((name (frameset-name wc))
- (app (frameset-app wc)))
- (setf (frameset-name new) name
- (frameset-app new) app)
- new))
-
(defun wc--update-active-config ()
(when wc--index
- (let ((ac (car (wc- wc--index))))
- (setf (car (wc- wc--index)) ;not local var..
- (wc--wrapped-config (wc--current-config) ac)))))
-
-(defvar wc--filter-alist
- (append
- (mapcar (lambda (s) (cons s :save))
- '(foreground-color background-color background-mode
- border-color cursor-color mouse-color))
- (copy-tree frameset-filter-alist))
- "Standard filters, plus: avoid restoring colors and color mode.")
+ (setf (car (wc- wc--index)) (wc--current-config))))
(defun wc--use-config (index)
(setq wc--index index)
- (frameset-restore (car (wc- wc--index))
- :reuse-frames t ;can reuse all
- :cleanup-frames t ;delete unaffected frames
- :filters wc--filter-alist) ;instead of
frameset-filter-alist
+ (window-state-put (car (wc- wc--index))
+ (frame-root-window (selected-frame))
+ 'safe)
(wc--update-info))
(defun wc--reset ()
@@ -130,6 +108,10 @@ this can be nil although wc--configs is not empty.")
(setq wc--index nil)
(wc--update-info))
+(defun wc--copy (wc)
+ "Return a deep copy of WC, using `copy-tree'."
+ (copy-tree wc t))
+
;; global stuff
(defun wc-change-config-default (index config)
@@ -145,7 +127,7 @@ position INDEX."
(interactive)
(let ((filename (or filename wc-file)))
(with-temp-file filename
- (prin1 (mapcar #'cdr wc--configs)
+ (prin1 (mapcar #'cdr wc--configs) ;-> (wc name)
(current-buffer)))
(message "wc: Save stored configurations in %s" filename)))
@@ -166,12 +148,6 @@ position INDEX."
(wc--sanitize-window-tree (cdr x))))
node))))
-(defun wc--sanitize-frameset (f)
- (mapc (lambda (x)
- ;; for each frame, only work on window tree
- (wc--sanitize-window-tree (cddr x)))
- (frameset-states f)))
-
;;;###autoload
(defun wc-load (&optional filename)
"Load stored configurations from FILENAME, defaults to `wc-file'."
@@ -185,9 +161,9 @@ position INDEX."
(goto-char (point-min))
(setq wc--configs
(mapcar
- (lambda (f)
- (wc--sanitize-frameset f)
- (cons f (frameset-copy f)))
+ (lambda (f) ;(wc name)
+ (wc--sanitize-window-tree (car f))
+ (cons (wc--copy (car f)) f))
(read (current-buffer)))))
(message "wc: Load stored configurations from %s" filename))
(wc--update-info))
@@ -207,13 +183,15 @@ one. The new configuration is appended to the list and
becomes active."
(progn
(message "wc: Created new configuration %s"
(length wc--configs))
- (cons (wc--current-config "new")
- (wc--current-config "new")))
+ (list (wc--current-config)
+ (wc--current-config)
+ "new"))
(let ((wc (wc- wc--index)))
(message "wc: Cloned configuration %s"
(wc--to-string wc--index))
- (cons (frameset-copy (car wc))
- (frameset-copy (cdr wc))))))))
+ (list (wc--copy (car wc))
+ (wc--copy (cadr wc))
+ (caddr wc)))))))
(wc--use-config (1- (length wc--configs))))
(defun wc-kill ()
@@ -252,7 +230,7 @@ one. The new configuration is appended to the list and
becomes active."
(when wc--index
(wc--update-active-config)
(let ((wc (wc- wc--index)))
- (setf (cdr wc) (frameset-copy (car wc)))))
+ (setf (cadr wc) (wc--copy (car wc)))))
(message "wc: Stored configuration %s" (wc--to-string wc--index)))
(defun wc-store-all ()
@@ -260,7 +238,7 @@ one. The new configuration is appended to the list and
becomes active."
(interactive)
(wc--update-active-config)
(mapc (lambda (wc)
- (setf (cdr wc) (frameset-copy (car wc))))
+ (setf (cadr wc) (wc--copy (car wc))))
wc--configs)
(message "wc: Stored all configurations"))
@@ -269,7 +247,7 @@ one. The new configuration is appended to the list and
becomes active."
(interactive)
(when wc--index
(let ((wc (wc- wc--index)))
- (setf (car wc) (frameset-copy (cdr wc))))
+ (setf (car wc) (wc--copy (cadr wc))))
(wc--use-config wc--index))
(message "wc: Restored configuration %s" (wc--to-string wc--index)))
@@ -277,7 +255,7 @@ one. The new configuration is appended to the list and
becomes active."
"Restore all stored configurations."
(interactive)
(mapc (lambda (wc)
- (setf (car wc) (frameset-copy (cdr wc))))
+ (setf (car wc) (wc--copy (cadr wc))))
wc--configs)
(when wc--index
(wc--use-config wc--index))
@@ -290,8 +268,8 @@ one. The new configuration is appended to the list and
becomes active."
(interactive
(list
(read-string "New window configuration name: "
- (frameset-name (car (wc- wc--index))))))
- (setf (frameset-name (car (wc- wc--index))) name)
+ (caddr (wc- wc--index)))))
+ (setf (caddr (wc- wc--index)) name)
(message "wc: Renamed configuration to %s" name)
(wc--update-info))
- [elpa] master updated (6340c15 -> 43c8384), Ingo Lohmar, 2015/08/02
- [elpa] master 5f9ee38 04/11: Check file can be read, Ingo Lohmar, 2015/08/02
- [elpa] master dcce243 03/11: Update README and docstring, Ingo Lohmar, 2015/08/02
- [elpa] master 3bc4e13 02/11: Add a README, Ingo Lohmar, 2015/08/02
- [elpa] master facc191 01/11: Initial commit, Ingo Lohmar, 2015/08/02
- [elpa] master 8f3160b 07/11: Fix missing dependency on cl-lib, Ingo Lohmar, 2015/08/02
- [elpa] master 2cb1de6 06/11: Fix/enhance interactive declarations, this fixes #1, Ingo Lohmar, 2015/08/02
- [elpa] master e5f23d1 05/11: Only deal with window configurations now, update doc,
Ingo Lohmar <=
- [elpa] master b8ea22f 10/11: Bump version and copyright, Ingo Lohmar, 2015/08/02
- [elpa] master ae106c9 08/11: Make interactive functions more robust/friendly, Ingo Lohmar, 2015/08/02
- [elpa] master f67e959 09/11: Use "wconf" as package and filename prefix, Ingo Lohmar, 2015/08/02
- [elpa] master 43c8384 11/11: Add 'packages/wconf/' from commit 'b8ea22f80bff19222136d9495f685888dc682b9d', Ingo Lohmar, 2015/08/02