summaryrefslogtreecommitdiff
path: root/modules/custom-functions.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-08-30 12:13:52 -0500
committerCraig Jennings <c@cjennings.net>2025-08-30 12:13:52 -0500
commit088e2b3f14f0ea02038e20dccbb62e05d4eec9b2 (patch)
treec2b9654f45741553be4c8b644d6c9f5a43f25b35 /modules/custom-functions.el
parent6be403ded18185bd26af38a9db734a970ca61537 (diff)
downloaddotemacs-088e2b3f14f0ea02038e20dccbb62e05d4eec9b2.tar.gz
dotemacs-088e2b3f14f0ea02038e20dccbb62e05d4eec9b2.zip
email, ai, and miscellaneous
refactor setup-email script - Enable "set -euo pipefail" for safer execution - Quote all variable references in test conditions - Update script header with usage notes and email setup steps email and org-msg changes - Configure org-msg with inline CSS, greeting, images, citations, and signature - Enable org-msg-mode in all mu4e compose buffers - Advise mu4e-compose-reply and mu4e-compose-wide-reply to use org-msg-edit-mode - Move no-auto-fill hook into mu4e-compose-mode-hook - Disable mu4e-compose-format-flowed and set mu4e-html2text-command - Update gnus-blocked-images comment and remove default signature-file setting - remove org-contact configurations ai changes - historian directive added - added all new directives to menu - changed default directive to default-directive! misc changes - org complains when tab-widths aren't at 8 - refactor and improve delete blank lines region or buffer - change name of add-header function to be more specific - updated tasks - updated abbrevs - documentation for local-arch-wiki-search
Diffstat (limited to 'modules/custom-functions.el')
-rw-r--r--modules/custom-functions.el36
1 files changed, 26 insertions, 10 deletions
diff --git a/modules/custom-functions.el b/modules/custom-functions.el
index 710623fe..16b68c51 100644
--- a/modules/custom-functions.el
+++ b/modules/custom-functions.el
@@ -435,16 +435,31 @@ and all articles are considered minor words."
(while (search-forward "" nil t)
(replace-match "" nil t))))
-;; ----------------------------- Clear Blank Lines -----------------------------
-
-(defun cj/clear-blank-lines (beginning end)
- "Remove blank lines in the region or the buffer if no region is selected.
-BEGINNING and END describe the selected region."
- (interactive "r")
+;; -------------------- Remove Blank Lines Region Or Buffer --------------------
+;; removes lines contiaining whitespace from region or buffer.
+
+(defun cj/delete-blank-lines-region-or-buffer (start end)
+ "Delete all blank lines in the region between START and END.
+Blank lines are lines that contain only whitespace (spaces or tabs).
+If called interactively with an active region, operate on that region.
+If no active region, prompt user before operating on the whole buffer.
+Otherwise signal a user-error and do nothing. The point is restored
+to its original position after deletion."
+ (interactive
+ (if (use-region-p)
+ ;; grab its boundaries if there's a region
+ (list (region-beginning) (region-end))
+ ;; or ask if user intended operating on whole buffer
+ (if (yes-or-no-p "Delete blank lines in entire buffer? ")
+ (list (point-min) (point-max))
+ (user-error "Aborted"))))
(save-excursion
- (goto-char beginning)
- (while (re-search-forward "^[ \t]*\n" end t)
- (replace-match ""))))
+ (save-restriction
+ (widen)
+ ;; Regexp "^[[:space:]]*$" matches lines of zero or more spaces/tabs.
+ (flush-lines "^[[:space:]]*$" start end)))
+ ;; Return nil (Emacs conventions). Point is already restored.
+ nil)
;; ---------------------- Fixup Whitespace Line Or Region ----------------------
@@ -635,8 +650,9 @@ Uses `sortable-time-format' for the formatting the date/time."
(define-key map "A" 'cj/unarrayify)
;; de/duplicate lines
(define-key map "d" 'cj/duplicate-line-or-region)
- (define-key map "D" 'cj/remove-duplicate-lines-from-region-or-buffer)
+ (define-key map "D" 'cj/remove-duplicate-lines-from-region-or-buffer)
+ (define-key map "D" 'cj/remove-duplicate-lines-from-region-or-buffer)
(define-key map ")" #'cj/jump-to-matching-paren)
(define-key map "/" #'cj/replace-fraction-glyphs)
(define-key map "L" #'cj/clear-blank-lines)