Add modules/tools/{electric-indent,rotate-text}

This commit is contained in:
Henrik Lissner 2017-02-20 20:42:37 -05:00
parent cb92f96739
commit d18a39924d
6 changed files with 68 additions and 6 deletions

View File

@ -77,6 +77,9 @@
nil))
(add-hook 'kill-buffer-query-functions 'doom|dont-kill-scratch-buffer)
;; enabled by default in Emacs 25+. No thanks.
(electric-indent-mode -1)
;;
;; Core Plugins
@ -167,11 +170,6 @@
(@def-package pcre2el :commands rxt-quote-pcre)
(@def-package rotate-text
:commands (rotate-text rotate-text-backward)
:config
(push '("true" "false") rotate-text-words))
(@def-package smart-forward
:commands (smart-up smart-down smart-backward smart-forward))

View File

@ -33,7 +33,6 @@
(@package imenu-anywhere)
(@package imenu-list)
(@package pcre2el)
(@package rotate-text :recipe (:fetcher github :repo "debug-ito/rotate-text.el"))
(@package smart-forward)
(@package swiper)
(@package wgrep)

View File

@ -57,10 +57,12 @@
hl-todo ; highlight TODO/FIXME/NOTE tags
:tools
electric-indent ; smarter, keyword-based electric-indent
eshell ; a consistent, cross-platform shell (WIP)
;; TODO dash ; interacting with dash.app
dired ; making dired pretty [functional]
restclient ; A REST REPL
rotate-text ; cycle region at point between text candidates
tmux ; an API for interacting with tmux
upload ; map local to remote projects via ssh/ftp

View File

@ -0,0 +1,36 @@
;;; tools/electric-indent/config.el
;; Smarter, keyword-based electric-indent
(defvar doom-electric-indent-p nil
"TODO")
(defvar-local doom-electric-indent-words '()
"TODO")
(setq electric-indent-chars '(?\n ?\^?))
(push (lambda (c)
(when (and (eolp) doom-electric-indent-words)
(save-excursion
(backward-word)
(looking-at-p
(concat "\\<" (regexp-opt doom-electric-indent-words))))))
electric-indent-functions)
(@def-setting :electric (modes &rest plist)
"Declare :words (list of strings) or :chars (lists of chars) in MODES that
trigger electric indentation."
(declare (indent 1))
(let ((modes (if (listp modes) modes (list modes)))
(chars (doom-mplist-get rest :chars))
(words (doom-mplist-get rest :words)))
(when (or chars words)
(let ((fn-name (intern (format "doom--electric-%s" (s-join "-" (mapcar 'symbol-name modes))))))
`(progn
(defun ,fn-name ()
(electric-indent-local-mode +1)
,(if chars `(setq electric-indent-chars ',chars))
,(if words `(setq doom-electric-indent-words ',words)))
(@add-hook ,modes ',fn-name))))))

View File

@ -0,0 +1,23 @@
;;; tools/rotate-text/config.el
(@def-package rotate-text
:commands (rotate-text rotate-text-backward)
:config
(push '("true" "false") rotate-text-words))
(@def-setting :rotate (mode &rest plist)
"Declare :symbols, :words or :patterns that `rotate-text' will cycle through."
(declare (indent 1))
(let ((modes (if (listp modes) modes (list modes)))
(symbols (plist-get plist :symbols))
(words (plist-get plist :words))
(patterns (plist-get plist :patterns)))
(when (or symbols words patterns)
(let ((fn-name (intern (format "doom--rotate-%s" (s-join "-" (mapcar 'symbol-name modes))))))
`(@after rotate-text
(defun ,fn-name ()
,(if symbols `(setq-local rotate-text-local-symbols ',symbols))
,(if words `(setq-local rotate-text-local-words ',words))
,(if patterns `(setq-local rotate-text-local-patterns ',patterns)))
(@add-hook ,modes ',fn-name))))))

View File

@ -0,0 +1,4 @@
;; -*- no-byte-compile: t; -*-
;;; tools/rotate-text/packages.el
(@package rotate-text :recipe (:fetcher github :repo "debug-ito/rotate-text.el"))