Basically, I’m going to write about the init configuration file. The file can be found at the ~/.emacs.d/init.el.
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)
To hide standard tutorial screen (Welcome emacs), just use the line below.
(setq inhibit-startup-message t)
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))
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))))
(setq make-backup-files nil)
(setq make-backup-files nil)
(global-display-line-numbers-mode t)
(tool-bar-mode -1) ; Disable the toolbar
(menu-bar-mode -1) ; Disable tabbar
;; 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))))
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))
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 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)
In order to show recently opened files we should use
;; show recent files
(require 'recentf)
(recentf-mode 1)
(setq recentf-auto-cleanup 'never)
(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 to open when type C-x C-f
(setq default-directory "~/Documents/notes")
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
- 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
orapt install aspell-fr
On ubuntu aspell lives in /usr/bin
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.