emacs init.el file
There are many opinions about the editor to use. Personally, I am not very picky, but I agree with Pragmatic Programmer that as a programmer that will write a lot of code it is worthwhile to become really proficient with an editor. Here my choice is emacs, powerful, flexible, and can be used also remotely in a terminal.
Emacs is very configurable, my current .emacs.d/init.el changed with time emacs grew and keeping it up to date things I do not actively use is not worth it, for example lost the Fortran and Haskell settings I had, now it is:
;;; Fawzi's setup
;; global variables
(setq
inhibit-startup-screen t
column-number-mode t
scroll-error-top-bottom t
use-package-always-ensure t)
(set-language-environment "UTF-8")
; work around for bug that made accented characters not typeable
(require 'iso-transl)
; mac fixes
(when (eq system-type 'darwin)
(setq mac-right-option-modifier 'none) ; use right alt as alt on mac
(add-to-list 'exec-path "/usr/local/bin") ; add brew stuff to the exec path
)
(setq user-mail-address "fawzi@kitabi.eu")
;; use only spaces, no tabs to indent
(setq-default indent-tabs-mode nil)
;; Melpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; ensime
;(add-to-list 'package-archives
; '("melpa" . "http://melpa.milkbox.net/packages/") t)
;(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
;(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)
; do not zap last char
(autoload 'zap-up-to-char "misc"
"Kill up to, but not including ARGth occurrence of CHAR." t)
(global-set-key (kbd "M-z") 'zap-up-to-char)
; nicer buffer names with duplicates
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
; remember place in buffer
(save-place-mode 1)
;(require 'saveplace)
;(setq-default save-place t)
(show-paren-mode 1)
(setq save-interprogram-paste-before-kill t
apropos-do-all t
mouse-yank-at-point t
require-final-newline t
visible-bell t
load-prefer-newer t
ediff-window-setup-function 'ediff-setup-windows-plain
save-place-file (concat user-emacs-directory "places")
backup-directory-alist `(("." . ,(concat user-emacs-directory
"backups"))))
;(dolist (el '(json-mode scala-mode whitespace-cleanup-mode flx-ido ido-vertical-mode projectile sbt-mode flycheck ensime) nil)
; (unless (package-installed-p el)
; (package-refresh-contents) (package-install el))
; )
(unless (package-installed-p 'use-package)
(package-refresh-contents) (package-install 'use-package))
(require 'use-package)
(use-package json-mode :pin melpa-stable)
(use-package scala-mode
:pin melpa-stable)
(use-package whitespace-cleanup-mode
:pin melpa-stable
:config
(global-whitespace-cleanup-mode)
)
;(use-package flx-ido :pin melpa-stable)
(use-package ido-vertical-mode
:pin melpa-stable
:config
(ido-mode 1)
(ido-vertical-mode 1)
(setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
)
(use-package projectile
:pin melpa-stable
:config
(projectile-mode)
)
(use-package sbt-mode :pin melpa-stable)
(use-package flycheck
:pin melpa-stable
:config
;(add-hook 'scala-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'flycheck-mode)
)
(use-package ensime
:pin melpa-stable
:config
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
)
; git support (magit)
(use-package magit
:pin melpa-stable
:config
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x M-g") 'magit-dispatch))
;; python
(use-package elpy
:mode ("\\.py\\'" . python-mode)
:pin melpa-stable
:config
(setq elpy-rpc-backend "jedi")
(elpy-enable))
(use-package blacken
:pin melpa
:demand t
:config
(add-hook 'python-mode-hook 'blacken-mode)
:after python)
;(use-package flx-ido
; :config (flx-ido-mode 1)
; ;; disable ido faces to see flx highlights.
; (setq ido-enable-flex-matching t)
; (setq ido-use-faces nil))
(global-set-key (kbd "M-g") 'goto-line)
;; cleanup whitespace of edited pieces of a file
;; spelling
(use-package ispell
:config
;(setq ispell-dictionary "german")
(setq ispell-program-name "hunspell" ; Use hunspell to correct mistakes
ispell-dictionary "english") ; Default dictionary to use
(add-hook 'scala-mode-hook 'flyspell-prog-mode)
(add-hook 'fundamental-mode-hook 'flyspell-mode)
(add-hook 'latex-mode-hook 'flyspell-mode)
(add-hook 'markdown-mode-hook 'flyspell-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
(add-hook 'org-mode-hook 'flyspell-mode)
)
;; setup files ending in ".md" to open in markdown-mode
(use-package markdown-mode
:config
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
(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.
'(package-selected-packages
(quote
(projectile markdown-mode blacken gxref magit whitespace-cleanup-mode use-package json-mode ido-vertical-mode flycheck ensime elpy))))
(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.
)