Skip to content

Latest commit

 

History

History
392 lines (366 loc) · 12.2 KB

config.org

File metadata and controls

392 lines (366 loc) · 12.2 KB

My Emacs Config

SENSIBLE DEFAULTS

VARIABLES

Prevent dired from using new buffers for all traversed directories (Since emacs 28)

(setf dired-kill-when-opening-new-dired-buffer t)

Auto saves and backup in temp directory

(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

Default directory will be home directory

(global-set-key (kbd "M-;")
		  'sensible-defaults/comment-or-uncomment-region-or-line)

GC threshold to higher value

(setq gc-cons-threshold 20000000)

Delete selection mode

(delete-selection-mode t)

Add file sizes in human-readable units (KB, MB, etc) to dired buffers.

(setq-default dired-listing-switches "-alh")

Don’t ask `yes/no?’, ask `y/n?’.

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

Auto refresh buffers

(global-auto-revert-mode t)

Visible bell

(setq visible-bell t)

Don’t assume that sentences should have two spaces after period

(setq sentence-end-double-space nil)

Isearch customizations

 (setq isearch-wrap-pause 'no
	isearch-repeat-on-direction-change t
	search-ring-max 100)

Scroll position to be not at topmost or bottommost line while scrolling

(setq scroll-preserve-screen-position t)

KEYMAPS REBINDING

Home and End key settings

(global-set-key (kbd "<home>") 'move-beginning-of-line)
(global-set-key (kbd "<end>") 'move-end-of-line)

Comment single line or region

   (defun sensible-defaults/comment-or-uncomment-region-or-line ()
   "Comments or uncomments the region or the current line if
 there's no active region."
   (interactive)
   (let (beg end)
     (if (region-active-p)
	  (setq beg (region-beginning) end (region-end))
	(setq beg (line-beginning-position) end (line-end-position)))
     (comment-or-uncomment-region beg end)))
  (global-set-key (kbd "M-;")
                 'sensible-defaults/comment-or-uncomment-region-or-line)

HOOKS

Trim trailing whitespaces before saving

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

Prompt to create parent directories, if not exists, when saving file

(add-hook 'before-save-hook
          (lambda ()
            (when buffer-file-name
              (let ((dir (file-name-directory buffer-file-name)))
                (when (and (not (file-exists-p dir))
                           (y-or-n-p (format "Directory %s does not exist. Create it?" dir)))
                  (make-directory dir t))))))

PACKAGE MANAGEMENT

** Setup package.el to work with MELPA

(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-refresh-contents)
(package-initialize)

** Installing use-package

(unless (package-installed-p 'use-package)
(package-install 'use-package))

NAVIGATION and SELECTION ENHANCEMENTS

Select quicker using expand-region

(use-package expand-region :ensure t :bind ("C-;" . er/expand-region))

Text Movement

Move text using MoveText

(use-package move-text :ensure t)
(move-text-default-bindings)

Hungry Deletion

(use-package hungry-delete :ensure t)
(global-hungry-delete-mode  1)
(setq hungry-delete-join-reluctantly t)

Dired-x for opening multiple files at once

This will replace find-file and find-file-other-window with the dired-x equivalents This will allow multiple files to be opened at once

(with-eval-after-load 'dired
  (require 'dired-x))

ORG Mode display preferences

Harry’s dotfiles I like to see an outline of pretty bullets instead of a list of asterisks.

(use-package org-superstar :ensure t
  :config
  (setq org-superstar-special-todo-items t)
  (setq org-hide-leading-stars t)
  (add-hook 'org-mode-hook (lambda ()
			       (org-superstar-mode 1))))

This hides the slashes and stars that denote emphasis and bold text unless point is on said text.

(setq org-hide-emphasis-markers t)

(use-package org-appear :ensure t
  :hook (org-mode . org-appear-mode))

Visibly render mathematical symbols.

(setq org-pretty-entities t)

Show linked images directly in my Org document. Don’t fully expand enormous images; instead, use imagemagick to display them at a manageable size.

(setq org-startup-with-inline-images t
      org-image-actual-width '(600))

Use syntax highlighting in source blocks while editing.

(setq org-src-fontify-natively t)

Make TAB act as if it were issued in a buffer of the language’s major mode.

(setq org-src-tab-acts-natively t)

When editing a code snippet, use the current window rather than popping open a new one (which shows the same information).

(setq org-src-window-setup 'current-window)

Quickly insert a block of elisp:

(add-to-list 'org-structure-template-alist
             '("el" . "src emacs-lisp"))

Don’t indent newly expanded blocks, even if they’re under a heading.

(setq org-adapt-indentation nil)

When hitting C-<return> to create a new heading, don’t insert the heading between the current heading and its content, but instead append it after the content.

(setq org-insert-heading-respect-content t)

Variable font Display different fonts

;; Highlight Line Colors
(add-hook 'org-mode-hook (lambda ()
(set-face-attribute 'org-level-1 nil                   :font "SauceCodePro Nerd Font" :height 220 :foreground "#FDF0ED")
(set-face-attribute 'org-level-2 nil                   :font "Ubuntu Nerd Font" :height 200 :foreground "#25B2BC")
(set-face-attribute 'org-level-3 nil                   :font "Ubuntu Nerd Font" :height 180)
(set-face-attribute 'org-level-4 nil                   :font "Ubuntu Nerd Font" :height 160 :italic nil)
))

Format of date and validation fields when exported to html.

(setq org-html-metadata-timestamp-format "%Y-%m-%d")
(setq org-html-validation-link nil)

DASHBOARD

Emacs dashboard is an extensible startup screen showing you recent files, bookmarks, agenda items, and an Emacs banner.

(use-package all-the-icons :ensure t) ;;Make sure all-the-icons package is installed
;;Ensure to run the command: all-the-icons-install-fonts
(use-package dashboard
:ensure t ;;install dashboard if not installed
:init ;; tweak dashboard's configuration before loading it
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-banner-logo-title "Keep Walking!")
(setq dashboard-startup-banner "~/.emacs.d/keep-walking.png")
(setq dashboard-center-content nil)
(setq dashboard-items '(
    (recents . 10)
    (agenda . 5)
    (bookmarks . 5)
    (registers . 5)
))
:config
(dashboard-setup-startup-hook)
(dashboard-modify-heading-icons '(
  (recents. "file-text")
  (bookmarks . "book"))))
;;This is for client mode
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))

ZOOM

Zooming in and out

Use Ctrl = and Ctrl - to increase and decrease scale

(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-0") (lambda () (interactive) (text-scale-adjust 0)))
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)

SEARCH SETTINGS

**All menu bars, tools bars

(setq lazy-highlight-cleanup nil) ;;This is to retain search highlight after searching is complete

GUI SETTINGS

All menu bars, tools bars

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-display-line-numbers-mode 1)
(setq-default line-spacing 0.10)
(setq display-line-numbers-type 'relative)

Cursor

(use-package beacon
:ensure t)
(beacon-mode 1)

Volatile highlights

(use-package volatile-highlights :ensure t)
(volatile-highlights-mode t)

Highlight numbers

(use-package highlight-numbers :ensure t)
(add-hook 'prog-mode-hook 'highlight-numbers-mode)
(add-hook 'sql-mode-hook 'highlight-numbers-mode)

WHICH KEY

**give all the commands bound to a prefix key

(use-package which-key
:ensure t)
(which-key-mode)
(which-key-setup-side-window-bottom)

MAGIT

(use-package magit :ensure t)
(setq magit-clone-set-remote-head t) ;;Preserve git's default of setting remote head, instead of magit's delete

KEY CAST for displaying keys and commands in mode line

https://www.youtube.com/watch?v=L9GcNrhx-iE **Modes and tools for web development

  (use-package keycast :ensure t)
;;  (keycast-mode) ;;  Disable keycast mode by default

Company mode for autocompletion

(use-package company :ensure t)
(company-mode 1)
(add-hook 'after-init-hook 'global-company-mode)

BUFFER MENU Customizations

Auto-completion ignore case

(setq completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
(setq read-buffer-completion-ignore-case t)

HISTORY

(savehist-mode 1)

PROCECTILE

(use-package projectile
:ensure t
:config
(projectile-global-mode 1))
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

WEB Development

**Modes and tools for web development

(use-package js2-mode :ensure t)
(use-package emmet-mode :ensure t)
(use-package markdown-mode :ensure t)
(use-package web-mode :ensure t)
(use-package prettier :ensure t)
(electric-pair-mode 1)
(emmet-mode 1)

GOLDPLATING

FONT

All fonts can be found at https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/SourceCodePro/Regular/complete https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Ubuntu/Regular/complete For windows, the font name should be different. This name can be found in the font manager against the tag Font Name. For instance, the below mentioned fonts will be “SauceCodePro NF 11” and “Ubuntu NF 11”

(set-face-attribute 'default nil
  :font "SauceCodePro Nerd Font 11"
  :weight 'medium)
(set-face-attribute 'variable-pitch nil
  :font "Ubuntu Nerd Font 11"
  :weight 'medium)
(set-face-attribute 'fixed-pitch nil
  :font "SauceCodePro Nerd Font 11"
  :weight 'medium)
;;Needed for client
(add-to-list 'default-frame-alist '(font . "SauceCodePro Nerd Font 11"))

THEME

** Doom emacs

(use-package doom-themes
:ensure t)
(setq doom-themes-enable-bold t doom-themes-enable-italic t)
(load-theme 'doom-shades-of-purple t)

MODE LINE

doom mode line

(use-package doom-modeline
:ensure t)
(doom-modeline-mode 1)

SPELL CHECKER

Hunspell

;;(setq-default ispell-program-name "D:/prog/hunspell/bin/hunspell.exe")