Defining C-< and C-> for indentation.

This commit is contained in:
Kazu Yamamoto 2012-02-28 20:38:50 +09:00
parent 2c320d4032
commit 18b6eec6ad
4 changed files with 43 additions and 2 deletions

View File

@ -1,5 +1,5 @@
SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el \
ghc-command.el ghc-info.el ghc-ins-mod.el
ghc-command.el ghc-info.el ghc-ins-mod.el ghc-indent.el
EMACS = emacs
DETECT = xemacs

35
elisp/ghc-indent.el Normal file
View File

@ -0,0 +1,35 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; ghc-indent.el
;;;
;; Author: Kazu Yamamoto <Kazu@Mew.org>
;; Created: Feb 28, 2012
;;; Code:
(defvar ghc-indent-offset 4)
(defun ghc-make-indent-shallower (beg end)
(interactive "r")
(let ((n ghc-indent-offset))
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char beg)
(while (not (eobp))
(delete-region (point) (+ (point) n))
(forward-line))))))
(defun ghc-make-indent-deeper (beg end)
(interactive "r")
(let ((indent (make-string ghc-indent-offset 32)))
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char beg)
(while (not (eobp))
(insert indent)
(forward-line))))))
(provide 'ghc-indent)

View File

@ -27,6 +27,7 @@
(require 'ghc-flymake)
(require 'ghc-command)
(require 'ghc-ins-mod)
(require 'ghc-indent)
(require 'dabbrev)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -54,6 +55,8 @@
(defvar ghc-module-key "\C-c\C-m")
(defvar ghc-expand-key "\C-c\C-e")
(defvar ghc-hoogle-key (format "\C-c%c" (ghc-find-C-h)))
(defvar ghc-shallower-key "\C-c<")
(defvar ghc-deeper-key "\C-c>")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@ -82,6 +85,8 @@
(define-key haskell-mode-map ghc-toggle-key 'ghc-flymake-toggle-command)
(define-key haskell-mode-map ghc-module-key 'ghc-insert-module)
(define-key haskell-mode-map ghc-hoogle-key 'haskell-hoogle)
(define-key haskell-mode-map ghc-shallower-key 'ghc-make-indent-shallower)
(define-key haskell-mode-map ghc-deeper-key 'ghc-make-indent-deeper)
(ghc-comp-init)
(setq ghc-initialized t)))

View File

@ -22,7 +22,8 @@ Cabal-Version: >= 1.6
Build-Type: Simple
Data-Dir: elisp
Data-Files: Makefile ghc.el ghc-func.el ghc-doc.el ghc-comp.el
ghc-flymake.el ghc-command.el ghc-info.el ghc-ins-mod.el
ghc-flymake.el ghc-command.el ghc-info.el
ghc-ins-mod.el ghc-indent.el
Executable ghc-mod
Main-Is: GHCMod.hs
Other-Modules: Browse