This blog post is a guide to installing and initially configuring Emacs, covering both the installation of the Emacs editor itself and basic customizations. It walks through downloading binaries for different operating systems, creating the initial configuration file (init.el), setting up the MELPA package archive (including proxy configuration for users in China), and basic editor settings like encoding, line endings, and appearance. The post details installing the Zenburn theme and Fira Code font, providing links to their respective GitHub repositories. It also covers some common view customizations such as maximizing the frame, toggling the scrollbar, and line numbers.

Get Emacs install binary pack

recommend to download have GUI version, good for use.

emacs gnu offcial site

get windows version binary file

get linux version binary package

Create emacs initial file

can get help by using “C-h v user-init-file”

windows path like: C:\Users\frederick\AppData\Roaming\.emacs.d\init.el

MELPA(Milkypostman’s Emacs Lisp Package Archive)

add MELPA

consider I am in China, need add a http proxy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; Proxy
(setq url-proxy-services
      '(("http" . "127.0.0.1:8889")
        ("https" . "127.0.0.1:8889")))

;; MELPA
(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/")
	     t)
(package-initialize)

after add,using “M-x eval-buffer” to evaluate this buffer or just “M-x load-file”. and then, using “M-x package-list-packages” to refresh local package list.

prevent MELPA refresh everytime when use “package-list-packages”

1
2
3
4
5
(require 'package)
(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
        ("melpa" . "http://melpa.org/packages/")))
(setq package-archive-exclude-alist '(("melpa" . "melpa-stable")))

After you’ve made these changes, MELPA will no longer refresh every time you use package-list-packages. Note that this may cause packages from MELPA to become outdated over time, so you may want to periodically refresh the MELPA repository manually using the “M-x package-refresh-contents” command.

Editor settings

encoding format

change prefer encoding format to utf-8

(prefer-coding-system 'utf-8)

These lines set the default EOL type to Unix (LF) for both the current buffer and new files.

;; Set default EOL type to Unix (LF)
(setq-default buffer-file-coding-system 'utf-8-unix)
;; Set default EOL type for new files to Unix (LF)
(setq-default default-buffer-file-coding-system 'utf-8-unix)

View settings

windows view

some I prefer to use settings:

1
2
3
(add-hook 'window-setup-hook 'toggle-frame-maximized t)
(toggle-scroll-bar -1)
(tool-bar-mode -1)

show line number

(global-linum-mode t)

some I give a try, but not like settings:

1
2
(setq inhibit-splash-screen t)
(menu-bar-mode -1)

zenburn theme install

zenburn theme github link

just use “M-x package-install zenburn-theme”,and add below code:

1
2
;; Theme
(load-theme 'zenburn t)

or use “M-x package-list-packages”, and then “C-s”(forward) / “C-r”(backward) to find what you want install:

  • Enter “M-x package-menu-describe-package” Describe the package under cursor.
  • i:(package-menu-mark-install) Mark for installation.
  • u:(package-menu-mark-unmark) Unmark.
  • d:(package-menu-mark-delete) Mark for deletion (removal of a installed package).
  • x:(package-menu-execute) For “execute” (start install/uninstall of marked items).
  • r:(package-menu-refresh) Refresh the list from server.

Fira font apply

FiraCode github link

and then go “Windows Settings –> Personalization –> Fonts –> Drag and drop to install”, drag every font file in folder over it to install FiraCode.

using “M-x menu-set-font” to preview already installed fonts. using “M-x describe-font” and TAB to list all font info.

then add code below and then apply it.

;; Font
(set-face-attribute 'default nil :font "Fira Code-12.0")