diff options
Diffstat (limited to 'modules/custom-whitespace.el')
| -rw-r--r-- | modules/custom-whitespace.el | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/modules/custom-whitespace.el b/modules/custom-whitespace.el index 0d4d1cc06..52cc4e54d 100644 --- a/modules/custom-whitespace.el +++ b/modules/custom-whitespace.el @@ -1,4 +1,4 @@ -;;; custom-whitespace.el --- -*- coding: utf-8; lexical-binding: t; -*- +;;; custom-whitespace.el --- Whitespace cleanup commands -*- coding: utf-8; lexical-binding: t; -*- ;;; Commentary: ;; @@ -12,19 +12,10 @@ ;; Runtime requires: keybindings. ;; Direct test load: yes (requires keybindings explicitly). ;; -;; This module provides whitespace manipulation operations for cleaning and transforming whitespace in text. - -;; Functions include: - -;; - removing leading and trailing whitespace -;; - collapsing multiple spaces to single spaces -;; - deleting blank lines -;; - converting whitespace to hyphens. - -;; All operations work on the current line, active region, or entire buffer depending on context. - -;; Bound to keymap prefix C-; w - +;; Whitespace cleanup under C-; w: trim line edges, collapse runs of spaces, +;; delete blank lines, enforce a single blank line, and hyphenate whitespace. +;; Commands choose region, buffer, or current line based on prefix/mark state. +;; ;;; Code: (require 'keybindings) ;; provides cj/custom-keymap @@ -237,5 +228,21 @@ Operate on the active region designated by START and END." "C-; w t" "untabify" "C-; w T" "tabify")) +;; --- align-regexp space enforcement + alignment/fill bindings --- +;; (formerly in custom-misc.el) +(defun cj/align-regexp-with-spaces (orig-fun &rest args) + "Call ORIG-FUN with ARGS while temporarily disabling tabs for alignment. +This advice ensures =align-regexp' uses spaces by binding =indent-tabs-mode' +to nil." + (let ((indent-tabs-mode nil)) + (apply orig-fun args))) + +;; avoid double advice stacking in case the file is reloaded +(advice-remove 'align-regexp #'cj/align-regexp-with-spaces) +(advice-add 'align-regexp :around #'cj/align-regexp-with-spaces) + +(cj/register-command "A" #'align-regexp "align regexp") +(cj/register-command "|" #'display-fill-column-indicator-mode "fill column") + (provide 'custom-whitespace) ;;; custom-whitespace.el ends here. |
