Seems to me that there should be just a defcustom `url-user-agent' and it should be used always. By default it should have whatever value it currently has and users will be able to customise it. On 19 January 2014 10:10, Vibhav Pant wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > I added support to url.el for a custom user agent string by defining a > variable url-custom-user-agent which contains a user-defined string. The > variable is nil by default, in which case the function > url-http-user-agent-string reutrns the default user agent. > (Patch was created on a git repository) > > diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el > index ac2e140..1b63a25 100644 > --- a/lisp/url/url-http.el > +++ b/lisp/url/url-http.el > @@ -214,11 +214,15 @@ request.") > (and (listp url-privacy-level) > (memq 'agent url-privacy-level))) > "" > - (format "User-Agent: %sURL/%s\r\n" > - (if url-package-name > - (concat url-package-name "/" url-package-version " ") > - "") > - url-version))) > + > + (if url-custom-user-agent > + (format "User-Agent: %s\n" url-custom-user-agent) > + > + (format "User-Agent: %sURL/%s\r\n" > + (if url-package-name > + (concat url-package-name "/" url-package-version " ") > + "") > + url-version)))) > > (defun url-http-create-request (&optional ref-url) > "Create an HTTP request for `url-http-target-url', referred to by > REF-URL." > diff --git a/lisp/url/url.el b/lisp/url/url.el > index cbbcfd4..c54a94e 100644 > --- a/lisp/url/url.el > +++ b/lisp/url/url.el > @@ -51,6 +51,10 @@ > :type 'directory > :group 'url) > > +(defvar url-custom-user-agent nil > + "User Agent used by url-http-create-request to fetch pages. If nil, > +the default user agent will be used.") > + > (defun url-do-setup () > "Setup the URL package. > This is to avoid conflict with user settings if URL is dumped with > > - -- > Vibhav Pant > vibhavp@gmail.com > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.22 (GNU/Linux) > > iQIcBAEBCgAGBQJS24fqAAoJEO86onTybWtcUdkP/2s5MGg3/zY/Xg8KmSxAU20x > Ki0UamZHp5xNgr6UcN0SIseVGTTMBfJrwWL70LnslvvzRcPysRK0v+sOL4PjNcsT > nkOU8BjsTt4HMFi48LPqhr+OacAFrMVT0E3vo0rtYoQSSw7tNgEprLUr3i2Yc1vY > II23YllVdIqb6Ys6arYuMb5V5vP83GfnV9hm1jNSt3TGefSMsgDVggBRiw7NBk8Q > pJqZ14rblX68V+b2cmw8JAzDkq7mWZ+s6CU/Ic4KI3a37k3kvoDwXwU8kCMVpP7Q > aBK9VzSLlDzzLD+TZI7I7K5n6dA4He4BwwhFgQuUwOmoI5nF3W7y1gSOCL4sBOLF > 5tqlRZFR+RJUDGabV6PoSux2K61sYegMN0NzzyrUCTPwqb9ISMNBfGfL0lp/QFuh > ENxHmTnyO/J+FTIFAQ4Dbv4RYn5xxivgPp4UmYG3vin7b3E/+2jsOKdeQO/V5iBA > 85XUKEdxH5JUergw0A9rsBvWkRw/iy89+edqg1hNJkWD8sSY+4H3QXGly63mQzdc > 51QWCwAJ1ShPif8RI9yD1Eyvctoasv+WM42NakCZ7bDUOwuHqJfAAEVbQeg9ijn9 > EynM7n5CmAAap6vrjdeNWJvxPWPXv32UHSsstOAN7MPgd9Cw6gZvfYY4DITHqWbe > BykRZe2zqv4iIlgL87Rg > =8VAL > -----END PGP SIGNATURE----- > >