cute-jumper/gscholar-bibtex

Error on any buffer interaction

mhlinder opened this issue · 13 comments

On trying to use any of the keybindings, I receive the error Args out of range: [], 1.

Any ideas what may be causing this? Thanks!

Could you please provide steps so that I can reproduce the problem?

Sure, thanks for the response!

Nothing set in init.el, M-x gscholar-bibtex, source Google Scholar, query test brings up 11 or so results, pressing A after any of them gives the error

Incidentally, using query mandelbrot causes it to not even load the buffer, complaining of

gscholar-bibtex-prettify-subtitle: Wrong type argument: stringp, nil

in *Messages*

A is used for appending the current BibTeX entry to gscholar-bibtex-database-file, so you need to set gscholar-bibtex-database-file to your database file in your init.el. You can use a (lower case A) and manually choose the file if you don't have a database file. But indeed, we need a better message to be shown when the user type A or W without setting gscholar-bibtex-database-file.

The second problem about the query mandelbrot should be a bug. I'll take a look at it later.

Thanks for reporting!

Thanks,
for the response

To clarify, though, neither a nor A with gscholar-bibtex-database-file set works properly; nor do w or W.

No. I can't reproduce the problem with a or w. They both work.

But indeed, we need a better message to be shown when the user type A or W without setting gscholar-bibtex-database-file.

Actually I was wrong. Such a thing has already been added. If I unset my gscholar-bibtex-database-file (set it to nil, which is also your case), it will ask me the file name of the database file first. That said, I can't really reproduce your first problem. Have you tried to use gscholar-bibtex with emacs -Q?

The second problem should be fixed in the newest commit. Still need to confirm that whether the first problem exists when using emacs -Q since I can't reproduce it.

I've traced the problem a bit further:

The cookie (with flag CF=4) doesn't seem to get passed through to gscholar-bibtex--url-retrieve-as-buffer, so there are no links to .bib files, so there are no URLs to index.

I'm trying to determine why the cookie isn't being passed through, but my Lisp is weak...

According to what you say, the cookie should be the root cause. You can use the curl command or other tools to confirm whether setting CF=4 works in your environment.

Strange...

curl -v -A "Mozilla/5.0" --cookie "GSP=ID=87969bbbc5530bab:CF=4" "http://scholar.google.com/scholar?q=test"

provides the desired .bib files, but

(let* ((url-request-method "GET")
    (url-request-extra-headers
     `(("User-Agent" . "Mozilla/5.0")
       ("Cookie" . "GSP=ID=87969bbbc5530bab:CF=4"))))
  (url-retrieve "https://scholar.google.com/scholar?q=test"
        (lambda (status) (switch-to-buffer (current-buffer)))))

does not provide any links to .bib files.

Do you have any insight?

Thanks!

That's really weird. I tried your code, and both work. I don't have any clue right now. What's your platform and what's your Emacs version? Is there any difference if you use http instead of https in the Emacs Lisp code? Also, try to set url-debug to t and inspect the *URL_DEBUG* buffer to see if there is anything suspicious.

Indeed, really weird.

Having tried on a different machine, I have reached the conclusion that this is because I'm on OS X. I use Emacs for OS X Modified, but the system emacs at /usr/bin/emacs also has this problem, so there must be some system setting preventing proper handling of the URL.

I'll leave this issue open, and report back and close it for future use.

Well, it seems to stem (at least in part) from the storage of cookies by w3m in ~/.emacs.d/url/cookies, and possibly some other setting related to accepting cookies. So, multiple cookie headers are

I seem also to have some trouble with

Regardless, setting the inhibit-cookies parameter to t in my example earlier succeeds, although adding this to the call to url-retrieve-synchronously in gscholar-bibtex--url-retrieve-as-buffer does not solve all issues—setting url-request-extra-headers in gscholar-bibtex--url-retrieve-as-buffer seems to overwrite the cookie set in gscholar-bibtex-google-scholar-search-results.

A temporary solution (since I only need the Google Scholar source) I'm using is to hard-code the cookie into gscholar-bibtex--url-retrieve-as-buffer.

Thanks for the help, and the package!

A temporary solution (since I only need the Google Scholar source) I'm using is to hard-code the cookie into gscholar-bibtex--url-retrieve-as-buffer.

I can confirm that that's working for me as a work-arounnd where I've encountered the problem, as described in #28.

(defun gscholar-bibtex--url-retrieve-as-buffer (url)
  (let* ((url-request-extra-headers
          (append url-request-extra-headers
		  `(("User-Agent" . ,gscholar-bibtex-user-agent-string)
		    ("Cookie" . "GSP=ID=87969bbbc5530bab:CF=4"))))
         (response-buffer (url-retrieve-synchronously url nil t)))
    (with-current-buffer response-buffer
      (gscholar-bibtex--delete-response-header)
      (set-buffer-multibyte t))
    response-buffer))