Select Git revision
init.el 19.98 KiB
;; Make startup faster by reducing the frequency of garbage
;; collection. The default is 0.8MB. Measured in bytes.
(setq gc-cons-threshold (* 50 1000 1000))
;;; Code:
;; Turn off mouse interface early in starup to avoid momentary display
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))
;(add-to-list 'load-path "~/.emacs.d/auto-complete-clang/")
;(dd-to-list 'load-path "~/.emacs.d/lisp/benchmark-init-el")
;(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/doxymacs")
;(require 'benchmark-init-loaddefs)
;(benchmark-init/activate)
;; (defconst my-start-time (current-time)
;; "Time emacs starts loading"
;; )
(setenv "ESHELL" (expand-file-name "~/bin/eshell"))
;; use smart line
(setq epg-gpg-program "/usr/local/bin/gpg")
;; frame font
;; Setting English Font
(when (string= system-type "darwin")
(setq dired-use-ls-dired nil))
;; ;;-------------------------- Backup
(setq backup-directory-alist `(("." . "~/.saves")))
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(require 'ansi-color)
(defun my/ansi-colorize-buffer ()
(let ((buffer-read-only nil))
(ansi-color-apply-on-region (point-min) (point-max))))
(add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)
;; (find-file "~/Dropbox/Orgfiles/master.org") ;
(setq is-mac (equal system-type 'darwin))
;; My location for external packages.
(global-set-key (kbd "M-2") #'er/expand-region)
(setq preview-gs-options '("-q" "-dNOSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4"))
(setq py-install-directory "~/.emacs.d/lisp/pdee-master")
(add-to-list 'load-path py-install-directory)
(setq display-battery-mode t) (display-battery-mode 1) ;; will make the display of date and time persistent.
(when (>= emacs-major-version 24)
(require 'package)
(message "add repos")
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("ELPA" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("MELPA" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
)
(when (not package-archive-contents)
(package-refresh-contents))
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
;; Setup packages
;(require 'setup-package)
; list the packages
(setq package-list '(
; dash
cl
sml-modeline
zenburn-theme
solarized-theme
color-theme
highlight-indentation
;ag
auctex
auctex-latexmk
org-journal
org-fstree
remember
;yasnippet
;expand-region
multiple-cursors
;dired+
;sx
linum
hlinum
server
;nav
recentf
;fill-column-indicator
browse-kill-ring
;mode-mapping
;semantic
ido
ido-vertical-mode
magit
;xcscope
;cmake-project
;cpputils-cmake
paren ;; will highlight matching parentheses next to cursor.
auto-complete
;auto-complete-clang-async
;auto-complete-clang
;company ;
;; irony ; needed by company-irony
autopair ;; to enable in all buffers
;flymake-cursor
;python
;python-mode
;ipython
;elpy
flycheck
;;ob-plantuml
; uniquify ;
;epl ; needed for projectile
;async ; needed for hlem
;pkg-info ; needed for projectile
;projectile
;helm-projectile
undo-tree
exec-path-from-shell
latex-preview-pane
golden-ratio
use-package
guide-key
ivy
swiper
counsel
dired-details
)
)
; activate all the packages (in particular autoloads)
(setq package-enable-at-startup nil) (package-initialize)
(message "packages initialized")
; fetch the list of packages available
(unless package-archive-contents
(package-refresh-contents))
(message "fetch packages")
; install the missing packages
(dolist (package package-list)
(message ">> load %s" package)
(unless (package-installed-p package)
(package-install package)
)
)
(message "done with loading pkgs")
;; Setup environment variables from the user's shell.
;; (when is-mac
;; (require 'exec-path-from-shell)
;; (exec-path-from-shell-initialize))
(setq abbrev-file-name ;; tell emacs where to read abbrev
"~/.emacs.d/abbrev_defs") ;; definitions from...
(setq save-abbrevs t) ;; save abbrevs when files are saved
;; you will be asked before the abbreviations are saved
(cond (( >= emacs-major-version 24)
;; (message "load solarized-light") ;zenburn
(message "load zenburn") ;zenburn
;; (load-theme 'solarized-light t)
(load-theme 'zenburn t)
(if (member "Monaco" (font-family-list))
(set-face-attribute
'default nil :font "Monaco 18")
(message "set Monaco")
)
)
);Version 24
;(defun on-after-init ()
; (unless (display-graphic-p (selected-frame))
; (set-face-background 'default "unspecified-bg" (selected-frame))))
;; (add-hook 'window-setup-hook 'on-after-init)
;; (require 'helm-git-grep) ;; Not necessary if installed by package.el
;; (global-set-key (kbd "C-c n") 'helm-git-grep)
;; ;; Invoke `helm-git-grep' from isearch.
;; (define-key isearch-mode-map (kbd "C-c n") 'helm-git-grep-from-isearch)
;; ;; Invoke `helm-git-grep' from other helm.
;; (eval-after-load 'helm
;; '(define-key helm-map (kbd "C-c n") 'helm-git-grep-from-helm))
;; ;; Keep emacs Custom-settings in separate file
;; (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;; (load custom-file)
;; Set up appearance early
(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.
'(ag-executable "/usr/local/bin/ag")
'(c-basic-offset 6)
'(c-default-style (quote ((c-mode . "stroustrup") (c++-mode . "stroustrup"))))
'(ecb-options-version "2.40")
'(org-agenda-ndays 7)
'(org-agenda-show-all-dates t)
'(org-agenda-skip-deadline-if-done t)
'(org-agenda-skip-scheduled-if-done t)
'(org-agenda-start-on-weekday nil)
'(org-deadline-warning-days 14)
'(org-display-custom-times t)
'(org-fast-tag-selection-single-key (quote expert))
'(org-reverse-note-order t)
'(org-time-stamp-custom-formats (quote ("<%d/%m/%Y %a>" . "<%d/%m/%Y %a [%H:%M]>")))
'(package-selected-packages
(quote
(powerline zenburn-theme use-package undo-tree solarized-theme sml-modeline org-journal org-fstree multiple-cursors magit latex-preview-pane ido-vertical-mode hlinum highlight-indentation guide-key golden-ratio flycheck exec-path-from-shell dired-details diminish counsel color-theme browse-kill-ring autopair auto-complete auctex-latexmk)))
'(python-indent-guess-indent-offset nil)
'(sml/battery-format " [ %p ] ")
'(sml/show-client t))
(message "load packages")
;; Automatic resizing of Emacs windows to the golden ratio
;(require 'golden-ratio)
;(golden-ratio-mode 1)
(use-package golden-ratio
;; Loads after 2 second of idle time.
:defer 4
:config
(setq golden-ratio-auto-scale t)
)
;; -------------------- require
;(require 'cl)
;; (autoload 'yasnippet "yasnippet" "load yasnippet" t)
;(require 'yasnippet)
;;(require 'flycheck)
;(yas/initialize)
;(yas/load-directory "~/.emacs.d/snippets")
;; (autoload 'flycheck "flycheck" "load flycheck" t)
;(autoload 'multiple-cursors "multiple-cursors" "load multiple-cursors" t)
;(require 'multiple-cursors)
(use-package multiple-cursors
;; Loads after 2 second of idle time.
:defer 2
:config
(global-set-key (kbd "C-c z") 'mc/edit-lines)
(global-set-key (kbd "C-c i") 'mc/insert-numbers)
(global-set-key (kbd "C-c C-n") 'mc/mark-next-like-this)
(global-set-key (kbd "C-c C-p") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-s") 'mc/mark-all-like-this)
)
;; (require 'semantic/ia)
;(require 'xcscope)
(use-package paren
;; Loads after 2 second of idle time.
:defer 2
:config
(show-paren-mode t)
)
(require 'highlight-indentation) ;; visual guides for indentation
(require 'autopair)
;; (require 'ob-plantuml)
;(require 'linum)
;(require 'server)
;(require 'nav)
;(require 'recentf)
(use-package recentf
;; Loads after 2 second of idle time.
:defer 2
:config
(setq recentf-exclude
(append recentf-exclude
'("~$"
"\\.emacs.d*")))
(setq
recentf-max-saved-items 30
recentf-max-menu-items 15) ;; max 15 in menu
)
;;(require 'flymake-cursor)
;; uniquify: unique buffer names
;(require 'uniquify) ;; make buffer names more unique
;; (require 'org-alert)
;; (setq alert-default-style 'libnotify)
(require 'setup-electric)
;(autoload 'setup-magit "setup-magit" "load magit")
;(require 'setup-org-mode)
(use-package setup-org-mode
:defer 2)
(use-package setup-magit
:defer 4)
;(require 'setup-helm)
;;(require 'flymake-setup)
;(require 'setup-hlinum)
;(require 'setup-python)
;(require 'setup-cc)
(require 'setup-ido)
;(require 'org-inlinetask)
;(require 'setup-tex)
(use-package setup-tex
:defer 3)
;---------------- load setups ----------------------------
(message "load my setups")
;; (autoload 'setup-helm "setup-helm" "load helm")
;; overwrite selected text
(delete-selection-mode t)
;; When popping the mark, continue popping until the cursor
;; actually moves
;(defadvice pop-to-mark-command (around ensure-new-position activate)
; (let ((p (point)))
; (dotimes (i 10)
; (when (= p (point)) ad-do-it))))
(setq set-mark-command-repeat-pop t)
;; http://endlessparentheses.com/new-in-emacs-25-1-have-prettify-symbols-mode-reveal-the-symbol-at-point.html
(setq prettify-symbols-unprettify-at-point 'right-edge)
(message "setups loaded")
;(cscope-setup)
;;setup-electric
(package-initialize)
;----------------------------
(autopair-global-mode) ;; to enable in all buffers
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)
(next-line)))
;; (global-set-key "\C-c\C-c" 'comment-region)
(defun comment-region-lines (beg end &optional arg)
"Like `comment-region', but comment/uncomment whole lines."
(interactive "*r\nP")
(if (> beg end) (let (mid) (setq mid beg beg end end mid)))
(let ((bol (save-excursion (goto-char beg) (line-beginning-position)))
(eol (save-excursion (goto-char end) (line-end-position))))
(comment-region bol end arg)))
(global-set-key (kbd "C-c ;") 'comment-or-uncomment-region-or-line)
;; (global-set-key (kbd "M-;") 'comment-region-lines)
;; after copy Ctrl+c in X11 apps, you can paste by `yank' in emacs
(setq x-select-enable-clipboard t)
;; after mouse selection in X11, you can paste by `yank' in emacs
(setq x-select-enable-primary t)
(global-auto-revert-mode t)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
;(global-set-key "\C-x\C-c" 'kill-emacs) ;; STRANGE
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;; ;;-------------------------- Macros
(defvar server-buffer-clients)
(when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
(server-start)
(defun fp-kill-server-with-buffer-routine ()
(and server-buffer-clients (server-done)))
(add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
(setq flymake-gui-warnings-enabled nil)
(setq
uniquify-buffer-name-style 'post-forward
uniquify-separator ":"
uniquify-after-kill-buffer-p t
uniquify-ignore-buffers-re "^\\*")
;; Emacs server
(use-package server
;; Loads after 3 second of idle time.
:defer 2
:config
(unless (server-running-p)
(server-start))
)
;; (unless (server-running-p)
;; (server-start))
;; define function to shutdown emacs server instance
(defun server-shutdown ()
"Save buffers, Quit, and Shutdown (kill) server."
(interactive)
(save-some-buffers)
(kill-emacs)
)
;; ;; get rid of `find-file-read-only' and replace it with something
;; ;; more useful.
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
;; ;; enable recent files mode.
;; (nav-disable-overeager-window-splitting)
;; https://github.com/magnars/.emacs.d/blob/master/init.el
;; (require 'fill-column-indicator)
;; (setq fci-rule-color "white")
;; Browse kill ring
(require 'browse-kill-ring)
(setq browse-kill-ring-quit-action 'save-and-restore)
(setq browse-kill-ring-highlight-current-entry t)
(global-set-key "\C-cy" 'browse-kill-ring)
;(global-linum-mode 1)
(defun nolinum ()
(global-linum-mode 0)
)
(add-hook 'org-mode-hook 'nolinum)
; todo if necessary
(setq ical-pull-list `("https://www.google.com/calendar/..../basic.ics"))
(defun aj-toggle-fold ()
"Toggle fold all lines larger than indentation on current line."
(interactive)
(let ((col 1))
(save-excursion
(back-to-indentation)
(setq col (+ 1 (current-column)))
(set-selective-display
(if selective-display nil (or col 1))))))
(global-set-key [(M C i)] 'aj-toggle-fold)
(setq ansi-color-for-comint-mode t)
;; (setq flyspell-make t)
;(setq flyspell-mode 0)
;(add-hook 'text-mode-hook 'flyspell-mode) ;
;(add-hook 'prog-mode-hook 'flyspell-prog-mode)
;; ;; KEYBINDINGS
(global-set-key "\C-cg" 'goto-line)
;(global-set-key [f4] 'speedbar-get-focus)
;(global-set-key [f4] 'speedbar-get-focus)
(global-set-key (kbd "\C-cm") 'magit-status) ;; ...git mode
(global-set-key (kbd "<f4>") 'nav-toggle)
(global-set-key [f5] 'buffer-menu)
(global-set-key [end] 'end-of-line)
(global-set-key [home] 'beginning-of-line)
(global-set-key [next] 'pager-page-down)
(global-set-key [prior] 'pager-page-up)
;; Page down/up move the point, not the screen.
;; In practice, this means that they can move the
;; point to the beginning or end of the buffer.
(global-set-key [next]
(lambda () (interactive)
(condition-case nil (scroll-up)
(end-of-buffer (goto-char (point-max))))))
(global-set-key [prior]
(lambda () (interactive)
(condition-case nil (scroll-down)
(beginning-of-buffer (goto-char (point-min))))))
(defun toggle-fullscreen (&optional f)
(interactive)
(let ((current-value (frame-parameter nil 'fullscreen)))
(set-frame-parameter nil 'fullscreen
(if (equal 'fullboth current-value)
(if (boundp 'old-fullscreen) old-fullscreen nil)
(progn (setq old-fullscreen current-value)
'fullboth)))))
(global-set-key [f11] 'toggle-fullscreen)
(use-package windmove
:bind
(("C-x <right>" . windmove-right)
("C-x <left>" . windmove-left)
("C-x <up>" . windmove-up)
("C-x <down>" . windmove-down)
))
(use-package guide-key
:defer 2
:diminish guide-key-mode
:config
(progn
(setq guide-key/guide-key-sequence '("C-x r" "C-x 4" "C-c"))
(guide-key-mode 1))) ; Enable guide-key-mode
(use-package undo-tree
:diminish undo-tree-mode
:config
(progn
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)))
;; ;; DICCTIONARIES
(let ((langs '("american" "francais" "german")))
(setq lang-ring (make-ring (length langs)))
(dolist (elem langs) (ring-insert lang-ring elem)))
(defun cycle-ispell-languages ()
(interactive)
(let ((lang (ring-ref lang-ring -1)))
(ring-insert lang-ring lang)
(ispell-change-dictionary lang)))
(global-set-key [f6] 'cycle-ispell-languages)
(global-set-key (kbd "<f8>") 'ispell-word)
(global-set-key (kbd "C-<f8>") 'flyspell-mode)
(global-set-key (kbd "C-<f9>") 'reftex-mode)
;;---------------------- ispell
(define-key ctl-x-map "\C-i"
#'endless/ispell-word-then-abbrev)
(defun endless/simple-get-word ()
(car-safe (save-excursion (ispell-get-word nil))))
(defun endless/ispell-word-then-abbrev (p)
"Call `ispell-word', then create an abbrev for it.
With prefix P, create local abbrev. Otherwise it will
be global.
If there's nothing wrong with the word at point, keep
looking for a typo until the beginning of buffer. You can
skip typos you don't want to fix with `SPC', and you can
abort completely with `C-g'."
(interactive "P")
(let (bef aft)
(save-excursion
(while (if (setq bef (endless/simple-get-word))
;; Word was corrected or used quit.
(if (ispell-word nil 'quiet)
nil ; End the loop.
;; Also end if we reach `bob'.
(not (bobp)))
;; If there's no word at point, keep looking
;; until `bob'.
(not (bobp)))
(backward-word)
(backward-char))
(setq aft (endless/simple-get-word)))
(if (and aft bef (not (equal aft bef)))
(let ((aft (downcase aft))
(bef (downcase bef)))
(define-abbrev
(if p local-abbrev-table global-abbrev-table)
bef aft)
(message "\"%s\" now expands to \"%s\" %sally"
bef aft (if p "loc" "glob")))
(user-error "No typo at or before point"))))
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
;;--------------------------------------- PAREN
(setq show-paren-style 'parenthesis) ; highlight just brackets
;(setq show-paren-style 'expression) ; highlight entire bracket expression
;; ;;--------------------------------- ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)
(autoload 'ibuffer "ibuffer" "List buffers." t)
(setq ibuffer-default-sorting-mode 'major-mode)
(setq ibuffer-expert t)
(setq ibuffer-show-empty-filter-groups nil)
(use-package my-core-settings)
(use-package setup-ivy
:defer 1
)
;; ;; ;; dired
(setq dired-dwim-target t)
(use-package dired-details
:defer 2
:config
(setq-default dired-details-hidden-string "--- ")
(dired-details-install)
;; Move files between split panes
(setq dired-dwim-target t)
)
;; (require 'ls-lisp)
;; (setq dired-listing-switches "-alhG")
;; (setq ls-lisp-use-insert-directory-program nil)
;; (setq ls-lisp-ignore-case t)
;; (setq ls-lisp-use-string-collate nil)
;; ;; customise the appearance of the listing
;; (setq ls-lisp-verbosity '(links uid))
;; (setq ls-lisp-format-time-list '("%b %e %H:%M" "%b %e %Y"))
;; (setq ls-lisp-use-localized-time-format t)
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
; -------------------- DONE -------------------
;; Use a hook so the message doesn't get clobbered by other messages.
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
(message "DONE")
(provide 'init)
;;; init.el ends here
(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.
'(show-paren-match ((((class color) (background light)) (:background "blue")))))