Springe zum Hauptinhalt

Emacs Config

Emacs Configuration

Emacs

Customize variables

Package initialization

Add some sources do download new packages from

(require 'package)

(let** ((no-ssl (and (memq system-type '(windows-nt ms-dos))
		    (not (gnutls-available-p))))
		    (url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
		    (add-to-list 'package-archives (cons "melpa" url) t))
(add-to-list 'package-archives
	     '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
	     '("org" . "http://orgmode.org/elpa/"))

(add-to-list 'load-path (expand-file-name "~/.emacs.d/plugins"))
(package-initialize)

Screw scrollbars and similiar

I tend to dislike scrollbars, emacs has nice hotkey-based scrolling anyways, so why should I touch my mouse? Nuts.

(scroll-bar-mode -1)
(tool-bar-mode nil)
(menu-bar-mode nil)

(custom-set-variables '(inhibit-startup-screen 't))

Theme

(require 'doom-themes)
(setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
      doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-molokai t)
(doom-themes-visual-bell-config)
(doom-themes-org-config)

;;(add-to-list 'default-frame-alist '(foreground-color . "#CCCCCC"))
;;(add-to-list 'default-frame-alist '(background-color . "#000000"))

;;(custom-set-variables '(color-theme-directory nil))

This enables my favorite doom-theme, the visual bell and fixes the org mode fontification.

(require 'rainbow-mode)

(define-globalized-minor-mode my-global-rainbow-mode rainbow-mode
  (lambda () (rainbow-mode 1)))

(my-global-rainbow-mode 1)

Some infos to display

e.g. battery, time, column number, …

(display-battery-mode t)
(display-time-mode 1)
(column-number-mode)
(size-indication-mode t)

(custom-set-variables '(battery-update-interval 30))

Keymappings

Swap meta and super.

(setq  x-meta-keysym 'super
       x-super-keysym 'meta)

Faster indentation than M-\ or whatever the real hotkey was.

(define-key global-map (kbd "C-ü") 'indent-region)

I like to be able to jump to any kind of char visible in the buffer.

(define-key global-map (kbd "C-c f") 'iy-go-to-char)
(define-key global-map (kbd "C-c g") 'iy-go-to-char-backward)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)

Other

  • No sleeping!

    I really dislike this hotkey. Why would I want to pause my emacs? Ancient function for ancient machines.

    (global-unset-key (kbd "C-z"))
    
  • Zone
    (require 'zone)
    (zone-when-idle 180)
    

    A little screensaver fun. ;)

  • Timestamp
    (defun insert-timestamp ()
      "Insert string for the current time formatted like '2:34 PM' or 1507121460"
      (interactive)                 ; permit invocation in minibuffer
      ;;(insert (format-time-string "%D %-I:%M %p")))
      ;;(insert (format-time-string "%02y%02m%02d%02H%02M%02S")))
      (insert (format-time-string "%F %H:%M:%S UTC+02:00")))
    
  • Misc
    (custom-set-variables '(shell-input-autoexpand t)
    		      '(history-length 1024))
    (set-face-attribute 'default nil :height 100)
    (ac-config-default)
    (require 'wgrep)
    

expand-region

(require 'expand-region)
(define-key global-map (kbd "C-ö") 'er/expand-region)

yasnippet

(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
(setq yas-trigger-key "<tab>")

org-mode

(require 'org)

Display preferences

Fancy bullets instead of lists of asterisks are fancier.

(add-hook 'org-mode-hook
	  (lambda() (org-bullets-mode t)))

(setq org-hide-leading-stars t)

Syntax highlighting in source blocks while editing

(setq org-src-fontify-natively t)

Babel

  (org-babel-do-load-languages
    'org-babel-load-languages
      '((emacs-lisp . t)
	(sh . t)
	(python . t)
	(latex . t)
	(plantuml . t)))

(setq org-plantuml-jar-path (expand-file-name "/usr/share/plantuml/plantuml.jar"))

Keymappings

(global-set-key (kbd "C-c o") 
		(lambda () (interactive)
			   (find-file "~/org/central.org")
			   (end-of-buffer)
			   ))
(global-set-key (kbd "C-c c") 'org-capture)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)

Agenda

Set agenda files location

(setq org-agenda-files (list "/home/matthis/org"))
(setq org-agenda-file-regexp ".*\\.org")

Log

(setq org-log-done t)
(setq org-log-repeat "time")

Publish

  • Export
    (require 'ox-reveal)
    (require 'ox-twbs)
    

    Reveal allows me to create nice presentations, twbs is for bootstrap export.

  • org-publish
    (setq org-publish-project-alist '(("emacs-conf"
    				   :base-directory       "~/.emacs.d/"
    				   :base-extension       "org"
    				   :publishing-directory "/home/matthis/www/posts/"
    				   :publishing-function org-publish-attachment
    				   :headline-levels 3
    				   :section-numbers nil
    				   :with-toc t
    				   :html-preamble t)
    
    				   ;; ("images"
    				   ;;  :base-directory "~/images/"
    				   ;;  :base-extension "jpg\\|gif\\|png"
    				   ;;  :publishing-directory "/ssh:standard@217.160.183.244:~/html/images/"
    				   ;;  :publishing-function  org-html-publish-to-html
    				   ;;  :publishing-function org-publish-attachment)
    
    				   ;; ("other"
    				   ;;  :base-directory "~/other/"
    				   ;;  :base-extension "css\\|el"
    				   ;;  :publishing-directory "/ssh:user@host:~/html/other/"
    				   ;;  :publishing-function org-publish-attachment)
    
    				   ;;  ("website" :components ("orgfiles" "images" "other"))
    				 ))
    

    This allows me to upload the stuff to my server with org-publish.

web-mode

Filetypes

Add some filetypes where I want web-mode

(require 'web-mode)

(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))

Indentation

(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2) ;; <- js, php, perl, ...

Highlight

Highlighting selected element and the column

(setq web-mode-enable-current-element-highlight t)
(setq web-mode-enable-current-column-highlight t)

c++-ish

Indentation

(c-set-offset 'substatement-open 0)
(setq c-default-style "linux"
      c-basic-offset 4)
(setq-default indent-tabs-mode nil
	      c-toggle-hungry-state t)

CEDET

Loading cedet

(load-file "~/cedet/cedet-devel-load.el")
(global-ede-mode t)
  • Folding
    (add-to-list 'semantic-default-submodes 'global-semantic-tag-folding-mode t)
    
  • Autocompletion
    (semantic-load-enable-code-helpers)
    (global-srecode-minor-mode 1)
    (add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode t)
    (add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t)
    (add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t)
    
    (semantic-mode 1)
    
    (require 'semantic/bovine/gcc)
    
    ;; Intelli Sense like
    (defun my-c-mode-cedet-hook ()
    ;; (local-set-key "." 'semantic-complete-self-insert)
    ;; (local-set-key ":" 'semantic-complete-self-insert)
    ;; (local-set-key ">" 'semantic-complete-self-insert))
      (add-to-list 'ac-sources 'ac-source-gtags)
      (add-to-list 'ac-sources 'ac-source-semantic))
    (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
    
  • EDE
    • Projects

Neotree

(add-to-list 'load-path "/home/matthis/.emacs.d/plugins/neotree")
(require 'neotree)
(global-set-key [f12] 'neotree-toggle)

Java

(require 'eclim)
(setq eclimd-autostart t)

(defun my-java-mode-hook ()
    (eclim-mode t)
    (gradle-mode t))

(add-hook 'java-mode-hook 'my-java-mode-hook)

(custom-set-variables
    '(eclim-eclipse-dirs '("~/eclipse"))
    '(eclim-executable "~/eclipse/eclim"))

(setq help-at-pt-display-when-idle t)
(setq help-at-pt-timer-delay 0.1)
(help-at-pt-set-timer)

(require 'ac-emacs-eclim)
(ac-emacs-eclim-config)

(require 'company)
(require 'company-emacs-eclim)
(company-emacs-eclim-setup)
(global-company-mode t)

Haskell

Documentation lookup

(eval-after-load 'haskell-mode
  '(define-key haskell-mode-map (kbd "C-c C-d") 'ac-haskell-process-popup-doc))

Haskell autocompletion

(require 'hs-lint)

(defun my-haskell-mode-hook ()
  "hs-lint binding, plus autocompletion and paredit."
  (local-set-key "\C-cl" 'hs-lint)
  (setq ac-sources
	(append '(ac-source-yasnippet
		  ac-source-abbrev
		  ac-source-words-in-buffer
		  my/ac-source-haskell)
		ac-sources))
  (dolist (x '(haskell literate-haskell))
    (add-hook
     (intern (concat (symbol-name x)
		     "-mode-hook"))
     'turn-on-paredit)))

(eval-after-load 'haskell-mode
  '(progn
     (require 'flymake)
     (push '("\\.l?hs\\'" flymake-haskell-init) flymake-allowed-file-name-masks)
     (add-hook 'haskell-mode-hook 'flymake-haskell-enable)
     (add-hook 'haskell-mode-hook 'my-haskell-mode-hook)))

(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)