blob: aded3b6afd3856020599a7f621521cf686a0102f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
;;; org-agenda-config-debug.el --- Debug functions for org-agenda-config -*- lexical-binding: t; coding: utf-8; -*-
;; author: Craig Jennings <c@cjennings.net>
;;
;;; Commentary:
;;
;; This file contains debug functions for org-agenda-config.el.
;; It is only loaded when cj/debug-modules includes 'org-agenda or is t.
;;
;; Enable with: (setq cj/debug-modules '(org-agenda))
;; or: (setq cj/debug-modules t)
;;
;; Available debug functions:
;; - cj/org-agenda-debug-dump-files - Show all org-agenda-files with status
;; - cj/org-agenda-debug-rebuild-timing - Measure rebuild performance
;;
;;; Code:
(require 'user-constants)
;; ---------------------------- Helper Functions -------------------------------
(defun cj/log-silently (format-string &rest args)
"Append formatted message to *Messages* buffer without echoing.
FORMAT-STRING and ARGS are passed to `format'.
This is a local copy of the pattern from system-utils.el."
(let ((inhibit-read-only t))
(with-current-buffer (get-buffer-create "*Messages*")
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert (apply #'format format-string args))
(unless (bolp) (insert "\n")))))
;; ---------------------------- Debug Functions --------------------------------
;;;###autoload
(defun cj/org-agenda-debug-dump-files ()
"Dump all org-agenda-files to *Messages* buffer with status.
Shows which files exist, which are missing, and their sizes."
(interactive)
(cj/log-silently "=== Org Agenda Debug: Files ===")
(cj/log-silently "Total files: %d" (length org-agenda-files))
(cj/log-silently "")
(dolist (file org-agenda-files)
(if (file-exists-p file)
(let ((size (file-attribute-size (file-attributes file)))
(mtime (format-time-string "%Y-%m-%d %H:%M:%S"
(file-attribute-modification-time
(file-attributes file)))))
(cj/log-silently "✓ %s" file)
(cj/log-silently " Size: %d bytes, Modified: %s" size mtime))
(cj/log-silently "✗ %s [MISSING]" file)))
(cj/log-silently "")
(cj/log-silently "=== End Org Agenda Debug ===")
(message "Org Agenda: Dumped %d files to *Messages* buffer" (length org-agenda-files)))
;;;###autoload
(defun cj/org-agenda-debug-rebuild-timing ()
"Measure and report timing for rebuilding org-agenda-files.
Runs cj/build-org-agenda-list and reports detailed timing."
(interactive)
(cj/log-silently "=== Org Agenda Debug: Rebuild Timing ===")
(let ((start-time (current-time)))
(cj/build-org-agenda-list)
(let ((elapsed (float-time (time-subtract (current-time) start-time))))
(cj/log-silently "Rebuild completed in %.3f seconds" elapsed)
(cj/log-silently "Files found: %d" (length org-agenda-files))
(cj/log-silently "Average time per file: %.4f seconds"
(if (> (length org-agenda-files) 0)
(/ elapsed (float (length org-agenda-files)))
0.0))))
(cj/log-silently "=== End Org Agenda Debug ===")
(message "Org Agenda: Timing info dumped to *Messages* buffer"))
(provide 'org-agenda-config-debug)
;;; org-agenda-config-debug.el ends here
|