Skip to content

Instantly share code, notes, and snippets.

@craigstjean
Last active June 8, 2017 14:49
Show Gist options
  • Save craigstjean/b61c07ffa1916bdff04fe44f9d58dd16 to your computer and use it in GitHub Desktop.
Save craigstjean/b61c07ffa1916bdff04fe44f9d58dd16 to your computer and use it in GitHub Desktop.
My dotspacemacs/user-init ()
(defun untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(indent-buffer)
(untabify-buffer)
(delete-trailing-whitespace))
(defun cleanup-region (beg end)
"Remove tmux artifacts from region."
(interactive "r")
(dolist (re '("\\\\|\.*\n" "\W*|\.*"))
(replace-regexp re "" nil beg end)))
(global-set-key (kbd "C-x M-t") 'cleanup-region)
(global-set-key (kbd "C-c n") 'cleanup-buffer)
(defun save-some-buffers-silently ()
(interactive)
(save-some-buffers '!))
(global-set-key (kbd "C-x w") 'save-some-buffers-silently)
(defun check-expansion ()
(save-excursion
(if (looking-at "\\_>") t
(backward-char 1)
(if (looking-at "\\.") t
(backward-char 1)
(if (looking-at "->") t nil)))))
(defun do-yas-expand ()
(let ((yas/fallback-behavior 'return-nil))
(yas/expand)))
(defun tab-indent-or-complete ()
(interactive)
(if (minibufferp)
(minibuffer-complete)
(if (or (not yas/minor-mode)
(null (do-yas-expand)))
(if (check-expansion)
(company-complete-common)
(indent-for-tab-command)))))
(global-set-key [tab] 'tab-indent-or-complete)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment