1 ;;; riece-layout.el --- layout manager add-on
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
24 ;; This add-on allows you to switch window configurations by their names.
26 ;; To use, add the following line to your ~/.riece/init.el:
27 ;; (add-to-list 'riece-addons 'riece-layout)
31 (require 'riece-display)
33 (defgroup riece-layout nil
34 "Manage window layouts"
38 (defcustom riece-default-layout "default"
39 "The default layout name."
43 (defcustom riece-layout riece-default-layout
44 "Current layout setting."
48 (defcustom riece-layout-alist
49 '(("default" riece-configure-windows riece-configure-windows-predicate))
50 "An alist mapping the names to configure/predicate functions."
54 (defun riece-layout-option-set-function (symbol value)
55 "Function called when setting `riece-layout'."
56 (let ((layout (cdr (assoc value riece-layout-alist))))
58 (error "No such layout!"))
59 (setq riece-configure-windows-function (car layout)
60 riece-configure-windows-predicate (nth 1 layout))
61 (riece-redisplay-buffers t)))
63 (defun riece-command-change-layout (name)
64 "Select a layout-name from all current available layouts and change
65 the layout to the selected layout-name."
66 (interactive (list (completing-read "Layout: " riece-layout-alist)))
67 (customize-set-variable 'riece-layout name))
69 (defvar riece-dialogue-mode-map)
71 (defun riece-layout-insinuate ()
72 (define-key riece-dialogue-mode-map "\C-tl" #'riece-command-change-layout)
73 ;; Delay setting `riece-layout' using riece-layout-option-set-function.
74 (add-hook 'riece-startup-hook
76 (put 'riece-layout 'custom-set
77 'riece-layout-option-set-function)
78 (riece-layout-option-set-function 'riece-layout riece-layout))))
80 (provide 'riece-layout)
82 ;;; riece-layout.el ends here