Skip to content

ignaciobll/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Contents

Basic Config

Melpa, marmalade

Milkypostman’s Emacs Lisp Package Archive - https://melpa.org/#/

De este repositorio se descargarán los paquetes que instalaremos en Emacs. Antes comprobamos que realmente podemos usarlo al tener una versión correcta de Emacs.

Añadimos también melpa stable para evitar algunos conflictos con los paquetes.

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/") t)
  (add-to-list
   'package-archives
   '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/") t)
  (package-initialize))

Use-package

Use-package es un paquete que nos permite instalar y configurar paquetes de Emacs de forma cómoda y más compacta.

Para automatizar más la instalación, comprobamos si ya tenemos instalado use-package, y si no lo tenemos, lo instalamos.

https://github.com/jwiegley/use-package

(unless (featurep 'use-package)
  (package-refresh-contents)
  (package-install 'use-package)
  )

Backup files

Para evitar que Emacs nos llene los directorios con archivos propios de backups determinamos que los guarde automáticamente en el directorio .emacs.d/backup/. *NOT WORKING*

(setq make-backup-files nil) ;; Hello GIT

;; (setq backup-directory-alist '(("" . "~/.emacs.d/backup")))

Interface

Sesión

Aunque por lo general use Emacs en modo daemon, entre sesión y sesión se puede establecer que nos guarde el escritorio.

;(desktop-save-mode 1)

Emacs bars

Para una interfaz más limpia y sin botones a la vista (shortcuts/macros al poder), eliminamos todas las barras y botones que vienen por defecto con la interfaz de Emacs.

(tooltip-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)

Tema

Me encanta Darkokai

(use-package darkokai-theme
  :ensure t
  :init (load-theme 'darkokai t))

Navigation

Avy

Avy - Nos permite saltar a cualquier linea, palabra o caracter visible.

(use-package avy
  :ensure t
  :bind (("C-:" . avy-goto-char)
         ("C-." . avy-goto-char2)
         ("M-g g" . avy-goto-line)
         ("M-g w" . avy-goto-word-1)))

WindMove

windmove - [built-in] Tired with C-x o? Now you can use shift+arrows to jump between windows.

(use-package windmove
  :ensure t
  :bind (("C-c <up>" . windmove-up)
         ("C-c <left>" . windmove-left)
         ("C-c <right>" . windmove-right)
         ("C-c <down>" . windmove-down))
  )

ido

Ido es un modo que nos permite visualizar los datos de autocompletado para manejarnos entre búsquedas de ficheros o cambios de buffers.

(use-package ido
  :init (ido-mode))

Project Management

Projectile

https://github.com/bbatsov/projeEmacs Lisp without the use of GNU find (but for performance sake an indexing mechanism backed by external commands exists as well).

  • Basis Usage
KeybindingDescription
C-c p fDisplay a list of all files in the project. With a prefix argument it will clear the cache first.
C-c p FDisplay a list of all files in all known projects.
C-c p gDisplay a list of all files at point in the project. With a prefix argument it will clear the cache first.
C-c p 4 fJump to a project’s file using completion and show it in another window.
C-c p 4 gJump to a project’s file based on context at point and show it in another window.
C-c p dDisplay a list of all directories in the project. With a prefix argument it will clear the cache first.
C-c p 4 dSwitch to a project directory and show it in another window.
C-c p 4 aSwitch between files with the same name but different extensions in other window.
C-c p TDisplay a list of all test files(specs, features, etc) in the project.
C-c p lDisplay a list of all files in a directory (that’s not necessarily a project)
C-c p s gRun grep on the files in the project.
M-- C-c p s gRun grep on `projectile-grep-default-files` in the project.
C-c p vRun `vc-dir` on the root directory of the project.
C-c p bDisplay a list of all project buffers currently open.
C-c p 4 bSwitch to a project buffer and show it in another window.
C-c p 4 C-oDisplay a project buffer in another window without selecting it.
C-c p aSwitch between files with the same name but different extensions.
C-c p oRuns `multi-occur` on all project buffers currently open.
C-c p rRuns interactive query-replace on all files in the projects.
C-c p iInvalidates the project cache (if existing).
C-c p RRegenerates the projects `TAGS` file.
C-c p jFind tag in project’s `TAGS` file.
C-c p kKills all project buffers.
C-c p DOpens the root of the project in `dired`.
C-c p eShows a list of recently visited project files.
C-c p EOpens the `.dirs-local.el` file of the project.
C-c p s sRuns `ag` on the project. Requires the presence of `ag.el`.
C-c p !Runs `shell-command` in the root directory of the project.
C-c p &Runs `async-shell-command` in the root directory of the project.
C-c p cRuns a standard compilation command for your type of project.
C-c p PRuns a standard test command for your type of project.
C-c p tToggle between an implementation file and its test file.
C-c p 4 tJump to implementation or test file in other window.
C-c p zAdds the currently visited file to the cache.
C-c p pDisplay a list of known projects you can switch to.
C-c p SSave all project buffers.
C-c p mRun the commander (an interface to run commands with a single key).
C-c p ESCSwitch to the most recently selected Projectile buffer.

If you ever forget any of Projectile’s keybindings just do a:

C-c p C-h

(use-package projectile
  :ensure t
  :init (projectile-global-mode))

Programming

YASnippets

Para poder usar los snippets, necesitamos ejecutar antes estos comandos.

$ mkdir -p ~/.emacs.d/plugins
$ cd ~/.emacs.d/plugins
$ git clone --recursive https://github.com/capitaomorte/yasnippet

Y esto es lo que necesitamos para configurarlo en Emacs.

(use-package yasnippet
  :ensure t
  :init (yas-global-mode 1)
  :config
  (define-key yas-minor-mode-map (kbd "<tab>") nil)
  (define-key yas-minor-mode-map (kbd "TAB") nil)
  (define-key yas-minor-mode-map (kbd "<C-tab>") 'yas-expand)
  )

Para que no entre en conflicto con otros autocompletados, hacemos que los yasnippets se lancen con la combinación C-tab.

auto-yasnippet

Auto-yasnippet nos permite crear snippets locales. Por ejemplo:

count_of_red = get_total("red");
count_of_blue = get_total("blue");
count_of_green = get_total("green");

Para poder crear esto, antes tenemos que definir lo siguiente:

count_of_~red = get_total("~red");

A “~” is representing a variable. To create a auto-snippet, que execute command aya-create (which I binded to C-x a). This replace de variable with it value, and save the snipppet.

~ representa una variable. Para crear el snippet local tenemos que ejecutar el comando aya-create, bindeado a C-x a. Este comando reemplaza la varible por su valor y guarda el snippet.

count_of_red = get_total("red");

Para volver a usar el snippet guardado necesitamos expandirlo. Ejecutamos el comando aya-expand asociado a C-x e y se nos prepara el snippet con el cursor correctamente colocado.

count_of_red = get_total("red");
count_of_ = get_total("");

La configuración correspondiente:

(use-package auto-yasnippet
  :ensure t
  :bind (("C-x a" . aya-create)
         ("C-x e" . aya-expand)
         ("C-o" . aya-open-line)))

SmartParens

Smartparens - Deals with parens pairs and tries to be smart about it.

https://ebzzry.github.io/emacs-pairs.html

(use-package smartparens-config
  :ensure smartparens
  :config
  (progn (show-smartparens-global-mode t)))

(setq sp-highlight-wrap-overlay nil)
(setq sp-highlight-pair-overlay nil)
(setq sp-highlight-wrap-overlay nil)

(add-hook 'prog-mode-hook 'turn-on-smartparens-mode)
(add-hook 'markdown-mode-hook 'turn-on-smartparens-mode)

Aggresive-indent

Aggressive-indent - Keeps your code always indented automatically.

Sin embargo, no lo uso en todos los lenguajes.

(use-package aggressive-indent
  :ensure t
  :init
  (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
  (add-hook 'css-mode-hook #'aggressive-indent-mode)
  )

Auto-complete

(use-package auto-complete
  :ensure t
  :config (ac-config-default))

Company-mode

Company - A text completion framework.

(use-package company-mode
  :init
  (add-hook 'after-init-hook 'global-company-mode))

I will add company-quickhelp. You can use it with M-h and show documentation next to company options.

(use-package company-quickhelp
  :ensure t
  :init (company-quickhelp-mode 1)
  :config (eval-after-load 'company
            '(define-key company-active-map (kbd "C-c h") #'company-quickhelp-manual-begin)))

Programming Language

Haskell

haskell-mode - Major mode for Haskell.

(use-package haskell-mode
  :ensure t
  :mode "\\.hs\\'"
  :config 
  (add-hook 'haskell-mode-hook 'turn-on-haskell-doc)
  (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
  (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
  )

Scala

scala-mode2 - scala major mode for emacs 24. Based on the Scala Language Specification 2.9

(use-package scala-mode2
  :interpreter
  ("scala" . scala-mode))

Ensime - ENhanced Scala Interaction Mode for Emacs

(use-package ensime
  :pin melpa-stable
  :ensure t
  :commands ensime ensime-mode
  :init  (add-hook 'scala-mode-hook 'ensime-mode))

Python

Elpy is probably the best module for programming in python. Elpy is an Emacs package to bring powerful Python editing to Emacs. It combines and configures a number of other packages, both written in Emacs Lisp as well as Python.

(use-package elpy
  :ensure t
  :mode "\\.hs\\'"
  :init (elpy-enable))

Matlab

We will need to add matlab to our path. With a symlink.

(use-package matlab-mode
  :ensure t
  :mode ("\\.m$\\'" . matlab-mode)
  :config
  (setq matlab-indent-function t)
  (setq matlab-shell-command "matlab")
  (setq matlab-shell-command-switches (list "-nodesktop"))
  )

Erlang

(use-package erlang  
    :ensure t
    :mode "\\.erl\\'"
    :config (erlang-mode)
    )

Visual

Rainbow Delimiters

https://github.com/Fanael/rainbow-delimiters

(use-package rainbow-delimiters
  :ensure t
  :init
  (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
  )

<2016-04-12 mar 11:13>

Rainbow Mode

Rainbow-mode - Display color on color-code string (hex/rgb) directly.

(use-package rainbow-mode
  :ensure t
  :mode "\\.css\\'"
  )

<2016-04-13 mié 00:42>

Editing

Multiple cursors

Multiple cursors - Mark, edit multiple lines at once.

(use-package multiple-cursors
  :ensure t
  :bind (("C-S-c C-S-c" . mc/edit-lines)
         ("C->" . mc/mark-next-like-this)
         ("C-<" . mc/mark-previous-like-this)
         ("C-c C-<" . mc/add-cursor-on-click))
  )

Notes

Org Babel

(org-babel-do-load-languages
 'org-babel-load-languages
 '((dot . t)
   (latex . t)
   (java . t)
   (sh . t)
   (python . t)
   ))

Minted

(use-package ox-latex
  :init (add-to-list 'org-latex-packages-alist '("" "minted"))
  (setq org-latex-listings 'minted)
  (setq org-latex-pdf-process
        '("xelatex -shell-escape -interaction nonstopmode -output-directory %o %f"))    
  )

Ox - Reveal

https://github.com/yjwen/org-reveal

Whe need some things to install in order to make this work properly, bur it’s not needed if you are not going to use org-reveal.

First, whe have to install reveal.js from here and do the full setup, wich requires Node.js and Grunt.

Once we have installed reveal.js, you should change de org-reveal-root variable in the next code block with your own path:

(use-package ox-reveal
  :ensure t
  :config
  (setq org-reveal-root "file:///home/ignaciobll/.reveal.js")
  )

Auto-fill

(use-package auto-fill-mode
  :bind ("C-c q" . turn-on-auto-fill-mode)
  :init (add-hook 'org-mode-hook 'turn-on-auto-fill)
  :config (add-hook 'org-mode-hook 'xah-math-input-mode))

Org tree slide

(use-package org-tree-slide
  :ensure t
  :config
  (define-key org-tree-slide-mode-map (kbd "<f9>")
    'org-tree-slide-move-previous-tree)
  (define-key org-tree-slide-mode-map (kbd "<f10>")
    'org-tree-slide-move-next-tree)
  (define-key org-tree-slide-mode-map (kbd "<f11>")
    'org-tree-slide-content)
  (org-tree-slide-narrowing-control-profile)
  (setq org-tree-slide-skip-outline-level 4)
  (setq org-tree-slide-skip-done nil)
  :bind (("<f8>" . org-tree-slide-mode)
         ("S-<f8>" . org-tree-slide-skip-done)))

xah-math-input

(use-package xah-math-input
  :ensure t)

toc-org

Toc-org add a :toc: headline at the top of the org document.

https://github.com/snosov1/toc-org

Shortcut to a :Toc: tag: C-c C-q T RET

(use-package toc-org
  :ensure t
  :init (add-to-list 'org-tag-alist '("TOC" . ?T)))

Markdown

(use-package markdown-mode
  :ensure t
  :commands (markdown-mode gfm-mode)
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode))
  :init (setq markdown-command "multimarkdown"))

Cheatsheet

Cuando se quieren aprender nuevos módulos, es útil tener una lista con las combinaciones de teclado más comunes para recordar fácilmente cómo hacer las acciones básicas.

(use-package cheatsheet
  :ensure t
  :config
  (cheatsheet-add :group 'Erlang
                  :key "C-c C-q"
                  :description "Indents the current Erlang function. - (erlang-indent-function)")
  (cheatsheet-add :group 'Erlang
		    :key "C-c C-j"
		    :description "Create a new clause in the current Erlang function. The point is placed between the parentheses of the argument list.  (erlang-generate-new-clause)")
  (cheatsheet-add :group 'Erlang 
		    :key "C-c C-y" 
		    :description "Copy the function arguments of the preceding Erlang clause. This command is useful when defining a new clause with almost the same argument as the preceding.  (erlang-clone-arguments)")
  (cheatsheet-add :group 'Erlang 
		    :key "C-c C-a" 
		    :description "aligns arrows after clauses inside a region.  (erlang-align-arrows)")
  (cheatsheet-add :group 'Erlang
                  :key "C-c C-k"
                  :description "Kompila ")
  (cheatsheet-add :group 'Erlang
                  :key "C-c C-z"
                  :description "Abre una nueva terminal interactiva de Erlang")  
  (cheatsheet-add :group 'Emacs
                  :key "C-x r s r"
                  :description "Copy region into register r (copy-to-register).")
  (cheatsheet-add :group 'Emacs
                  :key "C-x r i r"
                  :description "Insert text from register r (insert-register).")

  :bind ("C-c C-s" . cheatsheet-show)
  )

Version Control

Magit

(use-package magit
  :ensure t
  :bind (("C-x g" . magit-status)
         ("C-x M-g" . magit-dispatch-popup))
  )

Console

Multi-term

(use-package multi-term
  :ensure t
  :config (setq multi-term-program "/bin/zsh"))

Google

LeMacsGTFY

(use-package google-this
  :ensure t
  :init (google-this-mode 1))

About

Mi* configuración de emacs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published