(setq user-full-name "Pablo Rauzy"
user-mail-address (concat "r@" "uzy" ".me"))
(setq x-super-keysym 'alt)
(setq frame-title-format
(concat "%b - " invocation-name "@" system-name))
(setq home-emacs-dir (concat (getenv "HOME") "/.emacs.d/"))
(setq local-emacs-dir (concat (getenv "HOME") "/local/share/emacs/site-lisp/"))
(setq my-load-path (list home-emacs-dir local-emacs-dir
(concat local-emacs-dir "mu4e/")))
(setq load-path (append my-load-path load-path))
(set-language-environment 'utf-8)
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-input-method nil)
(blink-cursor-mode -1)
(setq x-stretch-cursor t)
(delete-selection-mode t)
(setq default-fill-column 79)
(setq sentence-end-double-space nil)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-;") 'kill-whole-line)
(global-set-key (kbd "C-c s") 'replace-string)
(global-set-key (kbd "C-c r") 'replace-regexp)
(global-set-key (kbd "C-x r a") 'string-insert-rectangle)
(load "rect-missing-features")
(global-set-key (kbd "C-x r z") 'string-insert-after-rectangle)
(global-set-key (kbd "C-x r e") 'string-insert-rectangle-eol)
(global-set-key (kbd "C-c w") 'delete-trailing-whitespace)
(global-set-key (kbd "C-c a") 'align-entire)
(global-set-key (kbd "C-c A") 'align-string)
(global-set-key (kbd "C-c f") 'font-lock-fontify-buffer)
(global-set-key (kbd "C-c b") 'revert-buffer)
(global-set-key (kbd "C-c h H") 'hs-hide-all)
(global-set-key (kbd "C-c h S") 'hs-show-all)
(global-set-key (kbd "C-c h h") 'hs-hide-block)
(global-set-key (kbd "C-c h s") 'hs-show-block)
(global-set-key (kbd "C-c h t") 'hs-toggle-hiding)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(autoload 'twitter-get-friends-timeline "twitter" nil t)
(autoload 'twitter-status-edit "twitter" nil t)
(setq twitter-username "p4bl0")
(add-hook 'twitter-timeline-view-mode-hook
(lambda ()
(set-face-foreground 'twitter-user-name-face "#dddddd")
(set-face-background 'twitter-user-name-face "#1D73C8")
(set-face-foreground 'twitter-time-stamp-face "#dddddd")
(set-face-background 'twitter-time-stamp-face "#1D73C8")))
(global-set-key (kbd "C-x t t") 'twitter-get-friends-timeline)
(global-set-key (kbd "C-x t s") 'twitter-status-edit)
(require 'identica-mode)
(setq identica-username "p4bl0"
identica-status-format "%i %s (%S), %@, from %f:\n %t"
identica-timer-interval 120)
(global-set-key (kbd "C-x t i") 'identica-mode)
(global-set-key (kbd "C-x t p") 'identica-update-status-interactive)
(require 'geiser-install)
(setq geiser-active-implementations '(racket)
geiser-repl-history-filename (concat home-emacs-dir "geiser-history")
geiser-mode-smart-tab-p t)
(defun jao-racket-help (file)
(w3m (url-unhex-string file)))
(setq tetris-score-file (concat home-emacs-dir "tetris"))
(setq default-major-mode 'text-mode)
(require 'rainbow-mode)
(require 'pretty-lambdada)
(pretty-lambda-mode t)
(add-hook 'css-mode-hook
(lambda ()
(font-lock-add-keywords nil
'((": *\\(#\\([0-9a-fA-F]\\{3\\}\\)\\{1,2\\}\\)" 1
font-lock-type-face)))))
(defun font-lock-fontify-numbers ()
"Use this function as a hook to fontify numbers as constant"
(font-lock-add-keywords nil
'(("\\b\\(0x[0-9a-fA-F]+\\)" 1 font-lock-constant-face) ("\\b\\(-?[0-9]+\\.[0-9]+\\(d\\|f\\)?\\)" 1
font-lock-constant-face) ("[\`^\(){\[,\+\\-\\*/\%><=\s-]\\(-?[0-9]+U?L?L?\\)" 1
font-lock-constant-face)))) (add-hook 'c-mode-hook 'font-lock-fontify-numbers)
(add-hook 'c++-mode-hook 'font-lock-fontify-numbers)
(add-hook 'scheme-mode-hook 'font-lock-fontify-numbers)
(add-hook 'lisp-mode-hook 'font-lock-fontify-numbers)
(add-hook 'lisp-interaction-mode-hook 'font-lock-fontify-numbers)
(add-hook 'emacs-lisp-mode-hook 'font-lock-fontify-numbers)
(add-hook 'js-mode-hook 'font-lock-fontify-numbers)
(add-hook 'html-mode-hook 'font-lock-fontify-numbers)
(add-hook 'xml-mode-hook 'font-lock-fontify-numbers)
(add-hook 'css-mode-hook 'font-lock-fontify-numbers)
(add-hook 'perl-mode-hook 'font-lock-fontify-numbers)
(add-hook 'php-mode-hook 'font-lock-fontify-numbers)
(add-hook 'sh-mode-hook 'font-lock-fontify-numbers)
(if (>= emacs-major-version 23)
(set-default-font "DejaVu Sans Mono-8.5")) (global-font-lock-mode t)
(show-paren-mode t)
(transient-mark-mode t)
(set-face-background 'default "#333333") (set-face-foreground 'default "#cccccc") (set-face-background 'cursor "#ffaa00") (set-face-foreground 'cursor "#333333") (setq x-pointer-foreground-color "#aaaaaa") (set-face-background 'region "#33aaff")
(set-face-foreground 'region "#eeeeee")
(set-face-background 'show-paren-match-face "#666666")
(set-face-foreground 'show-paren-match-face "#ffffff")
(set-face-background 'show-paren-mismatch-face "#dd0000")
(set-face-foreground 'show-paren-mismatch-face "#333333")
(set-face-foreground 'font-lock-warning-face "#dd0000")
(set-face-foreground 'font-lock-preprocessor-face "#99cc33")
(set-face-foreground 'font-lock-constant-face "#dd00dd")
(set-face-foreground 'font-lock-comment-face "#888888")
(set-face-foreground 'font-lock-keyword-face "#dddd00")
(set-face-foreground 'font-lock-type-face "#ffaa00")
(set-face-foreground 'font-lock-function-name-face "#2277dd")
(set-face-foreground 'font-lock-string-face "#33aaff")
(set-face-foreground 'font-lock-variable-name-face "#00bb00")
(set-face-foreground 'highlight "#333333")
(set-face-background 'highlight "#dddd00")
(set-face-foreground 'isearch "#333333")
(set-face-background 'isearch "#bbbb22")
(set-face-foreground 'isearch-lazy-highlight-face "#333333")
(set-face-background 'isearch-lazy-highlight-face "#bbbb66")
(set-face-background 'modeline "#aaaaaa")
(set-face-foreground 'modeline "#333333")
(set-face-foreground 'link "#4466ff")
(set-face-foreground 'link-visited "#aa33bb")
(set-face-foreground 'minibuffer-prompt "#bababa")
(set-face-foreground 'escape-glyph "#ccaa11")
(setq default-tab-width 2)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq css-indent-offset 2)
(setq-default sh-basic-offset 2)
(setq-default sh-indentation 2)
(setq-default perl-indent-level 2)
(setq-default js-indent-level 2)
(random t)
(setq inhibit-splash-screen t)
(tool-bar-mode -1) (menu-bar-mode -1)
(setq initial-frame-alist '((width . 90) (height . 45)))
(set-scroll-bar-mode 'right)
(setq column-number-mode t)
(require 'linum)
(global-linum-mode 1)
(setq linum-disabled-modes-list '(mu4e-headers-mode))
(defun linum-on ()
(unless (or (minibufferp) (member major-mode linum-disabled-modes-list))
(linum-mode 1)))
(require 'hideshow)
(add-hook 'after-change-major-mode-hook
(lambda ()
(hs-minor-mode t)))
(require 'diminish)
(eval-after-load 'abbrev
'(diminish 'abbrev-mode " Ab"))
(eval-after-load 'autopair
'(diminish 'autopair-mode " P"))
(eval-after-load 'rainbow-mode
'(diminish 'rainbow-mode " Rb"))
(eval-after-load 'yasnippet
'(diminish 'yas/minor-mode " Y"))
(global-set-key (kbd "C-x C-c")
(function
(lambda () (interactive)
(cond ((y-or-n-p "Quit? ")
(save-buffers-kill-emacs))))))
(global-set-key (kbd "C-z")
(function
(lambda () (interactive)
(message "Did you mean C-a or C-e? If not use C-Z."))))
(global-set-key (kbd "C-S-z") 'suspend-frame)
(global-set-key (kbd "C-x w") 'delete-frame)
(fset 'yes-or-no-p 'y-or-n-p)
(setq use-dialog-box nil)
(setq window-min-height 3)
(setq mouse-yank-at-point t)
(require 'cl) (defun find-projects (dir)
(let ((dir (if (string= (substring dir -1 nil) "/")
dir (concat dir "/"))))
(if (not (file-directory-p dir))
nil
(reduce (lambda (list prj)
(let ((prj-dir (concat dir prj)))
(if (not (file-exists-p (concat prj-dir "/.hidden")))
(cond
((null prj) nil)
((file-exists-p (concat prj-dir "/.git"))
(cons `(,prj . ,prj-dir) list))
((and (file-directory-p prj-dir)
(not (string= prj ".."))
(not (string= prj ".")))
(append (find-projects prj-dir) list))
(t list))
list)))
(directory-files dir)
:initial-value nil))))
(defun make-ibuffer-projects-list (prefix dir)
(reduce (lambda (list prj)
(cons
`(,(concat prefix (car prj)) (filename . ,(cdr prj)))
list))
(find-projects dir)
:initial-value nil))
(require 'ibuffer)
(setq ibuffer-saved-filter-groups
`(("default"
,@(make-ibuffer-projects-list "Project: "
(concat (getenv "HOME") "/prj/"))
("Courses"
(or
(filename . "/ulm/s")
(filename . "/ulm/_s")))
("Internship"
(filename . "/ulm/internships/"))
("Configuration"
(filename . "/.emacs.d/"))
,@(make-ibuffer-projects-list "Web: "
(concat (getenv "HOME") "/www/"))
("Code"
(or
(mode . c-mode)
(mode . c++-mode)
(mode . perl-mode)
(mode . python-mode)
(mode . ruby-mode)
(mode . emacs-lisp-mode)
(mode . lisp-mode)
(mode . sh-mode)
(mode . php-mode)
(mode . xml-mode)
(mode . html-mode)
(mode . css-mode)
(mode . js-mode)))
("Mail"
(or
(mode . message-mode)
(mode . mail-mode)
(mode . mu4e-main-mode)
(mode . mu4e-headers-mode)
(mode . mu4e-view-mode)
(mode . mu4e-compose-mode)))
("Chat"
(or
(mode . erc-mode)
(mode . identica-mode)
(mode . twitter-mode)))
("Dired"
(mode . dired-mode)))))
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-switch-to-saved-filter-groups "default")))
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key [C-tab] 'next-buffer)
(global-set-key [C-S-iso-lefttab] 'previous-buffer)
(windmove-default-keybindings 'meta)
(add-hook 'server-switch-hook
(lambda ()
(local-set-key (kbd "C-x k") '(lambda ()
(interactive)
(if server-buffer-clients
(server-edit)
(ido-kill-buffer))))))
(defun revert-all-buffers ()
"Revert all opened buffers from their respective files"
(interactive)
(let* ((list (buffer-list))
(buffer (car list)))
(while buffer
(when (buffer-file-name buffer)
(progn
(set-buffer buffer)
(revert-buffer t t t)))
(setq list (cdr list))
(setq buffer (car list))))
(message "All buffers reverted"))
(global-set-key (kbd "C-c B") 'revert-all-buffers)
(require 'browse-kill-ring)
(global-set-key (kbd "C-x y") 'browse-kill-ring)
(savehist-mode t)
(global-set-key (kbd "ESC ESC") 'dabbrev-expand) (require 'autopair)
(autopair-global-mode)
(setq autopair-blink nil)
(setq autopair-autowrap t)
(put 'autopair-insert-opening 'delete-selection t)
(put 'autopair-skip-close-maybe 'delete-selection t)
(put 'autopair-insert-or-skip-quote 'delete-selection t)
(put 'autopair-extra-insert-opening 'delete-selection t)
(put 'autopair-extra-skip-close-maybe 'delete-selection t)
(put 'autopair-backspace 'delete-selection 'supersede)
(put 'autopair-newline 'delete-selection t)
(defun textmate-next-line ()
"Go to next line and indent wherever you are in a line"
(interactive)
(end-of-line)
(newline-and-indent))
(global-set-key [C-return] 'textmate-next-line)
(defun textmate-semicolon-and-next-line ()
"Put a semicolon at the end of the line where you are then
go to next line and indent wherever you are in a line"
(interactive)
(end-of-line)
(insert ";")
(newline-and-indent))
(global-set-key [M-return] 'textmate-semicolon-and-next-line)
(defun comment-or-uncomment-region-or-line ()
"Like comment-or-uncomment-region, but if there's no mark \(that means no
region\) apply comment-or-uncomment to the current line"
(interactive)
(if (not mark-active)
(comment-or-uncomment-region
(line-beginning-position) (line-end-position))
(if (< (point) (mark))
(comment-or-uncomment-region (point) (mark))
(comment-or-uncomment-region (mark) (point)))))
(global-set-key (kbd "C-/") 'comment-or-uncomment-region-or-line)
(defun personal-layout ()
"Arrange windows to my personal layout."
(interactive)
(delete-other-windows)
(split-window-horizontally)
(windmove-right)
(split-window-vertically)
(enlarge-window-vertically 10))
(global-set-key (kbd "C-c l") 'personal-layout)
(defun toggle-php-and-html-mode ()
"Toggle between php-mode and html-mode"
(interactive)
(if (eq major-mode 'html-mode)
(php-mode)
(html-mode)))
(global-set-key (kbd "C-c g") 'toggle-php-and-html-mode)
(defun artist-mode-toggle ()
"Toggle artist-mode"
(interactive)
(if (eq major-mode 'artist-mode)
(artist-mode-off)
(artist-mode)))
(global-set-key (kbd "C-c d") 'artist-mode-toggle)
(put 'dired-find-alternate-file 'disabled nil)
(fset 'dired-find-file 'dired-find-alternate-file)
(fset 'dired-advertised-find-file 'dired-find-alternate-file)
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator "|")
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*")
(require 'dropdown-list)
(setq yas/prompt-functions '(yas/dropdown-prompt
yas/ido-prompt
yas/completing-prompt))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory (concat home-emacs-dir "snippets/"))
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t)
(require 'iedit)
(global-set-key (kbd "C-:") 'iedit-mode)
(setq scroll-preserve-screen-position t)
(setq scroll-margin 2)
(setq scroll-step 1)
(setq require-final-newline t)
(setq auto-save-default nil)
(setq tramp-default-method "scp")
(require 'scratch)
(global-set-key (kbd "C-c t") 'scratch)
(require 'php-mode)
(add-to-list 'auto-mode-alist
'("\\.php[345]?\\'\\|\\.inc\\'" . php-mode))
(add-to-list 'auto-mode-alist
'("\\.p?html\\(\\.[a-z]\\{2\\}\\)?\\'" . html-mode))
(require 'lustre)
(add-to-list 'auto-mode-alist
'("\\.lus\\'" . lustre-mode))
(require 'go-mode)
(add-to-list 'auto-mode-alist
'("\\.go$" . go-mode))
(add-to-list 'auto-mode-alist
'("\\.outline\\'" . outline-mode))
(require 'outline-presentation)
(add-hook 'outline-presentation-mode-hook
(lambda () (text-scale-increase 3)))
(require 'mu4e)
(global-set-key (kbd "C-x m") 'mu4e)
(require 'smtpmail)
(setq
user-mail-address-telecom (concat "pablo.rau" "zy@telecom-p" "aristech.fr")
user-mail-address-enst (concat "rau" "zy@e" "nst.fr")
user-mail-address-upmc (concat "pablo.ra" "uzy@etu.u" "pmc.fr")
user-mail-address-ens (concat "pablo.r" "auzy@" "ens.fr")
user-mail-address-di (concat "rauz" "y@di.e" "ns.fr")
user-mail-address-clipper (concat "rauzy@c" "lipper.en" "s.fr")
user-mail-address-normale (concat "pablo.r" "auzy@no" "rmale.fr")
user-mail-address-m4n (concat "pr@m" "4n.fr")
user-mail-address-uzy user-mail-address)
(setq
mu4e-maildir "~/mails"
mu4e-sent-folder "/_sent"
mu4e-drafts-folder "/_drafts"
mu4e-trash-folder "/_trash"
mu4e-user-mail-address-list (list user-mail-address-telecom
user-mail-address-enst
user-mail-address-upmc
user-mail-address-ens
user-mail-address-di
user-mail-address-clipper
user-mail-address-normale
user-mail-address-m4n
user-mail-address-uzy)
mu4e-html2text-command "html2text -utf8 -width 72"
mu4e-get-mail-command "offlineimap"
mu4e-headers-date-format "%Y-%m-%d %H:%M:%S"
mu4e-headers-fields '((:date . 20)
(:flags . 5)
(:from-or-to . 25)
(:subject . nil))
mu4e-bookmarks '(("flag:unread AND NOT flag:trashed" "Unread messages" ?u)
("flag:flagged" "Flagged messages" ?f)
("date:today..now" "Today's messages" ?t)
("date:7d..now" "Last 7 days" ?w))
mu4e-attachment-dir (expand-file-name (concat mu4e-maildir "/_files"))
mu4e-headers-seen-mark '("S" . "☑")
mu4e-headers-new-mark '("N" . "✉")
mu4e-headers-replied-mark '("R" . "↵")
mu4e-headers-passed-mark '("P" . "⇉")
mu4e-headers-encrypted-mark '("x" . "⚷")
mu4e-headers-signed-mark '("s" . "✍")
mu4e-headers-empty-parent-prefix '("-" . "◆")
mu4e-headers-first-child-prefix '("\\" . "▶")
mu4e-use-fancy-chars t)
(setq
mail-user-agent 'mu4e-user-agent
message-signature "Pablo Rauzy.\nhttp://pablo.rauzy.name/\n"
message-send-mail-function 'smtpmail-send-it
smtp-mail-function 'smtpmail-send-it
message-citation-line-format "On %Y-%m-%d, %f wrote:"
message-citation-line-function 'message-insert-formatted-citation-line
message-send-mail-partially-limit 5000000)
(setq
smtpmail-starttls-credentials '(("z.mines-telecom.fr" 587 nil nil))
smtpmail-default-smtp-server "z.mines-telecom.fr"
smtpmail-smtp-server "z.mines-telecom.fr"
smtpmail-smtp-service 587
smtpmail-queue-mail nil
smtpmail-queue-dir "~/mails/_queue")
(setq pgg-gpg-use-agent t)
(defun my-mu4e-choose-from ()
"Choose the From field from user mail address list"
(interactive)
(save-excursion
(goto-char (point-min))
(while (not (looking-at "From: ")) (forward-line))
(kill-line)
(insert (concat "From: " user-full-name " <>"))
(backward-char)
(insert
(ido-completing-read "From: " mu4e-user-mail-address-list))))
(define-key message-mode-map (kbd "C-c C-f f") 'my-mu4e-choose-from)
(defun my-mu4e-set-from ()
"Set the From address based on the To address of the original."
(let ((msg mu4e-compose-parent-message))
(setq user-mail-address
(cond
((null msg) user-mail-address-uzy)
((mu4e-message-contact-field-matches
msg :to (list user-mail-address-ens
user-mail-address-clipper
user-mail-address-di))
user-mail-address-ens)
((mu4e-message-contact-field-matches
msg :to (list user-mail-address-telecom
user-mail-address-enst))
user-mail-address-enst)
((mu4e-message-contact-field-matches
msg :to (list user-mail-address-normale
(concat "roo" "t@norm" "ale.fr")))
user-mail-address-normale)
((mu4e-message-contact-field-matches
msg :to user-mail-address-m4n)
user-mail-address-m4n)
((mu4e-message-contact-field-matches
msg :to user-mail-address-upmc)
user-mail-address-upmc)
(t user-mail-address-uzy)))))
(add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-from)
(add-hook 'mu4e-compose-mode-hook (lambda () (flyspell-mode)))
(defun jmg/ido-select-recipient ()
"Inserts a contact from the mu cache.
Uses ido to select the contact from all those present in the database."
(interactive)
(insert
(ido-completing-read
"Recipient: "
(mapcar
(lambda (contact-string)
(let* ((data (split-string contact-string ","))
(name (when (> (length (car data)) 0)
(car data)))
(address (cadr data)))
(if name
(format "%s <%s>" name address)
address)))
(remove-if (lambda (string) (= 0 (length string)))
(split-string (shell-command-to-string "mu cfind --format=csv")
"\n"))))))
(define-key message-mode-map (kbd "C-c C-f c") 'jmg/ido-select-recipient)
(setq custom-file (concat home-emacs-dir "custom.el"))
(load custom-file 'noerror)
(server-start)
(find-file "~/.todo")
(rename-buffer "*todo*")
(defun format-spec-make (&rest pairs)
"Return an alist suitable for use in `format-spec' based on PAIRS.
PAIRS is a list where every other element is a character and a value,
starting with a character."
(let (alist)
(while pairs
(unless (cdr pairs)
(error "Invalid list of pairs"))
(push (cons (car pairs) (cadr pairs)) alist)
(setq pairs (cddr pairs)))
(nreverse alist)))