From b39f215ff1f102bb3195e2e9abb1893c33c8ae41 Mon Sep 17 00:00:00 2001 From: Wolfgang Wiedmeyer Date: Wed, 28 Oct 2015 14:08:10 +0100 Subject: add basic emacs config --- emacs | 307 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 emacs diff --git a/emacs b/emacs new file mode 100644 index 0000000..6670e40 --- /dev/null +++ b/emacs @@ -0,0 +1,307 @@ +;; el-get setup +(add-to-list 'load-path "~/.emacs.d/el-get/el-get") +(require 'el-get) + +;; (unless (require 'el-get nil 'noerror) +;; (with-current-buffer +;; (url-retrieve-synchronously +;; "https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el") +;; (goto-char (point-max)) +;; (eval-print-last-sexp))) + +;; no own recipes so far +;;(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes") +(el-get 'sync) + +;; save installed packages +(setq my-packages + '(color-theme color-theme-sanityinc-tomorrow el-get undo-tree volatile-highlights yasnippet auctex mu4e)) +(el-get 'sync my-packages) + +;; perl disable autoindent +(defun perl-mode-disable-auto-indent () + (local-unset-key (kbd "{")) + (local-unset-key (kbd "}")) + (local-unset-key (kbd ";")) + (local-unset-key (kbd ":"))) + +(add-hook 'perl-mode-hook 'perl-mode-disable-auto-indent) + + +(require 'octave) + +(add-to-list 'auto-mode-alist '("\\.m$" . octave-mode)) + +;; Sets the syntax highlighting to the maximum amount of colorization. +(setq font-lock-maximum-decoration t) + +;; spaces instead of tabs +(setq-default indent-tabs-mode nil) + +;; show corresponding parentheses +(require 'paren) +(setq show-paren-style 'parenthesis) +(show-paren-mode +1) + +; turn on line numbers +(global-linum-mode t) + +(scroll-bar-mode -1) +(setq inhibit-startup-message t) + +;; move to different window with arrow keys +(global-set-key (kbd "C-x ") 'windmove-up) +(global-set-key (kbd "C-x ") 'windmove-down) +(global-set-key (kbd "C-x ") 'windmove-right) +(global-set-key (kbd "C-x ") 'windmove-left) + +;; no toolbar +(tool-bar-mode -1) + +;; Turn Semantic on + (semantic-mode 1) + ;; Try to make completions when not typing + (global-semantic-idle-completions-mode 1) + ;; Use the Semantic speedbar additions + (add-hook 'speedbar-load-hook (lambda () (require 'semantic/sb))) + +;; auto-complete +;; (require 'auto-complete) +;; (add-to-list 'ac-dictionary-directories "/usr/share/auto-complete/dict/") +;; (require 'auto-complete-config) +;; (ac-config-default) + +;; recent files +(require 'recentf) +(recentf-mode 1) +(setq recentf-max-menu-items 25) +(global-set-key "\C-x\ \C-r" 'recentf-open-files) + +;; enable better buffer switching +(require 'ido) +(ido-mode 'buffers) ;; only use this line to turn off ido for file names! +(setq ido-ignore-buffers '("^ " "*Completions*" "*Shell Command Output*" + "*Messages*" "Async Shell Command")) + +(icomplete-mode 99) + +;; for mail +(require 'mu4e) + +;; gpg +(add-hook 'mu4e-compose-mode-hook 'epa-mail-mode) +(add-hook 'mu4e-view-mode-hook 'epa-mail-mode) + +;; in order to read send mail +(setq mml2015-encrypt-to-self t) +(setq mml2015-sign-with-sender t) + +;; default +(setq mu4e-maildir (expand-file-name "~/Maildir")) + +;; don't save message to Sent Messages, GMail/IMAP will take care of this +;;(setq mu4e-sent-messages-behavior 'delete) + +;; allow for updating mail using 'U' in the main view: +(setq mu4e-get-mail-command "offlineimap -a wolfi,postmaster,postmaster_vps" + mu4e-update-interval 300) + +;; don't keep message buffers around +(setq message-kill-buffer-on-exit t) + +;; the headers to show in the headers list -- a pair of a field +;; and its width, with `nil' meaning 'unlimited' +;; (better only use that for the last field. +(setq mu4e-headers-fields + '( (:human-date . 12) + (:flags . 6) + (:from-or-to . 22) + (:subject . nil))) + +;; Don't prompt for applying of marks, just apply +(setq mu4e-headers-leave-behavior 'apply) + +;; sending mail -- replace USERNAME with your gmail username +;; also, make sure the gnutls command line utils are installed +;; package 'gnutls-bin' in Debian/Ubuntu, 'gnutls' in Archlinux. + +(require 'smtpmail) +;;(require 'starttls) + +;; for cert pinning +(if (fboundp 'gnutls-available-p) + (fmakunbound 'gnutls-available-p)) + +;; function for choosing account +(defun my-mu4e-set-account () + "Set the account for composing a message." + (let* ((account + (if mu4e-compose-parent-message + (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir))) + (string-match "/\\(.*?\\)/" maildir) + (match-string 1 maildir)) + (completing-read (format "Compose with account: (%s) " + (mapconcat #'(lambda (var) (car var)) + my-mu4e-account-alist "/")) + (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist) + nil t nil nil (caar my-mu4e-account-alist)))) + (account-vars (cdr (assoc account my-mu4e-account-alist)))) + (if account-vars + (mapc #'(lambda (var) + (set (car var) (cadr var))) + account-vars) + (error "No email account found")))) +(add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account) + +(autoload 'footnote-mode "footnote" nil t) +;;(add-hook 'mu4e-compose-mode-hook 'footnode-mode) +(add-hook 'message-mode-hook 'footnote-mode) + +;; add flagged filter +(add-to-list 'mu4e-bookmarks + '("flag:flagged" "starred" ?s)) + +;; further general options for mail +;; fetches images without asking? +;;(setq mu4e-view-show-images t) +;; (when (fboundp 'imagemagick-register-types) +;; (imagemagick-register-types)) + +;; converting destroys umlauts and new shr2text not yet available +;;(setq mu4e-html2text-command "html2text -utf8 -width 72") +;;(require 'mu4e-contrib) +;;(setq mu4e-html2text-command 'mu4e-shr2text) + +(defun my-render-html-message () + (let ((dom (libxml-parse-html-region (point-min) (point-max)))) + (erase-buffer) + (shr-insert-document dom) + (goto-char (point-min)))) + +(setq mu4e-html2text-command 'my-render-html-message) +;;(setq mu4e-html2text-command "w3m -dump -T text/html") +(setq mu4e-view-prefer-html t) +(setq mu4e-use-fancy-chars t) +(setq mail-user-agent 'mu4e-user-agent) +(setq mu4e-hide-index-messages t) + +;; use dired to attach multiple files +(require 'gnus-dired) +;; make the `gnus-dired-mail-buffers' function also work on +;; message-mode derived modes, such as mu4e-compose-mode +(defun gnus-dired-mail-buffers () + "Return a list of active message buffers." + (let (buffers) + (save-current-buffer + (dolist (buffer (buffer-list t)) + (set-buffer buffer) + (when (and (derived-mode-p 'message-mode) + (null message-sent-message-via)) + (push (buffer-name buffer) buffers)))) + (nreverse buffers))) + +(setq gnus-dired-mail-mode 'mu4e-user-agent) +(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) + +;; spell check +(add-hook 'mu4e-compose-mode-hook + (defun my-do-compose-stuff () + "My settings for message composition." + (set-fill-column 72) + (flyspell-mode))) + +;; cache keys +(setq epa-file-cache-passphrase-for-symmetric-encryption t) + +(defun print-vevent (msg attachnum) + "nicely print vevent attachment." + (concat "vcp.pl -f" msg attachnum)) + +;; defining 'c' as the shortcut +(add-to-list 'mu4e-view-attachment-actions + '("cprint vevent" . print-vevent) t) + + +;; change dictionaries +(defun fd-switch-dictionary() + (interactive) + (let* ((dic ispell-current-dictionary) + (change (if (string= dic "deutsch8") "english" "deutsch8"))) + (ispell-change-dictionary change) + (message "Dictionary switched from %s to %s" dic change) + )) + +(global-set-key (kbd "") 'fd-switch-dictionary) + +;; start mu4e +(global-set-key (kbd "") 'mu4e) + +;; default save before compile +(setq compilation-ask-about-save nil) +;; scroll compilation buffer +;;(setq compilation-scroll-output t) + +;; compile shortcut +(global-set-key (kbd "") 'compile) + +;; I like M-g for goto-line +(global-set-key "\M-g" 'goto-line) + +;; open files as root +(require 'tramp) + +;; git +(require 'git) +(require 'git-blame) + +;; latex +(setq TeX-PDF-mode t) +(setq TeX-auto-save t) +(setq TeX-parse-self t) +(setq-default TeX-master nil) +(add-hook 'LaTeX-mode-hook 'visual-line-mode) +(add-hook 'LaTeX-mode-hook 'flyspell-mode) +(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) +(add-hook 'LaTeX-mode-hook 'turn-on-reftex) +(setq reftex-plug-into-AUCTeX t) + +;; m-tab is already reserved for flyspell +(add-hook 'LaTeX-mode-hook + (lambda() + (local-set-key [C-tab] 'TeX-complete-symbol))) + +;:; awesome from https://github.com/bendikro/emacs-conf/blob/master/setup/setup-latexmk.el +;:; Sets this as the default pdf view command +(defun setup-qpdfview() +;;(setq TeX-view-program-list '(("qpdfview" "qpdfview --instance emacsauxtex --unique \"\"%o\"#src:%(buffer-name):%n:0\""))) +(setq TeX-view-program-list '(("qpdfview" "qpdfview --instance emacsauxtex --unique \"\"%o\"#src:%(default-dir)%(buffer-name):%n:0\""))) +(setq TeX-view-program-selection '((output-pdf "qpdfview"))) +) +(add-hook 'LaTeX-mode-hook 'setup-qpdfview) + +;; load color-theme-sanityinc-tomorrow +(require 'color-theme-sanityinc-tomorrow) + +(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. + '(custom-enabled-themes (quote (sanityinc-tomorrow-night))) + '(custom-safe-themes + (quote + ("06f0b439b62164c6f8f84fdda32b62fb50b6d00e8b01c2208e55543a6337433a" default))) + '(footnote-section-tag "") + '(safe-local-variable-values + (quote + ((eval when + (and + (buffer-file-name) + (string-match-p "\\.h\\'" + (buffer-file-name)) + (not + (string-match-p "/gnulib/" + (buffer-file-name)))) + (c++-mode) + (c-set-style "gnu")))))) + -- cgit v1.1