(add-to-list 'load-path (expand-file-name "~/.emacs.d/init"))
(add-to-list 'load-path (expand-file-name "~/.emacs.d/site-lisp"))
(add-to-list 'load-path (expand-file-name "~/.emacs.d/site-lisp/themes"))
(add-to-list 'custom-theme-load-path
(expand-file-name "~/.emacs.d/site-lisp/themes/"))
(defvar djcb-current-theme nil "The current theme")
(defconst djcb-cache-dir (expand-file-name "~/.emacs.d/cache/")
"dir with volatile data")
(defconst djcb-data-dir (expand-file-name "~/.emacs.d/data/")
"dir for user data")
(menu-bar-mode -1) (display-time-mode -1) (tool-bar-mode -1)
(blink-cursor-mode 0)
(setq
next-line-add-newlines nil require-final-newline t)
(file-name-shadow-mode t) (setq use-file-dialog nil)
(setq-default
cursor-type '(hbar . 2) cursor-in-non-selected-windows 'hollow)
(scroll-bar-mode -1)
(set-fringe-mode '(1 . 1)) (delete-selection-mode t)
(setq search-highlight t query-replace-highlight t) (fset 'yes-or-no-p 'y-or-n-p)
(setq
confirm-nonexistent-file-or-buffer nil completion-ignore-case t read-file-name-completion-ignore-case t)
(setq inhibit-startup-message t inhibit-startup-echo-area-message t initial-scratch-message
";; I am your editor. Please describe your program.\n")
(setenv "XMODIFIERS" "@im=none")
(setenv "GTK_IM_MODULE" "xim")
(put 'downcase-region 'disabled nil)
(global-set-key (kbd "<f12>") (lambda()(interactive) (switch-to-buffer (get-buffer-create "*scratch*"))))
(global-set-key (kbd "<C-prior>") (lambda()(interactive)(goto-char(point-min))))
(global-set-key (kbd "<C-next>") (lambda()(interactive)(goto-char(point-max))))
(global-set-key (kbd "C-<f7>") 'compile) (global-set-key (kbd "C-<f8>") 'comment-or-uncomment-region)
(setq
enable-recursive-minibuffers nil max-mini-window-height 3 minibuffer-scroll-window t resize-mini-windows t)
(icomplete-mode t) (setq
icomplete-prospects-height 2 icomplete-compute-delay 0)
(setq frame-title-format '( "%b" " [" (:eval mode-name) "]"))
(require 'djcb-modeline nil 'noerror)
(require 'hl-line)
(global-hl-line-mode nil)
(require 'paren)
(show-paren-mode t)
(setq show-paren-style 'parentheses)
(cua-selection-mode 1)
(global-set-key (kbd "M-/") 'hippie-expand)
(setq abbrev-file-name (concat djcb-data-dir "abbrev_defs")) (abbrev-mode t) (setq default-abbrev-mode t save-abbrevs t) (when (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file)) (require 'djcb-abbrevs nil 'noerror)
(defun djcb-opacity-modify (&optional dec)
"modify the transparency of the emacs frame; if DEC i t,
decrease the transparency, otherwise increase it in 10%-steps"
(let* ((alpha-or-nil (frame-parameter nil 'alpha)) (oldalpha (if alpha-or-nil alpha-or-nil 100))
(newalpha (if dec (- oldalpha 5) (+ oldalpha 5))))
(when (and (>= newalpha frame-alpha-lower-limit) (<= newalpha 100))
(modify-frame-parameters nil (list (cons 'alpha newalpha))))))
(global-set-key (kbd "C-8") '(lambda()(interactive)(djcb-opacity-modify)))
(global-set-key (kbd "C-9") '(lambda()(interactive)(djcb-opacity-modify t)))
(global-set-key (kbd "C-0")
'(lambda()(interactive) (modify-frame-parameters nil `((alpha . 100)))))
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(setq
bookmark-default-file (concat djcb-cache-dir "bookmarks")
bookmark-save-flag 1)
(setq package-archives
'(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("sunrise" . "http://joseito.republika.pl/sunrise-commander/")
("marmalade" . "http://marmalade-repo.org/packages/")
))
(setq package-user-dir (expand-file-name "~/.emacs.d/elpa"))
(package-initialize)
(global-set-key (kbd "C-c p")
(lambda () (interactive)
(let ((buf (get-buffer "*Packages*")))
(if buf
(switch-to-buffer buf)
(package-list-packages)))))
(require 'djcb-ido)
(setq w3m-init-file (concat user-emacs-directory "init/djcb-w3m.el")
browse-url-browser-function (quote browse-url-generic)
browse-url-generic-program "firefox"
browse-url-generic-args '("-P" "default" "-new-tab")
url-configuration-directory (concat djcb-cache-dir "url"))
(when (require 'helm nil 'noerror)
(require 'helm-buffers)
(require 'helm-locate)
(require 'helm-bookmark)
(require 'helm-files)
(setq
helm-boring-buffer-regexp-list '("^diary$")
helm-boring-file-regexp-list
'("\\.git$" "\\.hg$" "\\.svn$" "^\\." "\\.$"
"\\.\\.$" "\\.Plo$" "\\.lo$" "_source.*"
"_8h.*" "\\.CVS$" "\\._darcs$" "\\.la$"
"\\.o$" "~$" "^#.*")
helm-buffer-max-length 20
helm-idle-delay 2.0
helm-find-files-show-icons t
helm-quick-update t
helm-candidate-number-limit 20
helm-use-standard-keys nil
helm-locate-case-fold-search t
helm-locate-command "locate -e -b %s -r %s")
(global-set-key (kbd "C-x b")
(lambda () (interactive)
(ignore-errors
(helm :prompt "Location:"
:sources '( helm-source-buffers-list
helm-source-locate
helm-source-bookmarks
helm-source-recentf
helm-source-files-in-current-dir))))))
(global-set-key (kbd "S-C-S") 'isearch-forward-regexp)
(global-set-key (kbd "S-C-R") 'isearch-backward-regexp)
(setq time-stamp-active t time-stamp-line-limit 10 time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") (add-hook 'write-file-hooks 'time-stamp)
(autoload 'magit-status "magit" "Magit status." t)
(global-set-key (kbd "C-<f6>") 'magit-status) (add-hook 'magit-log-edit-mode-hook
(lambda ()
(set-fill-column 72)))
(setq
dired-omit-files-p t
dired-omit-files "^\\.?#\\|^\\." dired-listing-switches "-l -a --dired --group-directories-first -h -G"
dired-no-confirm '(byte-compile chgrp chmod chown
copy delete load move symlink))
(require 'sunrise-commander nil 'noerror)
(add-hook 'dired-load-hook (lambda () (load "dired-x")))
(when (require 'ace-jump-mode nil 'noerror)
(define-key global-map (kbd "<M-return>") 'ace-jump-mode))
(when (load "auctex.el" nil t t)
(add-hook 'LaTeX-mode-hook
(lambda()
(add-to-list 'TeX-command-list
'("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")
(setq TeX-save-query nil)
(setq TeX-show-compilation t))))
(defun djcb-gtags-create-or-update ()
"Create or update the GNU-Global tag file"
(interactive
(if (zerop (call-process "global" nil nil nil "-p"))
(progn
(shell-command "global -u -q 2>/dev/null")
(message "Tagfile updated"))
(when (yes-or-no-p "Create tagfile?")
(let ((olddir default-directory)
(default-directory
(read-directory-name
"gtags: top of source tree:" default-directory)))
(shell-command "gtags -i -q 2>/dev/null")
(message "Created tagfile"))))))
(add-hook 'prog-mode-hook
(lambda ()
(when (require 'ggtags nil 'noerror) (ggtags-mode t)
(local-set-key (kbd "C-c .") 'ggtags-grep)
(local-set-key (kbd "M-,") 'ggtags-find-reference)
(when (fboundp 'djcb-gtags-create-or-update)
(djcb-gtags-create-or-update))) (when (require 'rainbow-delimiters nil 'noerror)
(rainbow-delimiters-mode))
(defvar djcb-yas-loaded nil)
(when (require 'yasnippet nil 'noerror)
(unless djcb-yas-loaded
(yas-reload-all)
(setq djcb-yas-loaded t))
(yas-minor-mode-on))
(require 'gtk-doc nil 'noerror)
(setq linum-format " %04d ")
(local-set-key (kbd "RET") 'newline-and-indent)))
(defconst djcb-c-style
'("linux"))
(c-add-style "djcb-c-style" djcb-c-style)
(defconst djcb-c++-style
'("djcb-c-style"
(c-offsets-alist . ((innamespace . [0])))))
(c-add-style "djcb-c++-style" djcb-c++-style)
(when (require 'ansi-color nil 'noerror)
(defun stante-colorize-compilation-buffer ()
"Colorize a compilation mode buffer.
Taken from http://stackoverflow.com/a/3072831/355252."
(interactive)
(when (eq major-mode 'compilation-mode)
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
(add-hook 'compilation-filter-hook
#'stante-colorize-compilation-buffer)))
(which-function-mode)
(setq-default header-line-format
'((which-func-mode ("" which-func-format " "))))
(setq mode-line-misc-info
(assq-delete-all 'which-func-mode mode-line-misc-info))
(defun djcb-c-mode ()
"My c-mode settings"
(font-lock-add-keywords nil '(("\\<\\(FIXME\\|TODO\\|XXX+\\|BUG\\|NOTE\\)" 1 font-lock-warning-face prepend))) (font-lock-add-keywords nil '(("\\<\\(__FUNCTION__\\|__LINE__\\)" 1 font-lock-preprocessor-face prepend)))
(font-lock-add-keywords nil
'(("\\<\\(g_debug\\|g_warning\\|g_message\\|g_error\\)"
1 font-lock-builtin-face prepend)))
(font-lock-add-keywords nil
'(("\\<\\(g_return_if_fail\\|g_return_val_if_fail\\)"
1 font-lock-builtin-face prepend))) (font-lock-add-keywords nil
'(("\\<\\(g_return_if_reached\\|g_return_val_if_reached\\)"
1 font-lock-builtin-face prepend)))
(font-lock-add-keywords nil
'(("\\<\\(TRUE\\|FALSE\\|G_SOURCE_CONTINUE\\|G_SOURCE_REMOVE\\)"
1 font-lock-constant-face prepend)))
(setq
c-auto-newline nil c-syntactic-indentation t c-hungry-delete-key t c-indent-tabs-mode nil c-tab-always-indent t
backward-delete-function nil)
(when (require 'doxymacs nil 'noerror) (doxymacs-mode t) (doxymacs-font-lock))
(add-to-list 'c-cleanup-list 'compact-empty-funcall)
(add-to-list 'c-cleanup-list 'brace-else-brace)
(add-to-list 'c-cleanup-list 'brace-elseif-brace)
(add-to-list 'c-cleanup-list 'brace-catch-brace)
(add-to-list 'c-cleanup-list 'defun-close-semi)
(add-to-list 'c-cleanup-list 'list-close-comma)
(add-to-list 'c-cleanup-list 'scope-operator)
(local-set-key (kbd "RET") 'c-context-line-break)
(local-set-key (kbd "C-c <up>") 'previous-error)
(local-set-key (kbd "C-c <down>") 'next-error)
(local-set-key (kbd "C-c o") 'ff-find-other-file)
(local-set-key (kbd "C-h C-g") 'gtk-lookup-symbol)
(local-set-key (kbd "<M-return>") 'align-current)
(setq whitespace-line-column 80))
(add-hook 'c-mode-hook
(lambda ()
(c-set-style "djcb-c-style")))
(add-hook 'c++-mode-hook
(lambda ()
(c-set-style "djcb-c++-style")
(setq whitespace-line-column 100)))
(add-hook 'c-mode-common-hook 'djcb-c-mode)
(add-hook 'emacs-lisp-mode-hook
(lambda ()
"My settings for emacs-lisp mode."
(setq emacs-lisp-docstring-fill-column 67)
(setq mode-name "el")
(local-set-key (kbd "C-<f7>") '(lambda()(interactive)
(let ((debug-on-error t))
(eval-buffer)
(message "buffer evaluated"))))
(setq lisp-indent-offset 2) (font-lock-add-keywords nil '(("^[^\n]\\{100\\}\\(.*\\)$"
1 font-lock-warning-face prepend)))
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|XXX+\\|BUG\\|NOTE\\)"
1 font-lock-warning-face prepend)))
(font-lock-add-keywords nil
'(("\\<\\(add-hook\\|setq\\)"
1 font-lock-keyword-face prepend)))))
(add-hook 'scheme-mode-hook
(lambda ()
(interactive)
(when (require 'geiser-install nil 'noerror)
(setq
geiser-impl-installed-implementations '(guile)
geiser-active-implementations '(guile)
geiser-guile-init-file "~/.guile"
geiser-repl-history-filename
(concat djcb-cache-dir "geiser-history")))
(require 'quack nil 'noerror)
(geiser-mode)))
(defun djcb-paredit ()
(when (require 'paredit nil 'noerror)
(paredit-mode t)))
(add-hook 'lisp-mode-hook 'djcb-paredit)
(add-hook 'scheme-mode-hook 'djcb-paredit)
(add-hook 'makefile-mode-hook
(lambda()
(setq whitespace-style '(face trailing tabs))
(whitespace-mode)))
(setq
compilation-scroll-output 'first-error compilation-read-command nil compilation-window-height 12 compilation-auto-jump-to-first-error t compilation-auto-jump-to-next-error t)
(defun bury-compile-buffer-if-successful (buf str)
"Bury a compilation buffer if succeeded without warnings "
(if (and
(string-match "compilation" (buffer-name buf))
(string-match "finished" str)
(not (with-current-buffer buf
(save-excursion
(goto-char (point-min))
(search-forward "warning" nil t)))))
(run-with-timer 5 nil
(lambda (b)
(with-selected-window (get-buffer-window b)
(kill-buffer-and-window))) buf)))
(add-hook 'compilation-finish-functions 'bury-compile-buffer-if-successful)
(add-to-list 'command-line-functions
(lambda ()
(when (string= "--org" argi)
(require 'djcb-mu4e)
(require 'djcb-org)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "<f6>")
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(kmacro-exec-ring-item (quote ("aa" 0 "%d")) arg)))
(fset 'next-actions "\C-cacn")
(global-set-key (kbd "<f7>") 'next-actions)
(fset 'next-actions-not-at-home "\C-cacn/-h")
(global-set-key (kbd "<s-f7>") 'next-actions-not-at-home)
(fset 'todo "\C-cact")
(global-set-key (kbd "<S-f7>")'todo)
(global-set-key (kbd "<f8>") 'org-capture) (global-set-key (kbd "<f5>") 'mu4e)
(when (require 'edit-server nil t)
(edit-server-start))
(server-start)
(load-theme 'deeper-blue t nil)
(mu4e))))
(add-to-list 'command-line-functions
(lambda ()
(when (string= "--erc" argi)
(require 'djcb-sauron)
(require 'djcb-erc)
(global-set-key (kbd "C-c s") 'sauron-toggle-hide-show)
(global-set-key (kbd "C-c t") 'sauron-clear)
(load-theme 'tango-dark t nil)
(djcb-irc))))
(when (require 'dream-theme nil 'noerror)
(load-theme 'dream t nil))