1
0
mirror of https://github.com/balkian/dotfiles.git synced 2024-11-21 19:52:29 +00:00

Polished emacs.d config

This commit is contained in:
J. Fernando Sánchez 2015-03-24 22:58:59 +01:00
parent 043530ca03
commit 44d496f846
7 changed files with 293 additions and 151 deletions

View File

@ -0,0 +1,55 @@
(evil-define-key 'normal ein:notebooklist-mode-map
"r" 'ein:notebooklist-reload
"q" 'bury-buffer)
(evil-define-key 'normal ein:notebook-mode-map
",w" 'ein:notebook-save-notebook-command
",cc" 'ein:worksheet-execute-cell
",e" 'ein:worksheet-clear-output
",v" 'ein:worksheet-set-output-visibility-all
",l" 'ein:worksheet-clear-output
",L" 'ein:worksheet-clear-all-output
",d" 'ein:worksheet-kill-cell
",y" 'ein:worksheet-copy-cell
",p" 'ein:worksheet-yank-cell
",O" 'ein:worksheet-insert-cell-above
",o" 'ein:worksheet-insert-cell-below
"]e" 'ein:notebook-worksheet-move-next
"[e" 'ein:notebook-worksheet-move-rev
",t" 'ein:worksheet-toggle-cell-type
",u" 'ein:worksheet-change-cell-type
",s" 'ein:worksheet-split-cell-at-point
",m" 'ein:worksheet-merge-cell
"\C-n" 'ein:worksheet-goto-next-input
"\C-p" 'ein:worksheet-goto-prev-input
(kbd "<C-return>") 'ein:worksheet-execute-cell)
(evil-define-key 'insert ein:notebook-mode-map
(kbd "<C-return>") 'ein:worksheet-execute-cell)
(defun ipybackground ()
(interactive)
;(setq prevfg (face-attribute 'default :foreground))
(face-remap-add-relative 'ein:cell-input-area :background (face-attribute 'default :background))
;(face-remap-add-relative 'default :background "#ffffff")
(setq buffer-face-mode-face '(:background "#343434"))
(buffer-face-mode))
(add-hook
'ein:notebook-mode-hook 'ipybackground)
;; (add-hook
;; 'ein:notebook-mode-hook '(linum-mode 0))
(setq ein:notebook-modes '(ein:notebook-mumamo-mode ein:notebook-plain-mode))
(setq mumamo-background-colors nil)
(when (and (>= emacs-major-version 24)
(>= emacs-minor-version 2))
(eval-after-load "mumamo"
'(setq mumamo-per-buffer-local-vars
(delq 'buffer-file-name mumamo-per-buffer-local-vars))))
(provide 'config-ein)

View File

@ -0,0 +1,36 @@
;;
;; Evil and keybindings
;;
(evil-mode)
(require 'evil-nerd-commenter)
(require 'evil-matchit)
(require 'evil-surround)
(require 'evil-jumper)
;; Evil global modes
(global-evil-matchit-mode 1)
(global-evil-jumper-mode)
(global-evil-surround-mode 1)
;; Evil global modes config
(evilnc-default-hotkeys)
(setq evil-default-cursor t)
;; Exclude modes from evil mode
(add-to-list 'evil-emacs-state-modes 'git-rebase-mode)
(add-to-list 'evil-emacs-state-modes 'undo-tree-visualizer-mode)
(add-to-list 'evil-emacs-state-modes 'neotree-mode)
;;
;; Evil keys
;; cool jumping
(define-key evil-normal-state-map (kbd "[b") 'evil-next-buffer)
(define-key evil-normal-state-map (kbd "]b") 'evil-prev-buffer)
(define-key evil-normal-state-map (kbd "s") 'evil-ace-jump-char-mode)
(define-key evil-normal-state-map (kbd ",d") 'neotree-toggle)
(define-key evil-normal-state-map (kbd "C-c +") 'evil-numbers/inc-at-pt)
(define-key evil-normal-state-map (kbd "C-c -") 'evil-numbers/dec-at-pt)
(provide 'config-evil)

View File

@ -0,0 +1,37 @@
;;; Helm
(helm-mode 1)
(require 'projectile)
(require 'helm-projectile)
(require 'helm-locate)
(require 'helm-config)
(require 'helm-misc)
(require 'helm-locate)
(setq helm-quick-update t)
(setq helm-bookmark-show-location t)
(setq helm-buffers-fuzzy-matching t)
;; Config
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebihnd tab to do persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
(define-key helm-grep-mode-map (kbd "<return>") 'helm-grep-mode-jump-other-window)
(define-key helm-grep-mode-map (kbd "n") 'helm-grep-mode-jump-other-window-forward)
(define-key helm-grep-mode-map (kbd "p") 'helm-grep-mode-jump-other-window-backward)
;; Better helm fonts
(set-face-attribute 'helm-selection nil :background "gold" :foreground "black")
;;; Evil helm
(define-key evil-normal-state-map (kbd "C-p") 'helm-mini)
(define-key evil-normal-state-map (kbd "SPC") 'helm-M-x)
(define-key evil-normal-state-map (kbd ",f") 'helm-occur)
(define-key evil-normal-state-map (kbd ",a") 'helm-ag)
(define-key evil-normal-state-map (kbd ",p") 'helm-show-kill-ring)
;;; Keyboard
(global-set-key (kbd "M-x") 'helm-M-x)
(define-key helm-map (kbd "C-w") 'backward-kill-word)
(provide 'config-helm)

View File

@ -0,0 +1,38 @@
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-view-program-list '(
;; ("Evince" "evince --page-index=%(outpage) %o"),
("Okular" "okular --noraise --unique %o#src:%n%a")
))
;; (setq TeX-view-program-selection '((output-pdf "Evince")))
(setq TeX-view-program-selection '((output-pdf "Okular")))
(setq LaTeX-command "latex -synctex=1")
(setq TeX-source-correlate-method 'synctex)
;(setq TeX-one-master "<none>") ;; If you don't want emacs to write the variables to the file
(setq-default TeX-master nil) ;
;; Avoid questions :)
(defun build-view ()
(interactive)
(let ((TeX-save-query nil))
(TeX-save-document (TeX-master-file)))
(setq build-proc (TeX-command "LaTeX" 'TeX-master-file -1))
(set-process-sentinel build-proc 'build-sentinel)
)
(defun build-sentinel (process event)
(if (string= event "finished\n")
(TeX-view)
(message "Errors! Check with C-`")))
(add-hook 'LaTeX-mode-hook '(lambda () (local-set-key (kbd "\C-c\C-c") 'build-view)))
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(add-hook 'LaTeX-mode-hook 'reftex-mode)
(provide 'config-latex)

View File

@ -0,0 +1,18 @@
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-directory "~/Dropbox/org")
(setq org-mobile-inbox-for-pull "~/Dropbox/org/inbox.org")
(setq org-mobile-directory "~/Dropbox/Apps/MobileOrg")
(setq org-mobile-files '("~/Dropbox/org"))
(setq org-default-notes-file (concat org-directory "/notes.org"))
(setq org-agenda-files (list org-directory))
(define-key global-map "\C-cc" 'org-capture)
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(provide 'config-org)

View File

@ -0,0 +1,24 @@
(require 'python)
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "--pylab"
python-shell-prompt-regexp "In \\[[0-9]+\\]: "
python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
python-shell-completion-setup-code
"from IPython.core.completerlib import module_completion"
python-shell-completion-module-string-code
"';'.join(module_completion('''%s'''))\n"
python-shell-completion-string-code
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
(add-hook 'python-mode-hook 'auto-complete-mode)
(add-hook 'python-mode-hook '(lambda () (require 'nose)))
(add-hook 'python-mode-hook 'jedi:setup)
(eval-after-load "python"
'(progn
(define-key python-mode-map (kbd "C-c C-d") 'helm-pydoc)))
(setq jedi:complete-on-dot t)
(provide 'config-python)

View File

@ -1,6 +1,22 @@
; BalkEmacs --- My emacs configuration
;;; Commentary:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes (quote ("c3c0a3702e1d6c0373a0f6a557788dfd49ec9e66e753fb24493579859c8e95ab" "3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;; Config that needs to be loaded before require
(setq evil-want-C-u-scroll t)
;;; Code:
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
@ -18,8 +34,6 @@
(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes")
(setq evil-want-C-u-scroll t)
(setq el-get-sources
'((:name molokai-theme
:type github
@ -40,6 +54,7 @@
evil-jumper
evil-matchit
evil-nerd-commenter
evil-numbers
evil-surround
fill-column-indicator
flycheck
@ -51,14 +66,17 @@
jedi
magit
markdown-mode
neotree
nxhtml
nose
pivotal-tracker
powerline
popwin
pretty-mode
projectile
;; smex
smart-mode-line
switch-window ; takes over C-x o
undo-tree
yasnippet
; zencoding-mode ; http://www.emacswiki.org/emacs/ZenCoding
;; color-theme-solarized
@ -79,7 +97,6 @@
(set-default-font "DejaVu Sans Mono")
(evil-mode)
;;(color-theme-solarized-dark)
;(load-theme 'soothe t)
;;(require 'monokai-theme)
@ -88,27 +105,13 @@
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-hook 'after-init-hook #'global-flycheck-mode)
(require 'ido)
(ido-mode t)
(setq flycheck-temp-prefix ".flycheck")
;;(require 'autopair)
;;(autopair-global-mode) ;; to enable in all buffers
;; SMEX, improvement of M-X
;;(global-set-key (kbd "M-x") 'smex)
;;(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
;;(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;;(setq completion-cycle-threshold t)
(helm-mode 1)
(define-key evil-normal-state-map (kbd "C-p") 'helm-mini)
(require 'evil-nerd-commenter)
(evilnc-default-hotkeys)
(defun toggle-current-window-dedication ()
(interactive)
(let* ((window (selected-window))
@ -120,102 +123,83 @@
(global-set-key [pause] 'toggle-current-window-dedication)
;;; Linum
(require 'linum)
(global-linum-mode 1)
(set-face-attribute 'linum nil :height 100 :foreground "#666")
(setq linum-format " %d ")
(set-face-background 'hl-line-face "gray18")
(setq linum-mode-inhibit-modes-list '(eshell-mode
shell-mode
ein:notebook-bg-mode
ein:bg/ein:notebook
ein:bg
ein:notebook
)
)
;; (global-linum-mode 1)
;; (setq linum-mode-inhibit-modes-list '(eshell-mode
;; helm-buffer
;; shell-mode
;; ein:notebook-bg-mode
;; ein:bg/ein:notebook
;; ein:bg
;; ein:notebook
;; ))
;; (defadvice linum-on (around linum-on-inhibit-for-modes)
;; "Stop the load of linum-mode for some major modes."
;; (unless (member major-mode linum-mode-inhibit-modes-list)
;; ad-do-it))
;; (ad-activate 'linum-on)
(add-hook 'prog-mode-hook 'linum-mode)
(defadvice linum-on (around linum-on-inhibit-for-modes)
"Stop the load of linum-mode for some major modes."
(unless (member major-mode linum-mode-inhibit-modes-list)
ad-do-it))
;; (require 'powerline)
;; (powerline-center-evil-theme)
(ad-activate 'linum-on)
(sml/setup)
(sml/apply-theme 'dark)
(require 'evil-matchit)
(global-evil-matchit-mode 1)
(require 'powerline)
(powerline-center-evil-theme)
(display-time-mode t)
(setq evil-default-cursor t)
;;; Global emacs settings
;; Disable splash screen
(setq inhibit-splash-screen t)
(setq truncate-partial-width-windows nil)
(set-default 'truncate-lines nil)
;; No tabs, only 4 spaces, as default
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
(setq default-tab-width 4);
;; Disable splash screen
(setq inhibit-splash-screen t)
(set-default 'truncate-lines nil)
(setq truncate-partial-width-windows nil)
(savehist-mode 1)
;; Parenthesis
(show-paren-mode t)
;; Separate Configs
(add-to-list 'load-path (concat user-emacs-directory "config"))
(require 'config-latex)
(require 'config-python)
(eval-after-load 'ein-notebooklist
'(require 'config-ein))
(require 'config-helm)
(require 'config-evil)
(require 'config-org)
(require 'config-secret)
;; Latex
(require 'config-latex)
;;; popwin
(require 'popwin)
;; Latex
(require 'config-python)
;; Cool surrounding
;;; Global modes
(tool-bar-mode -1)
(global-hl-line-mode)
(savehist-mode 1)
(show-paren-mode t)
(popwin-mode 1)
(yas-global-mode 1)
(require 'evil-surround)
(global-evil-surround-mode 1)
;;; Specific modes
;; (autoload 'markdown-mode "markdown-mode"
;; "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; helm settings (TAB in helm window for actions over selected items,
;; C-SPC to select items)
(require 'helm-config)
(require 'helm-misc)
(require 'helm-locate)
(setq helm-quick-update t)
(setq helm-bookmark-show-location t)
(setq helm-buffers-fuzzy-matching t)
(global-set-key (kbd "M-x") 'helm-M-x)
;;
;; Global Keybindings
;;
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(require 'projectile)
(require 'helm-locate)
(define-key evil-normal-state-map (kbd ",f") 'helm-occur)
;; Better jumping
(require 'evil-jumper)
(global-evil-jumper-mode)
(provide '.emacs)
;; cool jumping
(define-key evil-normal-state-map (kbd "SPC") 'helm-M-x)
(define-key evil-normal-state-map (kbd "[b") 'evil-next-buffer)
(define-key evil-normal-state-map (kbd "]b") 'evil-prev-buffer)
(define-key evil-normal-state-map (kbd ",,") 'evil-ace-jump-char-mode)
(global-set-key [escape] 'keyboard-escape-quit)
(define-key helm-map (kbd "C-w") 'backward-kill-word)
;; Don't clover my folders
@ -230,59 +214,25 @@
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" , temporary-file-directory t)))
(global-hl-line-mode)
;; (autoload 'markdown-mode "markdown-mode"
;; "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Preven #file#.txt files
(setq create-lockfiles nil)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(toggle-indicate-empty-lines)
;;; Columns
(require 'fill-column-indicator)
(setq fci-rule-column 79)
(fringe-mode '(1 . 1))
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-directory "~/Dropbox/org")
(setq org-mobile-inbox-for-pull "~/Dropbox/org/inbox.org")
(setq org-mobile-directory "~/Dropbox/Apps/MobileOrg")
(setq org-mobile-files '("~/Dropbox/org"))
(setq org-default-notes-file (concat org-directory "/notes.org"))
(setq org-agenda-files (list org-directory))
(define-key global-map "\C-cc" 'org-capture)
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(yas-global-mode 1)
(require 'config-secret)
(eval-after-load 'magit
'(progn
(set-face-foreground 'magit-diff-add "green3")
(set-face-foreground 'magit-diff-del "red3")
(set-face-background 'magit-item-highlight "black")))
;; Preven #file#.txt files
(setq create-lockfiles nil)
;; Better helm fonts
(set-face-attribute 'helm-selection nil :background "yellow" :foreground "black")
;; Scrolling in tmux
;; Fix Scrolling in tmux
(defun my-terminal-config (&optional frame)
"Establish settings for the current terminal."
(if (not frame) ;; The initial call.
@ -294,32 +244,16 @@
;; Evaluate both now (for non-daemon emacs) and upon frame creation
;; (for new terminals via emacsclient).
(my-terminal-config)
(add-hook 'after-make-frame-functions 'my-terminal-config)
;; Don't use evil mode in magit
(add-to-list 'evil-emacs-state-modes 'git-rebase-mode)
;; Disable copying to the clipboard
;; (setq x-select-enable-clipboard nil)
;; (setq x-select-enable-primary t)
(setq flycheck-temp-prefix ".flycheck")
;;; Neotree
(setq projectile-switch-project-action 'neotree-projectile-action)
;;; .emacs ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes (quote ("d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "c3c0a3702e1d6c0373a0f6a557788dfd49ec9e66e753fb24493579859c8e95ab" "9b41f298ad28dc56765b227e4b9ed38f98a236706a3a26b148491a0dade90568" "0eebf69ceadbbcdd747713f2f3f839fe0d4a45bd0d4d9f46145e40878fc9b098" "1297a022df4228b81bc0436230f211bad168a117282c20ddcba2db8c6a200743" "146d24de1bb61ddfa64062c29b5ff57065552a7c4019bee5d869e938782dfc2a" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
;; '(default ((t (:inherit nil :stipple nil :background "#1b1d1e" :foreground "#f8f8f0" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight semi-light :height 113 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))
;; '(ein:cell-input-area ((t nil)))
'(ein:cell-input-prompt ((t (:inherit header-line :background "firebrick"))))
)
;;; Dired
(setq-default dired-listing-switches "-alhv")
(provide '.emacs)