[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f67e959 09/11: Use "wconf" as package and filename prefix
From: |
Ingo Lohmar |
Subject: |
[elpa] master f67e959 09/11: Use "wconf" as package and filename prefix |
Date: |
Sun, 02 Aug 2015 14:43:05 +0000 |
branch: master
commit f67e959a45395110a90d51b397340e4b132a66db
Author: Ingo Lohmar <address@hidden>
Commit: Ingo Lohmar <address@hidden>
Use "wconf" as package and filename prefix
- update docs
- update (error) messages
---
README.org | 40 ++++----
wconf.el | 324 +++++++++++++++++++++++++++++++-----------------------------
2 files changed, 186 insertions(+), 178 deletions(-)
diff --git a/README.org b/README.org
index 2a99752..a13d508 100644
--- a/README.org
+++ b/README.org
@@ -20,27 +20,27 @@ Here is an example from my configuration to show you the
intended use of
#+begin_src emacs-lisp
(add-hook 'desktop-after-read-hook ;so we have all buffers again
(lambda ()
- (wc-load)
- (wc-switch-to-config 0)
+ (wconf-load)
+ (wconf-switch-to-config 0)
(add-hook 'kill-emacs-hook
(lambda ()
- (wc-store-all)
- (wc-save))))
+ (wconf-store-all)
+ (wconf-save))))
'append)
-(global-set-key (kbd "C-c w s") #'wc-store)
-(global-set-key (kbd "C-c w S") #'wc-store-all)
-(global-set-key (kbd "C-c w r") #'wc-restore)
-(global-set-key (kbd "C-c w R") #'wc-restore-all)
-(global-set-key (kbd "C-c w w") #'wc-switch-to-config)
-(global-set-key (kbd "C-<prior>") #'wc-use-previous)
-(global-set-key (kbd "C-<next>") #'wc-use-next)
+(global-set-key (kbd "C-c w s") #'wconf-store)
+(global-set-key (kbd "C-c w S") #'wconf-store-all)
+(global-set-key (kbd "C-c w r") #'wconf-restore)
+(global-set-key (kbd "C-c w R") #'wconf-restore-all)
+(global-set-key (kbd "C-c w w") #'wconf-switch-to-config)
+(global-set-key (kbd "C-<prior>") #'wconf-use-previous)
+(global-set-key (kbd "C-<next>") #'wconf-use-next)
#+end_src
After =desktop= has restored all file buffers from my last session,
-=wc-load= will get its stored configs from =wc-file= (defaults to
-=<YOUREMACSDIR>/window-configs.el=), and I want it to immediately switch
-to the first configuration. Then we hook into killing emacs to store
-and save all our configurations in that same file. The global key
+=wconf-load= will get its stored configs from =wconf-file= (defaults to
+=<YOUREMACSDIR>/wconf-window-configs.el=), and I want it to immediately
+switch to the first configuration. Then we hook into killing emacs to
+store and save all our configurations in that same file. The global key
bindings expose those commands that I consider useful in day-to-day
work.
** Concepts
@@ -57,7 +57,7 @@ the stored one, or do likewise for all configurations. For
example, you
might decide that you have a carefully hand-crafted set of
configurations that you always want to start from, but that you do not
wish to change this setup, except when doing so explicitly. That's
-easy: just remove the =(wc-store-all)= call from the above hook
+easy: just remove the =(wconf-store-all)= call from the above hook
function.
A nice feature of =wconf= is that it does not alter any hooks or
@@ -70,7 +70,7 @@ great package, which offers a lot of additional features
besides the
core business of managing window configs. It also has some
shortcomings, is somewhat complex (at 79k), and I occasionally
experienced minor glitches. Most importantly, it has been unmaintained
-for >3yrs now.
+for roughly 4 years now.
https://github.com/pashinin/workgroups2 promises to pick up where
workgroups left, and is actively maintained. The main difference, as I
@@ -91,9 +91,9 @@ provide persistent switchable configurations.
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.
+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
diff --git a/wconf.el b/wconf.el
index 5634f60..eb5f14b 100644
--- a/wconf.el
+++ b/wconf.el
@@ -33,303 +33,311 @@
"Easily use several window configurations."
:group 'convenience)
-(defcustom wc-change-config-function #'wc-change-config-default
+(defcustom wconf-change-config-function #'wconf-change-config-default
"Function called with current config whenever it is set."
:group 'wconf)
-(defcustom wc-file (expand-file-name "window-configs.el" user-emacs-directory)
+(defcustom wconf-file (expand-file-name "wconf-window-configs.el"
+ user-emacs-directory)
"File used to save and load window configurations."
:group 'wconf)
-(defcustom wc-fallback-buffer-name "*scratch*"
+(defcustom wconf-fallback-buffer-name "*scratch*"
"Name of the buffer to substitute for buffers which are not available."
:group 'wconf)
-(defcustom wc-no-configs-string "-----"
+(defcustom wconf-no-configs-string "-----"
"String to use if there are no configurations at all."
:group 'wconf)
-(defcustom wc-no-config-name "---"
+(defcustom wconf-no-config-name "---"
"String to use for the empty window configuration."
:group 'wconf)
;; internal variables and helper functions
-(defvar wc--configs nil
+(defvar wconf--configs nil
"List of configurations; each item a list (active stored name).")
-(defvar wc--index nil
+(defvar wconf--index nil
"Index of currently shown configuration. After clean and load
-this can be nil although wc--configs is not empty.")
+this can be nil although wconf--configs is not empty.")
-(defvar wc-string nil
+(defvar wconf-string nil
"String representing information on the current configuration.")
(require 'cl-lib)
-(defsubst wc--ensure-configs (&optional current)
- (unless wc--configs
- (error "wc: No window configurations"))
- (when (and current (not wc--index))
- (error "wc: No window configuration is currently used")))
+(defsubst wconf--ensure-configs (&optional current)
+ (unless wconf--configs
+ (error "wconf: No window configurations"))
+ (when (and current (not wconf--index))
+ (error "wconf: No window configuration is currently used")))
-(defsubst wc--ensure-index (&optional index)
- (unless (<= 0 index (1- (length wc--configs)))
- (error "wc: No window configuration index %s" index)))
+(defsubst wconf--ensure-index (&optional index)
+ (unless (<= 0 index (1- (length wconf--configs)))
+ (error "wconf: No window configuration index %s" index)))
-(defun wc--current-config ()
+(defun wconf--current-config ()
(window-state-get (frame-root-window (selected-frame))
'writable))
-(defun wc- (index)
- (nth index wc--configs))
+(defun wconf- (index)
+ (nth index wconf--configs))
-(defun wc--to-string (index)
+(defun wconf--to-string (index)
(if index
(format "%s:%s"
(number-to-string index)
- (cl-caddr (wc- index)))
- (concat "-:" wc-no-config-name)))
+ (cl-caddr (wconf- index)))
+ (concat "-:" wconf-no-config-name)))
-(defun wc--update-info ()
- (when (functionp wc-change-config-function)
- (funcall wc-change-config-function
+(defun wconf--update-info ()
+ (when (functionp wconf-change-config-function)
+ (funcall wconf-change-config-function
;; both will be nil if no list
- wc--index
- (and wc--index
- (car (wc- wc--index))))))
+ wconf--index
+ (and wconf--index
+ (car (wconf- wconf--index))))))
-(defun wc--update-active-config ()
- (when wc--index
- (setf (car (wc- wc--index)) (wc--current-config))))
+(defun wconf--update-active-config ()
+ (when wconf--index
+ (setf (car (wconf- wconf--index)) (wconf--current-config))))
-(defun wc--use-config (index)
- (setq wc--index index)
- (window-state-put (car (wc- wc--index))
+(defun wconf--use-config (index)
+ (setq wconf--index index)
+ (window-state-put (car (wconf- wconf--index))
(frame-root-window (selected-frame))
'safe)
- (wc--update-info))
+ (wconf--update-info))
-(defun wc--reset ()
+(defun wconf--reset ()
"Remove all configurations."
- (setq wc--configs nil)
- (setq wc--index nil)
- (wc--update-info))
+ (setq wconf--configs nil)
+ (setq wconf--index nil)
+ (wconf--update-info))
-(defun wc--copy (wc)
+(defun wconf--copy (wc)
"Return a deep copy of WC, using `copy-tree'."
(copy-tree wc t))
;; global stuff
-(defun wc-change-config-default (index config)
- "Update `wc-string' to represent configuration CONFIG at
+(defun wconf-change-config-default (index config)
+ "Update `wconf-string' to represent configuration CONFIG at
position INDEX."
- (setq wc-string (if wc--configs
- (wc--to-string index)
- wc-no-configs-string))
+ (setq wconf-string (if wconf--configs
+ (wconf--to-string index)
+ wconf-no-configs-string))
(force-mode-line-update))
-(defun wc-save (&optional filename)
- "Save stored configurations in FILENAME, defaults to `wc-file'."
+(defun wconf-save (&optional filename)
+ "Save stored configurations in FILENAME, defaults to
+`wconf-file'."
(interactive "F")
- (let ((filename (or filename wc-file)))
+ (let ((filename (or filename wconf-file)))
(with-temp-file filename
- (prin1 (mapcar #'cdr wc--configs) ;-> (wc name)
+ (prin1 (mapcar #'cdr wconf--configs) ;-> (wc name)
(current-buffer)))
- (message "wc: Save stored configurations in %s" filename)))
+ (message "wconf: Save stored configurations in %s" filename)))
-(defun wc--sanitize-buffer (b)
+(defun wconf--sanitize-buffer (b)
(unless (get-buffer (cadr b))
- (setf (cadr b) wc-fallback-buffer-name
+ (setf (cadr b) wconf-fallback-buffer-name
(cdr (assoc 'start b)) 1
(cdr (assoc 'point b)) 1
(cdr (assoc 'dedicated b)) nil)))
-(defun wc--sanitize-window-tree (node)
+(defun wconf--sanitize-window-tree (node)
(let ((buf (assoc 'buffer node)))
(if buf ;in a leaf already
- (wc--sanitize-buffer buf)
+ (wconf--sanitize-buffer buf)
(mapc (lambda (x)
(when (and (consp x)
(memq (car x) '(leaf vc hc)))
- (wc--sanitize-window-tree (cdr x))))
+ (wconf--sanitize-window-tree (cdr x))))
node))))
;;;###autoload
-(defun wc-load (&optional filename)
- "Load stored configurations from FILENAME, defaults to `wc-file'."
+(defun wconf-load (&optional filename)
+ "Load stored configurations from FILENAME, defaults to
+`wconf-file'."
(interactive "f")
- (let ((filename (or filename wc-file)))
+ (let ((filename (or filename wconf-file)))
(unless (file-readable-p filename)
- (error "wc: Cannot read file %s" filename))
- (wc--reset)
+ (error "wconf: Cannot read file %s" filename))
+ (wconf--reset)
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
- (setq wc--configs
+ (setq wconf--configs
(mapcar
(lambda (f) ;(wc name)
- (wc--sanitize-window-tree (car f))
- (cons (wc--copy (car f)) f))
+ (wconf--sanitize-window-tree (car f))
+ (cons (wconf--copy (car f)) f))
(read (current-buffer)))))
- (message "wc: Load stored configurations from %s" filename))
- (wc--update-info))
+ (message "wconf: Load stored configurations from %s" filename))
+ (wconf--update-info))
;; these functions affect the whole list of configs
;;;###autoload
-(defun wc-create (&optional new)
- "Clone the current configuration or create a new \"empty\"
-one. The new configuration is appended to the list and becomes active.
+(defun wconf-create (&optional new)
+ "Clone the current configuration or create a new \"empty\" one.
+The new configuration is appended to the list and becomes active.
With optional prefix argument NEW, or if there are no
configurations yet, create a new configuration from the current
window config."
(interactive "P")
- (wc--update-active-config)
- (setq wc--configs
- (append wc--configs
+ (wconf--update-active-config)
+ (setq wconf--configs
+ (append wconf--configs
(list
- (if (or new (not wc--configs))
+ (if (or new (not wconf--configs))
(progn
- (message "wc: Created new configuration %s"
- (length wc--configs))
- (list (wc--current-config)
- (wc--current-config)
+ (message "wconf: Created new configuration %s"
+ (length wconf--configs))
+ (list (wconf--current-config)
+ (wconf--current-config)
"new"))
- (wc--ensure-configs 'current)
- (let ((wc (wc- wc--index)))
- (message "wc: Cloned configuration %s"
- (wc--to-string wc--index))
- (list (wc--copy (car wc))
- (wc--copy (cadr wc))
+ (wconf--ensure-configs 'current)
+ (let ((wc (wconf- wconf--index)))
+ (message "wconf: Cloned configuration %s"
+ (wconf--to-string wconf--index))
+ (list (wconf--copy (car wc))
+ (wconf--copy (cadr wc))
(cl-caddr wc)))))))
- (wc--use-config (1- (length wc--configs))))
+ (wconf--use-config (1- (length wconf--configs))))
-(defun wc-kill ()
+(defun wconf-kill ()
"Kill current configuration."
(interactive)
- (wc--ensure-configs 'current)
- (let ((old-string (wc--to-string wc--index)))
- (setq wc--configs
- (append (butlast wc--configs (- (length wc--configs) wc--index))
- (last wc--configs (- (length wc--configs) wc--index 1))))
- (if wc--configs
- (wc--use-config (if (< (1- (length wc--configs)) wc--index)
- (1- wc--index)
- wc--index))
- (wc--reset)
- (wc--update-info))
- (message "wc: Killed configuration %s" old-string)))
-
-(defun wc-swap (i j)
+ (wconf--ensure-configs 'current)
+ (let ((old-string (wconf--to-string wconf--index)))
+ (setq wconf--configs
+ (append (butlast wconf--configs
+ (- (length wconf--configs) wconf--index))
+ (last wconf--configs
+ (- (length wconf--configs) wconf--index 1))))
+ (if wconf--configs
+ (wconf--use-config (if (< (1- (length wconf--configs)) wconf--index)
+ (1- wconf--index)
+ wconf--index))
+ (wconf--reset)
+ (wconf--update-info))
+ (message "wconf: Killed configuration %s" old-string)))
+
+(defun wconf-swap (i j)
"Swap configurations at positions I and J."
(interactive
(progn
- (wc--ensure-configs 'current) ;for interactive, we want current
config
+ (wconf--ensure-configs 'current) ;interactive? then want current config
(list
- wc--index
+ wconf--index
(read-number "Swap current config with index: "))))
- (wc--ensure-configs)
- (wc--ensure-index i)
- (wc--ensure-index j)
- (wc--update-active-config)
- (let ((wc (wc- i)))
- (setf (nth i wc--configs) (wc- j))
- (setf (nth j wc--configs) wc))
- (when (memq wc--index (list i j))
- (wc--use-config wc--index))
- (message "wc: Swapped configurations %s and %s"
+ (wconf--ensure-configs)
+ (wconf--ensure-index i)
+ (wconf--ensure-index j)
+ (wconf--update-active-config)
+ (let ((wc (wconf- i)))
+ (setf (nth i wconf--configs) (wconf- j))
+ (setf (nth j wconf--configs) wc))
+ (when (memq wconf--index (list i j))
+ (wconf--use-config wconf--index))
+ (message "wconf: Swapped configurations %s and %s"
(number-to-string i) (number-to-string j)))
;; manipulate single config
-(defun wc-rename (name)
+(defun wconf-rename (name)
"Rename current configuration to NAME."
(interactive
(progn
- (wc--ensure-configs 'current)
+ (wconf--ensure-configs 'current)
(list
(read-string "New window configuration name: "
- (cl-caddr (wc- wc--index))))))
- (wc--ensure-configs 'current)
- (setf (cl-caddr (wc- wc--index)) name)
- (message "wc: Renamed configuration to \"%s\"" name)
- (wc--update-info))
+ (cl-caddr (wconf- wconf--index))))))
+ (wconf--ensure-configs 'current)
+ (setf (cl-caddr (wconf- wconf--index)) name)
+ (message "wconf: Renamed configuration to \"%s\"" name)
+ (wconf--update-info))
;; interaction b/w stored and active configs
-;; these commands only make sense when there are wc--configs, and after
-;; wc--index has become non-nil
+;; these commands only make sense when there are wconf--configs, and
+;; after wconf--index has become non-nil
-(defsubst wc--store (wc)
- (setf (cadr wc) (wc--copy (car wc))))
+(defsubst wconf--store (wc)
+ (setf (cadr wc) (wconf--copy (car wc))))
-(defsubst wc--restore (wc)
- (setf (car wc) (wc--copy (cadr wc))))
+(defsubst wconf--restore (wc)
+ (setf (car wc) (wconf--copy (cadr wc))))
-(defun wc-store ()
+(defun wconf-store ()
"Store currently active configuration."
(interactive)
- (wc--ensure-configs 'current)
- (wc--update-active-config)
- (wc--store (wc- wc--index))
- (message "wc: Stored configuration %s" (wc--to-string wc--index)))
+ (wconf--ensure-configs 'current)
+ (wconf--update-active-config)
+ (wconf--store (wconf- wconf--index))
+ (message "wconf: Stored configuration %s" (wconf--to-string wconf--index)))
-(defun wc-store-all ()
+(defun wconf-store-all ()
"Store all active configurations."
(interactive)
- (wc--ensure-configs 'current)
- (wc--update-active-config)
- (mapc #'wc--store wc--configs)
- (message "wc: Stored all configurations"))
+ (wconf--ensure-configs 'current)
+ (wconf--update-active-config)
+ (mapc #'wconf--store wconf--configs)
+ (message "wconf: Stored all configurations"))
-(defun wc-restore ()
+(defun wconf-restore ()
"Restore stored configuration."
(interactive)
- (wc--ensure-configs 'current)
- (wc--restore (wc- wc--index))
- (wc--use-config wc--index)
- (message "wc: Restored configuration %s" (wc--to-string wc--index)))
+ (wconf--ensure-configs 'current)
+ (wconf--restore (wconf- wconf--index))
+ (wconf--use-config wconf--index)
+ (message "wconf: Restored configuration %s" (wconf--to-string wconf--index)))
-(defun wc-restore-all ()
+(defun wconf-restore-all ()
"Restore all stored configurations."
(interactive)
- (wc--ensure-configs 'current)
- (mapc #'wc--restore wc--configs)
- (wc--use-config wc--index)
- (message "wc: Restored all configurations"))
+ (wconf--ensure-configs 'current)
+ (mapc #'wconf--restore wconf--configs)
+ (wconf--use-config wconf--index)
+ (message "wconf: Restored all configurations"))
;; change config
-(defun wc-switch-to-config (index &optional force)
+(defun wconf-switch-to-config (index &optional force)
"Change to current config INDEX."
(interactive "P")
- (wc--ensure-configs)
+ (wconf--ensure-configs)
(let ((index (or index
(read-number "Switch to config number: "))))
- (wc--ensure-index index)
+ (wconf--ensure-index index)
;; remember active config (w/o name etc)
- (wc--update-active-config)
+ (wconf--update-active-config)
;; maybe use new configuration
- (if (and (eq wc--index index)
+ (if (and (eq wconf--index index)
(not force))
- (message "wc: Nothing to do")
- (wc--use-config index)
- (message "wc: Switched to configuration %s" (wc--to-string index)))))
+ (message "wconf: Nothing to do")
+ (wconf--use-config index)
+ (message "wconf: Switched to configuration %s"
+ (wconf--to-string index)))))
-(defun wc-use-previous ()
+(defun wconf-use-previous ()
"Switch to previous window configuration."
(interactive)
- (wc--ensure-configs)
- (wc-switch-to-config (mod (1- (or wc--index 1)) (length wc--configs))))
+ (wconf--ensure-configs)
+ (wconf-switch-to-config (mod (1- (or wconf--index 1))
+ (length wconf--configs))))
-(defun wc-use-next ()
+(defun wconf-use-next ()
"Switch to next window configuration."
(interactive)
- (wc--ensure-configs)
- (wc-switch-to-config (mod (1+ (or wc--index -1)) (length wc--configs))))
+ (wconf--ensure-configs)
+ (wconf-switch-to-config (mod (1+ (or wconf--index -1))
+ (length wconf--configs))))
(provide 'wconf)
;;; wconf.el ends here
- [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, 2015/08/02
- [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 <=
- [elpa] master 43c8384 11/11: Add 'packages/wconf/' from commit 'b8ea22f80bff19222136d9495f685888dc682b9d', Ingo Lohmar, 2015/08/02