From cf6d7d8bcea74e3dc51c94e6b61833f19b8e065a Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 15 Mar 2017 15:14:09 +0100 Subject: emacs: added an advice for find-file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way we can edit files as root if needed. Signed-off-by: Miquel Sabaté Solà --- emacs/init.html | 494 +++++++++++++++++--------------------------------------- 1 file changed, 152 insertions(+), 342 deletions(-) (limited to 'emacs/init.html') diff --git a/emacs/init.html b/emacs/init.html index d273f81..2687495 100644 --- a/emacs/init.html +++ b/emacs/init.html @@ -4,7 +4,7 @@ mssola's GNU Emacs configuration - + @@ -164,42 +164,41 @@ for the JavaScript code in this tag.
  • Project
  • -
  • Edit
  • -
  • Dired
  • -
  • Evil
  • -
  • Magit
  • -
  • mu4e
  • -
  • org +
  • Dired
  • +
  • Evil
  • +
  • Magit
  • +
  • mu4e
  • +
  • org
  • -
  • IRC
  • -
  • Languages +
  • IRC
  • +
  • Languages
  • -
  • WoMan
  • -
  • Misc
  • -
  • Credits
  • -
  • License
  • +
  • WoMan
  • +
  • Misc
  • +
  • Credits
  • +
  • License
  • @@ -776,7 +775,7 @@ require it here on the very top.
    -
    (use-package diminish
    +
    (use-package diminish
       :ensure t)
     
    @@ -794,7 +793,7 @@ Ayo silver!
    -
    (use-package ag
    +
    (use-package ag
       :ensure t
       :config
     
    @@ -816,12 +815,12 @@ Then, for keeping up with my projects I use the Projectile + Helm combination.
     
     
    -
    (use-package projectile
    +
    (use-package projectile
       :ensure t
       :config
       (projectile-mode 1))
     
    -(use-package helm
    +(use-package helm
       :ensure t
       :config
       (setq projectile-completion-system 'helm)
    @@ -853,10 +852,10 @@ Then, for keeping up with my projects I use the Projectile + Helm combination.
       (define-key helm-map (kbd "C-j") 'helm-next-line)
       (define-key helm-map (kbd "C-k") 'helm-previous-line)
     
    -  (use-package helm-ag
    +  (use-package helm-ag
         :ensure t))
     
    -(use-package helm-projectile
    +(use-package helm-projectile
       :ensure t
       :config
       (helm-projectile-on)
    @@ -935,198 +934,9 @@ binding to ,a a function that calls to the proper function.
     
    -

    Edit

    +

    Dired

    -In this section I define some useful packages for editing. First of all, one of -the coolest packages out there is undo-tree. It allows you to navigate through -the undo history in a tree (because GNU Emacs is cool and keeps track of undo -actions in a tree structure instead of in a stack). This package is included in -recent versions of GNU Emacs. -

    - -
    - -
    (with-eval-after-load 'undo-tree
    -  (global-undo-tree-mode 1)
    -
    -  (setq undo-tree-visualizer-diff t
    -        undo-tree-visualizer-timestamps t
    -        undo-tree-visualizer-relative-timestamps t)
    -
    -  (diminish 'undo-tree-mode)
    -
    -  (with-eval-after-load 'evil-leader
    -    (evil-leader/set-key
    -      "u" 'undo-tree-visualize)))
    -
    -
    - -

    -Another important package is flycheck, which is an on-the-fly syntax checking -extension. This works with lots of languages with proper glue code. -

    - -
    - -
    (use-package let-alist
    -  :ensure t)
    -
    -(use-package flycheck
    -  :ensure t
    -  :diminish
    -  :config
    -  (add-hook 'after-init-hook 'global-flycheck-mode)
    -
    -  ;; Only show the errors buffer if it isn't there and if I'm saving the
    -  ;; buffer.
    -  (setq flycheck-emacs-lisp-load-path 'inherit)
    -  (setq flycheck-check-syntax-automatically '(mode-enabled save))
    -  (setq flycheck-display-errors-function
    -    #'flycheck-display-error-messages-unless-error-list))
    -
    -
    - -

    -A recurring issue in speeches and presentations is that when showing something -with your editor, you have to increase/decrease the fonts. I use the -default-text-scale package for this. -

    - -
    - -
    (use-package default-text-scale
    -  :ensure t
    -  :config
    -  (global-set-key (kbd "C-+") 'default-text-scale-increase)
    -  (global-set-key (kbd "C--") 'default-text-scale-decrease))
    -
    -
    - -

    -Some languages use some delimiters a lot (e.g. lisp languages and -parenthesis). For this reason I'm using the rainbow-delimiters package, which -properly highlights each level in a different way (provided that your theme -supports it). -

    - -
    - -
    (use-package rainbow-delimiters
    -  :ensure t)
    -
    -
    - -

    -I never use the mouse. -

    - -
    - -
    (use-package disable-mouse
    -  :ensure t
    -  :config
    -  (global-disable-mouse-mode)
    -  (setq global-disable-mouse-mode-lighter ""))
    -
    -
    - -

    -Sometimes you begin typing a prefix, but then you forget the following -chord. For this reason which-key was created. It will show the available -commands for the current chord as a list. -

    - -
    - -
    (use-package which-key
    -  :ensure t)
    -
    -
    - -

    -For some modes it is important to count the number of words in the text. For -this, we have wc-mode. -

    - -
    - -
    (use-package wc-mode
    -  :ensure t)
    -
    -
    - -

    -Next on the list, we have writeroom-mode. I honestly don't use this package -that often, but it's cool to have a distraction-free screen from time to time. -

    - -
    - -
    (use-package writeroom-mode
    -  :ensure t)
    -
    -
    - -

    -The expand-region package is an extension that is based on a Vim one, which -expands the region of selection with a single key chord. Even if evil covers -most of my uses, it's convenient to have this tool anyways. -

    - -
    - -
    (use-package expand-region
    -  :ensure t
    -  :config
    -
    -  ; Set C-e as the expand command (mnemonic: expand). This command will
    -  ; supercede the evil binding for "move one line", which I never use anyways.
    -  (global-set-key (kbd "\C-e") 'er/expand-region)
    -  (with-eval-after-load 'evil
    -    (define-key evil-normal-state-map (kbd "\C-e") 'er/expand-region)
    -    (define-key evil-visual-state-map (kbd "\C-e") 'er/expand-region)))
    -
    -(defun er/add-text-mode-expansions ()
    -  "This way we can also expand the region into paragraphs & pages in text mode.
    -Directly taken from: https://github.com/magnars/expand-region.el."
    -
    -  (set (make-local-variable 'er/try-expand-list) (append
    -                                                  er/try-expand-list
    -                                                  '(mark-paragraph
    -                                                    mark-page))))
    -
    -(add-hook 'text-mode-hook 'er/add-text-mode-expansions)
    -
    -
    - -

    -Last but not least, YASnippet. This package allows people to define shortcuts -for writing some common blocks. Moreover, it comes with a set of builtin -snippets already. Since I don't remember some of these snippets, I've mapped -, h to yas-describe-tables, which shows the available -snippets in another buffer. -

    - -
    - -
    (use-package yasnippet
    -  :ensure t
    -  :diminish yas-minor-mode
    -  :init (yas-global-mode)
    -  :config
    -  (yas-global-mode 1)
    -  (with-eval-after-load 'evil-leader
    -    (evil-leader/set-key "h" 'yas-describe-tables)))
    -
    -
    -
    -
    - -
    -

    Dired

    -
    -

    I use dired mode mainly for attaching document into emails. That being said, whenever I use it, I want basic evil movement.

    @@ -1185,9 +995,9 @@ from the mu4
    -
    -

    Evil

    -
    +
    +

    Evil

    +

    Forgive me, Father, for I have sinned. I've been exposed to modal editing through Vim, and that has changed how I view editing for the foreseeable future. @@ -1270,7 +1080,7 @@ Now make sure that Evil is installed, and call the relevant configuration functi

    -
    (use-package evil
    +
    (use-package evil
       :ensure t
       :config
     
    @@ -1300,7 +1110,7 @@ Vim into Evil.
     
     
    -
    (use-package evil-leader
    +
    (use-package evil-leader
       :ensure t
       :config
       (global-evil-leader-mode)
    @@ -1327,7 +1137,7 @@ having double quotes with single quotes in a single command).
     
     
    -
    (use-package evil-surround
    +
    (use-package evil-surround
       :ensure t
       :config
       (global-evil-surround-mode 1))
    @@ -1343,7 +1153,7 @@ the current line, regardless of the programming language.
     
     
    -
    (use-package evil-commentary
    +
    (use-package evil-commentary
       :ensure t
       :config
       (evil-commentary-mode t))
    @@ -1359,7 +1169,7 @@ respectively.
     
     
    -
    (use-package evil-args
    +
    (use-package evil-args
       :ensure t
       :config
       ; Configuration taken from the documentation of evil-args.
    @@ -1385,7 +1195,7 @@ into Evil: C-a for increasing a number, and
     
     
    -
    (use-package evil-numbers
    +
    (use-package evil-numbers
       :ensure t
       :config
       (define-key evil-normal-state-map (kbd "C-a") 'evil-numbers/inc-at-pt)
    @@ -1395,9 +1205,9 @@ into Evil: C-a for increasing a number, and
     
    -
    -

    Magit

    -
    +
    +

    Magit

    +

    A git porcelain for GNU Emacs. Even if I'm still using the git CLI, it's certainly useful for some common tasks (I guess that I still need some learning). @@ -1405,7 +1215,7 @@ certainly useful for some common tasks (I guess that I still need some learning)

    -
    (use-package magit
    +
    (use-package magit
       :ensure t
       :config
     
    @@ -1458,7 +1268,7 @@ And repair some key bindings from Evil mode.
    (with-eval-after-load 'evil-leader
       (evil-leader/set-key "s" 'magit-status)
     
    -  (use-package evil-magit
    +  (use-package evil-magit
         :ensure t
         :config
     
    @@ -1474,9 +1284,9 @@ And repair some key bindings from Evil mode.
     
    -
    -

    mu4e

    -
    +
    +

    mu4e

    +

    I use mu and mu4e to manage my email. The configuration for this has been taken mainly from the documentation, plus some cool remarks on Reddit. This @@ -1806,7 +1616,7 @@ I want desktop notifications when receiving email.

    -
    (use-package mu4e-alert
    +
    (use-package mu4e-alert
       :ensure t
       :config
     
    @@ -1822,7 +1632,7 @@ I want desktop notifications when receiving email.
     
     ; Evil mode in mu4e
     (with-eval-after-load 'evil
    -  (use-package evil-mu4e
    +  (use-package evil-mu4e
         :ensure t
         :config
     
    @@ -1852,9 +1662,9 @@ And finally define a proper shortcut.
     
    -
    -

    org

    -
    +
    +

    org

    +

    org mode is an incredible tool that keeps me organized: TODOs, notes, agenda, etc. Moreover, it's built in GNU Emacs: @@ -1867,9 +1677,9 @@ etc. Moreover, it's built in GNU Emacs:

    -
    -

    General settings

    -
    +
    +

    General settings

    +

    First of all, let me define some helper functions.

    @@ -1955,9 +1765,9 @@ Where org files reside.
    -
    -

    Publishing

    -
    +
    +

    Publishing

    +

    In order to publish files into HTML, I would like to have htmlize installed. This package allows org to export to HTML in a better way (e.g. allowing code @@ -1966,7 +1776,7 @@ blocks to be converted into HTML as well, so we can properly colorize it).

    -
    (use-package htmlize
    +
    (use-package htmlize
       :ensure t)
     
    @@ -1989,9 +1799,9 @@ And now let's set all the related settings.
    -
    -

    Agenda

    -
    +
    +

    Agenda

    +

    Custom commands for org-agenda.

    @@ -2092,9 +1902,9 @@ Set up a key binding for org-agenda.
    -
    -

    Capture

    -
    +
    +

    Capture

    +

    Set the default notes file and the key binding.

    @@ -2120,9 +1930,9 @@ And finally set org-capture-templates.
    -
    -

    Other

    -
    +
    +

    Other

    +

    Insert a <kbd></kbd> value in org mode. See this StackExchange answer.

    @@ -2149,31 +1959,31 @@ Insert a <kbd></kbd> value in org mode. See this -

    TODO shortcut for making an org link, and transforming a link into a proper org link

    +
    +

    TODO shortcut for making an org link, and transforming a link into a proper org link

    -
    -

    TODO make it work with evil

    +
    +

    TODO make it work with evil

    -
    -

    TODO Proper keybindings for quick access.

    +
    +

    TODO Proper keybindings for quick access.

    -
    -

    TODO shortcuts for stuff like: create something urgent for today

    +
    +

    TODO shortcuts for stuff like: create something urgent for today

    -
    -

    IRC

    -
    +
    +

    IRC

    +

    I'm giving ERC a chance. First of all, I'm setting up basic stuff.

    -
    (use-package erc
    +
    (use-package erc
       :config
     
       (erc-track-mode t)
    @@ -2216,7 +2026,7 @@ Use the erc-hl-nicks package, so highlight support for nicknames is
     
     
    -
    (use-package erc-hl-nicks
    +
    (use-package erc-hl-nicks
       :ensure t
       :init
       (with-eval-after-load 'erc
    @@ -2285,12 +2095,12 @@ And now define a function to connect to both IRC servers.
     
    -
    -

    Languages

    -
    -
    -

    General

    -
    +
    +

    Languages

    +
    +
    +

    General

    +

    First of all, define a function that identifies some warning keywords (e.g. TODO). This function can then be applied to the proper mode. @@ -2323,9 +2133,9 @@ context too. In this case, I want spell check and wc-mode activated

    -
    -

    Lisp

    -
    +
    +

    Lisp

    +

    Emacs lisp needs rainbow-delimiters, so the amount of parenthesis is less confusing. Moreover, I'm also enabling eldoc-mode and the aforementioned @@ -2346,9 +2156,9 @@ confusing. Moreover, I'm also enabling eldoc-mode and the aforement

    -
    -

    C and C++

    -
    +
    +

    C and C++

    +

    C and C++ only require the warnings-mode-hook function, spell checking for the comments and the usage of tabs instead of spaces. @@ -2372,9 +2182,9 @@ comments and the usage of tabs instead of spaces.

    -
    -

    Ruby

    -
    +
    +

    Ruby

    +

    Include warning keywords in Ruby.

    @@ -2387,9 +2197,9 @@ Include warning keywords in Ruby.
    -
    -

    Go

    -
    +
    +

    Go

    +

    And now my Go configuration. This includes stuff like the usage of goimports, gofmt on save, among many other useful things. @@ -2418,18 +2228,18 @@ And now my Go configuration. This includes stuff like the usage of goimpor (flyspell-prog-mode) ; eldoc support - (use-package go-eldoc + (use-package go-eldoc :ensure t :config (require 'go-eldoc)) - (use-package go-add-tags + (use-package go-add-tags :ensure t :config (evil-leader/set-key "t" 'go-add-tags))) ;; Go -(use-package go-mode +(use-package go-mode :ensure t :pin melpa-stable :config @@ -2442,9 +2252,9 @@ And now my Go configuration. This includes stuff like the usage of goimpor

    -
    -

    Tabs vs spaces

    -
    +
    +

    Tabs vs spaces

    +

    Tabs or spaces? Both. The smart-tabs-mode has the philosophy of: tabs for indentation, spaces for alignment. This is only applied in languages where I'm @@ -2453,7 +2263,7 @@ usings tabs for indentation (C, C++ and Go).

    -
    (use-package smart-tabs-mode
    +
    (use-package smart-tabs-mode
       :ensure t
       :config
       (smart-tabs-add-language-support golang go-mode-hook
    @@ -2465,13 +2275,13 @@ usings tabs for indentation (C, C++ and Go).
     
    -
    -

    Inferior markup languages.

    -
    +
    +

    Inferior markup languages.

    +
    ;; Markdown mode with preview mode in the browser.
    -(use-package markdown-mode
    +(use-package markdown-mode
       :ensure t
       :config
     
    @@ -2481,14 +2291,14 @@ usings tabs for indentation (C, C++ and Go).
     
       ; Preview mode does its things through websockets, so it's a requirement.
       ; After that, we can safely require it.
    -  (use-package websocket
    +  (use-package websocket
         :ensure t
         :config
    -    (use-package markdown-preview-mode
    +    (use-package markdown-preview-mode
           :ensure t)))
     
     ; YAML
    -(use-package yaml-mode
    +(use-package yaml-mode
       :ensure t
       :config
     
    @@ -2498,26 +2308,26 @@ usings tabs for indentation (C, C++ and Go).
     
    -
    -

    Web-related stuff.

    -
    +
    +

    Web-related stuff.

    +

    Slim and SCSS.

    -
    (use-package slim-mode
    +
    (use-package slim-mode
       :ensure t)
     
    -(use-package scss-mode
    +(use-package scss-mode
       :ensure t
       :config
     
       (setq scss-compile-at-save nil)
       (add-hook 'yaml-mode-hook 'warnings-mode-hook))
     
    -(use-package coffee-mode
    +(use-package coffee-mode
       :ensure t)
     
    @@ -2529,10 +2339,10 @@ bundle of features which are interesting for web-related stuff.
    -
    (use-package php-mode
    +
    (use-package php-mode
       :ensure t)
     
    -(use-package web-mode
    +(use-package web-mode
       :ensure t
       :config
     
    @@ -2551,7 +2361,7 @@ bundle of features which are interesting for web-related stuff.
                   (setq js-indent-level 2)
                   (rainbow-delimiters-mode 1)))
     
    -  (use-package vue-mode
    +  (use-package vue-mode
         :ensure t
         :config
         (setq mmm-submode-decoration-level 0))
    @@ -2578,23 +2388,23 @@ can be frustrating without proper formatting.
     
     
    -
    (use-package json-reformat
    +
    (use-package json-reformat
       :ensure t)
     
    -
    -

    Others

    -
    +
    +

    Others

    +

    CMake for y'all.

    -
    (use-package cmake-mode
    +
    (use-package cmake-mode
       :ensure t
       :config
     
    @@ -2604,7 +2414,7 @@ CMake for y'all.
              '(("\\.cmake\\'" . cmake-mode))
              auto-mode-alist))
     
    -  (use-package cmake-font-lock
    +  (use-package cmake-font-lock
         :ensure t
         :config
     
    @@ -2620,19 +2430,19 @@ now because it's buggy, but I still have hope.
     
     
    -
    (use-package dockerfile-mode
    +
    (use-package dockerfile-mode
       :ensure t
       :config
     
       (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))
     
    -(use-package terraform-mode
    +(use-package terraform-mode
       :ensure t
       :config
     
       (terraform-format-on-save-mode))
     
    -(use-package hcl-mode
    +(use-package hcl-mode
       :ensure t)
     
     ;(use-package salt-mode
    @@ -2660,9 +2470,9 @@ criteria really).
     
    -