Emacs General Settings[Eng]

In the previous post we created the necessary structure for the emacs configuration. Now, let’s add a few settings for emacs and change some settings for ourselves. I will write all the settings in this article into the emacs-default.el file. Just to be clear.


Our first setting is theme. I’m using monokai theme. I created a directory for the theme and I copied the monokai theme into this folder. Of course, you can install the package you want directly by calling M-x el-get-install. I chose a little more manual way.

;; ----------------- THEME
(add-to-list 'custom-theme-load-path "~/.emacs.d/theme")
(load-theme 'monokai t)

-> In general, emacs and Vim users don’t use a mouse. But if you want to use a touchpad or mouse like me, let’s make a setting.

;; ----------------- Mouse Integration
(require 'mouse) ;; needed for iterm2 compatibility
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
(setq mouse-sel-mode t)
(defun track-mouse (e))

-> Now we create our backup file and make a few adjustments.
(https://www.emacswiki.org/emacs/ForceBackups)

;; ----------------- BACKUP
(setq backup-directory-alist '(("." . "~/.emacs.d/backups"))
delete-old-versions t ;; for auto delete (https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Deletion.html)
version-control t
vc-make-backup-files t
auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))

-> Now we can make our settings for save-history

;; ----------------- HISTORY
(savehist-mode 1) ;; savehist mode active
(setq savehist-file "~/.emacs.d/savehist"
history-length t
history-delete-duplicates t
savehist-save-minibuffer-history 1
savehist-additional-variables
'(kill-ring search-ring regexp-search-ring))

-> We change a few settings for the startup screen. At first, we will look at the text we wrote and close some unnecessary settings because we will use the emacs on the terminal.

;; ----------------- Startup Screen Conf
(setq initial-scratch-message ";; Hi Kerem, How is it going? o_O"
inhibit-startup-screen t)
(menu-bar-mode -1)
(toggle-scroll-bar -1)

-> Other setting is about parentheses.

;; ----------------- Show Matching Parenthesis
(show-paren-mode t)
(setq show-paren-delay 0)

-> Once you’ve saved the file, if there are whitespaces in the file, emacs will clear those spaces for us.

;; ----------------- WHITESPACE CLEANUP
(add-hook 'before-save-hook 'whitespace-cleanup)

In this article, we have simply made our general settings. In the other article, we will make a few adjustments to these plugins by installing a few plugins.