add org word count function for file(s)
This commit is contained in:
@@ -742,6 +742,36 @@ Suggest the URL title as a description for resource."
|
|||||||
(use-package org-tempo ;; expand <s to a src block, ...
|
(use-package org-tempo ;; expand <s to a src block, ...
|
||||||
:after (org))
|
:after (org))
|
||||||
|
|
||||||
|
(use-package org-wc
|
||||||
|
:defer t
|
||||||
|
:commands (org-word-count-aux my-org-word-count-file my-org-word-count-files)
|
||||||
|
:config
|
||||||
|
(defun my-org-word-count-file (FILE)
|
||||||
|
"Count words in FILE.
|
||||||
|
Example: (my-org-word-count-file \"/opt/emacs-conf/lisp/org-ref/org-ref.org\")"
|
||||||
|
(interactive "fTarget file: ") ; "f" prompts the user for a file path interactively
|
||||||
|
(save-excursion
|
||||||
|
(let ((buf (find-file-noselect FILE)))
|
||||||
|
(with-current-buffer buf
|
||||||
|
(let ((count (org-word-count-aux (point-min) (point-max))))
|
||||||
|
(if (called-interactively-p 'interactive)
|
||||||
|
(message "%i" count)
|
||||||
|
count))))))
|
||||||
|
(defun my-org-word-count-files (FILES)
|
||||||
|
"Count words in FILES.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
(my-org-word-count-files
|
||||||
|
(list \"/opt/emacs-conf/lisp/my/my-org-article.org\"
|
||||||
|
\"/opt/emacs-conf/lisp/org-ref/org-ref.org\"))
|
||||||
|
|
||||||
|
(my-org-word-count-files \"/opt/emacs-conf/lisp/org-ref/org-ref.org\")"
|
||||||
|
(unless (listp FILES)
|
||||||
|
(setq FILES (list FILES)))
|
||||||
|
(apply '+ (mapcar (lambda (file)
|
||||||
|
(my-org-word-count-file file))
|
||||||
|
FILES))))
|
||||||
|
|
||||||
(use-package ob-core
|
(use-package ob-core
|
||||||
;; :hook (org-babel-after-execute . org-redisplay-inline-images)
|
;; :hook (org-babel-after-execute . org-redisplay-inline-images)
|
||||||
:commands (by-backend svg-fname)
|
:commands (by-backend svg-fname)
|
||||||
|
|||||||
Reference in New Issue
Block a user