Skip to content

Instantly share code, notes, and snippets.

@najibninaba
Last active July 12, 2019 01:01
Show Gist options
  • Save najibninaba/07fd524030015d20e16a2343d245df9d to your computer and use it in GitHub Desktop.
Save najibninaba/07fd524030015d20e16a2343d245df9d to your computer and use it in GitHub Desktop.
Current Emacs init.el configuration
(setq delete-old-versions -1 ) ; delete excess backups silently
(setq version-control t )
(setq vc-make-backup-files t )
(setq vc-follow-symlinks t )
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")) )
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)) )
(setq inhibit-startup-screen t )
(setq ring-bell-function 'ignore ) ; silent bell on mistakes
(setq coding-system-for-read 'utf-8 )
(setq coding-system-for-write 'utf-8)
(setq sentence-end-double-space nil)
(setq-default fill-column 80) ; toggle wrapping text at this column
(global-display-line-numbers-mode t )
(menu-bar-mode -1) ; no need for the menu bars - we've got key combos for that!
(toggle-scroll-bar -1)
(tool-bar-mode -1)
;; enable the log feature
(setq org-log-into-drawer t)
;; auto revert mode
(global-auto-revert-mode 1)
;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(setq-default buffer-file-coding-system 'utf-8-unix)
(setq-default default-buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(when (eq system-type 'windows-nt)
(set-clipboard-coding-system 'utf-16le-dos))
;; use-package setup
(require 'package)
(setq package-enable-at-startup nil) ; dont do it immediately
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
;; Bootstrap use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents) ; update archives
(package-install 'use-package)) ; grab the newest use-package
;; Define packages
(require 'use-package)
;; Always download if not available
(setq use-package-always-ensure t)
(use-package persistent-scratch
:ensure t
:config
(persistent-scratch-setup-default))
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "pandoc.exe"))
(use-package all-the-icons)
(use-package unicode-fonts)
(require 'unicode-fonts)
(unicode-fonts-setup)
(use-package ag
:ensure t)
(use-package ace-window
:ensure t
:bind (("M-p" . ace-window)))
;; Theme
(use-package doom-themes
:ensure t
:config
(load-theme 'doom-one t))
(use-package wttrin
:ensure t
:config
(setq wttrin-default-cities '("Singapore"))
(setq wttrin-default-accept-language '("Accept-Language" . "en")))
(use-package deft
:ensure t
:bind ("C-c SPC" . deft)
:commands (deft)
:config (setq deft-directory "~/Dropbox/org"
deft-extensions '("md" "org")))
;; Which Key
(use-package which-key
:ensure t
:init
(setq which-key-separator " ")
(setq which-key-prefix-prefix "+")
:config
(which-key-mode))
;; Ivy
(use-package ivy
:diminish (ivy-mode . "")
:init (ivy-mode 1) ; globally at startup
:config
(setq ivy-use-virtual-buffers t)
(setq ivy-height 20)
(setq ivy-count-format "%d/%d "))
;; counsel/swiper
(use-package counsel
:bind* ; load when pressed
(("M-x" . counsel-M-x)
("C-s" . swiper)
("C-x C-f" . counsel-find-file)
("C-x C-r" . counsel-recentf) ; search for recently edited
("C-c g" . counsel-git) ; search for files in git repo
("C-c j" . counsel-git-grep) ; search for regexp in git repo
("C-c /" . counsel-ag) ; Use ag for regexp
("C-x l" . counsel-locate)
("C-x C-f" . counsel-find-file)
("<f1> f" . counsel-describe-function)
("<f1> v" . counsel-describe-variable)
("<f1> l" . counsel-find-library)
("<f2> i" . counsel-info-lookup-symbol)
("<f2> u" . counsel-unicode-char)
("C-c C-r" . ivy-resume))) ; Resume last Ivy-based completion
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode))
(use-package flycheck
:init (global-flycheck-mode))
(use-package smartparens
:config
(require 'smartparens-config)
(smartparens-global-mode t)
(add-hook 'lisp-mode-hook #'smartparens-strict-mode))
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1))
(use-package yasnippet-snippets
:ensure t)
(setq yas-snippet-dirs
'("~/.emacs.d/snippets")) ;; personal snippets
(use-package atomic-chrome
:ensure t
:init
(atomic-chrome-start-server))
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(use-package engine-mode
:ensure t
:init
(engine-mode t))
;; (use-package xah-fly-keys
;; :ensure t
;; :config
;; (xah-fly-keys-set-layout "qwerty") ; required
;; (xah-fly-keys 1))
(use-package projectile
:ensure t
:config
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode +1))
(use-package cider
:ensure t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(markdown-mode persistent-scratch wttrin ag yasnippet-snippets yasnippet deft org-super-agenda ace-window engine-mode google-this atomic-chrome cider projectile xah-fly-keys org org-bullets edit-server-htmlize edit-server smartparens flycheck company ivy general helm which-key doom-themes all-the-icons use-package))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; check OS type
(cond
((string-equal system-type "windows-nt") ; Microsoft Windows
(progn
(message "Microsoft Windows"))
(set-frame-font "Source Code Pro-16" nil t)
(setq default-frame-alist '(
(fullscreen . maximized)
(font . "Source Code Pro-16")))
(add-to-list 'exec-path "c:/Tools/bin")
)
((string-equal system-type "darwin") ; Mac OS X
(progn
(message "Mac OS X")))
((string-equal system-type "gnu/linux") ; linux
(progn
(message "Linux"))
(set-frame-font "Source Code Pro-32" nil t)
(require 'org-mu4e)
(load-file "~/.emacs.d/mu4e-config.el")))
(show-smartparens-global-mode t)
(setq org-hide-emphasis-markers t)
(setq org-startup-indented t)
;;(setq org-adapt-indentation 4)
;; (add-hook 'org-mode-hook 'variable-pitch-mode)
;; (add-hook 'org-mode-hook 'visual-line-mode)
;;(add-hook 'org-mode-hook (lambda () (linum-mode 0)))
(defalias 'open 'browse-url)
(global-visual-line-mode 1) ; 1 for on, 0 for off.
(delete-selection-mode 1)
;; The following lines are always needed. Choose your own keys.
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-cb" 'org-switchb)
(defun create-scratch-buffer nil
"create a scratch buffer"
(interactive)
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
(defun find-start-org nil
"find and open start.org"
(interactive)
(find-file "~/org/start.org"))
(setq org-agenda-files '("~/org/inbox.org"
"~/org/projects.org"
"~/org/tickler.org"))
(setq org-capture-templates '(("t" "Todo [inbox]" entry
(file+headline "~/org/inbox.org" "Tasks")
"* TODO %i%?")
("T" "Tickler" entry
(file+headline "~/org/tickler.org" "Tickler")
"* %i%? \n %U")))
(setq org-refile-targets '(("~/org/projects.org" :maxlevel . 3)
("~/org/toread.org" :maxlevel . 3)
("~/org/someday.org" :level . 1)
("~/org/tickler.org" :maxlevel . 2)))
(setq org-todo-keywords '((sequence "TODO" "TODAY(t)" "WAITING(w)" "THIS WEEK(p)" "TO-READ(r)" "SOMEDAY(s)" "|" "DONE(d)" "CANCELLED(c)")))
(setq org-agenda-custom-commands
'(("t" todo "TODAY")
("p" todo "THIS WEEK")
("w" todo "WAITING")))
(global-set-key "\C-cs" 'create-scratch-buffer)
(global-set-key "\C-c1" 'find-start-org)
(global-set-key "\C-cf" 'counsel-imenu)
(defengine duckduckgo
"https://duckduckgo.com/?q=%s"
:keybinding "d")
(defengine github
"https://github.com/search?ref=simplesearch&q=%s")
(defengine google
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
:keybinding "g")
(defengine google-images
"http://www.google.com/images?hl=en&source=hp&biw=1440&bih=795&gbv=2&aq=f&aqi=&aql=&oq=&q=%s")
(defengine google-maps
"http://maps.google.com/maps?q=%s"
:docstring "Mappin' it up.")
(defengine project-gutenberg
"http://www.gutenberg.org/ebooks/search/?query=%s")
(defengine rfcs
"http://pretty-rfc.herokuapp.com/search?q=%s")
(defengine stack-overflow
"https://stackoverflow.com/search?q=%s")
(defengine twitter
"https://twitter.com/search?q=%s")
(defengine wikipedia
"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"
:keybinding "w"
:docstring "Searchin' the wikis.")
(defengine wiktionary
"https://www.wikipedia.org/search-redirect.php?family=wiktionary&language=en&go=Go&search=%s")
(defengine wolfram-alpha
"http://www.wolframalpha.com/input/?i=%s")
(defengine youtube
"http://www.youtube.com/results?aq=f&oq=&search_query=%s"
:keybinding "y")
(setq org-export-with-section-numbers nil)
(defun unfill-region (beg end)
"Unfill the region, joining text paragraphs into a single
logical line. This is useful, e.g., for use with
`visual-line-mode'."
(interactive "*r")
(let ((fill-column (point-max)))
(fill-region beg end)))
;; Handy key definition
(define-key global-map "\C-\M-Q" 'unfill-region)
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment