GithubHelp home page GithubHelp logo

emacsconf's Introduction

init.el or basic emacs configuration

My emacs configuration: explained

Basically, I’m going to write about the init configuration file. The file can be found at the ~/.emacs.d/init.el.

aspell

In order to install aspell, we should launch in terminal homebrew, like this => brew install aspell

(setq ispell-program-name "aspell")
(add-to-list 'exec-path "/usr/local/bin")

(define-globalized-minor-mode my-global-flyspell-mode
flyspell-mode
  (lambda () (flyspell-mode 1)))

(my-global-flyspell-mode 1)

IMPORTANT: finally, I’ve found we should keep only add-to-list function with the full path to make it work. So, it should be like this:

(add-to-list 'exec-path "/usr/local/bin/aspell")

 (define-globalized-minor-mode my-global-flyspell-mode
 flyspell-mode
   (lambda () (flyspell-mode 1)))

 (my-global-flyspell-mode 1)

Hide tutorial screen

To hide standard tutorial screen (Welcome emacs), just use the line below.

(setq inhibit-startup-message t)

Set aka writeroom-mode for Orgmode

To center text, limit length, we need to install a package, called visual-fill-column. It has a couple of settings.

(defun efs/org-mode-visual-fill ()
  (setq visual-fill-column-width 100
	  visual-fill-column-center-text t)
  (visual-fill-column-mode 1))


(use-package visual-fill-column
  :hook (org-mode . efs/org-mode-visual-fill))


Remove line numbers

In order to remove line numbers for some modes we should do:

;; Disable line numbers for some modes
(dolist (mode '(org-mode-hook term-mode-hook shell-mode-hook
		  treemacs-mode-hook eshell-mode-hook gfm-mode-hook))
		  (add-hook mode (lambda () (display-line-numbers-mode
		  0))))

Disable backups

(setq make-backup-files nil)

disable emacs’s #autosave#

(setq make-backup-files nil)

show line numbers

(global-display-line-numbers-mode t)

Disable the toolbar and the tabbar

(tool-bar-mode -1)          ; Disable the toolbar

(menu-bar-mode -1)          ; Disable tabbar

Org mode configuration

;; use org package

(use-package org)

In order to customize Org emphasis colors, the org-emphasis-alist must be overridden

(setq org-emphasis-alist '(("*" (bold :foreground "#00b295" )) ("/"
	     (italic :foreground "#bce7fd")) ("_" underline) ("=" (:background "#c492b1"
	     :foreground "black")) ("~" (:background "#dbbadd"
	     :foreground "black")) ("+" (:strike-through t))))

Markdown support

I use markdown mode. The full description can be found here and some keybindings [ at line 99 ]. This configuration described here I used in the init.el.

;; add markdown mode

(use-package markdown-mode
  :ensure t
  :mode ("\\.md\\'" . gfm-mode)
  :commands (markdown-mode gfm-mode)
  :config
  (setq markdown-command "pandoc -t html5"))

;; preview

(use-package simple-httpd
  :ensure t
  :config
  (setq httpd-port 7070)
  (setq httpd-host (system-name)))

(use-package impatient-mode
  :ensure t
  :commands impatient-mode)


(defun my-markdown-filter (buffer)
  (princ
   (with-temp-buffer
     (let ((tmp (buffer-name)))
	 (set-buffer buffer)
	 (set-buffer (markdown tmp))
	 (format "<!DOCTYPE html><html><title>Markdown
preview</title><link rel=\"stylesheet\" href =
\"https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css\"/>
<body><article class=\"markdown-body\" style=\"box-sizing:
border-box;min-width: 200px;max-width: 980px;margin: 0
auto;padding:
45px;\">%s</article></body></html>" (buffer-string))))
   (current-buffer)))

(defun my-markdown-preview ()
  "Preview markdown."
  (interactive)
  (unless (process-status "httpd")
    (httpd-start))
  (impatient-mode)
  (imp-set-user-filter 'my-markdown-filter)
  (imp-visit-buffer))

Fonts

Important ! I found, that on my mac the Fira Code Retina doesn’t work so just use Fira Code instead

(defvar kirill/default-font-size 180)
(defvar kirill/default-variable-font-size 180)

(set-face-attribute 'default nil :font "Fira Code Retina" :height kirill/default-font-size)

;; Set the fixed pitch face
(set-face-attribute 'fixed-pitch nil :font "Fira Code Retina" :height kirill/default-font-size)

;; Set the variable pitch face
(set-face-attribute 'variable-pitch nil :font "Cantarell" :height kirill/default-variable-font-size :weight 'regular)

To debug or just find out the current font used in the emacs (it’s also called faces). Use the command: M-x describe-font, but this command doesn’t work properly in my config, so I use m-x describe-face ret. By the way, to find ASCII code of the letter or character M-x describe-char.

Custom keys / shortcuts

;; custom key settings
(global-set-key (kbd "C-c ;") 'comment-line)
(global-set-key (kbd "C-c SPC") 'set-mark-command)
(global-set-key (kbd "C-c C-f") 'recentf-open-files)

Show list of recent files

In order to show recently opened files we should use

;; show recent files

(require 'recentf)
(recentf-mode 1)

(setq recentf-auto-cleanup 'never)

Buitiful linemode: updated Echo Area

(use-package all-the-icons)
;; works on mac
(add-hook 'after-init-hook #'doom-modeline-mode)
(setq doom-modeline-height 25)
;; works on linux
;; (use-package doom-modeline
;; :init (doom-modeline-mode 1)
;; :custom ((doom-modeline-height 15)))

Set default directory

;; set default directory to open when type C-x C-f
(setq default-directory "~/Documents/notes")

Abbrev config

Tutorial to the abbrev mode I used to undersand how it works

My config to activete always this mode

;; turn on abbrev mode globally
(setq-default abbrev-mode t)

Currently there are some abbreviation for ex. src and just hit SPC after it. My abbrevation file can be found, like by default, at ~/.emacs.d/abbrev_defs

Some notes

about aspell

  • to make it work on mac os should use standard brew command
brew install aspell

then aspell lives in /usr/local/bin

  • in order to make it work on ubuntu should use standard apt install aspell-ru or apt install aspell-fr

On ubuntu aspell lives in /usr/bin

about elpa, melpa packages

I’ve found that this configuration works on my computer:

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("org" . "https://orgmode.org/elpa/")
                         ("elpa" . "https://elpa.gnu.org/packages/")))

to avoid errors, that package was not found and so kind, we should update keys.

M-x package-install RET gnu-elpa-keyring-update RET

And what I’ve found that, we should add the following before package-initialize:

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

This is apparently a bug in Emacs for MacOS.

emacsconf's People

Contributors

rodnoy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.