Skip to content

Instantly share code, notes, and snippets.

@herberthamaral

herberthamaral/init.el

Last active Feb 23, 2018
Embed
What would you like to do?
Meu arquivo de config do emacs
;; -*- coding: utf-8 -*-
;; custom
;; Atenção: não esquecer de setar a variável HOME do windows para a
;; pasta home do usuário. Caso contrário o "~" não será reconhecido.
(setq frame-title-format "emacs do amaral")
(tool-bar-mode -1)
(scroll-bar-mode -1)
(set-default 'cursor-type 'hbar)
(ido-mode)
(global-hl-line-mode)
(show-paren-mode)
(winner-mode t)
(windmove-default-keybindings)
(prefer-coding-system 'utf-8)
;; el-get
;; Nota: não esquecer de remover o (package-initialize) do ~/.emacs
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
(goto-char (point-max))
(eval-print-last-sexp)))
(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes")
(el-get-bundle undo-tree)
(el-get-bundle goto-chg)
;; (el-get 'sync)
;; packages
;; Insight retirado de http://blog.zhengdong.me/2012/03/14/how-i-manage-emacs-packages/
;; Talvez deva trocar por https://github.com/jwiegley/use-package
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize)
(line-number-mode 1)
(column-number-mode 1)
(require 'cl)
(defvar packages-list
'(org
org-tree-slide
org-beautify-theme
leuven-theme
projectile
magit
hydra
evil
evil-escape
interleave
)
"List of packages to be installed at launch")
(defun has-package-not-installed ()
(loop for p in packages-list
when (not (package-installed-p p)) do (return t)
finally (return nil)))
(when (has-package-not-installed)
;; Check for new packages (package versions)
(message "%s" "Get latest versions of all packages...")
(package-refresh-contents)
(message "%s" " done.")
;; install missing packages
(dolist (p packages-list)
(when (not (package-installed-p p))
(package-install p))))
;; org-mode
(setq org-agenda-files '("~/org/captura.org"
"~/org/proximas-acoes.org"
"~/org/telessaude.org"
"~/org/emacs.org"
"~/org/aguardando.org"
"~/org/projetos.org"
"~/org/12min.org"
"~/org/agenda.org"))
(define-key global-map "\C-cc" 'org-capture)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-capture-templates '(("t" "Todo [inbox]" entry
(file+headline "~/org/captura.org" "Tasks")
"* TODO %i%?")
("T" "Tickler" entry
(file+readline "~/org/agenda.org" "Agenda")
"* %i \n %U")))
(setq org-todo-keywords
(quote ((sequence "TODO(t)" "DOING(d)" "WAITING(w)" "|" "DONE(o)" "CANCELLED(c)" "DELEGATED(e)")
(sequence "CALL(c)" "INCALL(i)" "|" "CALLED(d)" "CANCELLED(x)"))))
(setq org-enforce-todo-checkbox-dependencies 1)
(setq coding-system-for-read 'utf-8)
(setq org-clock-persist 'history)
(setq org-clock-in-resume t)
(setq org-clock-out-when-done t)
(setq org-log-done 'time)
(org-clock-persistence-insinuate)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
(setq org-confirm-babel-evaluate nil)
(setq org-src-fontify-natively t)
(setq org-agenda-window-setup 'current-window)
(add-to-list 'org-modules "org-habit")
;; Retirado originamente de https://mollermara.com/blog/Fast-refiling-in-org-mode-with-hydras/
(defun my/refile (file headline &optional arg)
(let ((pos (save-excursion
(find-file file)
(org-find-exact-headline-in-buffer headline))))
(org-refile arg nil (list headline file nil pos)))
(switch-to-buffer (current-buffer)))
(defhydra amaral/org-refile-hydra (:foreign-keys run)
"Refile"
("n" (my/refile "proximas-acoes.org" "Próximas ações") "Próximas ações")
("m" (my/refile "talvezumdia.org" "Talvez um dia") "Talvez um dia")
("a" (my/refile "aguardando.org" "Delegado. Aguardando") "Aguardando")
("l" (my/refile "leitura.org" "Fila de leitura") "Fila de leitura")
("t" (my/refile "agenda.org" "Tickler") "Agenda (tickler)")
("p" (my/refile "projetos.org" "Projetos") "Projetos")
("s" (my/refile "telessaude.org" "Telessaúde") "Telesaúde")
("1" (my/refile "12min.org" "12 minutos") "12 minutos")
("e" (my/refile "emacs.org" "emacs") "emacs")
("j" (my/refile "sij-jf.org" "sij-jf") "sij-jf")
("q" nil "cancel"))
(global-set-key (kbd "<f9> r") 'amaral/org-refile-hydra/body)
;; evil
(require 'evil)
(evil-mode 1)
(setq-default evil-escape-key-sequence "fd")
(setq-default evil-escape-delay 0.2)
(evil-escape-mode)
;; projectile
(projectile-mode)
(define-key global-map (kbd "<f5>") 'projectile-find-file)
;; magit
(if (eq system-type 'windows-nt)
(progn
(setq exec-path (add-to-list 'exec-path "C:/Program Files/Git/bin"))
(setenv "PATH" (concat "C:\\Program Files\\Git\\bin;" (getenv "PATH")))))
(define-key global-map (kbd "\C-cgs") 'magit-status)
;; desktop
(require 'desktop)
(desktop-save-mode 1)
(defun my-desktop-save ()
(interactive)
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'my-desktop-save)
;; configuração dos arquivos de save
;; extraído de https://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files#151946
(setq backup-directory-alist `(("." . "~/.saves")))
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;; org-tree-slide
(require 'org-tree-slide)
(define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode)
(define-key org-mode-map (kbd "S-<f8>") 'org-tree-slide-skip-done-toggle)
;; tema
(load-theme 'leuven t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.