From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gwern Branwen Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: 23.0.60; Allow ELinks in Emacs frames, or, Generalizing browse-url.el's browse-url-lynx-emacs Date: Tue, 16 Oct 2007 17:55:18 -0400 Message-ID: <20071016215518.GA23044@craft> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1300894104==" X-Trace: ger.gmane.org 1192574084 523 80.91.229.12 (16 Oct 2007 22:34:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Oct 2007 22:34:44 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 17 00:34:44 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ihuzp-0004R2-TL for ged-emacs-devel@m.gmane.org; Wed, 17 Oct 2007 00:34:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ihuzi-0003BP-PD for ged-emacs-devel@m.gmane.org; Tue, 16 Oct 2007 18:34:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IhuOT-0006Ib-Iw for emacs-devel@gnu.org; Tue, 16 Oct 2007 17:56:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IhuOR-0006Fd-8d for emacs-devel@gnu.org; Tue, 16 Oct 2007 17:56:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IhuOR-0006FK-0b for emacs-devel@gnu.org; Tue, 16 Oct 2007 17:56:03 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IhuOQ-0001Ml-FI for emacs-devel@gnu.org; Tue, 16 Oct 2007 17:56:02 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IhuOQ-0001Bb-0D for emacs-pretest-bug@gnu.org; Tue, 16 Oct 2007 17:56:02 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1IhuOL-0001LM-W7 for emacs-pretest-bug@gnu.org; Tue, 16 Oct 2007 17:56:01 -0400 Original-Received: from el-out-1112.google.com ([209.85.162.178]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IhuOL-0001K9-H2 for emacs-pretest-bug@gnu.org; Tue, 16 Oct 2007 17:55:57 -0400 Original-Received: by el-out-1112.google.com with SMTP id s27so513802ele for ; Tue, 16 Oct 2007 14:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; bh=eSkGSNdI+o5WFDPJJHv6LE3y4O/U599VVJIbTcc1nOo=; b=Q1yb7m9/ESjpabFnP8tfbuk3zV8cYpo3s1nHreKWJnNKf2HwoswZm6SHuJAu9qy4mGbxp7OolTW6Lw4ob9wwmYpFfBQTx86xMz/gAe8rpn4YLpgH99dEfnnqXW93fRp9ETJ/7HLXulKTtpS9SqJTkYJcto2JQSQetFyGwyzlu+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; b=eqVAaFM5y4wn1KxDAmrOVXc9AVyxfVn+NlSSJMfnxBURU3eZdcak6Omn8FNBqsjCagk0jllBD9aVdwj+u9niuvs1SQJTYKEUH8KG+m39hWuSbo9y09ZDvkGzsYstyCxOdxLgXr+0QVYDS++cRP9CGKKOYdem+e3XC8TLV/cuLL8= Original-Received: by 10.143.8.10 with SMTP id l10mr2367081wfi.1192571753223; Tue, 16 Oct 2007 14:55:53 -0700 (PDT) Original-Received: from craft ( [89.150.202.174]) by mx.google.com with ESMTPS id i33sm15581325wxd.2007.10.16.14.55.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Oct 2007 14:55:50 -0700 (PDT) Original-Received: by craft (sSMTP sendmail emulation); Tue, 16 Oct 2007 17:55:18 -0400 X-GnuPG-KeyID: F7E5D682 X-GnuPG-Fingerprint: 85F9 9FDE 8F20 898F 59BC DF32 BE90 E8E4 F7E5 D682 X-Editor: "GNU Emacs 23.0.50.1" X-Operating-System: "Gentoo x86_64 GNU/Linux" User-Agent: Mutt/1.5.16 (2007-06-09) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 (Google crawlbot) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Tue, 16 Oct 2007 18:31:58 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81025 gmane.emacs.pretest.bugs:20146 Archived-At: --===============1300894104== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4SFOXa2GPu3tIq4H" Content-Disposition: inline --4SFOXa2GPu3tIq4H Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Browse-url.el offers a neat function browse-url-lynx-emacs which opens up a= Lynx browser within the current Emacs frame; this is very nice for binding= so you can quickly follows hyperlinks and works very will with documentati= on and stuff like email in Gnus. But I don't use Lynx, don't have it installed; looking through the source, = there doesn't seem to be anything truly Lynx specific about it, and in fact= , just substituting 'elinks' for 'lynx' (and removing one or two superfluou= s lines) seems to work fine. Even better would be a general function which just runs a specified text br= owser (since there are a lot more than just ELinks and Lynx out there). It= wouldn't be terribly difficult to do - add a parameter to it, replace brow= se-url-lynx-emacs with a specialization of the generalization and you are m= ore or less done (although I don't know how one would handle the various va= riables tweaking browse-url-lynx-emacs); I've attached a sort of example. -- gwern tiger Bubba plutonium Fiel Cross quarter Tangimoana Vale president M72750 --text follows this line-- Please write in English if possible, because the Emacs maintainers usually= do not have translators to read other languages for them. In GNU Emacs 23= =2E0.60.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.12.0) of 2007-10-15 on= craft Windowing system distributor `The X.Org Foundation', version 11.0.10= 400000 configured using `configure '--with-gtk' '--enable-font-backend' '-= -with-xft' '--with-gif=3Dno'' Important settings: value of $LC_ALL: en_US= =2Eutf8 value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_= MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil valu= e of $LC_TIME: nil value of $LANG: nil value of $XMODIFIERS: nil loca= le-coding-system: utf-8-unix default-enable-multibyte-characters: t Major m= ode: Lisp Interaction Minor modes in effect: change-cursor-mode: t rece= ntf-mode: t display-time-mode: t msb-mode: t icomplete-mode: t iswitc= hb-mode: t show-paren-mode: t tooltip-mode: t mouse-wheel-mode: t file-= name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-curs= or-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-co= mpression-mode: t column-number-mode: t line-number-mode: t transient-mar= k-mode: t Recent input: M-x r e p o r - t - e B = r o w s B r <= backspace> A l l o w SPC e E l L i n k= s SPC i n SPC f r E m a c s SPC f r a m e s , SP= C o r , SPC G e n e r a l i z i n g SPC b r o w s e =3D - u r = l . e l ' s SPC M-e M-c b r o w s e - u r= l - l y n x - e m a c s B r o w s e - u r l . e l SPC i n c l u= d e s SPC a SPC n i f t y SPC f u n c t i o n SPC = C-g a a a a = C-/ C-/ C-/ C-/ C= -/ C-/ C-/ C-x k C-x k C-x 0 C-x k M-x Recent messages: Loading dupwords...done Loading recentf...done Star= ting new Ispell process [default] ... Beginning idle-require Auto-saving...= Type y, n, ! or SPC (the space bar): Quit Auto-saving...done Undo! [5 tim= es] undo-more: No further undo information undo-more: No further undo infor= mation --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=browse-url (defun browse-url-text-browser-emacs (url generic &optional new-buffer) "Ask for a Web address and an arbitrary text browser. When called interactively, if variable `browse-url-new-window-flag' is non-nil, load the document in a new text browser in a new term window, otherwise use any existing one. A non-nil interactive prefix argument reverses the effect of `browse-url-new-window-flag'. When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive "MWeb address: \nMBrowser: ") (let* ((system-uses-terminfo t) ; Text browsers use terminfo? (buf (get-buffer "*text-browser*")) (proc (and buf (get-buffer-process buf))) (n browse-url-lynx-input-attempts)) (if (and (browse-url-maybe-new-window new-buffer) buf) ;; Rename away the OLD buffer. This isn't very polite, but ;; term insists on working in a buffer named *lynx* and would ;; choke on *lynx*<1> (progn (set-buffer buf) (rename-uniquely))) (if (or (browse-url-maybe-new-window new-buffer) (not buf) (not proc) (not (memq (process-status proc) '(run stop)))) ;; start a new text browser (progn (setq buf (apply #'make-term `("text-browser" ,generic nil ,@browse-url-lynx-emacs-args ,url))) (switch-to-buffer buf) (term-char-mode) (set-process-sentinel (get-buffer-process buf) ;; Don't leave around a dead one (especially because of its ;; munged keymap.) (lambda (process event) (if (not (memq (process-status process) '(run stop))) (let ((buf (process-buffer process))) (if buf (kill-buffer buf))))))) ;; send the url to the text-browser in the old buffer (let ((win (get-buffer-window buf t))) (if win (select-window win) (switch-to-buffer buf))) (if (eq (following-char) ?_) (cond ((eq browse-url-lynx-input-field 'warn) (error "Please move out of the input field first")) ((eq browse-url-lynx-input-field 'avoid) (while (and (eq (following-char) ?_) (> n 0)) (term-send-down) ; down arrow (sit-for browse-url-lynx-input-delay)) (if (eq (following-char) ?_) (error "Cannot move out of the input field, sorry"))))) (term-send-string proc (concat "g" ; goto "\C-u" ; kill default url url "\r"))))) (defun browse-url-lynx-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls Lynx." (interactive (browse-url-interactive-arg "URL for Lynx: ")) (browse-url-text-browser-emacs url "lynx" new-buffer)) (defun browse-url-elinks-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls Elinks." (interactive (browse-url-interactive-arg "URL for Elinks: ")) (browse-url-text-browser-emacs url "elinks" new-buffer)) (defun browse-url-links-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls Links." (interactive (browse-url-interactive-arg "URL for Links: ")) (browse-url-text-browser-emacs url "links" new-buffer)) (defun browse-url-links2-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls Links2." (interactive (browse-url-interactive-arg "URL for Links2: ")) (browse-url-text-browser-emacs url "links2" new-buffer)) (defun browse-url-netrik-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls Netrik." (interactive (browse-url-interactive-arg "URL for Netrik: ")) (browse-url-text-browser-emacs url "netrik" new-buffer)) (defun browse-url-w3m-emacs (url &optional new-buffer) "Specializes browse-url-text-browser-emacs so it calls w3m." (interactive (browse-url-interactive-arg "URL for w3m: ")) (browse-url-text-browser-emacs url "w3m" new-buffer)) --jRHKVT23PllUwdXP-- --4SFOXa2GPu3tIq4H Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHFTNGvpDo5Pfl1oIRCn76AJ9KS3VAnWoqMOQhfvr8XUMJIXZo7wCgmZpa UwtK2I6P55OGqZrlXPKllwc= =hIqw -----END PGP SIGNATURE----- --4SFOXa2GPu3tIq4H-- --===============1300894104== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============1300894104==--