Customization

Table of Contents

Top

1 Customization

1.1 Basic Settings

1.1.1 Turn-off Alarm Bell

(setq ring-bell-function #'ignore)

1.1.2 Turn-off Cursor Blink

(blink-cursor-mode -1)

1.1.3 Turn-off Startup Screen

(setq inhibit-startup-screen t)

1.1.4 Ask y or n instead of yes or no

(defalias 'yes-or-no-p 'y-or-n-p)

1.1.5 Disable/Enable Blink Cursor

Enable Blink Cursor

(blink-cursor-mode 1)

Stop Blink Cursor

(blink-cursor-mode 0)

1.1.6 Space / Tabs - Indentation

Set indentation with spaces instead of tabs with 4 spaces

(setq tab-width 4 indent-tabs-mode nil)


;; set default tab char's display width to 4 spaces
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)

;; make tab key always call a indent command.
(setq-default tab-always-indent t)

;; make tab key call indent command or insert tab character, depending on cursor position
(setq-default tab-always-indent nil)

;; make tab key do indent first then completion.
(setq-default tab-always-indent 'complete)

1.1.7 Font Size and Type

(set-default-font "Inconsolata 14")

1.1.8 Character Encoding Default

;; Character encodings default to utf-8.
(prefer-coding-system 'utf-8)

(set-language-environment 'utf-8)

(set-default-coding-systems 'utf-8)

(set-terminal-coding-system 'utf-8)

(set-selection-coding-system 'utf-8)

1.1.9 Disable / Enable Backup Files

Enable

(setq make-backup-files t)

Disable

(setq make-backup-files nil)

1.1.10 Show Match Parenthesis

ELISP> (show-paren-mode 1)
t

Delete trailing whitespace before saving

(add-hook 'before-save-hook 'delete-trailing-whitespace)

1.1.11 Set Default Web Browser

Set the default web browsr used by (browse-url <url>) function and by org-mode.

 ;; Set the default web browser to Chromium Browsr
(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "chromium-browser")

1.2 Hide / Show Emacs Widgets   customize custom widget gui

1.2.1 Hide / Show Menu bar

Hide Menu Bar

(menu-bar-mode 0)

Show Menu Bar

(menu-bar-mode 1)

1.2.2 Hide / Show Toolbar

Show Tool Bar

(tool-bar-mode 1)

Hide Tool Bar

(tool-bar-mode 0)

1.2.3 Hide / Show Scroll Bar

Show

(scroll-bar-mode 1)

Hide

(scroll-bar-mode -1)

1.3 Quiet Startup

From: Ask HN Emacs Users: What's in your .emacs file?

;; Don't display the 'Welcome to GNU Emacs' buffer on startup
(setq inhibit-startup-message t)

;; Display this instead of "For information about GNU Emacs and the
;; GNU system, type C-h C-a.". This has been made intentionally hard
;; to customize in GNU Emacs so I have to resort to hackery.
(defun display-startup-echo-area-message ()
  "If it wasn't for this you'd be GNU/Spammed by now"
  (message ""))

;; Don't insert instructions in the *scratch* buffer
(setq initial-scratch-message nil)

1.4 Separte Customization from init file

It will keep the user customization created with M-x customize-theme, M-x customize-group in a separate file ~/.emacs.d/custom.el.

(setq custom-file (concat (file-name-as-directory user-emacs-directory)
                            "custom.el"
                            ))
(load custom-file 'noerror)

1.5 Languages and Encoding

(prefer-coding-system 'utf-8)

1.6 Tab width and Spaces

;; force emacs to always use spaces instead of tab characters
(setq-default indent-tabs-mode nil)

;; set default tab width to 4 spaces
(setq default-tab-width 4)
(setq tab-width 4)

1.7 Backup Settings

;disable backup
(setq backup-inhibited t)

;disable auto save
(setq auto-save-default nil)


;;  Get Rid of temporary files ending in ~
;;  The temporary files will be in the temporary directory
;;
(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))

;; Move Deleted Files to Trash
;;
(setq delete-by-moving-to-trash t)

1.8 Show Line number and column number in minibuffer

(setq line-number-mode               t)
(setq column-number-mode             t)

1.9 Enable find file at point

When doing C-x C-f use information at point (your cursor) to open file or URL. I.e. if your cursor is on a file path, or URL, it defaults to that filled in the minibuffer.

;;find-file-at-point, smarter C-x C-f when point on path or URL
(ffap-bindings)

1.10 Unique buffer names

;; Unique buffer name
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)

1.11 Mark Current Line

Enable Mark Current Line

;; mark current line:
(global-hl-line-mode 1)

Disable Mark Current Line

;; mark current line:
(global-hl-line-mode 0)

1.12 Recent Files

Show recent files in the File menu.

;; recentf stuff
;; recentf - F5
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-saved-items 500)
(setq recentf-max-menu-items 60)

1.13 Save Minibuffer History

Saves the minibuffer history on every Emacs session.

(savehist-mode 1)
(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring))

;; To set the file which the minibuffer is saved use:
(setq savehist-file "~/.emacs.d/tmp/savehist")

1.14 Themes   customize custom theme color

Load a color theme

(load-theme 'wombat t)

Choose a color theme

M-x customize-theme

Created: 2018-07-26 Thu 07:42

Emacs 25.3.1 (Org mode 8.2.10)

Validate