Function: csv-unalign-fields
csv-unalign-fields is an interactive and natively compiled function
defined in csv-mode.el.
Signature
(csv-unalign-fields HARD BEG END)
Documentation
Undo soft alignment and optionally remove redundant white space.
Undo soft alignment introduced by csv-align-fields. If invoked with
an argument then also remove all spaces and tabs around separators.
Also make all invisible separators visible again.
Ignore blank and comment lines. When called non-interactively, remove
spaces and tabs if HARD non-nil; BEG and END specify region to unalign.
If there is no selected region, default to the whole buffer.
Key Bindings
csv-mode-map C-c C-u
Source Code
;; Defined in /nix/store/3gmjnyw9n226b7k7jamikx980vf8267p-emacs-packages-deps/share/emacs/site-lisp/elpa/csv-mode-1.27/csv-mode.el
(defun csv-unalign-fields (hard beg end)
"Undo soft alignment and optionally remove redundant white space.
Undo soft alignment introduced by `csv-align-fields'. If invoked with
an argument then also remove all spaces and tabs around separators.
Also make all invisible separators visible again.
Ignore blank and comment lines. When called non-interactively, remove
spaces and tabs if HARD non-nil; BEG and END specify region to unalign.
If there is no selected region, default to the whole buffer."
(interactive (cons current-prefix-arg
(if (use-region-p)
(list (region-beginning) (region-end))
(list (point-min) (point-max)))))
;; Remove any soft alignment:
(mapc #'csv--delete-overlay (overlays-in beg end))
(with-silent-modifications
(remove-list-of-text-properties beg end '(display invisible)))
(when hard
(barf-if-buffer-read-only)
;; Remove any white-space padding around separators:
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(while (not (eobp))
(or (csv-not-looking-at-record)
(while (not (eolp))
;; Delete horizontal white space forward:
;; (delete-horizontal-space)
;; This relies on left-to-right argument evaluation;
;; see info node (elisp) Function Forms.
(delete-region (point)
(+ (point) (skip-chars-forward " \t")))
(csv-end-of-field)
;; Delete horizontal white space backward:
;; (delete-horizontal-space t)
(delete-region (point)
(+ (point) (skip-chars-backward " \t")))
(or (eolp) (forward-char))))
(forward-line))))))