From 03f4e6fb075c299e8dcad1784471a93ccdbc72fa Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Fri, 3 May 2019 08:58:47 -0400 Subject: [PATCH] Add word wrap commands --- lain/.emacs.d/config.org | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/lain/.emacs.d/config.org b/lain/.emacs.d/config.org index 2d8d7c6..116d080 100644 --- a/lain/.emacs.d/config.org +++ b/lain/.emacs.d/config.org @@ -749,39 +749,20 @@ Allows retrieving OpenWeatherMap forecasts in the minibuffer. (sunshine-show-icons t)) #+END_SRC * Programming -** Macros -A helper for defining programmatic emacs/evil macros -#+BEGIN_SRC emacs-lisp - (defun jf-replace-regexps-in-string (str regexps) - "Replace all pairs of (regex . replacement) defined by REGEXPS in STR." - (if (null regexps) - str - (jf-replace-regexps-in-string - (replace-regexp-in-string (caar regexps) (cdar regexps) str t) - (cdr regexps)))) - - (defun jf-kbd (str) - "Convert STR into a keyboard macro string by replacing terminal key sequences with GUI keycodes." - (let ((jf-kbd-regex '(("ESC" . "") - ("DEL" . "") - ("BS" . "") - ("RET" . "") - ("SPC" . "") - ("TAB" . "")))) - (jf-replace-regexps-in-string str jf-kbd-regex))) - - (defun jf-kbd-exec (str) - "Execute the key sequence defined by STR. Terminal based keys are expanded to their graphical counterparts." - (let ((minibuffer-message-timeout 0)) - (execute-kbd-macro (read-kbd-macro (jf-kbd str))))) - - (defmacro jf-kbd-defmacro (name &rest forms) - "Create an interactive function NAME with body FORMS, where the evaluation of each form is executed as a keyboard macro." - `(defun ,name () - (interactive) - ,@(mapcan (lambda (form) `((jf-kbd-exec ,form))) forms))) -#+END_SRC ** Formatting +*** Word Wrap +#+BEGIN_SRC emacs-lisp + (defun jf-word-wrap (column) + "Enable auto refill mode at COLUMN." + (interactive "nFill column: ") + (setq-local fill-column column) + (refill-mode)) + + (defun jf-nowrap () + "Disable auto refill mode." + (interactive) + (refill-mode)) +#+END_SRC *** Indentation Set some *sane* defaults #+BEGIN_SRC emacs-lisp