@ -4,7 +4,7 @@
#+DATE : <2019-01-30 Wed>
#+DATE : <2019-01-30 Wed>
#+LANGUAGE : en
#+LANGUAGE : en
#+BABEL : :cache yes
#+BABEL : :cache yes
#+HTML_HEAD : <link rel="stylesheet" type="text/css" href="http://thomasf.github.io/solarized-css/solarized-light.min .css" />
#+HTML_HEAD : <link rel="stylesheet" type="text/css" href="public/style .css" />
#+PROPERTY : header-args :tangle yes
#+PROPERTY : header-args :tangle yes
#+OPTIONS : num:10 whn:nil toc:10 H:10
#+OPTIONS : num:10 whn:nil toc:10 H:10
#+STARTUP : content
#+STARTUP : content
@ -54,6 +54,7 @@
company-go
company-go
counsel
counsel
counsel-projectile
counsel-projectile
dash-at-point
diminish
diminish
dockerfile-mode
dockerfile-mode
doom-themes
doom-themes
@ -61,6 +62,7 @@
eldoc-eval
eldoc-eval
elpy
elpy
expand-region
expand-region
fic-mode
gitignore-mode
gitignore-mode
go-mode
go-mode
go-playground
go-playground
@ -108,15 +110,57 @@
(run-with-idle-timer 0.1 nil
(run-with-idle-timer 0.1 nil
(lambda (fg) (set-face-foreground 'mode-line fg))
(lambda (fg) (set-face-foreground 'mode-line fg))
orig-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))
#+END_SRC
#+END_SRC
** Splash Screen
#+BEGIN_SRC emacs-lisp :results silent
(setq inhibit-splash-screen nil
fancy-splash-image "~/.emacs.d/public/emacs-logo.png"
fancy-splash-image-file "~/.emacs.d/public/emacs-logo.png")
#+END_SRC
** Basic Customization
** Basic Customization
#+BEGIN_SRC emacs-lisp :results silent
#+BEGIN_SRC emacs-lisp :results silent
(defvar backup-dir (expand-file-name "~/.emacs.d/backup/ "))
(defvar backup-dir (expand-file-name "~/.emacs.d/backup/ "))
(defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/ "))
(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))
backup-directory-alist (list (cons ".*" backup-dir))
auto-save-list-file-prefix autosave-dir
auto-save-list-file-prefix autosave-dir
auto-save-file-name-transforms `((".*" ,autosave-dir t)))
auto-save-file-name-transforms `((".*" ,autosave-dir t)))
@ -145,6 +189,9 @@
(require 'which-key)
(require 'which-key)
(which-key-setup-minibuffer)
(which-key-setup-minibuffer)
(which-key-mode)
(which-key-mode)
(require 'fic-mode)
(add-hook 'js-mode-hook 'fic-mode)
#+END_SRC
#+END_SRC
*** Company
*** Company
@ -286,9 +333,13 @@
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
(add-hook 'go-mode-hook (lambda ()
(add-hook 'go-mode-hook (lambda ()
(add-hook 'before-save-hook 'gofmn t-before-save)
(add-hook 'before-save-hook 'gofmt-before-save)
(local-set-key (kbd "M-.") 'godef-jump)
(local-set-key (kbd "M-.") 'godef-jump)
(local-set-key (kbd "M-,") 'pop-tag-mark)
(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))
(set (make-local-variable 'company-backends) '(company-go))
(setq company-tooltip-limit 20
(setq company-tooltip-limit 20
company-idle-delay .3
company-idle-delay .3
@ -306,8 +357,8 @@
(when window-system (set-exec-path-from-shell-PATH))
(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")
#+END_SRC
#+END_SRC
*** TypeScript
*** TypeScript
@ -411,7 +462,7 @@
(find-file "~/.emacs.d/init.org"))
(find-file "~/.emacs.d/init.org"))
(defun load-user-init-file ()
(defun load-user-init-file ()
"Reload the `~/.emacs.d/init.elc' file."
"LO: Reload the `~/.emacs.d/init.elc' file."
(interactive)
(interactive)
(load-file "~/.emacs.d/init.elc"))
(load-file "~/.emacs.d/init.elc"))
@ -439,6 +490,14 @@
(interactive)
(interactive)
(jump-to-symbol-internal))
(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 ()
(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."
"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."
@ -449,10 +508,24 @@
(switch-to-buffer (other-buffer))
(switch-to-buffer (other-buffer))
(bury-buffer "*scratch* ")))
(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")
(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 ()
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
"Comments or uncomments the region or the current line if there's no active region."
@ -463,21 +536,29 @@
(setq beg (line-beginning-position) end (line-end-position)))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)))
(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 ()
(defun new-line-below ()
"Create a new line below current line."
"LO: Create a new line below current line."
(interactive)
(interactive)
(move-end-of-line 1)
(move-end-of-line 1)
(newline-and-indent))
(newline-and-indent))
(defun new-line-above ()
(defun new-line-above ()
"Create a new line above current line."
"LO: Create a new line above current line."
(interactive)
(interactive)
(move-beginning-of-line 1)
(move-beginning-of-line 1)
(newline)
(newline)
(forward-line -1))
(forward-line -1))
(defun duplicate-thing (comment)
(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")
(interactive "P")
(save-excursion
(save-excursion
(let ((start (if (region-active-p) (region-beginning) (point-at-bol)))
(let ((start (if (region-active-p) (region-beginning) (point-at-bol)))
@ -489,22 +570,22 @@
(when comment (comment-region start end)))))
(when comment (comment-region start end)))))
(defun tidy ()
(defun tidy ()
"Ident, untabify and unwhitespacify current buffer, or region if active."
"LO: Ident, untabify and unwhitespacify current buffer, or region if active."
(interactive)
(interactive)
(let ((beg (if (region-active-p) (region-beginning) (point-min)))
(let ((beg (if (region-active-p) (region-beginning) (point-min)))
(end (if (region-active-p) (region-end) (point-max))))
(end (if (region-active-p) (region-end) (point-max))))
(if (region-active-p) (message "Indenting Region") (message "Indenting File"))
(let ((inhibit-message t))
(let ((inhibit-message t))
(indent-region beg end))
(indent-region beg end))
(whitespace-cleanup)
(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 ()
(defun phil-columns ()
"Good 'ol Phil-Columns."
"LO: Good 'ol Phil-Columns."
(interactive)
(interactive)
(message "Good 'ol fill-columns")
(message "Good 'ol fill-columns")
(with-output-to-temp-buffer "*PHIL-COLUMN* "
(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)
(other-window 1)
(delete-window))
(delete-window))
@ -569,14 +650,19 @@
(define-key global-map (kbd "M-p") 'jump-to-previous-like-this)
(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-n") 'jump-to-next-like-this)
(define-key global-map (kbd "M-<tab >") 'switch-to-next-buffer)
(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-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)
(global-set-key (kbd "C-S-<up >") 'mc/mark-previous-like-this)
(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-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C->") 'mc/mark-all-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))
;; (dolist (n (number-sequence 1 9))
;; (global-set-key (kbd (concat "M-" (int-to-string n)))
;; (global-set-key (kbd (concat "M-" (int-to-string n)))
;; (lambda () (interactive) (switch-shell n))))
;; (lambda () (interactive) (switch-shell n))))