Skip to content

Instantly share code, notes, and snippets.

@mokrates
Created November 9, 2023 21:42
Show Gist options
  • Save mokrates/a4ea7a52efa12ba1ebfd5bf81e789968 to your computer and use it in GitHub Desktop.
Save mokrates/a4ea7a52efa12ba1ebfd5bf81e789968 to your computer and use it in GitHub Desktop.
(defun region-length-kill (pref beg end)
"counts the length/chars in the region.
Prefix argument counts newlines twice for DOS"
(interactive "P\nr")
(let* ((reg-len (- end beg))
(reg-len-dos? (if pref (+ (count-matches "\n" beg end)
reg-len)
reg-len)))
(message (format "Region length: %s" reg-len-dos?))
(kill-new (format "%s" reg-len-dos?))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment