FG42/src/lib/modes.el

135 lines
4.3 KiB
EmacsLisp
Raw Normal View History

2011-01-03 05:51:37 +00:00
;; Kuso - My personal emacs IDE
2011-01-02 09:46:04 +00:00
;; Copyright (C) 2010 Sameer Rahmani <lxsameer@gnu.org>
;;
;; This program 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
;; any later version.
;;
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
2011-01-03 05:51:37 +00:00
;; This file will define the most popular modes for KusoIDE
2011-01-02 09:46:04 +00:00
2011-01-02 13:39:49 +00:00
;; ---------------------------------------------------------------------
;; Hooks
;; ---------------------------------------------------------------------
2011-01-03 05:51:37 +00:00
(defvar kuso-preinit-mode-hook '()
"This hook runs before initializing the 'kuso-mode' minor mode."
2011-01-02 13:39:49 +00:00
)
2011-01-03 05:51:37 +00:00
(defvar kuso-postinit-mode-hook '()
"This hook runs after 'kuso-mode' minor mode initialized."
2011-01-02 13:39:49 +00:00
)
2011-01-03 05:51:37 +00:00
(defvar kuso-prerm-mode-hook '()
"This hook runs before deactivating 'kuso-mode' minor mode."
2011-01-02 13:39:49 +00:00
)
2011-01-03 05:51:37 +00:00
(defvar kuso-postrm-mode-hook '()
"This hook runs after 'kuso-mode' minor mode deactivated."
2011-01-02 13:39:49 +00:00
)
2011-01-03 13:20:22 +00:00
(defvar kuso-plugin-preinit-hook '()
"This hook runs before initializing the plugins of Kuso IDE"
)
(defvar kuso-plugin-init-hook '()
"This hook allow plugins to initialize them self in Kuso IDE."
)
(defvar kuso-plugin-postinit-hook '()
"This hook runs after initializing the plugins of Kuso IDE"
)
2011-01-02 09:46:04 +00:00
;; ---------------------------------------------------------------------
;; Keymaps
;; ---------------------------------------------------------------------
2011-01-03 05:51:37 +00:00
(defvar kuso-map (make-sparse-keymap)
"Default keymap for kuso-mode minor mode that hold the global key
binding for Kuso IDE. each language plugin will have their own minor-mode
2011-01-02 13:53:57 +00:00
and keymap for their actions."
)
2011-01-02 09:46:04 +00:00
(defvar kuso-prefix-map (make-sparse-keymap)
"Make s-c as the default prefix for Kuso IDE minor mode.
By this prefix all the plugins that have small amount of keybindings
can define their key bindings easily."
)
2011-01-02 09:46:04 +00:00
;; ---------------------------------------------------------------------
;; Groups
;; ---------------------------------------------------------------------
2011-01-03 07:58:02 +00:00
(defgroup kuso-ide nil
"Default values for KusoIDE configuration will are categorized here."
:group 'emacs
)
2011-01-02 09:46:04 +00:00
2011-01-03 05:51:37 +00:00
(defgroup kuso-features nil
"This group contains all the optional components of KusoIDE."
2011-01-03 07:58:02 +00:00
:group 'kuso-ide
2011-01-02 12:29:07 +00:00
)
;; ----------------------------------------------------------------------
2011-01-02 13:53:57 +00:00
;; Functions
;; ----------------------------------------------------------------------
2011-01-02 14:05:40 +00:00
2011-01-02 13:53:57 +00:00
;; ----------------------------------------------------------------------
2011-01-02 12:29:07 +00:00
;; Minor Modes
;; ----------------------------------------------------------------------
2011-01-03 05:51:37 +00:00
(define-minor-mode kuso-mode
"Toggle Kuso mode.
2011-01-02 12:29:07 +00:00
This mode provide a basic configuration for an IDE."
2011-01-03 05:51:37 +00:00
:lighter " Kuso"
:keymap kuso-map
2011-01-02 12:29:07 +00:00
:global t
2011-01-03 05:51:37 +00:00
:group 'kuso-group
2011-01-02 12:29:07 +00:00
2011-01-03 05:51:37 +00:00
(if kuso-mode
;; kuso-mode is not loaded
2011-01-02 13:39:49 +00:00
(let ()
;; before initiazing mode
2011-01-03 06:49:01 +00:00
(run-hooks 'kuso-preinit-mode-hook)
2011-01-03 13:20:22 +00:00
2011-01-02 16:18:32 +00:00
;; i really found toolbar and scrollbar useless so i disabled them
(if tool-bar-mode (tool-bar-mode))
(if scroll-bar-mode (scroll-bar-mode))
2011-01-02 14:03:11 +00:00
(menu/init-menu)
2011-02-10 15:06:18 +00:00
(define-key kuso-map (kbd "s-c") 'kuso-prefix-map)
(global-set-key (kbd "s-j") 'shrink-window-horizontally)
(global-set-key (kbd "s-l") 'enlarge-window-horizontally)
(global-set-key (kbd "s-i") 'enlarge-window)
(global-set-key (kbd "s-k") 'shrink-window)
2011-02-08 13:17:18 +00:00
2011-01-05 05:38:58 +00:00
(if kuso-workspace (cd kuso-workspace))
2011-01-04 09:00:23 +00:00
(run-hooks 'kuso-plugin-preinit-hook)
(run-hooks 'kuso-plugin-init-hook)
(run-hooks 'kuso-plugin-postinit-hook)
2011-01-02 13:39:49 +00:00
;; after mode was initialized
2011-01-03 06:49:01 +00:00
(run-hooks 'kuso-postinit-mode-hook)
2011-01-05 06:53:32 +00:00
(message "<<< %s" kuso-postinit-mode-hook)
2011-01-02 13:39:49 +00:00
)
2011-01-03 05:51:37 +00:00
;; kuso-mode already loaded
2011-01-02 13:39:49 +00:00
(let ()
;; before deactivating mode
2011-01-03 06:49:01 +00:00
(run-hooks 'kuso-prerm-mode-hook)
2011-01-02 16:44:22 +00:00
2011-01-02 16:18:32 +00:00
;; return everything to normal
(if (not tool-bar-mode) (tool-bar-mode))
(if (not scroll-bar-mode) (scroll-bar-mode))
(menu/destruct-menu)
2011-01-02 13:39:49 +00:00
;; after deactivating mode
2011-01-03 06:49:01 +00:00
(run-hooks 'kuso-postrm-mode-hook)
2011-01-02 13:39:49 +00:00
)
)
2011-01-02 14:05:40 +00:00
)
;; TODO: provide a easy way for plugins to define a minor mode