summaryrefslogtreecommitdiff
path: root/debug-wttrin.el
blob: 8b8798b9c7750242fd8bff0c6337a61e5365c873 (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
;;; debug-wttrin.el --- Debug helper for wttrin -*- lexical-binding: t -*-
;;
;; This file provides utilities for debugging wttrin display issues.
;;
;;; Commentary:
;;
;; To enable debug mode:
;;   (setq wttrin-debug t)
;;
;; This will save raw weather responses to timestamped files in your
;; temp directory for bug reports.
;;
;; To view raw data with line numbers for development:
;;   M-x debug-wttrin-show-raw RET <location> RET
;;
;;; Code:

(require 'wttrin)

(defun debug-wttrin-show-raw (location)
  "Fetch and display raw wttr.in data for LOCATION with line numbers.
This is useful for debugging header parsing issues."
  (interactive "sLocation: ")
  (let ((raw-string (wttrin--get-cached-or-fetch location)))
    (with-current-buffer (get-buffer-create "*wttrin-debug*")
      (erase-buffer)
      (insert raw-string)
      (goto-char (point-min))
      (let ((line-num 1))
        (while (not (eobp))
          (beginning-of-line)
          (insert (format "%2d: " line-num))
          (setq line-num (1+ line-num))
          (forward-line 1)))
      (goto-char (point-min))
      (switch-to-buffer (current-buffer)))))

(defun debug-wttrin-enable ()
  "Enable wttrin debug mode.
Raw weather data will be saved to timestamped files for bug reports."
  (interactive)
  (setq wttrin-debug t)
  (message "Wttrin debug mode enabled. Raw data will be saved to: %s" temporary-file-directory))

(defun debug-wttrin-disable ()
  "Disable wttrin debug mode."
  (interactive)
  (setq wttrin-debug nil)
  (message "Wttrin debug mode disabled"))

(provide 'debug-wttrin)
;;; debug-wttrin.el ends here