This blog post documents the manual installation process for various coding plugins and formatters within Emacs. It covers Markdown, Python, Javascript, Emacs Lisp, Shell scripting, HTML, CSS, and JSON support. The author details both MELPA-based installation (where possible) and manual installation steps involving Git cloning and adding paths to the Emacs configuration file (init.el). It also includes key bindings for some formatters. The post primarily focuses on getting these tools working when they aren’t readily available via Emacs’ built-in package manager.

Language Support

markdown

markdown-mode github link

directly install form MELPA use “M-x package-install markdown-mode”

or git clone repository from github, and put markdown-mode.el to location like ~/.emacs.d/third-party/markdown-mode/markdown-mode.el. and add below code to init.el

1
2
3
4
;; Markdown mode
(add-to-list 'load-path
	     (concat user-emacs-directory "third-party/markdown-mode" ))
(load "markdown-mode") 

and then M-x eval-buffer to load the plugin.

python

javascript

Formatter

emacs lisp formatter

elfmt github link

I can’t install from MELPA, so insatll it manually. Download “elfmt.el” from github, place it under “~/.emacs.d/third-party/elfmt” directory.

add code below to load it:

1
2
3
4
;; elisp-format
(add-to-list 'load-path
	     (concat user-emacs-directory "third-party/elfmt" ))
(load "elfmt") ;; best not to include the ending “.el” or “.elc”

then eval it, and just use M-x elfmt.

  • Type M-x elfmt to format the current buffer
  • Type M-x elfmt-sexp to format the current sexp
  • Type M-x elfmt-mode to automatically format the buffer on save
  • Type M-x elfmt-global-mode to enable elfmt-mode everywhere

shell-like language formatter

shfmt github link

Download binary file, add to user PATH variable,I put under “C:/usr/Runtime/bin”

emacs-shfmt github link

could directly install from MELPA, use “M-x package-install shfmt”.

html,css,javascript formatter

web-beautify github link

directly install form MELPA use “M-x package-install markdown-mode”

Typing to use it:

  • M-x web-beautify-css
  • M-x web-beautify-html
  • M-x web-beautify-js

optional, can add code below binding shortcut key:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
;;;; web-beautify(html,css,javascript,json)
(require 'web-beautify) ;; Not necessary if using ELPA package
(eval-after-load 'js2-mode
  '(define-key js2-mode-map (kbd "C-c b") 'web-beautify-js))
     ;; Or if you're using 'js-mode' (a.k.a 'javascript-mode')
(eval-after-load 'js
  '(define-key js-mode-map (kbd "C-c b") 'web-beautify-js))

(eval-after-load 'json-mode
  '(define-key json-mode-map (kbd "C-c b") 'web-beautify-js))

(eval-after-load 'sgml-mode
  '(define-key html-mode-map (kbd "C-c b") 'web-beautify-html))

(eval-after-load 'web-mode
  '(define-key web-mode-map (kbd "C-c b") 'web-beautify-html))

(eval-after-load 'css-mode
  '(define-key css-mode-map (kbd "C-c b") 'web-beautify-css))