diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2022-11-24 23:15:12 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2022-11-24 23:15:12 +0000 |
commit | 2fecc133700f277dd78f7a9200e388dc614acd28 (patch) | |
tree | 05aa0efec312526d2eb94aa35359b981dfb4d545 /lisp/mrl-functions.el | |
parent | 168b4baa9c96b599dec6c59a689d4dd7204df746 (diff) |
renamed mrl-functions
Diffstat (limited to 'lisp/mrl-functions.el')
-rw-r--r-- | lisp/mrl-functions.el | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lisp/mrl-functions.el b/lisp/mrl-functions.el new file mode 100644 index 0000000..3ba9eff --- /dev/null +++ b/lisp/mrl-functions.el @@ -0,0 +1,49 @@ +;; for markdown mode +(defun mrl/get-start-and-lines-in-region () + "Cumbersome newbie way to get start line and number +of lines in region." + (let (pos1 pos2) + (setq pos1 (region-beginning) + pos2 (region-end)) + (let ((line1 (line-number-at-pos pos1)) + (line2 (line-number-at-pos pos2))) + (list line1 (- line2 line1))))) + +(defun mrl/clear-check-region (start lines) + "Clears check marks given a start line and number +of lines to run through." + (setq count 0) + (while (> lines 0) + (save-excursion + (goto-line (+ start count)) + (beginning-of-line) + (forward-char 3) + (delete-char 1) + (insert-char ?\s)) + (next-line) + (setq count (+ count 1)) + (setq lines (- lines 1)))) + + +(defun mrl/clear-check-from-region () + "Interactive func to clear markdown checks from a region." + (interactive) + (save-excursion + (mrl/clear-check-region + (car (mrl/get-start-and-lines-in-region)) + (car (last (mrl/get-start-and-lines-in-region)))))) + +;; do this for a region next +(defun mrl/clear-check-single-line (&optional lines) + "Remove the check from LINES number of markdown checkbox lines." + (interactive "p") + (while (> lines 0) + (save-excursion + (beginning-of-line) + (forward-char 3) + (delete-char 1) + (insert-char ?\s)) + (next-line) + (setq lines (- lines 1)))) +(provide 'mrl-functions) +;;; mrl_functions ends here |