Closed librarianmage closed 2 years ago
Hi! Thanks for trying it out. Uhm, could you (require 'cl-lib)
and then try again? As far as I know incf
comes from there and moldable-emacs.el requires that library.
If that does not change anything, I will look into how to setup straight.el to give a try on my system.
I tried that but it didn't seem to change anything Here's the debug log when I call the stats mold:
Debugger entered--Lisp error: (void-function incf)
incf(0)
me-count-raw-word-list(("." "'" "." "'" "," "'" "," "." "." "," "," "." "." "'" "," "." "." "," "," "." "," "." "'" "," "'" "." "." "." "," "." "'" "," "." "\"" "," "\"" "\"" "." "\"" "\"" "." "\"" "'" "'" "\"" "\"" "\"" "." "." "\"" ...))
me-word-stats("#+TITLE: My Emacsen (Emacs Configuration)\n#+AUTHOR...")
(let ((list (me-word-stats contents)) (i 0) it it-index) (ignore it it-index) (while list (setq it (pop list) it-index i i (1+ i)) (when (> (length (car it)) 2) (push it result))))
(--each (me-word-stats contents) (when (> (length (car it)) 2) (push it result)))
(let (result) (--each (me-word-stats contents) (when (> (length (car it)) 2) (push it result))) (nreverse result))
(--filter (> (length (car it)) 2) (me-word-stats contents))
(let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties (point-min) (point-max))) (lines (count-lines-page)) (words (call-interactively 'count-words)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter (> (length (car it)) 2) (me-word-stats contents))) (word-analysis-stats (-concat (-take 3 word-analysis) (reverse (-take 3 (reverse word-analysis))))) (funs (when self (length (me-by-type 'function_definition self)))) (methods (when self (length (me-by-type 'method_declaration self)))) (ifs (when self (length (--filter (or (eq ... ...) (eq ... ...)) self)))) (classes (when self (length (--filter (or (eq ... ...) (eq ... ...)) self)))) (comments (when self (length (me-by-type 'comment self))))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert (format " %s | %s\n" (substring (concat (number-to-string ...) (s-repeat 5 " ")) 0 3) (car it)))) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert (format "#Functions: %s \n" funs)) (insert (format "#Methods: %s \n" methods)) (insert (format "#If-else: %s \n" ifs)) (insert (format "#Classes: %s \n" classes)) (insert (format "#Comments: %s \n" comments))) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* ((nodes-with-duplication (me-nodes-with-duplication self)) (texts-by-type (--map (cons ... ...) (--group-by ... self)))) (me-require 'tree-sitter-query) (me-insert-treesitter-follow-overlay nodes-with-duplication (lambda (node) (let (... ...) (format "%s: %s/%s\n" type ... ...))))))))
(progn (get-buffer-create buffername) (let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties (point-min) (point-max))) (lines (count-lines-page)) (words (call-interactively 'count-words)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter (> (length (car it)) 2) (me-word-stats contents))) (word-analysis-stats (-concat (-take 3 word-analysis) (reverse (-take 3 (reverse word-analysis))))) (funs (when self (length (me-by-type 'function_definition self)))) (methods (when self (length (me-by-type 'method_declaration self)))) (ifs (when self (length (--filter (or ... ...) self)))) (classes (when self (length (--filter (or ... ...) self)))) (comments (when self (length (me-by-type 'comment self))))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert (format " %s | %s\n" (substring (concat ... ...) 0 3) (car it)))) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert (format "#Functions: %s \n" funs)) (insert (format "#Methods: %s \n" methods)) (insert (format "#If-else: %s \n" ifs)) (insert (format "#Classes: %s \n" classes)) (insert (format "#Comments: %s \n" comments))) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* ((nodes-with-duplication (me-nodes-with-duplication self)) (texts-by-type (--map ... ...))) (me-require 'tree-sitter-query) (me-insert-treesitter-follow-overlay nodes-with-duplication (lambda (node) (let ... ...))))))) (ignore-errors (switch-to-buffer-other-window (get-buffer buffername))))
(cond ((equal '(:then) '(:given)) 't) ((equal '(:then) '(:then)) (progn (get-buffer-create buffername) (let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties (point-min) (point-max))) (lines (count-lines-page)) (words (call-interactively 'count-words)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter (> ... 2) (me-word-stats contents))) (word-analysis-stats (-concat (-take 3 word-analysis) (reverse ...))) (funs (when self (length ...))) (methods (when self (length ...))) (ifs (when self (length ...))) (classes (when self (length ...))) (comments (when self (length ...)))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert (format " %s | %s\n" ... ...))) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert (format "#Functions: %s \n" funs)) (insert (format "#Methods: %s \n" methods)) (insert (format "#If-else: %s \n" ifs)) (insert (format "#Classes: %s \n" classes)) (insert (format "#Comments: %s \n" comments))) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* (... ...) (me-require ...) (me-insert-treesitter-follow-overlay nodes-with-duplication ...))))) (ignore-errors (switch-to-buffer-other-window (get-buffer buffername))))) (t :then))
(pcase '(:then) ('(:given) 't) ('(:then) (progn (get-buffer-create buffername) (let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties (point-min) (point-max))) (lines (count-lines-page)) (words (call-interactively 'count-words)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter (> ... 2) (me-word-stats contents))) (word-analysis-stats (-concat (-take 3 word-analysis) (reverse ...))) (funs (when self (length ...))) (methods (when self (length ...))) (ifs (when self (length ...))) (classes (when self (length ...))) (comments (when self (length ...)))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert (format " %s | %s\n" ... ...))) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert (format "#Functions: %s \n" funs)) (insert (format "#Methods: %s \n" methods)) (insert (format "#If-else: %s \n" ifs)) (insert (format "#Classes: %s \n" classes)) (insert (format "#Comments: %s \n" comments))) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* (... ...) (me-require ...) (me-insert-treesitter-follow-overlay nodes-with-duplication ...))))) (ignore-errors (switch-to-buffer-other-window (get-buffer buffername))))) (_ :then))
(let* nil (pcase '(:then) ('(:given) 't) ('(:then) (progn (get-buffer-create buffername) (let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties ... ...)) (lines (count-lines-page)) (words (call-interactively ...)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter ... ...)) (word-analysis-stats (-concat ... ...)) (funs (when self ...)) (methods (when self ...)) (ifs (when self ...)) (classes (when self ...)) (comments (when self ...))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert ...)) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert ...) (insert ...) (insert ...) (insert ...) (insert ...)) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* ... ... ...)))) (ignore-errors (switch-to-buffer-other-window (get-buffer buffername))))) (_ :then)))
(let ((buffername (concat "*moldable-emacs-" (or nil "Stats") "*"))) (let* nil (pcase '(:then) ('(:given) 't) ('(:then) (progn (get-buffer-create buffername) (let* ((old-buffer ...) (buffer ...) (buffersize ...) (self ...) (contents ...) (lines ...) (words ...) (book-pages ...) (reading-time ...) (word-analysis ...) (word-analysis-stats ...) (funs ...) (methods ...) (ifs ...) (classes ...) (comments ...)) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert ...) (insert ...) (insert ...) (insert ...) (insert ...) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats ...) (insert "\n") (when funs ... ... ... ... ... ... ... ...) (insert "\n") (when self ... ... ...))) (ignore-errors (switch-to-buffer-other-window (get-buffer buffername))))) (_ :then))))
(progn (let ((buffername (concat "*moldable-emacs-" (or nil "Stats") "*"))) (let* nil (pcase '(:then) ('(:given) 't) ('(:then) (progn (get-buffer-create buffername) (let* (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (with-current-buffer buffername ... ... ... ... ... ... ... ... ... ... ... ... ... ...)) (ignore-errors (switch-to-buffer-other-window ...)))) (_ :then)))))
eval((progn (let ((buffername (concat "*moldable-emacs-" (or nil "Stats") "*"))) (let* nil (pcase '(:then) ('(:given) 't) ('(:then) (progn (get-buffer-create buffername) (let* ... ...) (ignore-errors ...))) (_ :then))))) t)
me-mold-run-then((:key "Stats" :docs "View some generic buffer stats like reading time a..." :given (:fn 't) :then (:fn (let* ((old-buffer (buffer-name)) (buffer (get-buffer-create "Statistics")) (buffersize (buffer-size)) (self (me-mold-treesitter-to-parse-tree)) (contents (buffer-substring-no-properties (point-min) (point-max))) (lines (count-lines-page)) (words (call-interactively 'count-words)) (book-pages (me-get-book-pages contents)) (reading-time (me-get-reading-time contents)) (word-analysis (--filter (> ... 2) (me-word-stats contents))) (word-analysis-stats (-concat (-take 3 word-analysis) (reverse ...))) (funs (when self (length ...))) (methods (when self (length ...))) (ifs (when self (length ...))) (classes (when self (length ...))) (comments (when self (length ...)))) (with-current-buffer buffername (erase-buffer) (org-mode) (insert "* Generic Stats\n\n") (insert (format "- Reading time: %s minutes \n" reading-time)) (insert (format "- %s\n" lines)) (insert (format "- %s\n" words)) (insert (format "- Average book pages for this text: %s\n\n" book-pages)) (insert (format "- Buffer size in KiloBytes: %s\n\n" buffersize)) (insert "- Up to three most and least used words:\n\n") (--each word-analysis-stats (insert (format " %s | %s\n" ... ...))) (insert "\n") (when funs (insert "* Programming Stats\n\n") (insert "\n") (insert "-- Code Stats --\n\n") (insert (format "#Functions: %s \n" funs)) (insert (format "#Methods: %s \n" methods)) (insert (format "#If-else: %s \n" ifs)) (insert (format "#Classes: %s \n" classes)) (insert (format "#Comments: %s \n" comments))) (insert "\n") (when self (insert "* Duplication Stats\n\n") (insert "-- Code Duplication By Token Type --\n\n") (let* (... ...) (me-require ...) (me-insert-treesitter-follow-overlay nodes-with-duplication ...)))))) :docs "You can extract information from the original buff..." :examples ((:name "Basic stats" :given (:type file :name "/tmp/test.txt" :mode text-mode :contents "This is a little test file. Test!\n") :then (:type buffer :name "Statistics" :mode org-mode :contents "* Generic Stats\n\n- Reading time: 0 minutes \n- Page..."))) :origin "/home/librarianmage/.config/emacs/straight/build/m..."))
me-mold()
funcall-interactively(me-mold)
call-interactively(me-mold nil nil)
command-execute(me-mold)
Figured it out! It was unrelated to straight.el. In https://github.com/ag91/moldable-emacs/blob/98365b8d62cc64799429b3e67345daa6bd12d01f/moldable-emacs.el#L1089-L1099 you use incf
but cl-lib
uses cl-incf
. The cl
package aliases incf
to that as well.
Ah good catch! I have just renamed it to cl-incf. It should work fine now, right?
On Sun 02 Jan 2022 at 19:37, Ray @.***> wrote:
Figured it out! It was unrelated to straight.el. In https://github.com/ag91/moldable-emacs/blob/98365b8d62cc64799429b3e67345daa6bd12d01f/moldable-emacs.el#L1089-L1099 you use
incf
butcl-lib
usescl-incf
. Thecl
package aliasesincf
to that as well.
Yup! All's good now ^_^
Hello! I use
straight.el
with itsuse-package
integration to install my packages. However, it seems to not be loading things properly: for instance, when I try theStats
mold, I getSymbol's function definition is void: incf
.Here's my configuration:
Thanks!