;; -*- lexical-binding: t; -*- ;; Configure Melpa (setq package--init-file-ensured t package-enable-at-startup nil ;; package-user-dir doom-elpa-dir ;; package-gnupghome-dir (expand-file-name "gpg" doom-elpa-dir) package-archives `(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") ("org" . "https://orgmode.org/elpa/"))) (package-initialize) ;; Configure Use-Package (eval-when-compile (add-to-list 'load-path (concat user-emacs-directory "elpa/use-package-20190716.1829")) (add-to-list 'load-path (concat user-emacs-directory "elpa/bind-key-20180513.430")) (require 'use-package) (require 'bind-key)) ;; Compile function (defun compile-init () "If the current buffer is 'init.el' tangled file is compiled." (when (equal (buffer-file-name) (expand-file-name (concat user-emacs-directory "init.el"))) ;; Avoid running hooks when tangling. (let ((prog-mode-hook nil)) (byte-compile-file (concat user-emacs-directory "init.el"))))) ;; (add-hook 'after-save-hook 'compile-init) ;; Some Basic Init (defvar backup-dir (expand-file-name "~/.emacs.d/backup/")) (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/")) (setq initial-scratch-message nil backup-directory-alist (list (cons ".*" backup-dir)) auto-save-list-file-prefix autosave-dir auto-save-file-name-transforms `((".*" ,autosave-dir t))) ;; Turn off the menus, scrollbars, and toolbars (menu-bar-mode 0) (scroll-bar-mode 0) (tool-bar-mode 0) (horizontal-scroll-bar-mode 0) ;; Revert to file on disk if it changes (global-auto-revert-mode t) ;; Highlight the current line (global-hl-line-mode t) ;; Show the column number after the line number (i.e. 50:57) (column-number-mode t) ;; C-c | to undo|redo window changes like adding buffers. (winner-mode t) ;; Show matching paren (show-paren-mode t) ;; Indent w/spaces only (setq indent-tabs-mode nil) ;; Prevent stale elisp bytecode (setq load-prefer-newer t) ;; Add newline on save (setq require-final-newline t) ;; C-c to copy in Linux can be pasted in emacs (setq select-enable-clipboard t) ;; after mouse selection can be pasted in emacs (setq select-enable-primary t) ;; Paste at current point, not mouse location when "middle-clicking" (setq mouse-yank-at-point t) (add-hook 'before-save-hook 'delete-trailing-whitespace) ;; Set auth source ;; (setq auth-sources '("~/.authinfo.gpg")) (defalias 'yes-or-no-p 'y-or-n-p) (defun display-startup-echo-area-message () "Display startup echo area message." (message "Initialized in %s" (emacs-init-time))) (defun leo--find-user-init-file () "Edit the `~/.emacs.d/init.el' file." (interactive) (find-file "~/.emacs.d/init.el")) (defun leo--tidy () "Indent, untabify and unwhitespacify current buffer, or region if active." (interactive) (let ((beg (if (region-active-p) (region-beginning) (point-min))) (end (if (region-active-p) (region-end) (point-max)))) (let ((inhibit-message t)) (indent-region beg end)) (whitespace-cleanup) (untabify beg (if (< end (point-max)) end (point-max))) (if (region-active-p) (message "Indenting Region...Done") (message "Indenting File...Done")))) (defun leo--comment-or-uncomment-region-or-line () "Comment or uncomment 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))) (defun leo--duplicate-thing (comment) "Duplicates the current line, or the region if active. If an argument (COMMENT) is given, the duplicated region will be commented out." (interactive "P") (save-excursion (let ((start (if (region-active-p) (region-beginning) (point-at-bol))) (end (if (region-active-p) (region-end) (point-at-eol)))) (goto-char end) (unless (region-active-p) (newline)) (insert (buffer-substring start end)) (when comment (comment-region start end))))) (defun leo--kill-this-buffer-unless-scratch () "Works like `kill-this-buffer' unless the current buffer is the *scratch* buffer. In which case the buffer content is deleted and the buffer is buried." (interactive) (if (or (string= (buffer-name) "*dashboard*") (string= (buffer-name) "*scratch*")) (progn (bury-buffer (buffer-name)) (switch-to-buffer (other-buffer))) (kill-this-buffer))) (defun leo--jump-to-symbol (&optional backwardp) "Jumps to the next symbol near the point if such a symbol exists. If BACKWARDP is non-nil it jumps backward." (let* ((point (point)) (bounds (find-tag-default-bounds)) (beg (car bounds)) (end (cdr bounds)) (str (isearch-symbol-regexp (find-tag-default))) (search (if backwardp 'search-backward-regexp 'search-forward-regexp))) (goto-char (if backwardp beg end)) (funcall search str nil t) (cond ((<= beg (point) end) (goto-char point)) (backwardp (forward-char (- point beg))) (t (backward-char (- end point)))))) (defun leo--jump-to-prev-symbol () "Jumps to the previous occurrence of the symbol at point." (interactive) (leo--jump-to-symbol t)) (defun leo--jump-to-next-symbol () "Jumps to the next occurrence of the symbol at point." (interactive) (leo--jump-to-symbol)) ;; USE PACKAGE help ;; (use-package package-here ;; :commands (cmd cmd-all cmd-etc) ;; List commands used to ":defer" the package ;; :bind-keymap ;; ("M-q" . package-here-keymap) ;; Setup an entire keymap using Prefix "M-q" ;; :bind ;; (("M-s" . cmd) ;; Available Globally ;; :map here-mode-map ;; ("C-t" . cmd-all) ;; Available only in "here-mode" ;; ("C-e" . cmd-etc)) ;; Available only in "here-mode" ;; :init ;; (setq stuff t) ;; declar vars etc... ;; :config ;; (here-mode 1) ;; eval stuff here after the init ;; ;; (use-package ruby-mode ;; :mode "\\.rb\\'" ;; :interpreter "ruby" ;; ;; ;; OR when the package name isn't the same as the =mode= ;; (use-package python ;; :mode ("\\.py\\'" . python-mode) ;; :interpreter ("python" . python-mode)) ;; ;; USE ":defer" when you aren't using either :commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, :interpreter, or :hook ;; (use-package deferred-package ;; :defer t) (use-package bind-key :ensure t :bind ("C-" . leo--tidy) ("C-;" . leo--comment-or-uncomment-region-or-line) ("C-c e" . leo--find-user-init-file) ("M-q" . leo--kill-this-buffer-unless-scratch) ("C-c d" . leo--duplicate-thing) ("M-n" . leo--jump-to-next-symbol) ("M-p" . leo--jump-to-prev-symbol) ("M-u" . upcase-dwim) ("M-c" . capitalize-dwim) ("M-l" . downcase-dwim) ) ;; https://github.com/hlissner/emacs-doom-themes (use-package doom-themes :ensure t :config (load-theme 'doom-one t)) ;; https://github.com/belak/base16-emacs (use-package base16-theme :disabled :ensure t :config (load-theme 'base16-onedark t)) ;; https://github.com/coldnew/linum-relative (use-package linum-relative :ensure t :config (linum-relative-mode)) ;; https://github.com/Fanael/rainbow-delimiters (use-package rainbow-delimiters :ensure t :hook (prog-mode . rainbow-delimiters-mode)) ;; M-x all-the-icons-install-fonts (use-package all-the-icons :ensure t) (use-package doom-modeline :ensure t :after (all-the-icons) :hook (after-init . doom-modeline-mode)) (use-package dashboard :ensure t :init (setq dashboard-items '((recents . 6) (bookmarks . 5) ;; (projects . 5) (agenda . 5))) (setq dashboard-center-content t) (setq dashboard-banner-logo-title "Let's begin...") (setq dashboard-startup-banner 1) (setq dashboard-show-shortcuts t) (setq show-week-agenda-p t) (setq dashboard-org-agenda-categories '("work" "tasks")) :config (dashboard-setup-startup-hook)) (use-package helm :ensure t :demand t :bind ("M-x" . helm-M-x) ("C-c b" . helm-buffers-list) ("C-x C-f" . helm-find-files)) ;; https://github.com/emacsorphanage/helm-swoop (use-package helm-swoop :ensure t :after (helm) :bind ("C-s" . helm-swoop) :config ;; If you prefer fuzzy matching (setq helm-swoop-use-fuzzy-match t)) ;; https://github.com/syohex/emacs-helm-ag (use-package helm-ag :ensure t :after (helm) :bind ("C-c k" . helm-ag)) (use-package expand-region :ensure t :bind ("C-@" . er/expand-region) ("C-#" . er/contract-region)) ;; https://github.com/magnars/multiple-cursors.el (use-package multiple-cursors :ensure t :bind ("C-}" . mc/mark-next-like-this) ("C-)" . mc/unmark-next-like-this) ("C-{" . mc/mark-previous-like-this) ("C-(" . mc/unmark-previous-like-this)) ;; https://github.com/justbur/emacs-which-key (use-package which-key :ensure t :config (which-key-setup-minibuffer) (which-key-mode)) ;; https://github.com/lewang/fic-mode (use-package fic-mode :ensure t :hook prog-mode) ;; https://github.com/joaotavora/yasnippet (use-package yasnippet :ensure t :bind ("" . yas-expand) :init (setq yas-snippet-dirs (list (concat user-emacs-directory "snippets"))) :config (yas-reload-all) (yas-minor-mode 1)) ;; https://company-mode.github.io/ (use-package company :ensure t :hook (prog-mode . company-mode)) ;; https://github.com/magit/magit (use-package magit :commands magit-status :ensure t :init (setq magit-completing-read-function 'helm-completing-read-default-handler) :bind ("C-x g" . magit-status) ("C-c g" . magit-status)) ;; https://github.com/bbatsov/projectile (use-package projectile :ensure t :bind-keymap ("C-c p" . projectile-command-map) ) ;; https://github.com/magit/git-modes (use-package gitignore-mode :ensure t) ;; https://github.com/magit/git-modes (use-package gitconfig-mode :ensure t) ;; http://web-mode.org/ (use-package web-mode :ensure t :mode "\\.html?\\'") ;; https://github.com/joshwnj/json-mode (use-package json-mode :ensure t :mode "\\.json\\'") ;; https://orgmode.org/elpa.html (use-package org :commands (org-cycle-agenda-files org-capture) :ensure org-plus-contrib :mode ("\\.org\\'" . org-mode) :bind ( ("C-," . org-cycle-agenda-files) ("C-c C-d" . org-capture) :map org-mode-map ("M-RET" . org-insert-todo-heading) ) :init (setq org-agenda-files '("~/Dropbox/Org/todo.org" "~/Dropbox/Org/archive.org" "~/Dropbox/Org/diary/eaglecrk.org")) (setq org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)") (sequence "BUG(b)" "INPROGRESS(i)" "|" "FIXED(f)") (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)") (sequence "|" "CANCELED(c)") (sequence "|" "NEEDCLARIFICATION(n)") (sequence "|" "PROVIDEUPDATE(p)") (sequence "|" "WAITING(w)")) org-refile-targets '((nil :maxlevel . 3) (org-agenda-files :maxlevel . 3)) org-directory "~/Dropbox/Org" org-default-notes-file (concat org-directory "/todo.org") org-startup-folded t org-startup-indented t org-startup-align-all-tables t org-startup-with-inline-images t org-startup-with-latex-preview t org-src-tab-acts-natively t org-confirm-babel-evaluate nil org-log-done t org-log-done-with-time t org-log-into-drawer t org-hide-leading-stars t org-pretty-entities t org-use-property-inheritance t org-html-validation-link nil org-html-text-markup-alist '((bold . "%s") (code . "%s") (italic . "%s") (strike-through . "%s") (underline . "%s") (verbatim . "%s")) ) :config (org-babel-do-load-languages 'org-babel-load-languages '((js . t) (shell . t) (emacs-lisp . t))) (add-to-list 'org-structure-template-alist (list "e" (concat "#+BEGIN_SRC emacs-lisp :results silent\n" "\n" "#+END_SRC"))) (add-to-list 'org-structure-template-alist (list "j" (concat "#+BEGIN_SRC js :cmd \"/usr/local/bin/babel-node\" :results output code\n" "\n" "#+END_SRC"))) (add-to-list 'org-structure-template-alist (list "r" (concat "#+BEGIN_SRC restclient :results raw\n" "\n" "#+END_SRC"))) ) ;; https://github.com/sabof/org-bullets (use-package org-bullets :ensure t :after (org) :hook (org-mode . org-bullets-mode) :config (set-face-attribute 'org-level-1 nil :height 1.3) (set-face-attribute 'org-level-2 nil :height 1.1) (set-face-attribute 'org-level-3 nil :height 1.05) (set-face-attribute 'org-level-4 nil :height 1.05) (set-face-attribute 'org-scheduled-today nil :height 1.0) (set-face-attribute 'org-agenda-date-today nil :height 1.1)) ;; https://orgmode.org/worg/org-contrib/org-protocol.html (use-package org-protocol :ensure org-plus-contrib :after (org) :init (setq org-capture-templates '(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks") "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n") ("n" "new note" entry (file+headline org-default-notes-file "Notes") "* %?\n%i\n") ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled") "* %a\n%?\n") ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled") "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n") ("f" "dotfile" entry (file+headline "~/Dropbox/Org/dotfiles.org" "Other") "* %?\n:PROPERTIES:\n:CUSTOM_ID: %(org-id-get-create)\n:END:\n") )) ) (cond ((member "PragmataPro Liga" (font-family-list)) (set-face-attribute 'default nil :font "PragmataPro Liga-12"))) (server-start) ;; Reset GC as late as possible ;; (add-hook 'emacs-startup-hook ;; (setq gc-cons-threshold 16777216 ;; gc-cons-percentage 0.1)) (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 (doom-themes linum-relative org-bullets org-plus-contrib web-mode gitconfig-mode gitignore-mode rainbow-delimiters company company-mode projectile magit helm-ag helm-swoop yasnippet fic-mode which-key pdf-tools better-defaults use-package))) '(safe-local-variable-values (quote ((whitespace-line-column . 120))))) (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. )