aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 09:08:49 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 09:08:49 -0400
commit5fa06885d6a1da2b7e021f78ea0111a81f7b3500 (patch)
treee49d03314669cdd7fe16ca7521e7b50fa6fe03d4 /modules
parentc96ccf96fa667b1bd7d9a09485d31c75806b9280 (diff)
downloaddotemacs-5fa06885d6a1da2b7e021f78ea0111a81f7b3500.tar.gz
dotemacs-5fa06885d6a1da2b7e021f78ea0111a81f7b3500.zip
fix(eww): inject the User-Agent reliably under byte-compilation
eww-config.el is lexical-binding and the User-Agent advice let-binds url.el's url-request-extra-headers, but the file never declared it special. The byte-compiler then bound it lexically, so the injected header never reached url-retrieve and the desktop User-Agent silently dropped in compiled production (eww kept working, just with the default UA). A top-level (defvar url-request-extra-headers) makes the compiler treat it as dynamic so the binding propagates. The advice tests, which exercise the compiled path, now pass.
Diffstat (limited to 'modules')
-rw-r--r--modules/eww-config.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/eww-config.el b/modules/eww-config.el
index a5271f6b..ff7ddc21 100644
--- a/modules/eww-config.el
+++ b/modules/eww-config.el
@@ -44,6 +44,13 @@
:type 'string
:group 'my-eww-user-agent)
+;; This file is lexical-binding, so `let'-binding url.el's special var below
+;; needs it declared special at compile time. Without this the byte-compiled
+;; advice binds `url-request-extra-headers' lexically and the injected
+;; User-Agent never reaches `url-retrieve' (it reads the dynamic value) -- the
+;; UA injection silently no-ops in compiled production, and the test sees nil.
+(defvar url-request-extra-headers)
+
(defun my-eww--inject-user-agent (orig-fun &rest args)
"Set a User-Agent only when making requests from an EWW buffer."
(if (derived-mode-p 'eww-mode)