;; -*- mode: emacs-lisp; coding: utf-8 -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Author: Nicolas Berthier ;; Last modified: Tue Nov 3 16:49:04 2015 ;; ;; Main GNU Emacs configuration file. ;; ;; See `http://nberth.space/tools' for related configuration ;; files. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Change log: ;; 26-Aug-2015 Nicolas Berthier ;; Adding zero-width space key binding; change my web adresses. Also correct ;; Symbola font setup for mathematical alphanumeric symbols when in daemon ;; mode. ;; 11-May-2015 Nicolas Berthier ;; Load Controllable-Nbac mode library. ;; 6-May-2015 Nicolas Berthier ;; Fix some unicode character height problems on some configs. ;; 13-Mar-2015 Nicolas Berthier ;; Fix Zimbra / Caldav. ;; 27-Feb-2015 Nicolas Berthier ;; Adapt to Emacs 24.4. ;; Customization of links management by org-mode. ;; 3-Apr-2014 Nicolas Berthier ;; Some more utf-8 characters. ;; 30-Oct-2013 Nicolas Berthier ;; Extra utf-8 character bindings. Compact-uncompact-block (M-C-q). ;; Sentence-aware paragraph filling for LaTeX mode. ;; 2-Oct-2013 Nicolas Berthier ;; Stripped `IMAG' stuff. ;; 21-Nov-2012 Nicolas Berthier ;; Now uses `workgroups' to save/restore sessions (buffers, windows and ;; frames). Also disabled confirmation query when reverting PDF buffers. ;; 25-Oct-2012 Nicolas Berthier ;; Current directory is now shown in terminal buffer names (hence in the ;; tabbar). Also disabled `auto' directory of RefTeX. ;; 12-Oct-2012 Nicolas Berthier ;; Force loading of packages managed by ELPA at the beginnig of the init ;; file. ;; 2-Aug-2012 Nicolas Berthier ;; Org-latex export class for koma-article; Org-babel config. ;; Added global localization variables `my-emacs-run-at-lab' and ;; `my-emacs-host-is-europium'. ;; Notice about daemon usage. ;; 28-Jun-2012 Nicolas Berthier ;; New windmove keyboard shortcuts. ;; Added interactive "mailto:foo@bar?subject=bla%20bla…" URI handler. ;; 20-Jun-2012 Nicolas Berthier ;; Yaml mode. ;; Also updated personal website addresses. ;; 14-Jun-2012 Nicolas Berthier ;; EasyPG (Used by gnus). ;; 11-Jun-2012 Nicolas Berthier ;; Updated to emacs 24. ;; 2-Mar-2012 Nicolas Berthier ;; Basic org-mode customizations. ;; Bound windmove functions to "C-s-". ;; 28-Feb-2012 Nicolas Berthier ;; New functions for enabling/disabling French fill behavior. ;; 8-Sep-2011 Nicolas Berthier ;; Added licence header, and `header2' library. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; This program is free software; you can redistribute it and/or modify it under ;; the terms of the GNU General Public License version 3 (or higher) as ;; published by the Free Software Foundation. ;; ;; This program is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ;; details. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Usage: ;; ;; As usual GNU Emacs users might notice, this configuration file loads a lot of ;; packages right upon start-up. Indeed, previous versions of this file used ;; `autoload' constructs that dramatically reduced start-up time. ;; ;; Yet since the 23.1 version of GNU Emacs, its client/daemon capability became ;; more robust, thus lowering the need for a fast start-up. Also, the need to ;; save memory seems less important for a text editor nowadays… That's why I use ;; it as daemon and don't hesitate to load things directly. ;; ;; See the GNU Emacs documentation in order to set up your environment ;; appropriately [1]. Notably, the `ALTERNATE_EDITOR' environment variable ;; should be defined to the empty string so that the `emacsclient' command ;; always starts Emacs as daemon if it is not already started. ;; ;; Then, I start shells and Gnus by using the following commands (aliases or ;; small shell script wrappers are fine for these --- `goto-shell-buffer', ;; `new-shell-buffer' and `goto-gnus-buffer' functions are defined below): ;; ;; - "emacsclient -c -e '(goto-shell-buffer)'" starts the Emacs daemon if it is ;; not already running, and then creates a new frame with an interactive ;; terminal buffer, also starting one if none is running. ;; ;; - "emacsclient -c -e '(new-shell-buffer)'" is similar to the previous one ;; except that it always creates a new terminal buffer. ;; ;; - "emacsclient -c -e '(goto-gnus-buffer)'" starts the Emacs daemon if it is ;; not already running, and then creates a new frame showing the Gnus Group ;; buffer; it also starts Gnus if needed. ;; ;; At last, I use the following `kill-emacs' shell script wrapper to kill the ;; Emacs daemon (and incidentally, any attached frame and sub-process…), if any: ;; ;; #!/bin/sh ;; # Test presence of the server right now so that we do not accidentally ;; # start one to evaluate the `kill-emacs' function, if none is running. ;; if [ -S "/tmp/emacs$(id -u)/server" ]; then ;; emacsclient -e '(kill-emacs)'; ;; fi; ;; ;; [1] `http://gnu.org/s/emacs/manual/html_node/emacs/emacsclient-Options.html' ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Loaded Packages and Directory Structure: ;; ;; All packages that are not installed by using ELPA (the integrated package ;; management system of GNU Emacs >= 24 — `org' and `auctex') are placed under ;; the `~/.emacs.d/site-lisp/' directory (i.e., not directly under the ;; `user-emacs-directory', whose default value is "~/.emacs.d/"). It contains: ;; ;; - workgroups.el (`https://github.com/tlh/workgroups.el'); ;; ;; - tabbar.el (`http://emacswiki.org/emacs/TabBarMode'); ;; ;; - multi-term.el (`http://www.emacswiki.org/emacs/download/multi-term.el'); ;; ;; - some other major modes, plus `ocaml', `tuareg', `rml' amd `emms' ;; subdirectories (these are added in the search path via the `my-lpath-add' ;; function); ;; ;; Some other customizations (faces…), are stored in a separated file so that ;; this one is not messed up: `~/.emacs.d/customize'. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Some customizations use Common-Lisp constructs: (eval-when-compile (require 'cl)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Libraries path specification (before the compilation); note ;; `user-emacs-directory' equals "~/.emacs.d/" by default. (defconst my-emacs-lisp-dir (expand-file-name "site-lisp/" user-emacs-directory)) (defun my-lpath-add (&optional subdir) ;; see `http://www.anc.ed.ac.uk/~stephen/emacs/ell.html' "*Adds SUBDIR to the load path if it exists." (let* ((absolute (and subdir (or (char-equal ?\/ (string-to-char subdir)) (char-equal ?\~ (string-to-char subdir))))) (dir (cond (absolute subdir) (subdir (concat my-emacs-lisp-dir subdir)) (t my-emacs-lisp-dir)))) (when (file-exists-p dir) (add-to-list 'load-path (expand-file-name dir))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; my-require-maybe (`http://www.emacswiki.org/cgi-bin/wiki/LocateLibrary') this ;; is useful when this .emacs is used in an env where not all of the other stuff ;; is available. (defmacro my-require-maybe (feature &optional file) "*Try to require FEATURE, but don't signal an error if `require' fails." `(require ,feature ,file 'noerror)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; my-load-file-maybe (defun my-load-file-maybe (file) "*Loads FILE if it exists in the load path; only displays an error message othewise." (unless (load file 'noerror) (message (format "Cannot load file `%s'" file)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Default paths... (my-lpath-add) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Force loading of ELPA right now instead of after the init files (the default ;; behavior), so that I can change some variables below. (require 'package) (setq package-enable-at-startup nil) (package-initialize) (when (< emacs-major-version 24) (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro __private__ (x &optional description) "I use this hack to hide some information in public versions of the file" x) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Identity: (setq user-full-name "Nicolas Berthier" user-mail-address "" my-inria-address "" ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Calendar host: (setq my-zimbra-calendar-url "https:////") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Where am I? (let ((host (getenv "HOST")) (user (getenv "USER")) (home (getenv "HOME"))) (setq my-emacs-host-is-pierce (string= host "pierce") my-emacs-host-is-epicea (string= host "epicea.irisa.fr") my-emacs-host-is-cotopaxi (eq system-type 'darwin) ;Pfff my-emacs-run-at-lab (string= user "") my-home-dir home)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Appearance: (global-font-lock-mode t) (setq font-lock-support-mode 'jit-lock-mode font-lock-maximum-decoration t) (column-number-mode t) (transient-mark-mode t) ;active region highlighting: (setq inhibit-startup-message t) ;do not show the startup message (mouse-avoidance-mode 'jump) ;make the mouse cursor and the point ;play cat-and-mouse (setq dabbrev-case-replace nil) ;make completion case sensitive (put 'overwrite_mode 'disabled t) ;disable the overwrite mode (when (display-graphic-p) ;; 122 x 44 characters: (setq initial-frame-alist '((width . 122) (height . 44)))) (scroll-bar-mode -1) (tool-bar-mode -1) ;disable the tool-bar (menu-bar-mode -1) ;disable the menu (if (>= emacs-major-version 21) (blink-cursor-mode -1)) ;turn off blinking cursor (fset 'yes-or-no-p 'y-or-n-p) ;replace "yes" or "no" with "y" or "n" (setq x-stretch-cursor t ;cursor & scrolling behavior scroll-preserve-screen-position t) (when (my-require-maybe 'paren) (show-paren-mode t) ;show matching parenthesis (setq blink-matching-paren t blink-matching-paren-on-screen t blink-matching-paren-dont-ignore-comments t)) (when (fboundp 'auto-image-file-mode) (auto-image-file-mode t)) ;show images when possible (when (>= emacs-major-version 22) (setq use-dialog-box nil)) ;disable all dialog boxes (setq display-time-24hr-format t display-time-day-and-date t calendar-week-start-day 1) ;; ;; Setup highlight faces' background color: ;; (set-face-background 'highlight "#113") (set-cursor-color "red") (setq ring-bell-function 'ignore) (when (my-require-maybe 'hl-line) ;highlight current line... ;; (setq hl-line-face 'highlight) (global-hl-line-mode 1)) (setq truncate-partial-width-windows nil) ;do not truncate long lines in narrow ;buffers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Enable yanking after X11's primary selection (e.g, with mouse): (setq x-select-enable-primary t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Character encoding: ;; utf-8 / input-method (setq locale-coding-system 'utf-8) (set-default-coding-systems 'utf-8) ;; (set-terminal-coding-system 'utf-8) ;; (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) (set-language-environment "UTF-8") ;prefer utf-8 for language settings (set-input-method nil) ;no funky input for normal editing ;; (unify-8859-on-encoding-mode t) ;; (unify-8859-on-decoding-mode t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Correct display of unicode characters (see `http://emacs.stackexchange.com/\ ;; questions/251/line-height-with-unicode-characters') ;; Change font configuration on frame creation, so that emacs daemon does not ;; complain (XXX does not work on some settups…). ;; (add-hook 'window-setup-hook 'my-utf8-font-correct) (defun my-utf8-font-correct () (interactive) (when (and (or my-emacs-host-is-pierce my-emacs-host-is-cotopaxi) (find-font (font-spec :name "Symbola"))) (message "Setting up Symbola font for mathematical alphanumeric symbols") ;; Mathematical Alphanumeric Symbols (set-fontset-font t '(#x1d400 . #x1d7ff) "Symbola"))) ;; `http://emacs.stackexchange.com/questions/12351/when-to-call-find-font-if-\ ;; launching-emacs-in-daemon-mode' (run-with-idle-timer 1 nil 'my-utf8-font-correct) ;run only once after startup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Kill-ring manipulation: (comment it as I never use that...) (See also ;; `http://www-verimag.imag.fr/~moy/?L-Editeur-de-texte-Emacs' for details) ;; (my-require-maybe 'kill-ring-rotate) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Special characters: (defun my-french-quote () (interactive) (if (or (bolp) (= (preceding-char) 32)) (insert "« ") ;← note the non-breakable space (insert " »"))) ;← ibid (global-set-key (kbd "C-\"") 'my-french-quote) (defun my-ins-space () (interactive) (insert " ")) ;← ibid (global-set-key (kbd "S-SPC") 'my-ins-space) ;; Repace C-q outside of terminals: (global-set-key (kbd "C-c q") 'quoted-insert) (global-set-key (kbd "C-c C-q") 'quoted-insert) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tabulation: (setq tab-width 8 indent-tabs-mode t standard-indent 2) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Justification: (add-hook 'text-mode-hook 'my-justification-left) ;; Setup global fill column: (setq fill-column 80) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Viper mode: emacs power + key bindings of Vi. (setq viper-mode t viper-inhibit-startup-message 't viper-expert-level '3) (require 'viper) ;required! (defun my-viper-resuscitates () "Toggle viper mode, to be used in hooks of modes that kill it..." (viper-mode)) ;; Undef this particular keystroke when in vi mode as I always use it for its ;; initial purpose (mostly in `org-mode' actually). (define-key viper-vi-basic-map (kbd "C-u") nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Global function keys: (see below for the definition of the shell-related ;; functions) (global-set-key [f1] 'dired) (global-set-key [f2] 'goto-shell-buffer) (global-set-key [C-f2] 'new-shell-buffer) (global-set-key [M-f2] 'goto-shell-buffer-other-window) (global-set-key [f5] 'compile) (global-set-key [C-f5] 'recompile) (global-set-key [f6] 'visit-tags-table) (global-set-key [f8] 'add-change-log-entry-other-window) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Frame management (global-set-key [f12] 'make-frame) (global-set-key [C-f4] 'delete-frame) ;I never use it actually... (global-set-key (kbd "C-M-k") 'delete-frame) (global-unset-key (kbd "C-x C-z")) ;unbind `suspend-frame' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Window management. Inspired from GS's configuration file. ;; (winner-mode 1) ;history (C-left & C-right). Aargh! breaks C-c in term! (defun my-enlarge-window-diagonally () (interactive) (enlarge-window-horizontally 1) (enlarge-window 1)) (defun my-shrink-window-diagonally () (interactive) (shrink-window-horizontally 1) (shrink-window 1)) (global-set-key [C-kp-9] 'my-enlarge-window-diagonally) (global-set-key [C-kp-1] 'my-shrink-window-diagonally) (global-set-key [C-kp-6] 'enlarge-window-horizontally) (global-set-key [C-kp-4] 'shrink-window-horizontally) (global-set-key [C-kp-8] 'enlarge-window) (global-set-key [C-kp-2] 'shrink-window) (global-set-key [C-kp-5] 'balance-windows) (global-set-key [C-kp-0] 'delete-window) (global-set-key [C-tab] 'other-window) ;; Those two do not work very well: (global-set-key [C-S-iso-lefttab] #'(lambda () (interactive) (other-window -1))) (global-set-key [C-lefttab] #'(lambda () (interactive) (other-window -1))) ;; Let's give it a try… (XXX: `super' modifier may not be a good idea though…) (global-set-key (kbd "C-s-") 'windmove-left) (global-set-key (kbd "C-s-") 'windmove-right) (global-set-key (kbd "C-s-") 'windmove-up) (global-set-key (kbd "C-s-") 'windmove-down) (global-set-key (kbd "C-s-h") 'windmove-left) (global-set-key (kbd "C-s-l") 'windmove-right) (global-set-key (kbd "C-s-k") 'windmove-up) (global-set-key (kbd "C-s-j") 'windmove-down) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Workgroups to save/restore configuration of windows and frames (see ;; `https://github.com/tlh/workgroups.el' for more info): (when (my-require-maybe 'workgroups) ;; Keep C-z to viper's usage. (setq wg-prefix-key (kbd "C-q") ;I don't usually insert quoted stuff… wg-morph-on nil ;no animations at all wg-switch-on-load nil) ;; Enable it right now. (workgroups-mode 1) (wg-load (expand-file-name "workgroups" user-emacs-directory))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Buffer management: (when (my-require-maybe 'uniquify) ;make buffer names more unique (setq uniquify-buffer-name-style 'post-forward uniquify-separator ":" uniquify-after-kill-buffer-p t uniquify-ignore-buffers-re "^\\*")) ;; NB: Removed 'cause I don't like it.... ;; ;; ido : makes C-x C-f and C-x b a lot easier ;; ;; (inspired by `http://smeuuh.free.fr/.emacs') ;; (when (my-require-maybe 'ido) ;; (setq ido-create-new-buffer 'always ;; ido-enable-flex-matching t ;; ido-max-prospects 4 ;; ido-confirm-unique-completion t) ;; (ido-mode 1) ;; (ido-everywhere 1) ;; (icomplete-mode 1)) ;completion for commands that don't use ido (like help) (defun indent-buffer () ;custom indent func. (interactive) (indent-region (point-min) (point-max))) (global-set-key (kbd "C-c C-\\") 'indent-buffer) (defun my-disable-Cx-Cc () (local-set-key (kbd "C-x C-c") #'(lambda () (interactive) (message "Err…, use C-M-k instead.")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Icicles (see `http://www.emacswiki.org/emacs/Icicles'): ;; (my-lpath-add "icicles") ;; (when (my-require-maybe 'icicles) ;; (icy-mode 1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tabbar is wonderful (but with terminal buffers only!): (let ((km (make-sparse-keymap))) ;always erase tabbar keymap: ;; XXX: Hummm, this clashes with some useful org-mode keybindings… (define-key km [(control meta shift home)] 'tabbar-press-home) (define-key km [(control meta shift left)] 'tabbar-backward) (define-key km [(control meta shift right)] 'tabbar-forward) ;; (define-key km [(meta shift up)] 'tabbar-backward-group) ;; (define-key km [(meta shift down)] 'tabbar-forward-group) ;; (define-key km [(meta shift prior)] 'tabbar-press-scroll-left) ;; (define-key km [(meta shift next)] 'tabbar-press-scroll-right) (setq tabbar-mode-map km)) (when (my-require-maybe 'tabbar) ;; Cycle through visible tabs only. (setq tabbar-cycle-scope 'tabs tabbar-buffer-groups-function (lambda () ;custom groups for all terminals. (cond ((eq major-mode 'term-mode) '("Term Buffer")) ((string-equal "*" (substring (buffer-name) 0 1)) '("Emacs Buffer")) (t '("User Buffer"))))) ;; Enable tabbars globally: (tabbar-mode 1) ;; I use this minor-mode mainly as a global mode (see below): (define-minor-mode tabbar-on-term-only-mode "Display tabbar on terminals (and buffers in fundamental mode) only." :init-value t :lighter nil :keymap nil (if tabbar-on-term-only-mode ;; filter is enabled ;; ;; TODO: maybe define a customizable filter function... (if (eq major-mode 'term-mode) (tabbar-local-mode -1) (tabbar-local-mode 1)) ;; always activate tabbar locally when we disable the minor mode: (tabbar-local-mode -1))) (defun tabbar-on-term-only-mode-on () "Turn on tabbar if current buffer is a terminal." (unless (minibufferp) (tabbar-on-term-only-mode 1))) ;; Define a global switch for the mode. Note that this is not set for buffers ;; in fundamental mode. ;; ;; I use it 'cause some major modes do not run the ;; `after-change-major-mode-hook'... (XXX: actually, my own modes do not...) (define-globalized-minor-mode global-tabbar-on-term-only-mode tabbar-on-term-only-mode tabbar-on-term-only-mode-on) ;; XXX: This could be really dangerous and `heavy', but for now it's all I've ;; seen to completely disable the tabbar on every buffer by default, and in a ;; simple way. (defadvice create-file-buffer (after force-remove-tabbar activate) (with-current-buffer ad-return-value (tabbar-on-term-only-mode-on))) ;; This would be even more perilous (called even for each temporary ;; buffer...): ;; (defadvice generate-new-buffer (after force-remove-tabbar activate) ;; (with-current-buffer ad-return-value (tabbar-on-term-only-mode-on))) ;; Eventually, switch on this global filter for tabbars: (global-tabbar-on-term-only-mode 1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Dired options: (add-hook 'dired-load-hook (function (lambda () (load "dired-x")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (ANSI/Multi)-term options: ;; disable transient mark modes in term-char-mode ;; http://www.emacswiki.org/emacs/AnsiTermHints remember: Term-mode ;; remaps C-x to C-c (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) (setq term-term-name "eterm-color") (defconst my-term-prog "zsh") (defadvice term-char-mode (after term-char-mode-fixes ()) (set (make-local-variable 'transient-mark-mode) nil) (set (make-local-variable 'global-hl-line-mode) nil) (set (make-local-variable 'truncate-lines) nil) (ad-activate 'term-char-mode) (term-set-escape-char ?\C-x)) (defun my-term-mode-enter () (set (make-local-variable 'truncate-lines) nil) ;; (make-local-variable 'mouse-yank-at-point) ;; (make-local-variable 'transient-mark-mode) ;; (setq transient-mark-mode nil) (auto-fill-mode -1)) (add-hook 'term-mode-hook 'my-term-mode-enter) (when (my-require-maybe 'multi-term) (setq multi-term-program my-term-prog multi-term-buffer-name "term" ;shorten… multi-term-switch-after-close nil) ;; Let's add current directories in terminal buffer names. Do do so, we need ;; to tweak the original buffer management code of `multi-term'. (setq my-home-dir-re (concat "^" (regexp-quote my-home-dir))) (defun my-rename-term-buffer () (let ((dir (replace-regexp-in-string my-home-dir-re "~" default-directory))) (rename-buffer (format "*%s<%d>:%s*" multi-term-buffer-name my-term-index dir)))) ;; Let's define an index variable for all terminal buffers, and define a ;; dedicated association list to keep track of the mapping `integer → buffer'. (unless (boundp 'my-multi-terms) ;do not re-evaluate this on (setq my-multi-terms nil)) ;re-evaluation of this buffer. (defun my-multi-term-gc () "Removes killed buffers from the list." (setq my-multi-terms ;note the `buffer-name' of a killed buffer is nil (remove-if-not (lambda (e) (buffer-name (cdr e))) my-multi-terms))) (defun my-multi-term-find-index () "Allocates and returns an unused index." (my-multi-term-gc) (let ((index 1)) (while (some (lambda (e) (= index (car e))) my-multi-terms) (setq index (1+ index))) index)) (defun my-multi-term-reorder () "As its name says…" (setq my-multi-terms (sort my-multi-terms (lambda (a b) (< (car a) (car b)))))) (defun my-multi-term-chk-index () "Associates an unused integer to the current buffer if it does not have one already (i.e., local variable `my-term-index' is bound when this function returns)." (unless (boundp 'my-term-index) (my-multi-term-reorder) (let ((idx (my-multi-term-find-index))) (add-to-list 'my-multi-terms `(,idx . ,(current-buffer))) (set (make-local-variable 'my-term-index) idx)))) (defun multi-term-list () "Custom replacement for original `multi-term-list' that relies too much on buffer names." (my-multi-term-reorder) (mapcar 'cdr my-multi-terms)) ;; Change buffer's name with tracked directory. (defadvice term-handle-ansi-terminal-messages (around my-directory-tracker (m) activate) (let* ((old-directory default-directory) (m ad-do-it)) (unless (string= old-directory default-directory) (my-rename-term-buffer)) m)) (defun my-multi-term-get-default () (my-multi-term-gc) ;; TODO: Should I consider returning the one with the least index? Or the ;; first one (or last one?) in the whole list of buffers? (let ((b (cdr (assoc 1 my-multi-terms)))) (if (buffer-name b) b))) (defun my-new-term () (multi-term) (my-multi-term-chk-index) (my-rename-term-buffer)) (add-to-list 'term-bind-key-alist '("C-z" . term-stop-subjob)) (add-to-list 'term-bind-key-alist '("C-c" . term-interrupt-subjob)) (delete '("C-c C-c" . term-interrupt-subjob) term-bind-key-alist) (delete '("C-c C-e" . term-send-esc) term-bind-key-alist) (setq ;; term-bind-key-alist ;; (delete '("C-c C-c" . term-interrupt-subjob) ;; (delete '("C-c C-e" . term-send-esc) term-bind-key-alist)) term-unbind-key-list '(;; "C-x" "C-q" ;← workgroups management "C-c" "C-h" "C-y" "")) ) (unless (featurep 'multi-term) ;in case… (defun my-multi-term-get-default () (get-buffer "*ansi-term*")) (defun my-new-term () (ansi-term my-term-prog))) (setq term-default-bg-color "#000000" term-default-fg-color "#ffffaa" term-input-ignoredups t) (when (featurep 'tabbar) ;; Let's see what I use… (add-to-list 'term-bind-key-alist '("C-" . tabbar-backward)) (add-to-list 'term-bind-key-alist '("C-" . tabbar-forward)) (add-to-list 'term-bind-key-alist '("M-" . tabbar-backward)) (add-to-list 'term-bind-key-alist '("M-" . tabbar-forward))) (defun new-shell-buffer () "Creates a new shell buffer in the current window." (interactive) (my-new-term)) ;; Non-interactive function (defined using `labels' before): (defun make-shell-buffer (switch-to) ;; Applies SWITCH-TO to the default terminal buffer if it exists, or create ;; one if it doesn't. (let ((b (my-multi-term-get-default))) (if b (unless (eq (current-buffer) b) (apply switch-to (list b))) (my-new-term)))) (defun goto-shell-buffer () "Selects the default terminal buffer in the current window. Creates a terminal buffer if the default does not exist yet." (interactive) (make-shell-buffer 'switch-to-buffer)) (defun goto-shell-buffer-other-window () "Selects the default terminal buffer in another window. Creates a terminal buffer if the default does not exist yet." (interactive) (make-shell-buffer 'switch-to-buffer-other-window)) ;; TODO: see ;;http://stackoverflow.com/questions/2886184/copy-paste-in-emacs-ansi-term-shell ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; F**king Mac tweaks (when my-emacs-host-is-cotopaxi (setq shell-command-switch "-lc" mac-option-modifier 'super mac-command-modifier 'meta)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Global font size manipulation (defun my-font-size-add (val) (let ((height (face-attribute 'default :height))) (set-face-attribute 'default nil :height (+ height val)))) (defun my-font-size+ (val) (interactive (if (and current-prefix-arg (not (consp current-prefix-arg))) (list (prefix-numeric-value current-prefix-arg)) (list 20))) (my-font-size-add val)) (defun my-font-size- (val) (interactive (if (and current-prefix-arg (not (consp current-prefix-arg))) (list (prefix-numeric-value current-prefix-arg)) (list 20))) (my-font-size-add (- val))) (global-set-key (kbd "C-x C-M-+") 'my-font-size+) (global-set-key (kbd "C-x C-M--") 'my-font-size-) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Color theme: (unless my-emacs-host-is-cotopaxi (load-theme 'wombat)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Gnus: (require 'gnus) ;require! so that errors are notified for this one. (setq mail-user-agent 'gnus-user-agent) (defun goto-gnus-buffer () ;inspired from (moy)... "Manages to show the group buffer of gnus. If gnus is not running, launch it in another frame. Else, just display the group buffer." (interactive) (if (gnus-alive-p) (unless (eq (current-buffer) (get-buffer gnus-group-buffer)) (switch-to-buffer gnus-group-buffer)) (gnus))) ;; This function is called by a wrapper that looks like the first one you can ;; see on this page: `http://www.emacswiki.org/emacs/MailtoHandler'. (defun my-gnus-handle-mailto (mailto-uri) "Compose mail according to data encoded in MAILTO-URI, and starts Gnus if needed." (interactive) (unless (gnus-alive-p) (gnus)) (my-mailto-compose-mail mailto-uri)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Text formatting: ;; Sometimes I receive French texts without ` ' (non-breakable space) ;; characters… (defun my-fill-french () (interactive) (make-local-variable 'fill-nobreak-predicate) (add-to-list 'fill-nobreak-predicate 'fill-french-nobreak-p) (message "French fill mode enabled.")) (defun my-fill-other () (interactive) ;; XXX: Is there any use case that necessitates the following? : ;; (make-local-variable 'fill-nobreak-predicate) (setq fill-nobreak-predicate (delete 'fill-french-nobreak-p fill-nobreak-predicate)) (message "French fill mode disabled.")) ;; see `http://ergoemacs.org/emacs/modernization_fill-paragraph.html' (defun compact-uncompact-block () "Remove or add line ending chars on current paragraph. This command is similar to a toggle of `fill-paragraph'. When there is a text selection, act on the region." ;; This command symbol has a property “'compact-p”. (interactive) (let (compact (deactivate-mark nil)) (save-excursion ;; Determine whether the text is currently compact. (setq compact (if (eq last-command this-command) (get this-command 'compact-p) (if (> (- (line-end-position) (line-beginning-position)) fill-column) t nil))) (if (region-active-p) (if compact (fill-region (region-beginning) (region-end)) (let ((fill-column most-positive-fixnum)) (fill-region (region-beginning) (region-end)))) (if compact (fill-paragraph nil) (let ((fill-column most-positive-fixnum)) (fill-paragraph nil)))) (put this-command 'compact-p (if compact nil t))))) (global-set-key "\C-\M-q" 'compact-uncompact-block) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; folding: ;; (setq fold-mode-prefix-key "\C-z" ;maybe too short prefix... but we'll see ;; fold-mode-prefix-map (make-sparse-keymap)) ;; ;; use C-h to see fold-mode-map ;; (define-key fold-mode-prefix-map "\C-c" 'fold-create) ;; (define-key fold-mode-prefix-map "\C-r" 'fold-region) ;; (define-key fold-mode-prefix-map "+" 'fold-show) ;; (define-key fold-mode-prefix-map "-" 'fold-hide) ;; (define-key fold-mode-prefix-map "*" 'fold-whole-buffer) ;; (define-key fold-mode-prefix-map "\C-v" 'fold-toggle) ;; (define-key fold-mode-prefix-map "\C-a" 'fold-show-all) ;; (define-key fold-mode-prefix-map "\C-o" 'fold-hide-other) ;; (define-key fold-mode-prefix-map "\C-n" 'fold-next) ;; (define-key fold-mode-prefix-map "\C-p" 'fold-previous) ;; (my-require-maybe 'fold) ;to be done AFTER the previous ;; ;definitions. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; History: (setq recentf-max-saved-items 256) (when (my-require-maybe 'recentf) (recentf-mode 1) (global-set-key (kbd "C-x F") 'recentf-open-files)) (when (my-require-maybe 'savehist) (savehist-mode 1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Backup files: (setq make-backup-files nil ;no backup files ;; backup-directory-alist ;; `((".*" . ,temporary-file-directory))) auto-save-file-name-transforms `((".*" ,temporary-file-directory t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Time stamp: ;; ;; Inspired from: `http://sebastien.dinot.free.fr/dotemacs.html' ;; TODO: Choose some shortcuts for that... (defun insert-iso-date-string () ;AAAA-MM-JJ "Insert a nicely formated date string." (interactive) (insert (format-time-string "%Y-%m-%d"))) (defun insert-text-date-string () ;Month JJ AAAA "Insert a nicely formated date string." (interactive) (insert (format-time-string "%B %d, %Y"))) (defun insert-iso-time-string () ;AAAA-MM-JJ HH:NN:SS "Insert a nicely formated timestamp string." (interactive) (insert (format-time-string "%Y-%m-%d %H:%M:%S"))) (defun insert-text-time-string () ;JJ Month AAAA à HH:NN:SS "Insert a nicely formated timestamp string." (interactive) (insert (format-time-string "%B %d, %Y, %H:%M:%S"))) (defun my-insert-date () ; - Day, month MM AAAA, kk:NN "Insert date at point." (interactive) (insert (concat user-full-name (format-time-string " - %a, %b %e %Y, %k:%M")))) (defun my-insert-date-short () ; "Insert a short date at point." (interactive) (insert (format-time-string "N.B. - %02d/%02m/%Y-%02k:%02M"))) ;; Time stamp tools (see time-stamp.el) from ;; `http://www.charlescurley.com/emacs.init.html' (when (my-require-maybe 'time-stamp) (add-hook 'write-file-hooks 'time-stamp) ;; `http://www.linux-france.org/article/appli/cfg/emacs/hindy.emacs' A ;; function to insert the time stamp at point. (defun my-insert-time-stamp () "Insert at point the dummy time stamp string to activate the time stamp facility." (interactive "*") (insert "Time-stamp: \" \"") ;insert the bare bones, call the ;function to fill it in where we put it. (time-stamp))) ;; Another very interesting thing from ;; `http://members.tripod.com/~the_great_site/insmdate.htm' (defconst my-last-modified-date-prefix (concat "Last " "modified:") "This string is inserted immediately before the date.") (defun my-last-modified-date () "Update a file my-last-modified-date line." (save-excursion (goto-char (point-min)) ;; (when (search-forward-regexp my-last-modified-date-prefix nil t) (while (search-forward-regexp my-last-modified-date-prefix nil t) (progn (let ((date-start (point))) (end-of-line) (delete-region date-start (point))) (insert " " (current-time-string)))))) (defun insert-last-modified-date () "Insert at point a last-modified-date line" (interactive "*") (insert my-last-modified-date-prefix) ;insert the bare bones. (my-last-modified-date)) ;call the function to fill it in where ;we put it. (when (my-require-maybe 'header2) ;; see `http://www.emacswiki.org/emacs/AutomaticFileHeaders' ;; TODO: add `auto-make-header' hooks, and customize a little. (add-hook 'write-file-hooks 'auto-update-file-header)) ;; Still, use custom... (add-hook 'write-file-hooks 'my-last-modified-date) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; W3m configuration: (when (my-require-maybe 'w3m) ;; (setq browse-url-browser-function 'w3m-browse-url) ;; (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t) (autoload 'browse-url-interactive-arg "browse-url") (global-set-key "\C-xm" 'browse-url-at-point) (setq w3m-use-cookies t)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Check spelling: (setq ispell-program-name "aspell") (my-require-maybe 'flyspell) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Common edition hook: (defun my-text-hook () ;; I remove it 'cause it's annoying for commented code... ;; (when (fboundp 'flyspell-prog-mode) ;; (flyspell-prog-mode)) ;check spelling in comments/strings (when (fboundp 'dir-locals-mode) (dir-locals-mode t))) (defun my-flyspell-traverse-atlantic () (interactive) (ispell-change-dictionary "american")) (defun my-justification-left () (interactive) (setq default-justification 'left)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Customizations for all prog modes. (defun my-hook-save () (cond ;see `http://nmartin.free.fr/perso/index.php?go=emacs' ((eq major-mode 'c-mode) (delete-trailing-whitespace)) ((eq major-mode 'c++-mode) (delete-trailing-whitespace)) ((eq major-mode 'java-mode) (delete-trailing-whitespace)) ;; ((eq major-mode 'caml-mode) (delete-trailing-whitespace)) ((eq major-mode 'tuareg-mode) (delete-trailing-whitespace)) ((eq major-mode 'latex-mode) (delete-trailing-whitespace)) ((eq major-mode 'tex-mode) (delete-trailing-whitespace)))) (defun my-font-lock-fill-column-transcend (bound) "Helper for highlighting transcending characters." (re-search-forward ;TODO: that may be too heavy. It could ;be interesting to pre-eval it after all ;hooks and local variables of a file. (concat "^[^\n]\\{" (number-to-string fill-column) "\\}\\(.*\\)$") bound 'move)) (defun my-install-font-lock-fill-column-transcend () "" (interactive) (font-lock-add-keywords nil '((my-font-lock-fill-column-transcend 1 font-lock-warning-face prepend))) (font-lock-fontify-buffer)) (defun my-deinstall-font-lock-fill-column-transcend () "" (interactive) (font-lock-remove-keywords nil '((my-font-lock-fill-column-transcend 1 font-lock-warning-face prepend))) (font-lock-fontify-buffer)) (defadvice tags-search-mark (before tags-search (regexp &optional file-list-form) activate) (unless (and (equal regexp "") (eq (car tags-loop-scan) 're-search-forward) (null tags-loop-operate)) (push-mark))) ;; ad-do-it ;; (message "Remember that C-x C-SPC returns to the previous point…")) (defun my-prog-hook () (my-text-hook) (add-hook 'write-file-hooks 'my-hook-save) (font-lock-add-keywords nil '(("\\<\\(FIXME\\|TODO\\|XXX+\\|BUG\\)" 1 font-lock-warning-face prepend))) ;; (my-install-font-lock-fill-column-transcend) (set-fill-column 80) ;; (fold-mode 1) (local-set-key (kbd "M-<") 'tags-search)) (setq comment-style 'indent compilation-scroll-output 'first-error compilation-window-height 12) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Running Make with the closest Makefile (see ;; `http://emacswiki.org/emacs/CompileCommand'): (defun* get-closest-pathname (&optional (file "Makefile")) "Determine the pathname of the first instance of FILE starting from the current directory towards root. This may not do the correct thing in presence of links. If it does not find FILE, then it shall return the name of FILE in the current directory, suitable for creation" (let ((root (expand-file-name "/"))) ;; (expand-file-name ;; file (loop for d = default-directory then (expand-file-name ".." d) if (file-exists-p (expand-file-name file d)) return d if (equal d root) return nil)));; ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Customizations for all modes in CC Mode. (defun my-c-mode-common-hook () (c-toggle-hungry-state 1) (my-prog-hook)) (eval-after-load "cc-mode" '(progn (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) (add-hook 'c-mode-common-hook #'(lambda () (set (make-local-variable 'compile-command) (format "make -f %s/Makefile" (get-closest-pathname))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; C-style languages properties: (setq c-default-style "gnu" c-tab-always-indent t c-auto-align-backslashes t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; C proterties: (add-to-list 'auto-mode-alist (cons "\\.l$" 'c-mode)) (add-to-list 'auto-mode-alist (cons "\\.y$" 'c-mode)) (add-to-list 'auto-mode-alist (cons "\\.nc$" 'c-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Java proterties: (eval-after-load "cc-mode" '(progn (add-hook 'java-mode-hook 'my-install-font-lock-fill-column-transcend) (add-hook 'java-mode-hook #'(lambda () (progn (local-set-key (kbd "C-M-;") #'(lambda (arg) (interactive "*P") (let ((comment-style 'extra-line) (comment-start "/**") (comment-end "*/")) (comment-dwim arg))))))) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Java-like (soot): (add-to-list 'auto-mode-alist (cons "\\.jimple" 'java-mode)) ;jimple files… ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; AADL edition: (autoload 'aadl-mode "aadl-mode" "Major mode for editing AADL files." t) (add-to-list 'auto-mode-alist (cons "\\.aadl$" 'aadl-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Argos edition: (autoload 'argos-mode "argos" "Major mode for editing Argos files." t) (add-to-list 'auto-mode-alist (cons "\\.argos$" 'argos-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Lustre and other related languages: (my-lpath-add "/local/nberthie/opt/lurette/1.56/utils") (autoload 'lustre-mode "lustre" "Major mode for editing Lustre files." t) (autoload 'lucky-mode "lucky" "Major mode for editing Lucky code" t) (autoload 'lutin-mode "lutin" "Major mode for editing Lutin code" t) (autoload 'rif-mode "rif" "Major mode for viewing RIF outputs" t) (add-to-list 'auto-mode-alist (cons "\\.lus$" 'lustre-mode)) (add-to-list 'auto-mode-alist (cons "\\.luc$" 'lucky-mode)) (add-to-list 'auto-mode-alist (cons "\\.lut$" 'lutin-mode)) (add-to-list 'auto-mode-alist (cons "\\.rif$" 'rif-mode)) (add-to-list 'auto-mode-alist (cons "\\.ept$" 'lustre-mode)) (add-to-list 'auto-mode-alist (cons "\\.ept.pp$" 'lustre-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nesC edition: ;; (autoload 'nesc-mode "nesc" "Major mode for editing NesC files." t) ;; (add-to-list 'auto-mode-alist (cons "\\.nc$" 'nesc-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Elisp (Mostly from `http://www.djcbsoftware.nl/dot-emacs.html') (add-hook 'emacs-lisp-mode-hook (lambda () (local-set-key (kbd "") ;overrides global f5 (compile) #'(lambda () (interactive) (let ((debug-on-error t)) (eval-buffer) (message "buffer evaluated")))) ;; (set-fill-column 80) (my-prog-hook) (font-lock-add-keywords nil '(("\\<\\(my-require-maybe\\|add-hook\\|setq\\)\\>" 1 font-lock-keyword-face prepend))))) (setq lisp-indent-offset nil lisp-indent-function 'common-lisp-indent-function emacs-lisp-docstring-fill-column 80) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Python edition: (autoload 'python-mode "python-mode" "Major mode for editing Python files." t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; VHDL edition: (when (my-require-maybe 'vhdl-mode) (setq vhdl-underscore-is-part-of-word t) ;; Enable viper again: it is disabled by this mode! (add-hook 'vhdl-mode-hook 'my-viper-resuscitates)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ADA properties: (add-hook 'ada-mode-hook 'my-viper-resuscitates) ; <- ibid VHDL… ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Ml-style language properties: (defun my-ml-prog-hook () (setq indent-tabs-mode nil ;no tabs by default. comment-column 79 fill-column 80) (my-prog-hook)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (O')Caml: (my-lpath-add "ocaml") ;for `caml-types', loaded by `tuareg'. ;; (autoload 'caml-mode "caml" "Major mode for editing Caml code." t) ;; (add-to-list 'auto-mode-alist (cons "\\.ml[iylp]?$" 'caml-mode)) ;; (autoload 'camldebug "camldebug" "Run the Caml debugger" t) ;; (autoload 'run-caml "inf-caml" "Run an inferior Caml process." t) ;; (unless (my-require-maybe 'caml-font) (message "Couldn't load `caml-font'.")) ;; ;; TODO: Ok, `tuareg-mode' suits me more than `caml-mode', but I still have ;; problems with some alignments (eg, after `let ... = try`). (my-lpath-add "tuareg") ; <- installed through elpa (NO!) ;; JoCaml-compatible version: ;; (autoload 'tuareg-mode "juareg" "Major mode for editing (Jo)Caml code" t) (autoload 'tuareg-mode "tuareg" "Major mode for editing (Jo)Caml code" t) (add-to-list 'auto-mode-alist (cons "\\.ml\\w?$" 'tuareg-mode)) (setq tuareg-font-lock-symbols t) ;fancy symbols in code (eg, α, β, ≤, ≠, →, ⇐) (add-hook 'tuareg-mode-hook 'my-ml-prog-hook) (add-hook 'tuareg-mode-hook #'(lambda () (set (make-local-variable 'compile-command) (format "make -C %s" (get-closest-pathname))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ReactiveML mode: (my-lpath-add "rml") (autoload 'rml-mode "rml" "Major mode for editing Rml code." t) (autoload 'run-rml "inf-rml" "Run an inferior Rml process." t) (add-to-list 'auto-mode-alist (cons "\\.rml[i]?$" 'rml-mode)) (add-hook 'rml-mode-hook 'my-ml-prog-hook) (my-require-maybe 'rml-font) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Controllable-Nbac mode: (load-library "ctrln-mode.el") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Gnuplot mode: (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t) (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t) (add-to-list 'auto-mode-alist (cons "\\.gp$" 'gnuplot-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Procmail: (autoload 'procmail-mode "procmail-mode" "Major mode for editing procmailrc." t) (add-to-list 'auto-mode-alist (cons "procmailrc$" 'procmail-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Perl mode: (autoload 'cperl-mode "cperl-mode" "Perl major mode" t) (add-to-list 'auto-mode-alist (cons "\\.pl$" 'cperl-mode)) (setq cperl-continued-brace-offset -2 cperl-indent-level 2 cperl-invalid-face 'default cperl-hairy t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Lua edition: (when (my-require-maybe 'lua-mode) (add-to-list 'auto-mode-alist (cons "\\.lua$" 'lua-mode)) (add-hook 'lua-mode-hook 'my-prog-hook)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; WJCP mode (madeja... static analysis...): ;; (autoload 'wjtp-mode "wjtp" "my wjtp mode for madeja traces..." t) ;; (add-to-list 'auto-mode-alist (cons "\\.trace$" 'wjtp-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; XML file edition: (when (my-require-maybe 'nxml-mode) (fset 'xml-mode 'nxml-mode) (fset 'html-mode 'nxml-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; YAML file edition: (when (my-require-maybe 'yaml-mode) (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) (custom-set-variables '(yaml-indent-offset 3))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; LaTeX edition: (when (my-require-maybe 'tex-site) ;; (load "preview-latex.el" nil t t) (setq TeX-auto-save nil) ;no `auto' dir. (setq TeX-parse-self t) (setq-default TeX-master nil) (when (my-require-maybe 'reftex) (setq reftex-use-fonts nil reftex-plug-into-AUCTeX t reftex-vref-is-default t)) (my-require-maybe 'font-latex) (add-hook 'LaTeX-mode-hook 'my-text-hook) (add-hook 'LaTeX-mode-hook 'TeX-fold-mode) (add-hook 'LaTeX-mode-hook (lambda () (setq ispell-parser 'tex))) (when (fboundp 'reftex-mode) (add-hook 'LaTeX-mode-hook 'turn-on-reftex)) (setq TeX-save-query nil TeX-parse-self t) ;; force library loading: (when (my-require-maybe 'latex) ;; Add partial table of contents. (add-to-list 'LaTeX-clean-intermediate-suffixes "\\.ptc")) ;; see ;; `http://pleasefindattached.blogspot.fr/2011/12/emacsauctex-sentence-fill-greatly.html' (defadvice LaTeX-fill-region-as-paragraph (around LaTeX-sentence-filling) "Start each sentence on a new line." (let ((from (ad-get-arg 0)) (to-marker (set-marker (make-marker) (ad-get-arg 1))) tmp-end) (while (< from (marker-position to-marker)) (forward-sentence) ;; might have gone beyond to-marker --- use whichever is smaller: (ad-set-arg 1 (setq tmp-end (min (point) (marker-position to-marker)))) ad-do-it (ad-set-arg 0 (setq from (point))) (unless (or (bolp) (looking-at "\\s *$")) (LaTeX-newline))) (set-marker to-marker nil))) (ad-activate 'LaTeX-fill-region-as-paragraph) ;; `http://stackoverflow.com/questions/29944022/emacs-after-aquamacs-update-auto-fill-modes-alt-q-breaks-lines-at-maths-delim' (custom-set-variables '(LaTeX-fill-break-at-separators '(;; I comment the following line to allow splitting math groups: ;; \\\( \\\[ \\\]))) (when (and (my-require-maybe 'tex) (my-require-maybe 'tex-buf)) ;; Remove this `evince' stuff, and replace it with `zathura'. (add-to-list 'TeX-view-program-list '("zathura" "zathura %o")) (setq TeX-view-program-selection (delete '(output-pdf "Evince") TeX-view-program-selection)) (add-to-list 'TeX-view-program-selection '(output-pdf "zathura")) ;; Make BibTeX work in buffers that are not masters. Note it may break ;; features that I do not use… (defun LaTeX-bibliography-list () "Replacement function for master file handing…" (if (eq TeX-master t) (and LaTeX-bibliography-list ;return variable's value directly (list (car LaTeX-bibliography-list))) (let* ((master-name (TeX-master-file TeX-default-extension)) (master-buffer (find-file-noselect master-name))) (if master-buffer (with-current-buffer master-buffer (and LaTeX-bibliography-list (list (car LaTeX-bibliography-list)))))))) ;; Augment LaTeX sentinel to detect missing index file. (defadvice TeX-LaTeX-sentinel (after my-TeX-LaTeX-sentinel (process name) activate) ;; if further work is not already pending, then try to detect missing ;; index file. (when (and (string= TeX-command-next TeX-command-Show) (re-search-forward "^No file .*\\.ind\\.$" nil t)) (message "You should run Index now.") (setq TeX-command-next "Index")) ad-return-value) ;; Also augment `TeX-run-command' to set `LaTeX' as next command after ;; `Index'. (defadvice TeX-run-command (after my-TeX-Index-sentinel (name cmd file) activate) (when (string= name "Index") (setq TeX-sentinel-function (lambda (process name) ;; XXX: are we in the correct buffer to pick this value? (message "You should run %s now." TeX-command-default) (setq TeX-command-next TeX-command-default)))) ad-return-value))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Visiting docs (PDFs…) interactively: ;; Disabled since it's a little annoying when compiling with LaTeX actually: ;; (add-hook 'doc-view-mode-hook 'auto-revert-mode) (add-hook 'doc-view-mode-hook (lambda () ;; No confirmation needed when reverting a PDF file. (set (make-local-variable 'revert-without-query) '("\\.pdf$")))) (setq doc-view-resolution 300) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (moy) ;; (defun gdb-noshell () ;; (interactive) ;; "Calls gdb with an empty $SHELL environnement variable" ;; (let ((oldshell (getenv "SHELL"))) ;; (setenv "SHELL") ;; (call-interactively 'gdb) ;; (setenv "SHELL" oldshell))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Emms configuration: ;; (my-lpath-add "emms") ;; (when (my-require-maybe 'emms-setup) ;; (emms-all) ;global setup for emms. ;; (if (my-require-maybe 'emms-player-mpd) ;; (progn ;emms-mpd can be used. ;; (add-to-list 'emms-info-functions 'emms-info-mpd) ;; (add-to-list 'emms-player-list 'emms-player-mpd) ;; (require 'emms-volume) ;; (cond ;; (my-emacs-host-is-epicea ;; (setq emms-player-mpd-server-name "epicea.irisa.fr" ;at the lab... ;; emms-player-mpd-server-port "6600" ;; emms-volume-change-function 'emms-volume-mpd-change)) ;; (t ;; (setq emms-player-mpd-server-name "localhost" ;not at the lab... ;; emms-player-mpd-server-port "6601" ;own daemon port... ;; emms-volume-change-function 'emms-volume-mpd-change ;; emms-source-file-default-directory "/data/music")))) ;; ;; otherwise fallback to default players ;; (emms-default-players)) ;; (global-set-key (kbd "C-c +") 'emms-volume-mode-plus) ;; (global-set-key (kbd "C-c -") 'emms-volume-mode-minus) ;; (setq emms-volume-change-amount 5 ;; emms-volume-mode-timeout 3)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; "Yet Another Oddmuse Mode" (Comprehensive Emacs integration with Oddmuse ;; wikis --- like Emacswiki): ;; (if (my-require-maybe 'yaoddmuse) ;; (when (my-require-maybe 'yaoddmuse-extension) ;; (setq yaoddmuse-browse-function 'yaoddmuse-browse-page-in-w3m)) ;; (message "Could not load yaoddmuse.")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Synonyms (see `http://www.emacswiki.org/emacs/Synonyms'): ;; (setq synonyms-file (expand-file-name "mthesaur.txt" ;; (concat user-emacs-directory "synonyms/")) ;; synonyms-cache-file (expand-file-name "mthesaur-cache.txt" ;; (concat (getenv "HOME") "/.cache/"))) ;; (my-require-maybe 'synonyms) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; EasyPG (transparent encryption/decription): (require 'epa-file) (epa-file-enable) (setq epa-file-cache-passphrase-for-symmetric-encryption t) ;ask once per ;encripted file. ;; Do not use gpg agent to force prompting passphrases in minibuffer (see ;; `http://www.enigmacurry.com/2009/01/14/extending-emacs-with-advice/') (defadvice epg--start (around advice-epg-disable-agent activate) (let ((agent (getenv "GPG_AGENT_INFO"))) (setenv "GPG_AGENT_INFO" nil) ad-do-it (setenv "GPG_AGENT_INFO" agent))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ProofGeneral for Coq: ;; (load-file (expand-file-name "ProofGeneral/generic/proof-site.el" ;; my-emacs-lisp-dir)) ;; (add-to-list 'auto-mode-alist '("\\.v$" . coq-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Org mode customizations: (my-lpath-add "org-mode/lisp") (when (my-require-maybe 'org) ;; --------------------------------------------------------------------------- ;; Calendar configs: (setq my-org-tasks-file "~/org/todo.org" my-org-notes-file "~/org/notes.org" my-org-agenda-file "~/org/calendar.org" my-zimbra-calendar-inbox "~/org/zimbra-inbox.org" org-agenda-files (list my-org-agenda-file my-zimbra-calendar-inbox) my-zimbra-calendar-files (list my-org-agenda-file)) ;alias ;; `http://newartisans.com/2007/08/using-org-mode-as-a-day-planner/' is a good ;; start. (when (my-require-maybe 'org-agenda) ;should never fail actually… (define-key mode-specific-map [?a] 'org-agenda)) ;??? (when (and my-emacs-run-at-lab (my-require-maybe 'url-dav) (my-require-maybe 'org-caldav)) ;; Authentication info is encrypted in `~/.authinfo.gpg' (see ;; `https://github.com/dengste/org-caldav\ ;; #storing-authentication-information-in-authinfonetrc'). (setq org-caldav-url (concat my-zimbra-calendar-url my-inria-address) org-caldav-delete-org-entries 'never org-caldav-calendars `((:calendar-id "Calendar" :files ,my-zimbra-calendar-files :inbox (file+headline ,my-zimbra-calendar-inbox "Calendar")) ;; NB: Should use ics import instead as this is read-only. (:calendar-id "68nqrt" :files nil :inbox (file+headline ,my-zimbra-calendar-inbox "68NQRT")) ) org-icalendar-timezone "Europe/Paris")) (when (my-require-maybe 'org-capture) (define-key global-map "\C-\M-r" 'org-capture) (define-key global-map "\C-cc" 'org-capture) (setq org-default-notes-file my-org-notes-file ;; see `http://orgmode.org/manual/Template-expansion.html' org-capture-templates `(("t" "Todo" entry (file+headline ,my-org-tasks-file "Tasks") "* TODO %?\n %i\n %a") ;; XXX How can we show datetrees in calendar afterwards? ;; ("s" "Evnt" entry (file+datetree+prompt ,my-org-agenda-file)) ;; ("n" "Note" entry (file+datetree ,my-org-notes-file)) ("s" "Evnt" entry (file ,my-org-agenda-file) "* %^{Brief description}\nSCHEDULED: %^t\n%?%i\n%a") ("S" "Event (with time)" entry (file ,my-org-agenda-file) "* %^{Brief description}\nSCHEDULED: %^T\n%?%i\n%a") ("d" "Deadline" entry (file ,my-org-agenda-file) "* %^{Brief description}\nDEADLINE: %^t\n%?%i\n%a") ("D" "Deadline (with time)" entry (file ,my-org-agenda-file) "* %^{Brief description}\nDEADLINE: %^T\n%?%i\n%a") ("n" "Note" entry (file ,my-org-notes-file))))) (setq org-descriptive-links nil) (custom-set-variables `(org-default-notes-file ,my-org-notes-file) '(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 1) ;always start on Monday '(org-reverse-note-order t) '(org-fast-tag-selection-single-key 'expert) '(org-agenda-custom-commands '(("c" todo "DONE|CANCELLED" nil) ("W" agenda "" ((org-agenda-ndays 21))) ("A" agenda "" ((org-agenda-skip-function (lambda () (org-agenda-skip-entry-if 'notregexp "\\=.*\\[#A\\]"))) (org-agenda-ndays 1) (org-agenda-overriding-header "Today's Priority #A tasks: "))) ("u" alltodo "" ((org-agenda-skip-function (lambda () (org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>"))) (org-agenda-overriding-header "Unscheduled TODO entries: "))))) ) ;; --------------------------------------------------------------------------- ;; Some further customizations… (add-hook 'org-mode-hook 'turn-off-auto-fill) (add-hook 'org-mode-hook 'flyspell-mode) (add-hook 'org-mode-hook 'my-justification-left) ;; "Unbind" this 'cause those two keys are often used in reverse order. Note ;; that "C-M-k" is bound to `delete-frame' instead of ;; `save-buffers-kill-terminal' initially. (add-hook 'org-mode-hook 'my-disable-Cx-Cc) ;; Most of my org file are in american english: (add-hook 'org-mode-hook 'my-flyspell-traverse-atlantic) ;; Appearance (custom-set-variables '(org-startup-truncated nil)) ;; `http://draketo.de/english/emacs/writing-papers-in-org-mode-acpd' ;; Using RefTex: (when (my-require-maybe 'reftex-cite) (defun my-org-mode-reftex-setup () (interactive) (when (and (buffer-file-name) (file-exists-p (buffer-file-name))) ;; Reftex should use the org file as master file. See C-h v ;; TeX-master for infos. (setq TeX-master t) (set (make-local-variable 'reftex-cite-prompt-optional-args) nil) (set (make-local-variable 'reftex-cite-cleanup-optional-args) t) ;; (make-local-variable 'reftex-default-bibliography) ;; (make-local-variable 'bib) (turn-on-reftex) ;; enable auto-revert-mode to update reftex when bibtex file changes on disk ;; (global-auto-revert-mode t) ; careful: this can kill the undo history ;; ; when you change the file on-disk. (reftex-parse-all) ;; add a custom reftex cite format to insert links ;; This also changes any call to org-citation! ;; (reftex-set-cite-format ;; '((?\s . " [[cite:%l]]") ; standard citation style ;; (?t . " [[citet:%l]]") ; natbib inline text ;; (?p . " [[citep:%l]]") ; natbib with parens ;; ;; '((?\s . " \\cite{%l}") ; standard citation style ;; ;; (?t . " \\citet{%l}") ; natbib inline text ;; ;; (?p . " \\citep{%l}") ; natbib with parens ;; )) ;; (save-excursion ;; (save-restriction ;; (widen) ;; (let ((case-fold-search t) ;; (re "^[ \t]*#\\+BIBLIOGRAPHY:[ \t]+\\([^ \t\n]+\\)")) ;; (if (not (save-excursion ;; (or (re-search-forward re nil t) ;; (re-search-backward re nil t)))) ;; (message "No bibliography defined in file") ;; (setq bib (concat (match-string 1) ".bib")) ;; (setq reftex-default-bibliography (list bib))))))) ) ;; ) (define-key org-mode-map (kbd "C-c (") 'reftex-citation) ;; (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search) ) (add-hook 'org-mode-hook 'my-org-mode-reftex-setup)) (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (dot . t) (ditaa . t) ;; (R . t) ;; (python . t) ;; (ruby . t) (gnuplot . t) (sh . t) (ocaml . t) (org . t) (latex . t))) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar") (setq org-log-done t) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Ebib config: ;; (setq ebib-citation-commands ;; '((any ;; (("cite" "\\cite%<[%A]%>{%K}") ;; ("citep" "\\citep%<[%A]%>[%A]{%(%K%,)}") ;; ("citet" "\\citet%<[%A]%>[%A]{%(%K%,)}"))) ;; (org-mode ;; (("ebib" "[[ebib:%K][%D]]") ;; ("citep" "[[citep:%K][%D]]") ;; ("citet" "[[citet:%K][%D]]"))) ;; (markdown-mode ;; (("text" "@%K%< [%A]%>") ;; ("paren" "[%(%<%A %>@%K%<, %A%>%; )]") ;; ("year" "[-@%K%< %A%>]"))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Map some extra UTF-8 characters, that are not already mapped by xmodmap (the ;; xmodmap configuration file that I use can be found here: ;; `http://nberth.space/file:.xmodmaprc'): (mapcar #'(lambda (e) (lexical-let ((c (cdr e))) (global-set-key (car e) (lambda () (interactive) (insert c))))) '( ;; `G' stands for `Alt Gr' key; for qwerty keyboard. ([(control ?<)] . ?⊂) ;C-< ([(control ?>)] . ?⊃) ;C-> ([(control ?{)] . ?\〈) ;C-{ ([(control ?})] . ?\〉) ;C-} ([(control ? )] . ?​) ;C-S-space (zero-width space) ([(control ?«)] . ?ℤ) ;C-G-Z ([(control ?»)] . ?Ξ) ;C-G-X (in case…) ([(control ?È)] . ?\〈) ;C-G-{ ([(control ?×)] . ?⊗) ;C-G-* ([(control ?è)] . ?\⟦) ;C-G-[ ([(control ?Œ)] . ?∘) ;C-G-O (XXX dupl. X-G-o) ([(control ?œ)] . ?∘) ;C-G-O ("ring operator") ([(control ?Γ)] . ?∁) ;C-G-Γ (complement --- XXX dupl. C-G-γ) ([(control ?Δ)] . ?∇) ;C-G-D (nabla) ([(control ?Λ)] . ?𝓛) ;C-G-L (XXX dupl. C-c C-G-L) ([(control ?Π)] . ?℘) ;C-G-P ([(control ?Υ)] . ?∩) ;C-G-U ([(control ?γ)] . ?ɔ) ;C-G-γ (used as complement in traces) ([(control ?ζ)] . ?ℤ) ;C-G-z (XXX duplicates C-G-Z) ([(control ?λ)] . ?ℓ) ;C-G-l (math. "ell") ([(control ?ξ)] . ?Ξ) ;C-G-x (XXX duplicates C-G-X) ([(control ?π)] . ?¶) ;C-G-p (pilcrow sign) ([(control ?σ)] . ?§) ;C-G-s (XXX duplicates C-G-p) ([(control ?υ)] . ?∪) ;C-G-u ([(control ?…)] . ?∴) ;C-G-. (therefore) ([(control ?ℕ)] . ?₪) ;C-G-N (sign.) ([(control ?⇔)] . ?≝) ;C-G-= ([(control ?∃)] . ?∄) ;C-G-E ([(control ?∈)] . ?∖) ;C-G-\ (set minus) ([(control ?√)] . ?∫) ;C-G-J ([(control ?≈)] . ?⊕) ;C-G-+ ([(control ?≤)] . ?⊆) ;C-G-< ([(control ?≥)] . ?⊇) ;C-G-> ([(control ?♯)] . ?⊨) ;C-G-# ([(control ?→)] . ?⤳) ;C-→ ([(control dead-acute)] . ?\⟧) ;C-G-] ([(control meta ?,)] . ?⊑) ;C-M-, (XXX duplicates C-M-G-<) ([(control meta ?<)] . ?⊏) ;C-M-< ([(control meta ?>)] . ?⊐) ;C-M-> ([(control meta ?Δ)] . ?𝛁) ;C-M-G-D (bold nabla) ([(control meta ?Υ)] . ?⊓) ;C-M-G-U ([(control meta ?λ)] . ?𝔩) ;C-M-G-l (fraktur small l --- XXX dupl.) ([(control meta ?π)] . ?¶) ;C-M-G-p (pilcrow sign --- XXX dupl.) ([(control meta ?υ)] . ?⊔) ;C-M-G-u ([(control meta ?…)] . ?∙) ;C-M-G-. ("bullet operator") ([(control meta ?⇔)] . ?≜) ;C-M-G-= ([(control meta ?≤)] . ?⊑) ;C-M-G-< ([(control meta ?≥)] . ?⊒) ;C-M-G-> ([(control meta ?\()] . ?\() ;C-M-(G-)( (FF08 - fullwidth"\(" → "\left(") ([(control meta ?\))] . ?\)) ;C-M-(G-)) (FF09 - fullwidth")" → "\right)") ([(control meta ?{)] . ?\{) ;C-M-(G-){ (FF5B - fullwidth"{" → "\left\{") ([(control meta ?|)] . ?|) ;C-M-| (FF5C - fullwidth"|" → "\middle|") ([(control meta ?})] . ?\}) ;C-M-(G-)} (FF5D - fullwidth"}" → "\right\}") ([(control meta ?È)] . ?\{) ;C-M-G-{ (FF5B - fullwidth"{" → "\left\{") ([(control meta ?è)] . ?\[) ;C-M-G-[ (FF3B - fullwidth"[" → "\left[") ([(control meta ?∉)] . ?|) ;C-M-G-| (FF5C - fullwidth"|" → "\middle|") ([(control meta ?⊎)] . ?\]) ;C-M-G-] (FF3D - fullwidth"]" → "\right]") ([(control ?c) (?∀)] . ?𝓐) ;C-c G-A (bold script capital a) ([(control ?c) (?⊥)] . ?𝓑) ;C-c G-B (bold script capital b) ([(control ?c) (?Γ)] . ?𝓒) ;C-c G-C (bold script capital c) ([(control ?c) (?Δ)] . ?𝓓) ;C-c G-D (bold script capital d) ([(control ?c) (?∃)] . ?𝓔) ;C-c G-E (bold script capital e) ([(control ?c) (?Φ)] . ?𝓕) ;C-c G-F (bold script capital f) ([(control ?c) (?G)] . ?𝓖) ;C-c G-G (bold script capital g) ([(control ?c) (?Ψ)] . ?𝓗) ;C-c G-H (bold script capital h) ([(control ?c) (?‖)] . ?𝓘) ;C-c G-I (bold script capital i) ([(control ?c) (?√)] . ?𝓙) ;C-c G-J (bold script capital j) ([(control ?c) (?K)] . ?𝓚) ;C-c G-K (bold script capital k) ([(control ?c) (?Λ)] . ?𝓛) ;C-c G-L (bold script capital l) ([(control ?c) (?M)] . ?𝓜) ;C-c C-M (bold script capital m) ([(control ?c) (?ℕ)] . ?𝓝) ;C-c G-N (bold script capital n) ([(control ?c) (?Œ)] . ?𝓞) ;C-c G-O (bold script capital o) ([(control ?c) (?Π)] . ?𝓟) ;C-c G-P (bold script capital p) ([(control ?c) (?ℚ)] . ?𝓠) ;C-c G-Q (bold script capital q) ([(control ?c) (?ℝ)] . ?𝓡) ;C-c G-R (bold script capital r) ([(control ?c) (?Σ)] . ?𝓢) ;C-c G-S (bold script capital s) ([(control ?c) (?⊤)] . ?𝓣) ;C-c G-T (bold script capital t) ([(control ?c) (?Υ)] . ?𝓤) ;C-c G-U (bold script capital u) ([(control ?c) (?∧)] . ?𝓥) ;C-c G-V (bold script capital v) ([(control ?c) (?Ω)] . ?𝓦) ;C-c C-W (bold script capital w) ([(control ?c) (?»)] . ?𝓧) ;C-c G-X (bold script capital x) ([(control ?c) (?Θ)] . ?𝓨) ;C-c G-Y (bold script capital y) ([(control ?c) (?«)] . ?𝓩) ;C-c G-Z (bold script capital z) ([(control ?c) (control ?Δ)] . ?𝔇) ;C-c C-G-D (fraktur capital d) ([(control ?c) (control ?Φ)] . ?𝔉) ;C-c C-G-F (fraktur capital f) ([(control ?c) (control ?χ)] . ?𝔊) ;C-c C-G-G (fraktur capital g) ([(control ?c) (control ?√)] . ?𝔍) ;C-c C-G-J (fraktur capital j) ([(control ?c) (control ?K)] . ?𝔎) ;C-c C-(G-)K (fraktur capital k) ([(control ?c) (control ?Λ)] . ?𝔏) ;C-c C-G-L (fraktur capital l) ([(control ?c) (control ?⋯)] . ?𝔐) ;C-c C-G-M (fraktur capital m) ([(control ?c) (control ?ℕ)] . ?𝔑) ;C-c C-G-N (fraktur capital n) ([(control ?c) (control ?λ)] . ?𝔩) ;C-c C-G-l (fraktur small l) ([(control ?c) (control ?×)] . ?⨂) ;C-c C-G-* (n-ary circled times) ([(control ?c) (control ?Π)] . ?∏) ;C-c C-G-P (n-ary product) ([(control ?c) (control ?Σ)] . ?∑) ;C-c C-G-S (n-ary sum) ([(control ?c) (control ?Υ)] . ?⋂) ;C-c C-G-U (n-ary intersection) ([(control ?c) (control ?υ)] . ?⋃) ;C-c C-G-u (n-ary union) ([(control ?c) (control ?∧)] . ?⋀) ;C-c C-G-V (n-ary logical and) ([(control ?c) (control ?∨)] . ?⋁) ;C-c C-G-v (n-ary logical or) ([(control ?c) (control ?≈)] . ?⨁) ;C-c C-G-+ (n-ary circled plus) ([(control ?c) (control ?\〈)] . ?⟅) ;C-c C-G-( (bag left opening) ([(control ?c) (control ?\〉)] . ?⟆) ;C-c C-G-) (bag right closing) ([(control ?c) (control ?→)] . ?⟼) ;C-c C-G-→ (maps to) ([(control ?c) (control meta ?Υ)] . ?⨅) ;C-c C-M-G-U ([(control ?c) (control meta ?υ)] . ?⨆) ;C-c C-M-G-u ([(control ?c) (control ?<)] . ?⊑) ;C-c C-< ([(control ?c) (control ?≤)] . ?⋐) ;C-c C-G-< ) ) ;; Type C-e while incremental searching to insert characters above in search ;; string. (define-key isearch-mode-map (kbd "C-e") 'isearch-edit-string) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Automatic customizations (incl. some faces…) (setq custom-file (expand-file-name "customize" user-emacs-directory)) (load custom-file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; End