1 ;;; xwem-modes.el --- Minor modes support for XWEM.
3 ;; Copyright (C) 2004,2005 by XWEM Org.
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Created: Mon Oct 18 22:36:23 MSD 2004
8 ;; X-CVS: $Id: xwem-modes.el,v 1.4 2005-04-04 19:54:14 lg Exp $
10 ;; This file is part of XWEM.
12 ;; XWEM is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XWEM is distributed in the hope that it will be useful, but WITHOUT
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 ;; License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 ;;; Synched up with: Not in FSF
38 (defvar xwem-minor-mode-alist nil
39 "Alist saying how to show minor modes.
40 Each element is a list which looks like (VAR STRING).
41 STRING is shown when VAR is non-nil.")
44 (defvar xwem-minor-mode-map-alist nil
45 "Alist of keymaps for use of minor modes.
46 Each element looks like (VAR . KEYMAP).")
48 ;;;###xwem-autoload(autoload 'xwem-add-minor-mode "xwem-modes")
49 (defun xwem-add-minor-mode (toggle name &optional keymap)
50 "Add a minor mode to `xwem-minor-mode-alist'.
51 For TOGGLE, NAME, KEYMAP, usage take a look at `add-minor-mode'."
52 (setq xwem-minor-mode-alist
53 (put-alist toggle (list name) xwem-minor-mode-alist))
56 (setq xwem-minor-mode-map-alist
57 (put-alist toggle keymap xwem-minor-mode-map-alist))))
60 (defun xwem-turn-on-minor-mode (cl mm-toggle)
61 "On CL, turn on minor mode MM-TOGGLE."
62 (unless (if (xwem-client-local-variable-p mm-toggle)
63 (xwem-client-local-variable-value cl mm-toggle)
64 (symbol-value mm-toggle))
65 (let* ((km-sym (cdr (assq mm-toggle xwem-minor-mode-map-alist)))
66 (kmap (if (xwem-client-local-variable-p km-sym)
67 (xwem-client-local-variable-value cl km-sym)
68 (symbol-value km-sym))))
70 (xwem-kbd-install-grab kmap (xwem-cl-xwin cl))))
72 (if (xwem-client-local-variable-p mm-toggle)
73 (xwem-client-local-variable-set cl mm-toggle t)
74 (set-variable mm-toggle t))))
77 (defun xwem-turn-off-minor-mode (cl mm-toggle)
78 "On CL, turn off minor mode MM-TOGGLE."
79 (when (if (xwem-client-local-variable-p mm-toggle)
80 (xwem-client-local-variable-value cl mm-toggle)
81 (symbol-value mm-toggle))
82 (let* ((km-sym (cdr (assq mm-toggle xwem-minor-mode-map-alist)))
83 (kmap (if (xwem-client-local-variable-p km-sym)
84 (xwem-client-local-variable-value cl km-sym)
85 (symbol-value km-sym))))
87 (xwem-kbd-uninstall-grab kmap (xwem-cl-xwin cl))))
88 (if (xwem-client-local-variable-p mm-toggle)
89 (xwem-client-local-variable-set cl mm-toggle nil)
90 (set-variable mm-toggle nil))))
95 ;;; xwem-modes.el ends here