(add-hook 'lisp-mode-hook
          (lambda ()
            (local-set-key [tab] 'slime-indent-and-complete-symbol)
            (local-set-key [return] 'newline-and-indent)))

(add-hook 'clojure-mode-hook
          (lambda ()
            (local-set-key [tab] 'slime-indent-and-complete-symbol)
            (local-set-key [S-return] 'slime-eval-last-expression)
            (local-set-key [return] 'newline-and-indent)))

(global-set-key (kbd "RET") 'newline-and-indent)

(delete-selection-mode 1)

(defun hide-eol ()
  (interactive)
  (setq buffer-display-table (make-display-table))
  (aset buffer-display-table ?\^M []))
(blink-cursor-mode -1)
;(color-theme-high-contrast)
;(color-theme-snow)
;(color-theme-emacs-nw)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-names-vector ["black" "red" "green" "yellow" "blue" "magenta" "cyan" "white"])
 '(c-basic-offset 4)
 '(c-default-style "linux")
 '(column-number-mode t)
 '(default-tab-width 4 t)
 '(fill-column 79)
 '(global-visual-line-mode nil)
 '(indent-tabs-mode nil)
 '(ispell-personal-dictionary (expand-file-name "~/.aspell"))
 '(iswitchb-mode t)
 '(scroll-conservatively 100)
 '(scroll-preserve-screen-position t)
 '(scroll-step 1)
 '(tool-bar-mode nil)
 '(yas/prompt-functions (quote (yas/ido-prompt yas/x-prompt yas/completing-prompt yas/no-prompt))))


(mapc (lambda (face) (set-face-attribute face nil :weight 'normal :underline nil)) (face-list))
;(mapc (lambda (face) (set-face-attribute face nil :weight 'normal :underline nil :foreground "black")) (face-list))

(setq initial-frame-alist '((top . 0) (left . 0) (width . 79) (height . 62)))

(defun kill-all-buffers ()
  (interactive)
  (mapc 'kill-buffer (buffer-list)))

(defun yank-loop (number)
  (interactive "nEnter number of repetitions: ")
  (move-end-of-line nil)
  (newline-and-indent)
  (previous-line)
  (move-beginning-of-line nil)
  (kill-line 1)
  (dotimes (i number)
    (yank))
  (dotimes (i number)
    (previous-line))
  (move-end-of-line nil))

(global-set-key "\M-n" 'yank-loop)


(add-to-list 'load-path "c:/Users/Heitor/Desktop/LispCabinetHome/.emacs.d")
(add-to-list 'load-path "c:/Users/Heitor/Desktop/LispCabinetHome/.emacs.d/auto-complete")

(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "c:/Users/Heitor/Desktop/LispCabinetHome/.emacs.d/dict")
;(ac-config-default)
(setq-default ac-sources (add-to-list 'ac-sources 'ac-source-dictionary))
(global-auto-complete-mode t)
(setq ac-auto-start 2)
(setq ac-ignore-case nil)

;; (electric-indent-mode t)


(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :foundry "outline" :family "ProggyTinyTTSZ")))))


(menu-bar-mode -1)
(set-default 'cursor-type 'bar)


;;;; Python

;(add-hook 'python-mode-hook
;          'my-python-send-statement)
;(add-hook 'python-mode-hook
;          'my-python-send-block)

(defun line-emptyp ()
  (= (line-beginning-position) (line-end-position)))

(defun my-python-send-statement ()
  (interactive)
  (local-set-key [S-return] 'my-python-send-statement)
  (end-of-line)
  (set-mark (line-beginning-position))
  (call-interactively 'python-shell-send-region)
;  (python-shell-send-string "; print(end=\"\")"))
  (python-shell-send-string "\n"))

(defun my-python-send-block ()
  (interactive)
  (local-set-key [C-return] 'my-python-send-block)
  (set-mark (line-end-position))
  ; (previous-line)
  (let ((lines-of-block 0))
    (while (or (equal (line-beginning-position) 0) (not (line-emptyp)))
      (previous-line)
      (beginning-of-line)
      (set 'lines-of-block (+ 1 lines-of-block))
      
      )
    (beginning-of-line)
    (call-interactively 'python-shell-send-region)
    (python-shell-send-string "\n")

    (dotimes (i lines-of-block)
      (next-line))
    (end-of-line)
    )
  )

(add-hook 'python-mode-hook
          (lambda ()
            (local-set-key [S-return] 'my-python-send-statement)
            (local-set-key [C-return] 'my-python-send-block)))

;;;; scheme
(setq scheme-program-name "csi.exe -:c")

(defun my-scheme-send-buffer ()
  (interactive)
  (mark-whole-buffer)
  (call-interactively 'scheme-send-region))

(add-hook 'scheme-mode-hook
          (lambda ()
            (local-set-key [C-return] 'my-scheme-send-buffer)
            (local-set-key [S-return] 'scheme-send-last-sexp)))
