about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-05-27T22·23+0200
committerclbot <clbot@tvl.fyi>2022-05-27T23·24+0000
commite86d0101d54e0422d6c5b7d8ddb32162a84e859b (patch)
treeb58fe1e31e4df424c659445360a35e2b78fde129 /users
parent0d694afee4be922dab00808a4a55b77b3ec488af (diff)
feat(sterni/emacs): function to display texcount for current file r/4157
Change-Id: Iae09dd79494d65e4025e1e34ab1d848ef2b9cd47
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5722
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users')
-rw-r--r--users/sterni/emacs/init.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/sterni/emacs/init.el b/users/sterni/emacs/init.el
index fd4077172d73..0d3f9037f5fb 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)