Function: csv-guess-set-separator
csv-guess-set-separator is an interactive and natively compiled
function defined in csv-mode.el.
Signature
(csv-guess-set-separator)
Documentation
Guess and set the CSV separator of the current buffer.
Add it to the mode hook to have CSV mode guess and set the separator automatically when visiting a buffer:
(add-hook 'csv-mode-hook 'csv-guess-set-separator)
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/3gmjnyw9n226b7k7jamikx980vf8267p-emacs-packages-deps/share/emacs/site-lisp/elpa/csv-mode-1.27/csv-mode.el
(defun csv-guess-set-separator ()
"Guess and set the CSV separator of the current buffer.
Add it to the mode hook to have CSV mode guess and set the
separator automatically when visiting a buffer:
(add-hook \\='csv-mode-hook \\='csv-guess-set-separator)"
(interactive)
(let ((sep (csv-guess-separator
(buffer-substring-no-properties
(point-min)
;; We're probably only going to look at the first 2048
;; or so chars, but take more than we probably need to
;; minimize the chance of breaking the input in the
;; middle of a (long) row.
(min 8192 (point-max)))
2048)))
(when sep
(csv-set-separator sep))))