Hot answers tagged

13

M-x url-handler-mode C-x C-f http://emacs.stackexchange.com/questions/21180/is-there-a-way-to-show-open-a-file-from-a-uri-url This opens the HTML file of this stackexchange question in your Emacs.


8

Add /private/etc/ssl/cert.pem to gnutls-trustfiles: M-x customize-variable Customize variable: gnutls-trustfiles Select the last [INS] Bundle filename: /private/etc/ssl/cert.pem Select [ Apply and Save ]


8

Since there is a newline after the HTTP headers, the only alternative I'm aware of is using a re-search-forward: (with-current-buffer (url-retrieve-synchronously my-url) (goto-char (point-min)) (re-search-forward "^$") (delete-region (point) (point-min)) (buffer-string))


6

Summary is there a way to tell bug-reference-mode to use different URL formats for them? If you are using Emacs 24+, there most certainly is. The key to making bug-reference-mode more flexible lies in: customising bug-reference-bug-regexp to match all your preferred bug reference formats (which should be differentiable); and setting bug-reference-url-...


5

It seems to me that the question is a little vague: is the goal to recognize gzip-compressed data? If not, what formats need to be supported? Focussing on the gzip case: The way I see it, possible approaches depend on the use case. For instance, if the length of a possibly compressed response is expected to be small, one can try decompressing to test if it ...


4

Annoyingly, the problem was here: (url-request-method "post"). Changing that to (url-request-method "POST") fixes everything.


4

To solve this issue it seems sufficient to: Set gnutls-verify-error to t, and Add an appropriate trusted root certificate file to gnutls-trustfiles - the default setting for that list does not include any existing files on OS X and it doesn't seem to default to using the system keychain. This can be done, for example, by installing libressl from homebrew ...


4

A higher-level alternative to using url-http-end-of-headers, but equally undocumented, is url-insert-file-contents: (with-temp-buffer (url-insert-file-contents "https://api.stackexchange.com/2.2/questions/12464?site=emacs") (json-parse-buffer :object-type 'alist)) or equivalently, prior to Emacs 27 compiled with native JSON support: (require 'json) ...


3

With respect to a "proper API", I think the short answer, at present, is "no" -- unless you are willing to rely on an external library. url-http-end-of-headers seems to be as good as it gets, although it isn't mentioned in the URL Programmer's Manual nor does it appear to be documented in emacs source.


3

M-x ffap RET does what you want (will be requested a confirmation though). You can bind it to double mouse click with (global-set-key [double-mouse-1] 'ffap) As the name suggests, ffap finds files at point, not just URLs. If you want a function tailored to URLs look at the builtin browse-url package (as suggested by Dan), which also lets you choose the ...


2

I agree with @Constantine, this looks like a bug. Consider submitting a bug report. As for how to fix it, I personally prefer temporary overriding instead of advices (too many bad experiences with them), but none of the options is ideal. You can temporarily override functions by wrapping your code in a cl-letf. (cl-letf (((symbol-function 'url-handle-...


2

Just found solution: use decode-coding-string: (url-unhex-string "/%E5%85%B6%E4%BB%96/other") ;; => "/\345\205\266\344\273\226/other" (decode-coding-string (url-unhex-string "/%E5%85%B6%E4%BB%96/other") 'utf-8) ;; => "/其他/other"


2

I had the same problem and I have finally got it working. I applied the patch in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=11788#52. Then, to solve error in process filter: url-http-generic-filter: Wrong type argument: number-or-marker-p, http/1.1 I just had to add a line to url-http.el:462 which was (skip-chars-forward "HTTP/") ; Skip ...


2

Emacs search functions (such as re-search-forward, replace-regexp-in-string etc) store the search result as the Match data. The later search overwrites the previous search's Match data by default. If you have to do another search within one search, you need to save & restore the Match data before/after the inner search, Emacs provides save-match-data for ...


2

Suppose you have copied the link or address you want to process. After you have created a similar command: (defun normalize-string-to-make-it-file/path-safe () (interactive) (kill-new (mapconcat (function concat) (split-string (read-string "Input: ") "[:/]") "_"))) You can use "normalize-string-to-make-it-file/path-safe" to ...


2

Your tern package was compiled with the older Emacs, but the newer Emacs has changed the representation of structs: the [cl-struct-url http nil nil 127.0.0.1 39585 / nil nil nil nil t] in your error message is an "old-style" struct, returned by the old url-parse-make-urlobj. This happens because this function was inlined when tern was compiled. You can try ...


2

This took me forever to figure out, but it turns out Spacemacs had cached a bunch of environment variables. One in particular, $XAUTHORITY, was making it so that qutebrowser wouldn't start. Manually editing my spacemacs env file and updating that variable fixed the problem.


1

In Emacs 26.3 at least, the allowed characters are hard-coded in thing-at-point-bounds-of-url-at-point; so you would need to modify that function accordingly, to add a backslash to the allowed-chars binding. The comments below on escaping would apply here too: use "\\\\". (And likewise for having no idea whether or not this will have unwanted side-effects.)...


1

browse-url.el can easily be configured that way. The following section of the doc of browse-url-browser-function is relevant: If the value is not a function it should be a list of pairs (REGEXP . FUNCTION). In this case the function called will be the one associated with the first REGEXP which matches the current URL. The function is passed the ...


1

This seems to be a bug in emacs at url-cache-extract with its use of erase-buffer and wiping out that marker. More details when I'm not mobile. I'll be submitting a bug report :-) This seems to be a bug in either url-http-parse-headers or url-cache-extract. Before url-http-parse-headers calls url-cache-extract, url-http-end-of-headers is set correctly. ...


1

As the error implies, there was no such file /.../https/com/github/api/.... This is needed by (url-cache-extract (url-cache-create-filename (url-view-url t))) in url-http.el. Once I realized that url already had support for HTTP-304 caching, I discovered url-automatic-caching which seems to do the trick. However, now it's not setting url-http-end-of-...


1

The following minimal example code shows how to hide the urls in md-files: (defun md-hide-urls () "Hide all urls in the current buffer." (interactive) (goto-char (point-min)) (while (re-search-forward "\\(\\[.+\\]\\)\\((.+)\\)" nil t) (put-text-property (match-beginning 2) (match-end 2) 'invisible t))) Regular expression search via lisp is ...


1

If you want the file "rendered", you can use the web browser eww - just do M-x eww RET url RET


1

,----[ C-h f url-handler-mode RET ] | url-handler-mode is an interactive autoloaded compiled Lisp function | in `url-handlers.el'. | | (url-handler-mode &optional ARG) | | Toggle using `url' library for URL filenames (URL Handler mode). `----


1

M-x browse-url-emacs RET URL RET


1

This is an example of what I have in my init file, just customize it a little bit and you're ready to go (defun duckduckgo (what) "Use ddg to search for WHAT." (interactive "sSearch: ") (browse-url-firefox (concat "https://duckduckgo.com/?t=lm&q=" (url-unhex-string what))))


1

This looks like a bug in url-handle-content-transfer-encoding: I believe it should check url-inhibit-uncompression. Consider submitting a bug report. In the meantime you can add advice to this function, making it possible to (temporarily) disable it: (defvar url-handle-content-transfer-encoding-disable nil) (advice-add 'url-handle-content-transfer-encoding ...


Only top voted, non community-wiki answers of a minimum length are eligible