cleaning up django plugin for sending to emacs community

This commit is contained in:
lxsameer 2011-07-25 23:47:31 +04:30
parent 08a8da7f48
commit 5b0ee61acc
1 changed files with 21 additions and 24 deletions

View File

@ -1,5 +1,5 @@
;; Kuso - My personal emacs IDE ;; lxdjango-mode - My personal emacs IDE
;; Copyright (C) 2010 Sameer Rahmani <lxsameer@gnu.org> ;; Copyright (C) 2010-2011 Sameer Rahmani <lxsameer@gnu.org>
;; ;;
;; This program is free software: you can redistribute it and/or modify ;; 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 ;; it under the terms of the GNU General Public License as published by
@ -14,7 +14,7 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; django plugin ;; lxdjango plugin
(require 'cl) (require 'cl)
(require 'comint) (require 'comint)
@ -34,35 +34,41 @@
;; Hooks ;; Hooks
;; ------------------------------------------------------------------- ;; -------------------------------------------------------------------
(defvar django-preinit-hook '() (defvar django-preinit-hook '()
"This hook runs before initializing the Kuso django-plugin minor mode." "This hook runs before initializing the lxdjango minor mode."
) )
(defvar django-postinit-hook '() (defvar django-postinit-hook '()
"This hook runs after Kuso django-plugin minor mode initialized." "This hook runs after lxdjango minor mode initialized."
) )
(defvar django-prerm--hook '() (defvar django-prerm--hook '()
"This hook runs before deactivating Kuso django-plugin minor mode." "This hook runs before deactivating lxdjango minor mode."
) )
(defvar django-postrm-hook '() (defvar django-postrm-hook '()
"This hook runs after Kuso django-plugin minor mode deactivated." "This hook runs after lxdjango minor mode deactivated."
) )
;; --------------------------------------------------------------------- ;; ---------------------------------------------------------------------
;; Keymaps ;; Keymaps
;; --------------------------------------------------------------------- ;; ---------------------------------------------------------------------
(defvar django-map (make-sparse-keymap) (defvar django-map (make-sparse-keymap)
"Default keymap for Kuso django minor mode that hold the global key "Default keymap for lxdjango minor mode"
binding for Kuso IDE django plugin"
) )
;; ---------------------------------------------------------------------
;; Groups
;; ---------------------------------------------------------------------
(defgroup django nil
"Django minor mode for Emacs."
:group 'programming
:prefix "lxdjango")
;; --------------------------------------------------------------------- ;; ---------------------------------------------------------------------
;; Custom Variables ;; Custom Variables
;; --------------------------------------------------------------------- ;; ---------------------------------------------------------------------
(defcustom django-plugin t (defcustom django-plugin t
"KusoIDE Django programming language plugin." "Django framework minor mode."
:group 'kuso-features :group 'django
:type 'boolean :type 'boolean
:tag '"django plugins") :tag '"django plugins")
@ -74,7 +80,6 @@ binding for Kuso IDE django plugin"
(define-key django-map (kbd "<f6>") 'django-runserver) (define-key django-map (kbd "<f6>") 'django-runserver)
(define-key django-map (kbd "<f7>") 'django-syncdb) (define-key django-map (kbd "<f7>") 'django-syncdb)
(define-key django-map (kbd "\C-c s") 'django-shell) (define-key django-map (kbd "\C-c s") 'django-shell)
;; (define-key django-map (kbd "\C-x p f") 'django-buffer)
) )
(defun django/init-menus () (defun django/init-menus ()
@ -96,9 +101,6 @@ binding for Kuso IDE django plugin"
(defun django/destruct-menus () (defun django/destruct-menus ()
"Remove menus from menubar" "Remove menus from menubar"
(global-unset-key [menu-bar django]) (global-unset-key [menu-bar django])
;; (global-unset-key [menu-bar edit sep2])
;; (global-unset-key [menu-bar edit djangoreg])
;; (global-unset-key [menu-bar edit djangobuf])
) )
(defun get-project-path () (defun get-project-path ()
@ -119,9 +121,7 @@ binding for Kuso IDE django plugin"
(switch-to-buffer newcommand-buffer) (switch-to-buffer newcommand-buffer)
(add-hook 'after-change-functions 'buffer-change-colorizing t t) (add-hook 'after-change-functions 'buffer-change-colorizing t t)
(setq fullcommand (expand-file-name "manage.py" project-path)) (setq fullcommand (expand-file-name "manage.py" project-path))
;;(setq fullcommand (concat fullcommand " " command))
(message fullcommand) (message fullcommand)
;;(setq commandp (start-process-shell-command command-process-name newcommand-buffer fullcommand))
(setq commandp (apply 'make-comint-in-buffer command-process-name newcommand-buffer *python* nil (list fullcommand command))) (setq commandp (apply 'make-comint-in-buffer command-process-name newcommand-buffer *python* nil (list fullcommand command)))
(cd django-cwd) (cd django-cwd)
) )
@ -228,8 +228,6 @@ binding for Kuso IDE django plugin"
(add-hook 'after-change-functions 'buffer-change-colorizing t t) (add-hook 'after-change-functions 'buffer-change-colorizing t t)
(setq fullcommand (concat "pylint -f colorized " cbuffer-file)) (setq fullcommand (concat "pylint -f colorized " cbuffer-file))
(setq commandp (start-process-shell-command "pylint" pylint-buffer fullcommand)) (setq commandp (start-process-shell-command "pylint" pylint-buffer fullcommand))
;;(setq commandp (apply 'make-comint-in-buffer "pylint" pylint-buffer "pylint" nil (list fullcommand)))
) )
(message "This buffer did not visit any file.") (message "This buffer did not visit any file.")
) )
@ -242,16 +240,16 @@ binding for Kuso IDE django plugin"
;; Minor Modes ;; Minor Modes
;; ---------------------------------------------------------------------- ;; ----------------------------------------------------------------------
(define-minor-mode django-mode (define-minor-mode django-mode
"Toggle Kuso django plugin mode. "Toggle lxdjango minor mode.
This plugin provide some functionality for speedup django development on This plugin provide some functionality for speedup django development on
GNUEmacs." GNUEmacs."
:lighter nil :lighter nil
:keymap django-map :keymap django-map
:global t :global t
:group 'kuso-group :group 'django
(if django-mode (if django-mode
;; kuso-cplugin-mode is not loaded ;; lxdjango minor mode is not loaded
(let () (let ()
;; before initiazing mode ;; before initiazing mode
(run-hooks 'django-preinit-hook) (run-hooks 'django-preinit-hook)
@ -259,11 +257,10 @@ GNUEmacs."
(django/init-menus) (django/init-menus)
(setq django-cwd default-directory) (setq django-cwd default-directory)
;;(put 'django-region 'menu-enable nil) ;;(put 'django-region 'menu-enable nil)
;;(force-mode-line-update)
;; after mode was initialized ;; after mode was initialized
(run-hooks 'django-postinit-hook) (run-hooks 'django-postinit-hook)
) )
;; kuso-mode already loaded ;; lxdjango plugin already loaded
(let () (let ()
;; before deactivating mode ;; before deactivating mode
(run-hooks 'django-prerm-hook) (run-hooks 'django-prerm-hook)