2012-10-12 22:02:52 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; MAIN
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2013-05-31 19:01:32 +02:00
|
|
|
|
;; Folders.
|
|
|
|
|
|
|
|
|
|
(setq emacs-cache-folder "~/.cache/emacs/")
|
|
|
|
|
(if
|
|
|
|
|
(not (file-directory-p emacs-cache-folder))
|
|
|
|
|
(make-directory emacs-cache-folder))
|
|
|
|
|
|
|
|
|
|
;; Remember last cursor position
|
|
|
|
|
(require 'saveplace)
|
|
|
|
|
(setq save-place-file (concat emacs-cache-folder "saveplace"))
|
|
|
|
|
(setq-default save-place t)
|
|
|
|
|
|
|
|
|
|
;; Disable autosave features
|
2013-06-03 20:18:14 +02:00
|
|
|
|
;; TODO: does not work?
|
2013-05-31 19:01:32 +02:00
|
|
|
|
(setq auto-save-default nil)
|
2013-06-03 20:18:14 +02:00
|
|
|
|
(setq auto-save-list-file-name nil)
|
|
|
|
|
;; (setq auto-save-file-name-transforms
|
|
|
|
|
;; '((".*" ,temporary-file-directory t)))
|
2013-05-31 19:01:32 +02:00
|
|
|
|
|
|
|
|
|
;; Place Backup Files in Specific Directory
|
|
|
|
|
;; TODO: use cache variable.
|
|
|
|
|
(setq backup-directory-alist
|
|
|
|
|
(quote ((".*" . "~/.cache/emacs/backups/"))))
|
2013-06-03 20:18:14 +02:00
|
|
|
|
;; `(quote ((".*" . ,(concat emacs-cache-folder "backups/")))))
|
|
|
|
|
;; '((".*" . (concat emacs-cache-folder "backups/"))))
|
2013-05-31 19:01:32 +02:00
|
|
|
|
;; (setq backup-inhibited t) ;; Disable backup files.
|
|
|
|
|
;; (setq make-backup-files t) ;; Enable backup files.
|
|
|
|
|
;; (setq version-control t) ;; Enable numbered versioning.
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2013-02-04 21:32:40 +01:00
|
|
|
|
;; We use a minor mode to override global keys.To assign
|
|
|
|
|
;; global keys, you need to write
|
|
|
|
|
;; (define-key my-keys-minor-mode-map (kbd "C-i") 'some-function)
|
|
|
|
|
(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
|
|
|
|
|
|
|
|
|
|
(define-minor-mode my-keys-minor-mode
|
|
|
|
|
"A minor mode so that my key settings override annoying major modes."
|
|
|
|
|
t " my-keys" 'my-keys-minor-mode-map)
|
|
|
|
|
|
|
|
|
|
(add-hook 'minibuffer-setup-hook (lambda () (my-keys-minor-mode 0) ) )
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2013-02-28 22:09:31 +01:00
|
|
|
|
;; Default mode
|
|
|
|
|
(setq default-major-mode 'text-mode)
|
|
|
|
|
|
2013-05-24 11:44:23 +02:00
|
|
|
|
;; For convenience.
|
|
|
|
|
(setq inhibit-startup-screen t)
|
2013-05-24 12:03:48 +02:00
|
|
|
|
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
2013-05-24 11:44:23 +02:00
|
|
|
|
(menu-bar-mode -1)
|
2013-05-24 12:03:48 +02:00
|
|
|
|
;; (scroll-bar-mode -1)
|
2013-05-26 21:20:11 +02:00
|
|
|
|
(if (fboundp 'set-scroll-bar-mode) (set-scroll-bar-mode 'left))
|
2013-05-24 11:44:23 +02:00
|
|
|
|
|
2013-03-04 17:31:57 +01:00
|
|
|
|
;; Make questions less annoying.
|
2013-01-10 17:33:33 +01:00
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
2013-03-04 17:31:57 +01:00
|
|
|
|
;; Print column number.
|
2013-01-10 17:33:33 +01:00
|
|
|
|
(column-number-mode 1)
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
2013-03-04 17:31:57 +01:00
|
|
|
|
;; Kill whole line including \n.
|
2013-01-10 17:33:33 +01:00
|
|
|
|
(setq kill-whole-line t)
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
2013-02-26 12:04:44 +01:00
|
|
|
|
;; Alternative scrolling
|
2013-02-04 21:32:40 +01:00
|
|
|
|
(define-key my-keys-minor-mode-map [next]
|
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(condition-case nil (scroll-up)
|
|
|
|
|
(end-of-buffer (goto-char (point-max))))))
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
2013-02-04 21:32:40 +01:00
|
|
|
|
(define-key my-keys-minor-mode-map [prior]
|
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(condition-case nil (scroll-down)
|
|
|
|
|
(beginning-of-buffer (goto-char (point-min))))))
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
|
|
|
|
;; Line numbers
|
2013-05-24 11:44:23 +02:00
|
|
|
|
;; TODO: This mode is really messy. Replace it.
|
2012-10-12 15:23:36 +02:00
|
|
|
|
(autoload 'linum-mode "linum" "toggle line numbers on/off" t)
|
2013-05-25 13:43:22 +02:00
|
|
|
|
(if (not (fboundp 'tool-bar-mode)) (setq linum-format "%d "))
|
2013-05-24 11:44:23 +02:00
|
|
|
|
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
|
2013-02-04 21:32:40 +01:00
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-<f5>") 'linum-mode) ;; Toggle line numbers.
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
|
|
|
|
;; Indentation
|
2013-01-10 17:33:33 +01:00
|
|
|
|
;(setq standard-indent 4)
|
2013-02-27 22:35:16 +01:00
|
|
|
|
(setq-default tab-width 4)
|
2013-01-10 17:33:33 +01:00
|
|
|
|
(setq-default indent-tabs-mode nil) ;; Indentation cannot insert tabs
|
2012-10-12 15:23:36 +02:00
|
|
|
|
|
|
|
|
|
;; Line by line scrolling
|
|
|
|
|
(setq scroll-step 1)
|
|
|
|
|
|
|
|
|
|
;; Highlight selections -- not activated by default on old emacs.
|
|
|
|
|
(transient-mark-mode 1)
|
|
|
|
|
|
|
|
|
|
;; No trailing whitespace
|
|
|
|
|
;; WARNING: this can break some configuration files needing whitespaces at the
|
|
|
|
|
;; end.
|
|
|
|
|
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
|
|
|
|
2013-03-08 15:46:03 +01:00
|
|
|
|
;; Highlight trailing whitespaces. For programming languages only, so that it
|
2013-05-29 17:41:15 +02:00
|
|
|
|
;; does not affect buffer like calendar and so on. There is no prog-mode-hook on
|
|
|
|
|
;; Emacs<24.
|
2013-03-08 15:46:03 +01:00
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (mode-hook)
|
|
|
|
|
(add-hook
|
|
|
|
|
mode-hook
|
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(setq show-trailing-whitespace t))))
|
|
|
|
|
'(prog-mode-hook lua-mode-hook))
|
|
|
|
|
|
|
|
|
|
;; Remove whitespaces on region, or whole file.
|
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-\\") 'delete-trailing-whitespace)
|
|
|
|
|
|
2012-10-12 15:23:36 +02:00
|
|
|
|
;; Abbreviation support
|
|
|
|
|
(setq default-abbrev-mode t)
|
|
|
|
|
|
|
|
|
|
;; Set Fill Column
|
|
|
|
|
(setq-default fill-column 80)
|
2013-01-10 17:33:33 +01:00
|
|
|
|
;; (auto-fill-mode 1) ;; Will not work because it gets overridden by major modes.
|
2012-10-12 15:23:36 +02:00
|
|
|
|
(add-hook 'text-mode-hook 'turn-on-auto-fill)
|
|
|
|
|
|
|
|
|
|
;; Man-mode
|
|
|
|
|
(setenv "MANWIDTH" "80")
|
|
|
|
|
|
|
|
|
|
;; Windmove mode
|
|
|
|
|
(when (fboundp 'windmove-default-keybindings)
|
|
|
|
|
(windmove-default-keybindings))
|
|
|
|
|
|
|
|
|
|
;; Browser
|
2013-02-26 18:30:31 +01:00
|
|
|
|
(setq browse-url-generic-program
|
|
|
|
|
(executable-find
|
|
|
|
|
(let ((b (getenv "BROWSER")))
|
|
|
|
|
(if b b "w3m" )))
|
|
|
|
|
browse-url-browser-function 'browse-url-generic)
|
2012-11-13 18:46:20 +01:00
|
|
|
|
|
|
|
|
|
;; Default ispell dictionnay
|
2013-02-26 18:30:31 +01:00
|
|
|
|
;; (setq ispell-dictionary "fr")
|
|
|
|
|
(define-key my-keys-minor-mode-map
|
2013-02-27 22:35:16 +01:00
|
|
|
|
(kbd "C-<f7>")
|
2013-02-26 18:30:31 +01:00
|
|
|
|
(lambda () (interactive) (ispell-change-dictionary "en")))
|
|
|
|
|
(define-key my-keys-minor-mode-map
|
2013-02-27 22:35:16 +01:00
|
|
|
|
(kbd "C-<f8>")
|
2013-02-26 18:30:31 +01:00
|
|
|
|
(lambda () (interactive) (ispell-change-dictionary "fr")))
|
2012-12-21 21:30:54 +01:00
|
|
|
|
|
|
|
|
|
;; Use color escape sequences. Only use if needed.
|
|
|
|
|
;; (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
|
2013-01-08 00:36:02 +01:00
|
|
|
|
|
|
|
|
|
;; Long paragraphs. Useful for quick navigation with backward-paragraph and
|
|
|
|
|
;; forward-paragraph.
|
|
|
|
|
(setq paragraph-start "
|
|
|
|
|
")
|
2013-01-10 15:57:07 +01:00
|
|
|
|
|
|
|
|
|
;; Show matching parenthesis
|
|
|
|
|
(show-paren-mode 1)
|
|
|
|
|
;; By default, there’s a small delay before showing a matching parenthesis. Set
|
|
|
|
|
;; it to 0 to deactivate.
|
|
|
|
|
(setq show-paren-delay 0)
|
|
|
|
|
|
2013-01-23 14:59:25 +01:00
|
|
|
|
;; query-replace-regex fix on terminals.
|
2013-05-25 13:43:22 +02:00
|
|
|
|
(if (not (fboundp 'tool-bar-mode)) (define-key my-keys-minor-mode-map (kbd "C-M-y") 'query-replace-regexp))
|
2013-02-27 18:44:46 +01:00
|
|
|
|
|
2013-05-31 19:01:32 +02:00
|
|
|
|
;; Semantic options.
|
2013-02-27 18:44:46 +01:00
|
|
|
|
(semantic-mode 1)
|
2013-06-04 15:33:36 +02:00
|
|
|
|
(setq semanticdb-default-save-directory (concat emacs-cache-folder "semanticdb"))
|
2013-05-31 19:01:32 +02:00
|
|
|
|
;; Semantic with ghost display (allows M-n and M-p to browse completion).
|
2013-02-27 18:44:46 +01:00
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-c , d") 'semantic-ia-show-summary)
|
2013-05-27 20:36:12 +02:00
|
|
|
|
;; (setq semantic-complete-inline-analyzer-displayor-class 'semantic-displayor-ghost)
|
2013-05-29 17:41:15 +02:00
|
|
|
|
;; (setq semantic-complete-inline-analyzer-displayor-class 'semantic-displayor-tooltip)
|
2013-05-27 20:36:12 +02:00
|
|
|
|
;; (setq semanticdb-find-default-throttle '(project unloaded system recursive))
|
2013-02-27 18:44:46 +01:00
|
|
|
|
|
2013-03-01 16:43:21 +01:00
|
|
|
|
;; Electric Pairs to auto-complete () [] {} "" etc. You can use it on regions.
|
2013-05-22 17:35:54 +02:00
|
|
|
|
(if (string-match "^24.*" emacs-version )
|
|
|
|
|
(electric-pair-mode 1))
|
2013-02-27 22:35:16 +01:00
|
|
|
|
|
|
|
|
|
;; Run ranger asynchronously.
|
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-x D")
|
2013-03-01 16:43:21 +01:00
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(shell-command "urxvt -e ranger &")
|
|
|
|
|
(delete-windows-on "*Async Shell Command*")))
|
2013-02-27 22:35:16 +01:00
|
|
|
|
|
2013-03-01 16:43:21 +01:00
|
|
|
|
;; Calendar ISO display.
|
2013-02-27 22:35:16 +01:00
|
|
|
|
(setq calendar-week-start-day 1)
|
|
|
|
|
(setq calendar-date-style 'iso)
|
2013-02-28 22:09:31 +01:00
|
|
|
|
|
2013-03-01 16:43:21 +01:00
|
|
|
|
;; IDO (Interactively Do Thing) for finding files and buffers.
|
|
|
|
|
(require 'ido)
|
|
|
|
|
(ido-mode t)
|
|
|
|
|
(setq ido-enable-flex-matching t)
|
|
|
|
|
|
|
|
|
|
;; Quick buffer switching.
|
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-<prior>") 'previous-buffer)
|
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-<next>") 'next-buffer)
|
|
|
|
|
|
|
|
|
|
;; Do not open other window for buffer menu, plus hide non-file buffers.
|
|
|
|
|
(define-key my-keys-minor-mode-map (kbd "C-x C-b")
|
|
|
|
|
(lambda () (interactive)
|
|
|
|
|
(buffer-menu 1)))
|
2013-03-01 19:06:47 +01:00
|
|
|
|
|
|
|
|
|
;; Disable prompt (but leave warning) on git symlink.
|
|
|
|
|
(setq vc-follow-symlinks t)
|
|
|
|
|
|
2013-03-04 17:31:57 +01:00
|
|
|
|
;; Org mode config.
|
2013-03-02 19:34:12 +01:00
|
|
|
|
(add-hook 'org-mode-hook
|
2013-03-01 19:06:47 +01:00
|
|
|
|
(lambda () (interactive) )
|
2013-03-02 19:34:12 +01:00
|
|
|
|
(setq org-agenda-files '("~/todo.org"))
|
2013-03-01 19:06:47 +01:00
|
|
|
|
(setq org-enforce-todo-dependencies t))
|
2013-05-27 23:56:42 +02:00
|
|
|
|
|
|
|
|
|
;; Ediff in one frame.
|
|
|
|
|
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|