2020-09-01 11:17:43 +02:00
|
|
|
;;; functions.el --- Helper functions -*- lexical-binding: t -*-
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 11:17:43 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; Package-Requires: ((emacs "24"))
|
2018-04-25 19:26:53 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
2019-10-09 13:13:56 +02:00
|
|
|
;; This file hopefully contains friendly APIs that making ELisp development more
|
|
|
|
;; enjoyable.
|
|
|
|
|
|
|
|
;; TODO: Break these out into separate modules.
|
2018-04-25 19:26:53 +02:00
|
|
|
|
|
|
|
;;; Code:
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun functions-evil-window-vsplit-right ()
|
2020-09-01 14:44:18 +02:00
|
|
|
"Split the window vertically and focus the right half."
|
2018-04-25 19:26:53 +02:00
|
|
|
(interactive)
|
|
|
|
(evil-window-vsplit)
|
|
|
|
(windmove-right))
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun functions-evil-window-split-down ()
|
2020-09-01 14:44:18 +02:00
|
|
|
"Split the window horizontal and focus the bottom half."
|
2018-04-25 19:26:53 +02:00
|
|
|
(interactive)
|
|
|
|
(evil-window-split)
|
|
|
|
(windmove-down))
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun functions-create-snippet ()
|
2020-09-01 14:44:18 +02:00
|
|
|
"Create a window split and then opens the Yasnippet editor."
|
2018-04-25 19:26:53 +02:00
|
|
|
(interactive)
|
|
|
|
(evil-window-vsplit)
|
|
|
|
(call-interactively #'yas-new-snippet))
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun functions-evil-replace-under-point ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Faster than typing %s//thing/g."
|
2018-04-25 19:26:53 +02:00
|
|
|
(interactive)
|
2020-09-01 00:28:47 +02:00
|
|
|
(let ((term (s-replace "/" "\\/" (symbol-to-string (symbol-at-point)))))
|
2019-10-09 13:13:56 +02:00
|
|
|
(save-excursion
|
|
|
|
(evil-ex (concat "%s/\\b" term "\\b/")))))
|
2018-04-25 19:26:53 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun functions-buffer-dirname ()
|
2018-05-29 22:23:24 +02:00
|
|
|
"Return the directory name of the current buffer as a string."
|
|
|
|
(->> buffer-file-name
|
|
|
|
f-dirname
|
|
|
|
f-filename))
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
(provide 'functions)
|
|
|
|
;;; functions.el ends here
|