Skip to content

Latest commit

 

History

History
312 lines (273 loc) · 10.3 KB

emacsimize.org

File metadata and controls

312 lines (273 loc) · 10.3 KB

Emacsimize.me Org Init

http://blog.emacsimize.me

Init

Some actions needs to be done to prepare a good base for the rest of the configuration.

Personal Settings

(setq user-full-name "Stefan Eichberger"
   user-mail-address "[email protected]")

Load Path

http://www.emacswiki.org/emacs-en/LoadPath I like the approach to define which packages (sub directory) should be loaded.

(let ((default-directory "~/.emacs.d/elisp/"))
 	(normal-top-level-add-to-load-path '("use-package")))

Package Repositories

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

A package manager

The use-package is a really great way to have a tidy installation and configuration of your packages.

(package-refresh-contents)
(require 'use-package)   

Backup of files and history

(setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) 

I agree here with Sacha to save a lot but for me following is enough.

(setq delete-old-versions -1)
(setq version-control t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list" t)))

I have to read up on this history settings. http://www.wisdomandwonder.com/wordpress/wp-content/uploads/2014/03/C3F.html I remeber reading this but not in detail. I disable this for now.

(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
      '(kill-ring
        search-ring
        regexp-search-ring))

Look and Feel

Clearer view on X

(when window-system
  (tooltip-mode -1)
  (tool-bar-mode -1)
  (menu-bar-mode -1))

Paste from mouse at current cursor position (point)

I just hate it when I insert from my mouse clipboard and it adds it at the mouse cursor and not my caret.

(setq mouse-yenc-at-point 't)

Smoothen mouse scrolling

This makes the scolling with the mouse less irritating.

(setq redisplay-dont-pause t
      scroll-margin 1
      scroll-step 1
      scroll-conservatively 10000
      scroll-preserve-screen-position 1)
(setq mouse-wheel-follow-mouse 't)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))

Background Color and fonts

Solarize them is nice and highly advanded but I’m still found of it. this will brake !!!!

(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 (:stipple nil :background "darkslategrey" :foreground "AntiqueWhite" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 137 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))

I don’t need the splash screen

(setq inhibit-splash-screen t)

Shorten the yes/no questions

(fset 'yes-or-no-p 'y-or-n-p)

Tabs are bad!

(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq sh-basic-offset 2
        sh-indentation 2)

Ido mode

(ido-mode t)

I like to have it vertically

(use-package ido-vertical-mode
  :ensure ido-vertical-mode
  :init
  (ido-vertical-mode))

Org Mode Tunes

I want to clock into drawers

    

Packages

Luxurious Undo - undo-tree

(use-package undo-tree
  :ensure undo-tree
  :init
    (global-undo-tree-mode 1)
  :config
    (progn
      (global-set-key (kbd "C-z") 'undo-tree-undo)
      (global-set-key (kbd "C-S-z") 'undo-tree-redo)))   

Htmlize

(use-package htmlize
  :ensure htmlize)

Tramp

Just awesome.

(use-package tramp
  :ensure tramp
  :config
    (progn
      (setq tramp-default-method "ssh"
            tramp-default-user "eichberger"
            ido-enable-tramp-completion t
            tramp-backup-directory-alist backup-directory-alist
            auto-save-file-name-transforms nil)
      (tramp-set-completion-function "ssh"
                                     '((tramp-parse-sconfig "~/.ssh/config")))))

Smart Mode Line

Cleans up your mode line

(use-package smart-mode-line
  :ensure smart-mode-line
  :init
    (sml/setup))

Autocomplete me

(use-package auto-complete
  :ensure auto-complete
  :init
  (global-auto-complete-mode +1)
  :config
  (setq ac-auto-show-menu t
      ac-quick-help-delay 0.5
      ac-use-fuzzy t))

ibuffer

This is here by default but I put the configuration here

(setq ibuffer-saved-filter-groups
      (quote (("default"
               ("files" (or
                         (mode . emacs-lisp-mode)
                         (mode . cperl-mode)
                         (mode . elpy-mode)
                         (mode . python-mode)
                         (mode . sh-mode)
                         (mode . conf-unix-mode)
                         (mode . conf-space-mode)
                         (mode . conf-mode)
                         (mode . fundamental-mode)
                         (mode . text-mode)))
               ("tramp" (or
                         (name . "^\/ssh")))
               ("eshells" (or
                           (name . "^\\*eshell")))
               ("confluence" (mode . confluence-mode))
               ("dired" (mode . dired-mode))
               ("emacs" (or
                         (name . "^\\*scratch\\*$")
                         (name . "^\\*Warnings\\*$")
                         (name . "^\\*Buffer List")
                         (name . "^\\*Completions\\*$")
                         (name . "^\\*Help\\*$")
                         (name . "^\\*\\*$")))))))


(add-hook 'ibuffer-mode-hook
          (lambda ()
            (ibuffer-switch-to-saved-filter-groups "default")))

;; (use-package ibuf-ext
;;   :ensure ibuf-ext
;;   :config
;;   (progn
;;     (add-to-list 'ibuffer-never-show-predicates "^\\*tramp")
;;     (add-to-list 'ibuffer-never-show-predicates "^\\*helm")
;;     (add-to-list 'ibuffer-never-show-predicates "^\\*Messages")
;;     (add-to-list 'ibuffer-never-show-predicates "^\\*Backtrace")))
(global-set-key (kbd "C-x C-b") 'ibuffer)

dsvn

an svn interface

(autoload 'svn-status "dsvn" "Run `svn status'." t)
(autoload 'svn-update "dsvn" "Run `svn update'." t)

ace-jump

jump around …

(require 'ace-jump-mode)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)

Custom Functions

Open New Eshell

I got used of Eshell which adds some nice possiblities to my daily work.

(defun eshell-new ()
  (interactive)
  (eshell (quote (-1))))

(global-set-key (kbd "s-t") 'eshell-new)

Sudo edit file

I want to edit a file if I’m using dired mode with sudo rights. Especially if I work remote.

(use-package dired+
  :ensure dired+)

(defun sudo-edit-current-file ()
  (interactive)
  (let ((my-file-name) ; fill this with the file to open                                                                                                                      
        (position))    ; if the file is already open save position                                                                                                            
    (if (equal major-mode 'dired-mode) ; test if we are in dired-mode                                                                                                         
        (progn
          (setq my-file-name (dired-get-file-for-visit))
          (find-alternate-file (prepare-tramp-sudo-string my-file-name)))
      (setq my-file-name (buffer-file-name); hopefully anything else is an already opened file                                                                                
            position (point))
      (find-alternate-file (prepare-tramp-sudo-string my-file-name))
      (goto-char position))))


(defun prepare-tramp-sudo-string (tempfile)
  (if (file-remote-p tempfile)
      (let ((vec (tramp-dissect-file-name tempfile)))

        (tramp-make-tramp-file-name
         "sudo"
         (tramp-file-name-user nil)
         (tramp-file-name-host vec)
         (tramp-file-name-localname vec)
         (format "ssh:%s@%s|"
                 (tramp-file-name-user vec)
                 (tramp-file-name-host vec))))
    (concat "/sudo:root@localhost:" tempfile)))

(define-key dired-mode-map [s-return] 'sudo-edit-current-file)

Expand Region

This is very handy.

(use-package expand-region
  :ensure expand-region
  :config
  (global-set-key (kbd "C-=") 'er/expand-region))