tkf / emacs-request

Request.el -- Easy HTTP request for Emacs Lisp
http://tkf.github.com/emacs-request/
GNU General Public License v3.0
617 stars 91 forks source link

Debugger entered--Lisp error: (void-function request) #216

Closed soilc closed 1 year ago

soilc commented 1 year ago

Debugger entered--Lisp error: (void-function request) (request "http://httpbin.org/get" :params '(("key" . "value") ("key2" . "value2")) :parser 'json-read :success #'(lambda (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let ((data (car (cdr ...)))) (message "I sent: %S" (assoc-default 'args data))))) (progn (request "http://httpbin.org/get" :params '(("key" . "value") ("key2" . "value2")) :parser 'json-read :success #'(lambda (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let ((data (car ...))) (message "I sent: %S" (assoc-default 'args data)))))) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) command-execute(eval-last-sexp)

dickmao commented 1 year ago

This command-line invocation of emacs is a bit above your pay grade, but it demonstrably proves the basic case:

git clone https://github.com/tkf/emacs-request.git my-request.el
cd my-request.el
emacs -Q --batch -L . -l request --eval \
"(request \"http://httpbin.org/get\" \
  :params (quote ((\"key\" . \"value\") (\"key2\" . \"value2\"))) \
  :parser (quote json-read) \
  :sync t \
  :success (cl-function \
            (lambda (&key data &allow-other-keys) \
              (message \"I sent: %S\" (assoc-default (quote args) data)))))"

Output:

I sent: ((key . "value") (key2 . "value2"))

There's a lot to know about emacs, the first being how to install a package, and then require'ing it.

soilc commented 1 year ago

I thought that smart people like you should understand that the package is already installed according to the instructions given: M-x package-refresh-contents RET M-x package-install RET request RET

So, you can see it: Package request is installed.

 Status: Installed in ‘request-0.3.3/’. Delete
Version: 0.3.3
Summary: Compatible layer for URL request in Emacs

Requires: emacs-24.4 Website: https://github.com/tkf/emacs-request Maintainer: Takafumi Arakaki Author: Takafumi Arakaki Other versions: 0.3.3 (nongnu), 20221022.1122 (melpa).

dickmao commented 1 year ago

I thought that smart people like you

Sorry, you must be mistaking me for someone else.

soilc commented 1 year ago

Why did you close the question?

soilc commented 1 year ago

This command-line invocation

Yes, it works. But the correct answer to my question is quite different - (require 'request) in 'init.el'. The problem is in your poor instruction (https://github.com/tkf/emacs-request): "... M-x package-refresh-contents RET M-x package-install RET request RET Alternatively, directly clone this repo and make install." And yes, you are not very kind.

dickmao commented 1 year ago

you are not very kind.

Glad you noticed. But a samaritan @tomterl has come to your aid in #217 so that the following works (note the absence of -l request),

emacs -Q --batch -f package-initialize --eval \
"(request \"http://httpbin.org/get\" \
  :params (quote ((\"key\" . \"value\") (\"key2\" . \"value2\"))) \
  :parser (quote json-read) \
  :sync t \
  :success (cl-function \
            (lambda (&key data &allow-other-keys) \
              (message \"I sent: %S\" (assoc-default (quote args) data)))))"

works once the beat drops in MELPA two hours from now.

soilc commented 1 year ago

I see that you are a writer, not a reader. Therefore, I will repeat. The problem is in your poor instruction (https://github.com/tkf/emacs-request). And the correct answer to my question is a lack of the '(require 'request)' in my 'init.el'. That's all you need for the right answer.

tomterl commented 1 year ago

I see that you are a writer, not a reader. Therefore, I will repeat. The problem is in your poor instruction (https://github.com/tkf/emacs-request). And the correct answer to my question is a lack of the '(require 'request)' in my 'init.el'. That's all you need for the right answer.

No, the require is no longer needed once the autoload cookie update hits melpa...

dickmao commented 1 year ago

I see that you are a writer, not a reader.

Odd that you mention it. I just finished all 1300 pages of Les Miserables by Hugo. The musical was better.

soilc commented 1 year ago

No, the require is no longer needed once the autoload cookie update hits melpa...

It just means that a samaritan @tomterl is helping you, not me.