From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: raman@google.com Newsgroups: gmane.emacs.devel Subject: eww: Feature request: Dont hard-wire shr-external-rendering-functions Date: Mon, 18 May 2015 08:45:52 -0700 Message-ID: <21850.2352.916316.846855@gargle.gargle.HOWL> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1431964060 32460 80.91.229.3 (18 May 2015 15:47:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 May 2015 15:47:40 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 18 17:47:40 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YuNGW-00007V-2t for ged-emacs-devel@m.gmane.org; Mon, 18 May 2015 17:47:40 +0200 Original-Received: from localhost ([::1]:41625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuNGV-0001Zp-HG for ged-emacs-devel@m.gmane.org; Mon, 18 May 2015 11:47:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuNFD-0008OZ-HO for emacs-devel@gnu.org; Mon, 18 May 2015 11:46:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuNF9-0005dy-5b for emacs-devel@gnu.org; Mon, 18 May 2015 11:46:19 -0400 Original-Received: from mail-pd0-x233.google.com ([2607:f8b0:400e:c02::233]:33371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuNF8-0005dd-Mo for emacs-devel@gnu.org; Mon, 18 May 2015 11:46:15 -0400 Original-Received: by pdbqa5 with SMTP id qa5so154341828pdb.0 for ; Mon, 18 May 2015 08:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:mime-version:content-type:content-transfer-encoding:message-id :date:to:subject; bh=qoj0cXDsCjSYi/OVr4YF3/SlsU0OCQUDR1X/tpuuwSQ=; b=WXRb3gNyquQWoG3LRNMk9EIi8mg17GloGAdHpKy953XoLR4lKZwnuPydcK20q4KmFE rqJlt8BM01PSUZCpBpjR0xDKbhVARYE4aoaxu/ckhV2m2fqAmyBQlAuhHFdsjTMxpscY hnkLAcGMio02t1fV3cd0rJtK3FNyXQQlAznmIT7oFwxKQrTzOQANObn3bqRAaiBf5Zdw NJXYe5KA4E+ik6tnFMjs3jWGOH1iaZsIfYudXLDNaw2IfFGKNCdHbANZrFsbblj/KIAV 6pfG5Guymsemo+jpjYYgq6FuMCB+6Bh4SdoF0Y8i/WpL4YZtDVMOQYhdwy23LnCTbM9Z AYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject; bh=qoj0cXDsCjSYi/OVr4YF3/SlsU0OCQUDR1X/tpuuwSQ=; b=P6mLMjcpCqZRwebhrd8g30YQa6sl8SEOBYQXnUTu3+lA/9xTnWn5vQ2OwxAcO13fZc y/1DFO9xKDo/hrIWJ6vmqVKNzG+HKywk+GIRR29TUV4hNv2McRjHuS9EqKRbK2aee+ww qsK+n0u3v1KxqKaml6dA+fJSlUOs0nLjC/PDp734IHo8NuI/8S93jfKOMtyXQfoZPwGc f6fDdwud/m21RBaPcBdJrsNcY6YVn1RUd6IpIPKD7yk9NRgaxD7Whc1xFEue0OtZTC5X pM15zx6IjJzz+gNisYYzMQN/rPsjtTBWQ+81wiJsXKv12xELUVNQwv1fknnAjEJAU+Gr fgaQ== X-Gm-Message-State: ALoCoQmxgbh6PBpatDu6zV9oceSwLTftZ5+shZSnQdFcqzNy3Mb+IADHVzHq+P0B51TGIc3EYzxs X-Received: by 10.68.139.225 with SMTP id rb1mr44531686pbb.68.1431963973307; Mon, 18 May 2015 08:46:13 -0700 (PDT) Original-Received: from raman-glaptop ([207.198.105.24]) by mx.google.com with ESMTPSA id ym6sm10497795pac.32.2015.05.18.08.46.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 18 May 2015 08:46:12 -0700 (PDT) X-Mailer: VM 8.1.1 under 25.0.50.1 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:186580 Archived-At: I have a feature request motivated by the need to "tag" portions of the EWW rendered buffer with the tag-name of the sub-tree that produced the rendering; this helps me then implement structured navigation of the EWW buffer for Emacspeak. I've achieved this for header tags etc via an advice on the relevant shr-tag- functions. At present the
element is handled by shr-generic which is a defsubst -- so advice wont work. I implemented byself a simple emacspeak-eww-tag-article that does: (defun emacspeak-eww-tag-article (dom) "Tag article, then render." (let ((start (point))) (shr-generic dom) (put-text-property start (point) 'article 'eww-tag))) But at present, I have no way of telling EWW to add this to shr-external-rendering-functions -- since that variable is let-bound in eww-display-html --- I could probably still get away with advicing shr-insert-document -- but I'd prefer a simpler solution:-) Possibilities -- 1. Implement shr-tag-article as above -- essentially rename emacspeak-eww-tag-article to shr-tag-article -- and update the other shr functions in the recursive descent walk of the HTML tree to set property 'eww-tag -- 2. If this is overkill for mainstream Emacs users -- then perhaps allow external packages to customize what list of rendering functions eww uses? For completeness, here is how I generate the advice on the shr-tag- functions to emit the necessary eww-tag properties in the EWW rendered buffer: (loop for tag in '(h1 h2 h3 div ; sectioning ul ol dl ; Lists li dt dd p ; block-level: bullets, paras form blockquote ; block-level a b it em span ; in-line br hr ; separators th tr table ) do (eval ` (defadvice ,(intern (format "shr-tag-%s" tag)) (around emacspeak pre act comp) (let ((start (point))) ad-do-it (let ((start (if (char-equal (following-char) ?\n) (min (point-max) (1+ start) )start)) (end (if (> (point) start) (1- (point)) (point)))) (put-text-property start end (quote ,tag) 'eww-tag) (when (memq (quote ,tag) '(h1 h2 h3)) (put-text-property start end 'h 'eww-tag))))))) -- --