1
0
mirror of https://github.com/Foltik/dotfiles synced 2025-02-08 11:24:15 -05:00

Add word wrap commands

This commit is contained in:
Jack Foltz 2019-05-03 08:58:47 -04:00
parent 9633a901c7
commit 03f4e6fb07
Signed by: foltik
GPG Key ID: D1F0331758D1F29A

View File

@ -749,39 +749,20 @@ Allows retrieving OpenWeatherMap forecasts in the minibuffer.
(sunshine-show-icons t)) (sunshine-show-icons t))
#+END_SRC #+END_SRC
* Programming * 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" . "<escape>")
("DEL" . "<delete>")
("BS" . "<backspace>")
("RET" . "<return>")
("SPC" . "<SPC>")
("TAB" . "<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 ** 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 *** Indentation
Set some *sane* defaults Set some *sane* defaults
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp