Last active
September 6, 2018 10:33
-
-
Save romuloceccon/dcab3cc5853c4261eddcf6f136dbbb17 to your computer and use it in GitHub Desktop.
My .emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (package-initialize) | |
| (require 'package) | |
| (add-to-list 'package-archives | |
| '("melpa-stable" . "http://stable.melpa.org/packages/") t) | |
| ;; --- begin my settings --- | |
| (defun switch-whitespace-mode-and-set-line-length-to-79 (a b c) | |
| "Switches `whitespace-mode' on and sets line length to 79. | |
| This function switches `whitespace-mode' on and sets line length to 79 for | |
| Python source code (PEP8), but only after the buffer is modified. It is set | |
| as a change hook in Python mode and removes itself as a hook once the first | |
| modification is detected. As such, it's not supposed to be used directly." | |
| (when (buffer-modified-p) | |
| (setq-local whitespace-line-column 79) | |
| (whitespace-mode t) | |
| ;; Note that the hook `after-change-functions' expects a function with 3 | |
| ;; arguments, which are not used here. | |
| (remove-hook 'after-change-functions | |
| 'switch-whitespace-mode-and-set-line-length-to-79 t))) | |
| (defun revert-buffer-no-confirmation () | |
| "Reverts the current buffer without confirmation. | |
| This function reverts the current buffer without confirmation. It uses | |
| `revert-buffer' internally and therefore has the same semantics." | |
| (interactive) | |
| (revert-buffer t t)) | |
| (defun setup-frame-home-end-key-map (frame) | |
| "Sets up correct key maps for C-home, C-end, C-S-home and C-S-end." | |
| (with-selected-frame frame | |
| (define-key input-decode-map "\e[1;5H" [C-home]) | |
| (define-key input-decode-map "\e[1;5F" [C-end]) | |
| (define-key input-decode-map "\e[1;6H" [C-S-home]) | |
| (define-key input-decode-map "\e[1;6F" [C-S-end]))) | |
| (defun setup-frame-dark-background (frame) | |
| "Configures emacs for dark background." | |
| ;; TODO: fire the block inside with-selected-frame from the 'not window-system' | |
| ;; block (with a nil argument), so that the correct color is set when starting | |
| ;; Emacs in non-client mode in xterm (no screen) | |
| (with-selected-frame frame | |
| (set-terminal-parameter frame 'background-mode 'dark) | |
| (setq frame-background-mode 'dark) | |
| (frame-set-background-mode frame))) | |
| ;; If not a console session: | |
| (when (window-system) | |
| ;; Hide the menu bar | |
| (menu-bar-showhide-tool-bar-menu-customize-disable) | |
| ;; Configure two side-by-side panes of 85 cols and 50 lines each | |
| (set-frame-size (selected-frame) 180 50) | |
| (split-window-right)) | |
| ;; If a console session: | |
| (when (not window-system) | |
| (add-hook 'after-make-frame-functions #'setup-frame-home-end-key-map) | |
| (add-hook 'after-make-frame-functions #'setup-frame-dark-background)) | |
| ;; Configure default whitespace highlighting | |
| (setq whitespace-style '(face empty tabs lines-tail trailing tab-mark)) | |
| ;; Do not automatically insert the "encoding" comment at the begining when | |
| ;; saving a Ruby file | |
| (setq ruby-insert-encoding-magic-comment nil) | |
| (add-hook 'ruby-mode-hook | |
| (lambda () | |
| (make-local-variable 'tab-stop-list) | |
| (setq tab-stop-list '(2 4)) | |
| (column-number-mode t) | |
| (linum-mode t) | |
| (show-paren-mode t) | |
| (whitespace-mode t))) | |
| (add-hook 'html-mode-hook | |
| (lambda () | |
| (linum-mode t) | |
| (whitespace-mode t))) | |
| (add-hook 'cperl-mode-hook | |
| (lambda () | |
| (setq-local indent-tabs-mode nil) | |
| (linum-mode t) | |
| (show-paren-mode t) | |
| (whitespace-mode t))) | |
| (add-hook 'sh-mode-hook | |
| (lambda () | |
| (linum-mode t) | |
| (whitespace-mode t) | |
| (set (make-local-variable 'indent-tabs-mode) nil))) | |
| ;; Show line numbers and highlight parentesis and blanks for Python files | |
| (add-hook 'python-mode-hook | |
| (lambda () | |
| (linum-mode t) | |
| (show-paren-mode t) | |
| (add-hook 'after-change-functions | |
| 'switch-whitespace-mode-and-set-line-length-to-79 t t))) | |
| (add-hook 'global-git-commit-mode-hook | |
| (lambda () | |
| (column-number-mode t))) | |
| ;; Revert buffer without confirmation on "C-x 4 v" | |
| (global-set-key (kbd "C-x 4 v") 'revert-buffer-no-confirmation) | |
| ;; Prefer cperl-mode over perl-mode | |
| (defalias 'perl-mode 'cperl-mode) | |
| (setq cperl-indent-level 2) | |
| ;; Activate Git-commit mode when editing a COMMIT_EDITMSG file | |
| (add-to-list 'auto-mode-alist '(".*_EDITMSG\\'" . global-git-commit-mode)) | |
| ;; --- end my settings --- | |
| (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. | |
| '(package-selected-packages (quote (magit)))) | |
| (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. | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment