summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <fcuny@twitter.com>2019-02-16 14:10:22 -0800
committerFranck Cuny <fcuny@twitter.com>2019-02-16 14:10:22 -0800
commit67c2168998c829c8739a0a4f73ab9d6117d07f0a (patch)
treea4dcb9f8a99f527187b08e77aea85e632c6a1396
parent[emacs] Add a function to select and copy buffer. (diff)
downloademacs.d-67c2168998c829c8739a0a4f73ab9d6117d07f0a.tar.gz
[emacs] Split configuration in multiple files.
This is actually an easier thing to maintain.
-rw-r--r--emacs.d/custom/fcuny-common.el42
-rw-r--r--emacs.d/custom/fcuny-docker.el5
-rw-r--r--emacs.d/custom/fcuny-edit.el29
-rw-r--r--emacs.d/custom/fcuny-flycheck.el67
-rw-r--r--emacs.d/custom/fcuny-git.el14
-rw-r--r--emacs.d/custom/fcuny-go.el13
-rw-r--r--emacs.d/custom/fcuny-hygiene.el14
-rw-r--r--emacs.d/custom/fcuny-json.el14
-rw-r--r--emacs.d/custom/fcuny-lisp.el6
-rw-r--r--emacs.d/custom/fcuny-make.el5
-rw-r--r--emacs.d/custom/fcuny-navigation.el67
-rw-r--r--emacs.d/custom/fcuny-protobuf.el7
-rw-r--r--emacs.d/custom/fcuny-puppet.el6
-rw-r--r--emacs.d/custom/fcuny-python.el8
-rw-r--r--emacs.d/custom/fcuny-settings.el36
-rw-r--r--emacs.d/custom/fcuny-shell.el8
-rw-r--r--emacs.d/custom/fcuny-text.el25
-rw-r--r--emacs.d/custom/fcuny-ui.el37
-rw-r--r--emacs.d/custom/fcuny-vars.el10
-rw-r--r--emacs.d/custom/fcuny-yaml.el4
-rw-r--r--emacs.d/init.el354
21 files changed, 442 insertions, 329 deletions
diff --git a/emacs.d/custom/fcuny-common.el b/emacs.d/custom/fcuny-common.el
new file mode 100644
index 0000000..079c042
--- /dev/null
+++ b/emacs.d/custom/fcuny-common.el
@@ -0,0 +1,42 @@
+(defun fcuny/rename-this-buffer-and-file ()
+  "Renames current buffer and file it is visiting."
+  (interactive)
+  (let ((name (buffer-name))
+        (filename (buffer-file-name))
+        (read-file-name-function 'read-file-name-default))
+    (if (not (and filename (file-exists-p filename)))
+        (error "Buffer '%s' is not visiting a file!" name)
+      (let ((new-name (read-file-name "New name: " filename)))
+        (cond ((get-buffer new-name)
+               (error "A buffer named '%s' already exists!" new-name))
+              (t
+               (rename-file filename new-name 1)
+               (rename-buffer new-name)
+               (set-visited-file-name new-name)
+               (set-buffer-modified-p nil)
+               (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
+
+(defun fcuny/remove-mysql-columns ()
+  "Removes | from text. This is useful when I want to drop the column separator from some text coming from a mysql query."
+  (interactive)
+  (if (region-active-p)
+      (replace-regexp "\s?|\s?" "" nil (region-beginning) (region-end))
+    (replace-regexp "\s?|\s?" "")))
+
+(defun fcuny/copy-whole-buffer ()
+  "Selects the buffer and copy it."
+  (interactive)
+  (save-excursion
+    (mark-whole-buffer)
+    (copy-region-as-kill 1 (buffer-size))))
+
+(defun fcuny/check-work-machine-p ()
+  "Returns t if this is a work machine"
+  (string-match "tw-mbp.*" (system-name)))
+
+(defun fcuny/check-source-predicate-python-p ()
+  (and (executable-find "check.pex")
+       (buffer-file-name)
+       (string-match "src/source/.*\.py$" (buffer-file-name))))
+
+(provide 'fcuny-common)
diff --git a/emacs.d/custom/fcuny-docker.el b/emacs.d/custom/fcuny-docker.el
new file mode 100644
index 0000000..be31098
--- /dev/null
+++ b/emacs.d/custom/fcuny-docker.el
@@ -0,0 +1,5 @@
+(use-package dockerfile-mode
+  :ensure t
+  :mode "Dockerfile[a-zA-Z.-]*\\'")
+
+(provide 'fcuny-docker)
diff --git a/emacs.d/custom/fcuny-edit.el b/emacs.d/custom/fcuny-edit.el
new file mode 100644
index 0000000..5df8196
--- /dev/null
+++ b/emacs.d/custom/fcuny-edit.el
@@ -0,0 +1,29 @@
+(use-package autorevert
+  :config
+  (setq global-auto-revert-non-file-buffers t)
+  (setq auto-revert-verbose nil)
+  (global-auto-revert-mode t))
+
+(use-package whitespace
+  :custom
+  (whitespace-style '(face trailing))
+  (show-trailing-whitespace t)
+  :hook (whitespace-mode))
+
+(use-package electric-pair-mode
+  :commands electric-pair-mode
+  :init (add-hook 'prog-mode-hook 'electric-pair-mode))
+
+(use-package paren
+  :ensure t
+  :custom
+  (show-paren-delay 0)
+  :config
+  (show-paren-mode 1))
+
+(use-package general
+  :config
+  (general-define-key
+   "M-j" 'join-line))
+
+(provide 'fcuny-edit)
diff --git a/emacs.d/custom/fcuny-flycheck.el b/emacs.d/custom/fcuny-flycheck.el
new file mode 100644
index 0000000..26e9b72
--- /dev/null
+++ b/emacs.d/custom/fcuny-flycheck.el
@@ -0,0 +1,67 @@
+(require 'fcuny-common)
+
+(use-package flycheck
+  :ensure t
+  :custom ((flycheck-idle-change-delay 2)
+           (flycheck-emacs-lisp-load-path 'inherit))
+  :config
+  (progn
+    (use-package flycheck-pos-tip
+      :ensure t
+      :config
+      (flycheck-pos-tip-mode))
+
+    (add-hook 'prog-mode-hook 'flycheck-mode)
+    (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
+    (setq flycheck-highlighting-mode 'lines)
+    (setq flycheck-check-syntax-automatically '(mode-enabled save))
+
+    (flycheck-define-checker source-check
+      "A syntax checker for python source code in Source, using `check.pex'"
+      :command ("check.pex" source)
+    ;;; errors are reported like this:
+    ;;; E241:ERROR   <file name>:<line> <message>
+      :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end)
+                       (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end))
+      :predicate fcuny/check-source-predicate-python-p
+      :modes (python-mode))
+    (add-to-list 'flycheck-checkers 'source-check)
+
+    (defface fc/flycheck-error
+      '((t (:foreground "#f40000")))
+      "Face for flycheck error feedback in the modeline."
+      :group 'fc/flycheck)
+    (defface fc/flycheck-warning
+      '((t (:foreground "#724a09")))
+      "Face for flycheck warning feedback in the modeline."
+      :group 'fc/flycheck)
+    ;;; errors are reported like this:
+    ;;; E241:ERROR   <file name>:<line> <message>
+    (defface fc/flycheck-info
+      '((t (:foreground "#19baff")))
+      "Face for flycheck info feedback in the modeline."
+      :group 'fc/flycheck)
+    (defface fc/flycheck-success
+      '((t (:foreground "#2cb250")))
+      "Face for flycheck success feedback in the modeline."
+      :group 'fc/flycheck)
+
+    (setq flycheck-mode-line
+        '(:eval
+          (pcase flycheck-last-status-change
+            (`running (propertize " ⟲ Running" 'face 'fc/flycheck-info))
+            (`errored (propertize " ⚠ Error" 'face 'fc/flycheck-error))
+            (`no-checker (propertize " ⚠ No Checker" 'face 'fc/flycheck-info))
+            (`suspicious (propertize " ⚠ Suspicious" 'face 'fc/flycheck-warning))
+            (`not-checked (propertize " ✖ Disabled" 'face 'fc/flycheck-info))
+            (`interrupted (propertize " ⚠ Interrupted" 'face 'fc/flycheck-warning))
+            (`finished
+             (let* ((error-counts (flycheck-count-errors flycheck-current-errors))
+                    (no-errors (cdr (assq 'error error-counts)))
+                    (no-warnings (cdr (assq 'warning error-counts)))
+                    (face (cond (no-errors 'fc/flycheck-error)
+                                (no-warnings 'fc/flycheck-warning)
+                                (t 'fc/flycheck-success))))
+               (propertize (if (or no-errors no-warnings) (format " ✘ %s/%s Issues" (or no-errors 0) (or no-warnings 0)) " ✔ No Issues") 'face face))))))))
+
+(provide 'fcuny-flycheck)
diff --git a/emacs.d/custom/fcuny-git.el b/emacs.d/custom/fcuny-git.el
new file mode 100644
index 0000000..d056896
--- /dev/null
+++ b/emacs.d/custom/fcuny-git.el
@@ -0,0 +1,14 @@
+(use-package gitconfig-mode
+  :ensure t
+  :defer 5)
+
+(use-package magit
+  :ensure t
+  :after (flyspell)
+  :hook ((magit-mode . hl-line-mode))
+  :bind (("C-x g s" . magit-status))
+  :config
+  (setq git-commit-summary-max-length 50)
+  (setq fill-column 72))
+
+(provide 'fcuny-git)
diff --git a/emacs.d/custom/fcuny-go.el b/emacs.d/custom/fcuny-go.el
new file mode 100644
index 0000000..3926c9e
--- /dev/null
+++ b/emacs.d/custom/fcuny-go.el
@@ -0,0 +1,13 @@
+(use-package go-mode
+  :ensure t
+  :after (exec-path-from-shell)
+  :hook (go-mode . fcuny/go-mode-setup)
+  :init
+  (defun fcuny/go-mode-setup ()
+    (setq tab-width 4)
+    (add-hook 'before-save-hook 'gofmt-before-save))
+  :config
+  (when (memq window-system '(mac ns))
+    (exec-path-from-shell-copy-env "GOPATH")))
+
+(provide 'fcuny-go)
diff --git a/emacs.d/custom/fcuny-hygiene.el b/emacs.d/custom/fcuny-hygiene.el
new file mode 100644
index 0000000..2d74c82
--- /dev/null
+++ b/emacs.d/custom/fcuny-hygiene.el
@@ -0,0 +1,14 @@
+(use-package midnight
+  :config
+  (midnight-mode t))
+
+(use-package server
+  :hook (after-init . server-start))
+
+(use-package exec-path-from-shell
+  :ensure t
+  :if (memq window-system '(mac ns))
+  :config
+  (exec-path-from-shell-initialize))
+
+(provide 'fcuny-hygiene)
diff --git a/emacs.d/custom/fcuny-json.el b/emacs.d/custom/fcuny-json.el
new file mode 100644
index 0000000..126ed03
--- /dev/null
+++ b/emacs.d/custom/fcuny-json.el
@@ -0,0 +1,14 @@
+(require 'fcuny-common)
+
+(use-package json-mode
+  :after (flyspell flycheck)
+  :custom
+  (json-reformat:indent-width 2)
+  (js-indent-level 2)
+  :hook ((json-mode . flyspell-prog-mode)
+         (json-mode . flycheck-mode))
+  :init
+  (if (fcuny/check-work-machine-p)
+    (add-to-list 'auto-mode-alist '("\\.workflow$" . json-mode))))
+
+(provide 'fcuny-json)
diff --git a/emacs.d/custom/fcuny-lisp.el b/emacs.d/custom/fcuny-lisp.el
new file mode 100644
index 0000000..08d55a4
--- /dev/null
+++ b/emacs.d/custom/fcuny-lisp.el
@@ -0,0 +1,6 @@
+(use-package lisp-mode
+  :bind
+  (("C-c C-e" . eval-buffer)
+   ("C-c C-r" . eval-region)))
+
+(provide 'fcuny-lisp)
diff --git a/emacs.d/custom/fcuny-make.el b/emacs.d/custom/fcuny-make.el
new file mode 100644
index 0000000..a031c46
--- /dev/null
+++ b/emacs.d/custom/fcuny-make.el
@@ -0,0 +1,5 @@
+(use-package make-mode
+  :config
+  (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2))))
+
+(provide 'fcuny-make)
diff --git a/emacs.d/custom/fcuny-navigation.el b/emacs.d/custom/fcuny-navigation.el
new file mode 100644
index 0000000..8073a8c
--- /dev/null
+++ b/emacs.d/custom/fcuny-navigation.el
@@ -0,0 +1,67 @@
+(require 'fcuny-vars)
+
+(use-package ace-window
+  :ensure t
+  :bind (("C-x o" . ace-window)))
+
+(use-package ag
+  :ensure t
+  :bind (:map ag-mode-map
+              ("p" . compilation-previous-error)
+              ("n" . compilation-next-error)
+              ("N" . compilation-next-file)
+              ("P" . compilation-previous-file))
+  :custom
+  (ag-highlight-search t)
+  (ag-reuse-buffers t)
+  (ag-reuse-window t))
+
+(use-package bookmark
+  :custom
+  (bookmark-default-file (expand-file-name "bookmarks" fcuny-path-emacs-var))
+  (bookmark-save-flag 1))
+
+(use-package counsel
+  :ensure t
+  :init (counsel-mode 1) (ivy-mode 1)
+  :bind
+  (("M-x"     . counsel-M-x)
+   ("C-s"     . counsel-grep-or-swiper)
+   ("C-x C-f" . counsel-find-file)
+   ("C-x C-r" . counsel-recentf)
+   ("C-c f"   . counsel-git)
+   ("C-c s"   . counsel-git-grep)
+   ("C-c /"   . counsel-ag)
+   ("C-x r l" . counsel-bookmark))
+  :custom
+  (counsel-find-file-at-point t)
+  (ivy-use-virtual-buffers t)
+  (ivy-count-format "(%d/%d) ")
+  (ivy-height 10)
+  :config
+  (use-package swiper
+    :ensure t))
+
+(use-package dired
+  :defer t
+  :bind (("C-x C-d" . dired)
+         ("C-x C-j" . dired-jump))
+  :init
+  (setq-default dired-dwim-target t)
+  (setq-default dired-listing-switches "--group-directories-first -alh")
+  (setq dired-recursive-deletes 'always)
+  (setq dired-recursive-copies 'always)
+
+  (let ((gls (executable-find "/opt/twitter/bin/gls")))
+    (when gls (setq insert-directory-program gls))))
+
+(use-package ibuffer
+  :bind ("C-x C-b" . ibuffer))
+
+(use-package recentf
+  :config
+  (recentf-mode 1)
+  (setq recentf-max-saved-items 500
+        recentf-save-file (expand-file-name "var/recentf" user-emacs-directory)))
+
+(provide 'fcuny-navigation)
diff --git a/emacs.d/custom/fcuny-protobuf.el b/emacs.d/custom/fcuny-protobuf.el
new file mode 100644
index 0000000..c344684
--- /dev/null
+++ b/emacs.d/custom/fcuny-protobuf.el
@@ -0,0 +1,7 @@
+(use-package protobuf-mode
+  :after (flyspell flycheck)
+  :ensure t
+  :hook ((protobuf-mode . flyspell-prog-mode)
+         (protobuf-mode . flycheck-mode)))
+
+(provide 'fcuny-protobuf)
diff --git a/emacs.d/custom/fcuny-puppet.el b/emacs.d/custom/fcuny-puppet.el
new file mode 100644
index 0000000..5d4a44e
--- /dev/null
+++ b/emacs.d/custom/fcuny-puppet.el
@@ -0,0 +1,6 @@
+(use-package puppet-mode
+  :ensure t
+  :bind (:map puppet-mode-map
+              ("C-c |" . puppet-align-block)))
+
+(provide 'fcuny-puppet)
diff --git a/emacs.d/custom/fcuny-python.el b/emacs.d/custom/fcuny-python.el
new file mode 100644
index 0000000..a12c477
--- /dev/null
+++ b/emacs.d/custom/fcuny-python.el
@@ -0,0 +1,8 @@
+(use-package python
+  :mode (("\\.py$"   . python-mode)
+         ("BUILD\\'" . python-mode))
+  :commands python-mode
+  :hook ((python-mode . eldoc-mode))
+  :custom (python-indent-offset 2))
+
+(provide 'fcuny-python)
diff --git a/emacs.d/custom/fcuny-settings.el b/emacs.d/custom/fcuny-settings.el
new file mode 100644
index 0000000..4bdb447
--- /dev/null
+++ b/emacs.d/custom/fcuny-settings.el
@@ -0,0 +1,36 @@
+(require 'fcuny-vars)
+
+;; set utf-8 as the default encoding
+(prefer-coding-system 'utf-8-unix)
+(set-terminal-coding-system 'utf-8)
+(set-keyboard-coding-system 'utf-8)
+
+;; alias yes-or-no to y-or-n
+(fset 'yes-or-no-p 'y-or-n-p)
+
+(setq auto-save-default nil)                     ;; don't auto save files
+(setq auto-save-list-file-prefix nil)            ;; no backups
+(setq create-lockfiles nil)                      ;; don't use a lock file
+(setq custom-file fcuny/custom-settings)         ;; where to save custom settings
+(setq make-backup-files nil)                     ;; really no backups
+(setq minibuffer-message-timeout 0.5)            ;; How long to display an echo-area message
+(setq next-screen-context-lines 5)               ;; scroll 5 lines at a time
+(setq require-final-newline t)                   ;; ensure newline exists at the end of the file
+(setq ring-bell-function 'ignore)                ;; really no bell
+(setq tab-always-indent 'complete)               ;; when using TAB, always indent
+(setq visible-bell nil)                          ;; no bell
+(setq column-number-mode t)                      ;; show column number in the mode line
+(setq-default indent-tabs-mode nil)              ;; turn off tab indentation
+(setq-default cursor-type 'hbar)                 ;; cursor is a horizontal bar
+(setq vc-handled-backends nil)                   ;; don't use the VC backend, it's too slow with source
+(setq-default delete-by-moving-to-trash t)       ;; delete files by moving them to the trash
+(setq initial-scratch-message "")                ;; empty scratch buffer
+
+(custom-set-variables
+ '(use-file-dialog nil)
+ '(use-dialog-box nil)
+ '(inhibit-startup-screen t)
+ '(inhibit-startup-message t)
+ '(inhibit-startup-echo-area-message t))
+
+(provide 'fcuny-settings)
diff --git a/emacs.d/custom/fcuny-shell.el b/emacs.d/custom/fcuny-shell.el
new file mode 100644
index 0000000..5d41f92
--- /dev/null
+++ b/emacs.d/custom/fcuny-shell.el
@@ -0,0 +1,8 @@
+(use-package sh-script
+  :mode ("bashrc" . sh-mode)
+  :hook (after-save . executable-make-buffer-file-executable-if-script-p)
+  :config
+  (setq-default sh-indentation 2
+                sh-basic-offset 2))
+
+(provide 'fcuny-shell)
diff --git a/emacs.d/custom/fcuny-text.el b/emacs.d/custom/fcuny-text.el
new file mode 100644
index 0000000..37a1338
--- /dev/null
+++ b/emacs.d/custom/fcuny-text.el
@@ -0,0 +1,25 @@
+(use-package flyspell
+  :hook ((text-mode . flyspell-mode)
+         (prog-mode . flyspell-prog-mode))
+  :config
+  (setq ispell-dictionary "en_US")
+
+  (when (executable-find "aspell")
+    (setq ispell-program-name "aspell"))
+
+  (use-package flyspell-correct
+    :after (flyspell)
+    :commands (flyspell-correct-word-generic
+               flyspell-correct-previous-word-generic)
+    :bind (:map flyspell-mode-map
+                ("C-;" . flyspell-correct-previous-word-generic))))
+
+(use-package markdown-mode
+  :ensure t
+  :after (flyspell)
+  :commands (markdown-mode gfm-mode)
+  :mode (("README\\.md\\'" . gfm-mode)
+         ("\\.md\\'"       . gfm-mode)
+         ("\\.markdown\\'" . gfm-mode)))
+
+(provide 'fcuny-text)
diff --git a/emacs.d/custom/fcuny-ui.el b/emacs.d/custom/fcuny-ui.el
new file mode 100644
index 0000000..54034f8
--- /dev/null
+++ b/emacs.d/custom/fcuny-ui.el
@@ -0,0 +1,37 @@
+(use-package fringe
+  :custom
+  (left-fringe-width 10)
+  (right-fringe-width 10))
+
+(use-package scroll-bar
+  :config
+  (scroll-bar-mode -1))
+
+(use-package tool-bar
+  :config
+  (tool-bar-mode -1))
+
+(use-package frame
+  :bind (("C-c C-m" . toggle-frame-fullscreen))
+  :config
+  (blink-cursor-mode -1)
+  (setq frame-title-format "%b")
+  (set-face-attribute 'default nil :height 160 :weight 'normal :width 'normal :font "Source Code Pro")
+  (when (memq window-system '(mac ns))
+    (setq ns-use-native-fullscreen nil)
+    (setq mac-allow-anti-aliasing t)))
+
+(use-package hl-line
+  :config
+  (set-face-background 'hl-line "#E0EBF5")
+  (global-hl-line-mode t))
+
+(use-package uniquify
+  :defer 5
+  :config
+  (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
+  (setq uniquify-buffer-name-style 'forward)
+  (setq uniquify-separator "/"))
+
+(provide 'fcuny-ui)
+
diff --git a/emacs.d/custom/fcuny-vars.el b/emacs.d/custom/fcuny-vars.el
new file mode 100644
index 0000000..d4ff49f
--- /dev/null
+++ b/emacs.d/custom/fcuny-vars.el
@@ -0,0 +1,10 @@
+(defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory)
+  "Path to some files for Emacs.")
+
+(defvar fcuny/custom-settings (expand-file-name "emacs-custom.el" fcuny-path-emacs-var)
+  "Path to emacs custom variables.")
+
+(defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var)
+  "Path to elpa's local files.")
+
+(provide 'fcuny-vars)
diff --git a/emacs.d/custom/fcuny-yaml.el b/emacs.d/custom/fcuny-yaml.el
new file mode 100644
index 0000000..b84c041
--- /dev/null
+++ b/emacs.d/custom/fcuny-yaml.el
@@ -0,0 +1,4 @@
+(use-package yaml-mode
+  :ensure t)
+
+(provide 'fcuny-yaml)
diff --git a/emacs.d/init.el b/emacs.d/init.el
index c0c2d60..4afc820 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -3,11 +3,10 @@
 
 (setq package-archives '(("melpa" . "https://melpa.org/packages/")))
 
-(defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory)
-  "Path to some files for Emacs.")
+;; and now we load custom configurations
+(add-to-list 'load-path (expand-file-name "custom" user-emacs-directory))
 
-(defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var)
-  "Path to elpa's local files.")
+(require 'fcuny-vars)
 
 ;; where to store the packages
 (setq package-user-dir fcuny-path-emacs-elpa)
@@ -22,329 +21,26 @@
 
 (require 'use-package)
 
-(defvar fcuny/bookmarks-dir (expand-file-name "bookmarks" fcuny-path-emacs-var)
-  "Path to save the bookmarks")
+(require 'fcuny-settings)
+(require 'fcuny-ui)
+(require 'fcuny-hygiene)
+(require 'fcuny-common)
+(require 'fcuny-navigation)
+(require 'fcuny-edit)
+(require 'fcuny-text)
+(require 'fcuny-git)
+
+(require 'fcuny-flycheck)
+
+(require 'fcuny-docker)
+(require 'fcuny-json)
+(require 'fcuny-protobuf)
+(require 'fcuny-puppet)
+(require 'fcuny-yaml)
+
+(require 'fcuny-go)
+(require 'fcuny-lisp)
+(require 'fcuny-make)
+(require 'fcuny-python)
+(require 'fcuny-shell)
 
-(defvar fcuny/custom-settings (expand-file-name "emacs-custom.el" fcuny-path-emacs-var)
-  "Path to emacs custom variables.")
-
-(defun fcuny/rename-this-buffer-and-file ()
-  "Renames current buffer and file it is visiting."
-  (interactive)
-  (let ((name (buffer-name))
-        (filename (buffer-file-name))
-        (read-file-name-function 'read-file-name-default))
-    (if (not (and filename (file-exists-p filename)))
-        (error "Buffer '%s' is not visiting a file!" name)
-      (let ((new-name (read-file-name "New name: " filename)))
-        (cond ((get-buffer new-name)
-               (error "A buffer named '%s' already exists!" new-name))
-              (t
-               (rename-file filename new-name 1)
-               (rename-buffer new-name)
-               (set-visited-file-name new-name)
-               (set-buffer-modified-p nil)
-               (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
-
-(defun fcuny/check-work-machine-p ()
-  "Returns t if this is a work machine"
-  (string-match "tw-mbp.*" (system-name)))
-
-(defun fcuny/remove-mysql-columns ()
-  "Removes | from text. This is useful when I want to drop the column separator from some text coming from a mysql query."
-  (interactive)
-  (if (region-active-p)
-      (replace-regexp "\s?|\s?" "" nil (region-beginning) (region-end))
-    (replace-regexp "\s?|\s?" "")))
-
-(defun fcuny/copy-whole-buffer ()
-  "Selects the buffer and copy it."
-  (interactive)
-  (save-excursion
-    (mark-whole-buffer)
-    (copy-region-as-kill 1 (buffer-size))))
-
-;; set utf-8 as the default encoding
-(prefer-coding-system 'utf-8-unix)
-(set-terminal-coding-system 'utf-8)
-(set-keyboard-coding-system 'utf-8)
-
-;; alias yes-or-no to y-or-n
-(fset 'yes-or-no-p 'y-or-n-p)
-
-(setq auto-save-default nil)                     ;; don't auto save files
-(setq auto-save-list-file-prefix nil)            ;; no backups
-(setq create-lockfiles nil)                      ;; don't use a lock file
-(setq custom-file fcuny/custom-settings)         ;; where to save custom settings
-(setq make-backup-files nil)                     ;; really no backups
-(setq minibuffer-message-timeout 0.5)            ;; How long to display an echo-area message
-(setq next-screen-context-lines 5)               ;; scroll 5 lines at a time
-(setq require-final-newline t)                   ;; ensure newline exists at the end of the file
-(setq ring-bell-function 'ignore)                ;; really no bell
-(setq tab-always-indent 'complete)               ;; when using TAB, always indent
-(setq visible-bell nil)                          ;; no bell
-(setq column-number-mode t)                      ;; show column number in the mode line
-(setq-default indent-tabs-mode nil)              ;; turn off tab indentation
-(setq-default cursor-type 'hbar)                 ;; cursor is a horizontal bar
-(setq bookmark-default-file fcuny/bookmarks-dir) ;; where to save bookmarks
-(setq bookmark-save-flag 1)                      ;; save bookmarks when emacs qui
-(setq vc-handled-backends nil)                   ;; don't use the VC backend, it's too slow with source
-(setq-default delete-by-moving-to-trash t)       ;; delete files by moving them to the trash
-(setq initial-scratch-message "")                ;; empty scratch buffer
-
-(custom-set-variables
- '(tool-bar-mode nil)
- '(scroll-bar-mode nil)
- '(use-file-dialog nil)
- '(use-dialog-box nil)
- '(blink-cursor-mode nil)
- '(inhibit-startup-screen t)
- '(inhibit-startup-message t)
- '(inhibit-startup-echo-area-message t))
-
-(use-package frame
-  :bind (("C-c C-m" . toggle-frame-fullscreen))
-  :config
-  (progn
-    (defun fcuny/setup-frame(&optional frame)
-      (fringe-mode '(10 . 10))
-      (setq-default frame-title-format "%b")
-      (set-face-attribute 'default nil :height 160 :weight 'normal :width 'normal :font "Source Code Pro")
-      (when (eq system-type 'darwin)
-        (setq ns-use-native-fullscreen nil)
-        (setq mac-allow-anti-aliasing t)))
-  (fcuny/setup-frame)))
-
-(use-package general
-  :config
-  (general-define-key
-   "M-j" 'join-line))
-
-;;; emacs hygiene
-
-(use-package midnight
-  :config
-  (midnight-mode t))
-
-(use-package server
-  :hook (after-init . server-start))
-
-(use-package exec-path-from-shell
-  :ensure t
-  :if (memq window-system '(mac ns))
-  :config
-  (exec-path-from-shell-initialize))
-
-;;; general editing
-
-(use-package ace-window
-  :ensure t
-  :bind (("C-x o" . ace-window)))
-
-(use-package recentf
-  :config
-  (recentf-mode 1)
-  (setq recentf-max-saved-items 500
-        recentf-save-file (expand-file-name "var/recentf" user-emacs-directory)))
-
-(use-package autorevert
-  :config
-  (setq global-auto-revert-non-file-buffers t)
-  (setq auto-revert-verbose nil)
-  (global-auto-revert-mode t))
-
-(use-package hl-line
-  :config
-  (set-face-background 'hl-line "#E0EBF5")
-  (global-hl-line-mode t))
-
-(use-package uniquify
-  :defer 5
-  :config
-  (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
-  (setq uniquify-buffer-name-style 'forward)
-  (setq uniquify-separator "/"))
-
-;;; files navigation
-
-(use-package ag
-  :ensure t
-  :bind (:map ag-mode-map
-              ("p" . compilation-previous-error)
-              ("n" . compilation-next-error)
-              ("N" . compilation-next-file)
-              ("P" . compilation-previous-file))
-  :custom
-  (ag-highlight-search t)
-  (ag-reuse-buffers t)
-  (ag-reuse-window t))
-
-(use-package dired
-  :defer t
-  :bind (("C-x C-d" . dired)
-         ("C-x C-j" . dired-jump))
-  :init
-  (setq-default dired-dwim-target t)
-  (setq-default dired-listing-switches "--group-directories-first -alh")
-  (setq dired-recursive-deletes 'always)
-  (setq dired-recursive-copies 'always)
-
-  (let ((gls (executable-find "/opt/twitter/bin/gls")))
-    (when gls (setq insert-directory-program gls))))
-
-(use-package ibuffer
-  :bind ("C-x C-b" . ibuffer))
-
-;;; general text editing
-
-(use-package flyspell
-  :hook ((text-mode . flyspell-mode)
-         (prog-mode . flyspell-prog-mode))
-  :config
-  (setq ispell-dictionary "en_US")
-
-  (when (executable-find "aspell")
-    (setq ispell-program-name "aspell"
-          ispell-list-command "--list"))
-
-  (use-package flyspell-correct
-    :after (flyspell)
-    :commands (flyspell-correct-word-generic
-               flyspell-correct-previous-word-generic)
-    :bind (:map flyspell-mode-map
-                ("C-;" . flyspell-correct-previous-word-generic))))
-
-(use-package whitespace
-  :custom
-  (whitespace-style '(face trailing))
-  (show-trailing-whitespace t)
-  :hook (whitespace-mode))
-
-(use-package electric-pair-mode
-  :commands electric-pair-mode
-  :init (add-hook 'prog-mode-hook 'electric-pair-mode))
-
-(use-package paren
-  :ensure t
-  :custom
-  (show-paren-delay 0)
-  :config
-  (show-paren-mode 1))
-
-;;; text formats
-
-(use-package markdown-mode
-  :ensure t
-  :after (flyspell)
-  :commands (markdown-mode gfm-mode)
-  :mode (("README\\.md\\'" . gfm-mode)
-         ("\\.md\\'"       . gfm-mode)
-         ("\\.markdown\\'" . gfm-mode)))
-
-;;; source control
-
-(use-package magit
-  :ensure t
-  :after (flyspell)
-  :hook ((magit-mode . hl-line-mode))
-  :bind (("C-x g s" . magit-status))
-  :config
-  (setq git-commit-summary-max-length 50)
-  (setq git-commit-fill-column 72)
-  (setq git-commit-turn-on-auto-fill t))
-
-;;; prog mode
-
-(use-package flycheck
-  :ensure t
-  :custom
-  (flycheck-idle-change-delay 2))
-
-(use-package lisp-mode
-  :bind
-  (("C-c C-e" . eval-buffer)
-   ("C-c C-r" . eval-region)))
-
-(use-package make-mode
-  :config
-  (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2))))
-
-(use-package go-mode
-  :ensure t
-  :after (exec-path-from-shell)
-  :hook (go-mode . fcuny/go-mode-setup)
-  :init
-  (defun fcuny/go-mode-setup ()
-    (setq tab-width 4)
-    (add-hook 'before-save-hook 'gofmt-before-save))
-  :config
-  (when (memq window-system '(mac ns))
-    (exec-path-from-shell-copy-env "GOPATH")))
-
-(use-package python
-  :mode (("\\.py$"   . python-mode)
-         ("BUILD\\'" . python-mode))
-  :commands python-mode
-  :custom (python-indent-offset 2))
-
-(use-package sh-script
-  :mode ("bashrc" . sh-mode)
-  :hook (after-save . executable-make-buffer-file-executable-if-script-p)
-  :config
-  (setq-default sh-indentation 2
-                sh-basic-offset 2))
-
-;;; configurations
-
-(use-package dockerfile-mode
-  :ensure t
-  :mode "Dockerfile[a-zA-Z.-]*\\'")
-
-(use-package gitconfig-mode
-  :ensure t
-  :defer 5)
-
-(use-package puppet-mode
-  :ensure t
-  :bind (:map puppet-mode-map
-              ("C-c |" . puppet-align-block)))
-
-(use-package yaml-mode
-  :ensure t)
-
-(use-package json-mode
-  :after (flyspell flycheck)
-  :custom
-  (json-reformat:indent-width 2)
-  (js-indent-level 2)
-  :hook ((json-mode . flyspell-prog-mode)
-         (json-mode . flycheck-mode))
-  :init
-  (if (fcuny/check-work-machine-p)
-    (add-to-list 'auto-mode-alist '("\\.workflow$" . json-mode))))
-
-(use-package protobuf-mode
-  :after (flyspell flycheck)
-  :ensure t
-  :hook ((protobuf-mode . flyspell-prog-mode)
-         (protobuf-mode . flycheck-mode)))
-
-(use-package counsel
-  :ensure t
-  :init (counsel-mode 1) (ivy-mode 1)
-  :bind
-  (("M-x"     . counsel-M-x)
-   ("C-s"     . counsel-grep-or-swiper)
-   ("C-x C-f" . counsel-find-file)
-   ("C-x C-r" . counsel-recentf)
-   ("C-c f"   . counsel-git)
-   ("C-c s"   . counsel-git-grep)
-   ("C-c /"   . counsel-ag)
-   ("C-x r l" . counsel-bookmark))
-  :custom
-  (counsel-find-file-at-point t)
-  (ivy-use-virtual-buffers t)
-  (ivy-count-format "(%d/%d) ")
-  (ivy-height 10)
-  :config
-  (use-package swiper :ensure t))