~lucasemmoreira/first-emacs

first-emacs/README.md -rw-r--r-- 4.5 KiB
b47220d3Lucas Moreira minor organization changes 10 months ago

#What is this?

I created this config to make emacs a more smooth first experience for my girlfriend. I do not think this setup is meant to be used always, but it does break a few first annoying barriers. Mainly the C-c and the C-x hotkeys.

#How to use it?

Well, you can use it as an org file. To do so, create the \~/.emacs file like this:

(org-babel-load-file "~/path/to/this/file/name-of-this-file.org")

A note of caution: in my config, my emacs only converts to the configuration what is with emacs-lisp. If you fell the need, just erase the elisp to be extra safe.

#Make it simpler please!

Ok, so this is the main dish. This repository contains the configuration that breaks those first barriers I mentioned earlier. I was not able to download it through use-package. So you will have to do it yourself. But it is very simple. All you have to do is put the main file wakib-keys.el inside the emacs configuration folder \~/.emacs.d/. Done! Good to go!

;; https://github.com/darkstego/wakib-keys
(require 'wakib-keys "~/.emacs.d/wakib-keys.el")
(wakib-keys 1)

I will not elongate on what the lib does (you can read it the original repo =]) but the idea is that Ctrl + c and Ctrl + x (or in emacs notation C-c and C-x) are used as expected in most guis applications, i.e., for copying and cutting.

#Some basic stuff (in my opinion!)

Well here we can divide in a few parts.

#Packages please!

This setup is for you to be able to install packages more easily.

;; Configure package.el to include MELPA.
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)

;; Ensure that use-package is installed.
;;
;; If use-package isn't already installed, it's extremely likely that this is a
;; fresh installation! So we'll want to update the package repository and
;; install use-package before loading the literate configuration.
(when (not (package-installed-p 'use-package))
  (package-refresh-contents)
  (package-install 'use-package))

#Some keybindings (shortcuts)

These are some keybindings that I find very useful. They are very similar to web browsers (except for the last three).

(global-set-key (kbd "<C-tab>") 'other-window)
(global-set-key (kbd "<C-f4>") 'delete-window)
(global-set-key (kbd "C-t") 'split-window-right)
(global-set-key (kbd "C-<") 'previous-buffer)
(global-set-key (kbd "C->") 'next-buffer)

#A more friendly interface for the next step =]

This part I put because it not so trivial to create a first version, and it is useful if you want to be a more "emacs user". Also, this code creates a good search in the buffer with Ctrl + s (or C-s).

(use-package ivy
  :diminish
  :bind (("C-s" . swiper)
	 :map ivy-minibuffer-map
	 ("TAB" . ivy-alt-done)
	 ("C-f" . ivy-alt-done)
	 ("C-l" . ivy-alt-done)
	 ("C-j" . ivy-next-line)
	 ("C-k" . ivy-previous-line)
	 :map ivy-switch-buffer-map
	 ("C-k" . ivy-previous-line)
	 ("C-l" . ivy-done)
	 ("C-d" . ivy-switch-buffer-kill)
	 :map ivy-reverse-i-search-map
	 ("C-k" . ivy-previous-line)
	 ("C-d" . ivy-reverse-i-search-kill))
  :config
  (ivy-mode 1))

(use-package counsel
  :demand t
  :bind (("M-x" . counsel-M-x)
	 ("C-x b" . counsel-ibuffer)
	 ("C-x C-f" . counsel-find-file)
	 ("C-M-l" . counsel-imenu)
	 :map minibuffer-local-map
	 ("C-r" . 'counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  :config
  (setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^

#Help me with the chords!

Emacs is widely know for its chords, and it can be intimidating. This package helps you see what is that you chording for.

(use-package which-key
  :config (which-key-mode))

#Add more!

Well, here it is important for me to say that, the wakib-keys package may have some impact but fell free to add more stuff! The nice thing of emacs is to that is very modular and you can try a bunch of packages! For example the very nice elpy package for python development:

(use-package elpy
  :ensure t
  :init
  (elpy-enable))