diff --git a/init.html b/index.html similarity index 90% rename from init.html rename to index.html index fd40270..0455b53 100644 --- a/init.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Emacs Configuration @@ -235,48 +235,49 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Summary

+
+

1 Summary

I've really been wanting to have a nicely formatted emacs config file and this is my attempt at it.

-
-

2 Required Magic

+
+

2 Required Magic

-
-

2.1 Lexical Binding

+
+

2.1 Lexical Binding

;;; -*- lexical-binding: t -*-
@@ -309,8 +310,8 @@ I've really been wanting to have a nicely formatted emacs config file and this i
 
-
-

2.2 The Magical Glue

+
+

2.2 The Magical Glue

The following auto compiles the emacs-lisp within the init.org file. @@ -335,12 +336,12 @@ Simply run `org-babel-tangle` to make it RAIN!

-
-

3 Config

+
+

3 Config

-
-

3.1 Packages

+
+

3.1 Packages

(require 'package)
@@ -354,6 +355,7 @@ Simply run `org-babel-tangle` to make it RAIN!
     company-go
     counsel
     counsel-projectile
+    dash-at-point
     diminish
     dockerfile-mode
     doom-themes
@@ -361,6 +363,7 @@ Simply run `org-babel-tangle` to make it RAIN!
     eldoc-eval
     elpy
     expand-region
+    fic-mode
     gitignore-mode
     go-mode
     go-playground
@@ -398,8 +401,8 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.2 Better Defaults

+
+

3.2 Better Defaults

(require 'better-defaults)
@@ -413,20 +416,67 @@ Simply run `org-babel-tangle` to make it RAIN!
           (run-with-idle-timer 0.1 nil
                                (lambda (fg) (set-face-foreground 'mode-line fg))
                                orig-fg))))
+
+(defun set-frame-size-according-to-resolution ()
+  "Set the Emacs window size on startup."
+  (interactive)
+  (if window-system
+      (progn
+        ;; WIDTH
+        (if (> (x-display-pixel-width) 1280)
+            ;; Large Screen (only show 120 cols)
+            (add-to-list 'default-frame-alist (cons 'width 240))
+          ;; Small Screen (fill window)
+          (add-to-list 'default-frame-alist (cons 'width (/ (x-display-pixel-width) (frame-char-width)))))
+
+        ;; HEIGHT
+        (if (> (x-display-pixel-height) 1080)
+            ;; Large Screen (only fill half screen)
+            (add-to-list 'default-frame-alist (cons 'height (/ (/ (x-display-pixel-height) 2)
+                                                               (frame-char-height))))
+          ;; Small Screen (fill window)
+          (add-to-list 'default-frame-alist (cons 'height (/ (x-display-pixel-height) (frame-char-height)))))
+        )))
+
+(set-frame-size-according-to-resolution)
+
+(defun window-px-width ()
+  "Get the width of the Emacs window in pixels."
+  (interactive)
+  (* (* (window-total-width) 2.874) (frame-char-width)))
+
+(defun window-px-left-pos ()
+  "Calculate the left position of the Emacs window."
+  (interactive)
+  (/ (- (x-display-pixel-width) (window-px-width)) 2))
+
+
+(add-to-list 'default-frame-alist (cons 'top 0))
+(add-to-list 'default-frame-alist (cons 'left 1000))
 
-
-

3.3 Basic Customization

+
+

3.3 Splash Screen

+
(setq inhibit-splash-screen nil
+      fancy-splash-image "~/.emacs.d/public/emacs-logo.png"
+      fancy-splash-image-file "~/.emacs.d/public/emacs-logo.png")
+
+
+
+
+
+

3.4 Basic Customization

+
+
(defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))
 (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))
 
-(setq inhibit-startup-message t
-      initial-scratch-message nil
+(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)))
@@ -452,36 +502,42 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.4 Tools

-
+
+

3.5 Tools

+
-
-

3.4.1 General

-
+
+

3.5.1 General

+
(require 'which-key)
 (which-key-setup-minibuffer)
 (which-key-mode)
+
+(require 'fic-mode)
+(add-hook 'js-mode-hook 'fic-mode)
 
-
-

3.4.2 Company

-
+
+

3.5.2 Company

+
(require 'company)
 (add-hook 'after-init-hook 'global-company-mode)
+
+(setq company-dabbrev-downcase nil)
+(setq company-idle-delay 0.1)
 
-
-

3.4.3 Diminish

-
+
+

3.5.3 Diminish

+
(require 'diminish)
 (diminish 'auto-revert-mode)
@@ -500,9 +556,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.4.4 Dired

-
+
+

3.5.4 Dired

+
(defun dired-mode-setup ()
   "Will run as hook for `dired-mode'."
@@ -512,9 +568,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.4.5 Ivy

-
+
+

3.5.5 Ivy

+
(require 'ivy-hydra)
 (require 'ivy)
@@ -553,9 +609,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.4.6 Magit

-
+
+

3.5.6 Magit

+
(require 'magit)
 (global-set-key (kbd "C-x g") 'magit-status)
@@ -566,9 +622,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.4.7 Projectile

-
+
+

3.5.7 Projectile

+
(require 'projectile)
 (require 'counsel-projectile)
@@ -584,13 +640,13 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.5 Development Specific

-
+
+

3.6 Development Specific

+
-
-

3.5.1 General

-
+
+

3.6.1 General

+
(require 'rainbow-delimiters)
 (global-flycheck-mode)
@@ -622,9 +678,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.5.2 Python

-
+
+

3.6.2 Python

+
(elpy-enable)
 (setq python-shell-interpreter "jupyter"
@@ -642,9 +698,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.5.3 Go

-
+
+

3.6.3 Go

+
(require 'go-mode)
 (require 'go-playground)
@@ -653,12 +709,15 @@ Simply run `org-babel-tangle` to make it RAIN!
 
 (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
 (add-hook 'go-mode-hook (lambda ()
-                          (add-hook 'before-save-hook 'gofmnt-before-save)
+                          (add-hook 'before-save-hook 'gofmt-before-save)
                           (local-set-key (kbd "M-.") 'godef-jump)
                           (local-set-key (kbd "M-,") 'pop-tag-mark)
+                          (local-set-key (kbd "C-c C-c") (lambda ()
+                                                           (interactive)
+                                                           (ansi-term)
+                                                           (comint-send-string "*ansi-term*" "make\n")))
                           (set (make-local-variable 'company-backends) '(company-go))
                           (setq company-tooltip-limit 20
-                                company-idle-delay .3
                                 company-echo-delay 0
                                 company-begin-commands '(self-insert-command))
                           (gorepl-mode)))
@@ -673,16 +732,16 @@ Simply run `org-babel-tangle` to make it RAIN!
 
 (when window-system (set-exec-path-from-shell-PATH))
 
-(setenv "GOPATH" "/home/leviolson/go")
-(add-to-list 'exec-path "/home/leviolson/go/bin")
+(setenv "GOPATH" "/Users/leviolson/go")
+(add-to-list 'exec-path "/Users/leviolson/go/bin")
 
-
-

3.5.4 TypeScript

-
+
+

3.6.4 TypeScript

+
(defun setup-tide-mode ()
   "Tide setup function."
@@ -710,7 +769,6 @@ Simply run `org-babel-tangle` to make it RAIN!
           '(lambda ()
              (set (make-local-variable 'company-backends) '(company-tide))
              (setq company-tooltip-limit 20
-                   company-idle-delay .3
                    company-echo-delay 0
                    company-begin-commands '(self-insert-command)
                    tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))
@@ -718,9 +776,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-
3.5.4.1 TSX
-
+
+
3.6.4.1 TSX
+
(require 'web-mode)
 (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
@@ -734,9 +792,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-
3.5.4.2 JSX
-
+
+
3.6.4.2 JSX
+
(require 'web-mode)
 (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
@@ -752,9 +810,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.5.5 Org

-
+
+

3.6.5 Org

+
(org-babel-do-load-languages
  'org-babel-load-languages
@@ -794,9 +852,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.6 Functions

-
+
+

3.7 Functions

+
(defun find-user-init-file ()
   "Edit the `~/.emacs.d/init.org' file."
@@ -804,7 +862,7 @@ Simply run `org-babel-tangle` to make it RAIN!
   (find-file "~/.emacs.d/init.org"))
 
 (defun load-user-init-file ()
-  "Reload the `~/.emacs.d/init.elc' file."
+  "LO: Reload the `~/.emacs.d/init.elc' file."
   (interactive)
   (load-file "~/.emacs.d/init.elc"))
 
@@ -832,6 +890,14 @@ Simply run `org-babel-tangle` to make it RAIN!
   (interactive)
   (jump-to-symbol-internal))
 
+(defun match-paren (arg)
+  "Go to the matching paren if on a paren; otherwise insert ARG (a literal % sign)."
+  (interactive "p")
+  (cond ((looking-at "\\s(") (forward-list 1))
+        ((looking-back "\\s(" 2) (backward-char 1) (forward-list 1))
+        ((looking-at "\\s)") (forward-char 1) (backward-list 1))
+        ((looking-back "\\s)" 2) (backward-list 1))
+        (t (self-insert-command (or arg 1)))))
 
 (defun 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."
@@ -842,10 +908,24 @@ Simply run `org-babel-tangle` to make it RAIN!
     (switch-to-buffer (other-buffer))
     (bury-buffer "*scratch*")))
 
-(defun backward-delete-to-word (arg)
-  "Delete words backward.  With ARG, do this many times."
+(defun delete-backward-sentence ()
+  "LO: Delete to the beginning of the sentence/line."
+  (interactive)
+  (delete-region (point) (progn (backward-sentence) (point))))
+
+(defun delete-backward-to-boundary (arg)
+  "LO: Delete backward to the previous word boundary.  With ARG, do this many times."
   (interactive "p")
-  (delete-region (point) (progn (backward-to-word arg) (point))))
+  (let ((a (point))
+        (b (progn
+             (backward-word arg)
+             (forward-word)
+             (point))))
+    (if (< a b)
+        (delete-region a (progn (backward-word arg) (point)))
+      (if (= a b)
+          (delete-region a (progn (backward-word arg) (point)))
+        (delete-region a b)))))
 
 (defun comment-or-uncomment-region-or-line ()
   "Comments or uncomments the region or the current line if there's no active region."
@@ -856,21 +936,29 @@ Simply run `org-babel-tangle` to make it RAIN!
       (setq beg (line-beginning-position) end (line-end-position)))
     (comment-or-uncomment-region beg end)))
 
+(defun fold-toggle (column)
+  "Code folding by COLUMN."
+  (interactive "P")
+  (set-selective-display
+   (or column
+       (unless selective-display
+         (1+ (current-column))))))
+
 (defun new-line-below ()
-  "Create a new line below current line."
+  "LO: Create a new line below current line."
   (interactive)
   (move-end-of-line 1)
   (newline-and-indent))
 
 (defun new-line-above ()
-  "Create a new line above current line."
+  "LO: Create a new line above current line."
   (interactive)
   (move-beginning-of-line 1)
   (newline)
   (forward-line -1))
 
 (defun 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."
+  "LO: 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)))
@@ -882,22 +970,22 @@ Simply run `org-babel-tangle` to make it RAIN!
       (when comment (comment-region start end)))))
 
 (defun tidy ()
-  "Ident, untabify and unwhitespacify current buffer, or region if active."
+  "LO: Ident, 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))))
-    (if (region-active-p) (message "Indenting Region") (message "Indenting File"))
     (let ((inhibit-message t))
       (indent-region beg end))
     (whitespace-cleanup)
-    (untabify beg (if (< end (point-max)) end (point-max)))))
+    (untabify beg (if (< end (point-max)) end (point-max)))
+    (if (region-active-p) (message "Indenting Region...Done") (message "Indenting File...Done"))))
 
 (defun phil-columns ()
-  "Good 'ol Phil-Columns."
+  "LO: Good 'ol Phil-Columns."
   (interactive)
   (message "Good 'ol fill-columns")
   (with-output-to-temp-buffer "*PHIL-COLUMN*"
-    (shell-command "mpv --no-video 'https://www.youtube.com/watch?v=YkADj0TPrJA&t=3m16s' > /dev/null 2>&1 & sleep 7; pkill mpv"))
+    (shell-command "mpv --no-video 'https://www.youtube.com/watch?v=YkADj0TPrJA&t=3m16s' > /dev/null 2>&1 & sleep 8; pkill mpv"))
   (other-window 1)
   (delete-window))
 
@@ -948,9 +1036,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.7 Bindings

-
+
+

3.8 Bindings

+
(require 'company)
 (add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-comint)))
@@ -967,14 +1055,19 @@ Simply run `org-babel-tangle` to make it RAIN!
 (define-key global-map          (kbd "M-p")          'jump-to-previous-like-this)
 (define-key global-map          (kbd "M-n")          'jump-to-next-like-this)
 (define-key global-map          (kbd "M-<tab>")      'switch-to-next-buffer)
-(define-key global-map          (kbd "M-<backspace>")'backward-delete-to-word)
-(define-key global-map          (kbd "C-<backspace>")'backward-delete-to-word)
+(define-key global-map          (kbd "M-<backspace>")'delete-backward-to-boundary)
+(define-key global-map          (kbd "C-<backspace>")'delete-backward-to-boundary)
 
 (global-set-key                 (kbd "C-S-<down>")   'mc/mark-next-like-this)
-(global-set-key                 (kbd "C->")          'mc/mark-next-like-this)
+(global-set-key                 (kbd "C->")          'mc/mark-next-like-this-symbol)
 (global-set-key                 (kbd "C-S-<up>")     'mc/mark-previous-like-this)
 (global-set-key                 (kbd "C-<")          'mc/mark-previous-like-this)
 (global-set-key                 (kbd "C-c C->")      'mc/mark-all-like-this)
+(global-set-key                 "%"                  'match-paren)
+(global-set-key                 (kbd "C-x .")        'dash-at-point)
+(global-set-key                 (kbd "C-x ,")        'dash-at-point-with-docset)
+(global-set-key                 (kbd "C-s")          (lambda () (interactive) (swiper (format "%s" (thing-at-point 'symbol)))))
+
 ;; (dolist (n (number-sequence 1 9))
 ;;   (global-set-key (kbd (concat "M-" (int-to-string n)))
 ;;                   (lambda () (interactive) (switch-shell n))))
@@ -1026,9 +1119,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.8 UI

-
+
+

3.9 UI

+
(cond ((member "PragmataPro" (font-family-list))
        (set-face-attribute 'default nil :font "PragmataPro-14")))
@@ -1036,9 +1129,9 @@ Simply run `org-babel-tangle` to make it RAIN!
 
-
-

3.8.1 Modeline

-
+
+

3.9.1 Modeline

+
(require 'use-package)
 (require 'anzu)
@@ -1818,7 +1911,7 @@ Simply run `org-babel-tangle` to make it RAIN!
 

Date: 2019-01-30 Wed 00:00

Author: Levi Olson

-

Created: 2019-02-01 Fri 18:16

+

Created: 2019-02-13 Wed 14:20

Validate

diff --git a/init.elc b/init.elc index 0f317f0..0d1863e 100644 Binary files a/init.elc and b/init.elc differ diff --git a/init.org b/init.org index b3d9447..e5a1c00 100644 --- a/init.org +++ b/init.org @@ -5,6 +5,7 @@ #+LANGUAGE: en #+BABEL: :cache yes #+HTML_HEAD: +#+EXPORT_FILE_NAME: index.html #+PROPERTY: header-args :tangle yes #+OPTIONS: num:10 whn:nil toc:10 H:10 #+STARTUP: content