During my LaTeX typesetting I need to "visually" check if URLs point to reacheable pages. I'd like to do it with lynx in a separate emacs buffer so I wrote this function:

(defun urls-check-if-working-link ()
    (let* ((a (copy-marker (point-min)))
       (case-fold-search nil)
       (enable-recursive-minibuffers t))

      (goto-char a)
      (while (search-forward-regexp "\\\\\\(?:href\\|url\\){\\([^}]+\\)}" nil t)
      (let ((URL (match-string 1)))

        (unless (or
             ;; 1 - Commented String
             (nth 4 (syntax-ppss)) 

             ;; 2 - It's a DOI
             (string-match-p "doi\\.org" URL))

          ;; (eww-browse-url URL)
          (shell-command (concat "lynx " URL))

          ;; taking time to do something:
          (read-string (concat URL ": TEST"))))))


Running it I get the error:

Your Terminal type is unknown!

I found I need to use ansi-term to make lynx work. The command:

(ansi-term "lynx" "*BUFFER-NAME*")

works, but I'm not able to make it open a given URL. I mean something like:

(ansi-term "lynx https://www.google.com" "*BUFFER-NAME*")
  1. Where I'm doing wrong?
  2. Do you suggest a different approach?

1 Answer 1


ansi-term doesn't support arguments. PROGRAM means an executable file. COMMAND usually means a shell command.

You can use eshell-command (it works out-of-box because eshell-visual-commands includes lynx)

M-x eshell-command RET lynx http://example.com RET

or in Lisp

(eshell-command "lynx http://example.com")

and term-ansi-make-term works as well

(term-ansi-make-term "*BUFFER-NAME*" "lynx" nil "http://example.com")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.