;; this is for shells that set either delete or backspace
;; as ctrl h use M-x help to get to help instead
(global-set-key "\C-h" 'backward-delete-char)
;; set the tab width slightly smaller
(setq default-tab-width 4)
(setq-default tab-width 4)
(setq-default c-basic-offset 4)

;; do not display a splash screen on startup for emacs 22
(setq inhibit-splash-screen t)

;; turn off menu bar in terminal
(if (not window-system)
    (menu-bar-mode -1))

;; don't use tabs to indent, may or may not want this
;; to insert a tab C-q
(setq-default indent-tabs-mode nil)

;; show trailing whitespace and add some keybindings
(setq-default show-trailing-whitespace t)
(global-set-key (kbd "C-x 7") 'display-line-numbers-mode)
(global-set-key (kbd "C-x 8") 'whitespace-mode)
(global-set-key (kbd "C-x 9") '(lambda () (interactive)
                                 (setq show-trailing-whitespace (not show-trailing-whitespace))
                                 (force-mode-line-update)
                                 (cond (show-trailing-whitespace (message "show-trailing-whitespace is True"))
                                       (t    (message "show-trailing-whitespace is False")))))

;; make sure octave files are opened in octave mode and not obj-c mode
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))

;; add code folding hs-minor-mode to all programming modes
(add-hook 'prog-mode-hook #'hs-minor-mode)
;; if you want line numbers on the lefthand side of programming modes
;;(add-hook 'prog-mode-hook 'display-line-numbers-mode)


;; https://github.com/magnars/multiple-cursors.el/blob/master/README.md
;; many terminals do not do not send C-> or C-. due to the term emulation
;; xterm does (along with C-S-c, 'S' is shift)
;; the weird bindings here are to get around terminal breakage
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-]") 'mc/mark-next-like-this)
(global-set-key (kbd "C-c C-]") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-c C-]") 'mc/mark-all-like-this)


;; remap the prefix for the hide/show to something easier
(setq hs-minor-mode-map
      (let ((map (make-sparse-keymap)))
        ;; These bindings roughly imitate those used by Outline mode.
        (define-key map (kbd "C-c h C-h") 'hs-hide-block)
        (define-key map (kbd "C-c h C-s") 'hs-show-block)
        (define-key map (kbd "C-c h M-h") 'hs-hide-all)
        (define-key map (kbd "C-c h M-s") 'hs-show-all)
        (define-key map (kbd "C-c h C-l") 'hs-hide-level)
        (define-key map (kbd "C-c h C-c") 'hs-toggle-hiding)
        (define-key map [(shift mouse-3)] 'hs-toggle-hiding)
        map))

;; python stuff
(add-hook 'python-mode-hook
          (lambda ()
            (setq indent-tabs-mode nil)
            (setq tab-width 4)
            (setq python-indent 4)
            ))
