From e86d0101d54e0422d6c5b7d8ddb32162a84e859b Mon Sep 17 00:00:00 2001 From: sterni Date: Sat, 28 May 2022 00:23:50 +0200 Subject: [PATCH] feat(sterni/emacs): function to display texcount for current file Change-Id: Iae09dd79494d65e4025e1e34ab1d848ef2b9cd47 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5722 Tested-by: BuildkiteCI Autosubmit: sterni Reviewed-by: sterni --- users/sterni/emacs/init.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/users/sterni/emacs/init.el b/users/sterni/emacs/init.el index fd4077172..0d3f9037f 100644 --- a/users/sterni/emacs/init.el +++ b/users/sterni/emacs/init.el @@ -120,6 +120,19 @@ "/.config/emacs-custom/pa-jira.el"))) (when (file-exists-p jira-config) (load jira-config)))))) +;; latex + +(defun latex-word-count () + "Calls texcount on the file the current buffer points to and displays the result." + (interactive) + (save-buffer) + (let* ((file (buffer-file-name)) ; needs to happen outside with-current-buffer + (word-count + (with-output-to-string + (with-current-buffer standard-output + (call-process "texcount" nil t nil "-brief" "-utf8" file))))) + (message (string-trim-right word-count)))) + ;; ediff ; doesn't create new window for ediff controls which I always open accidentally (setq ediff-window-setup-function 'ediff-setup-windows-plain)