From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.devel Subject: Re: terminal escapes in Info files? Date: Sun, 26 Oct 2003 13:40:02 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <200310261220.h9QCKsb15110@f7.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1067172200 10328 80.91.224.253 (26 Oct 2003 12:43:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 26 Oct 2003 12:43:20 +0000 (UTC) Cc: Alex Schroeder , dirt@gtk.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Oct 26 13:43:17 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ADkEn-0004bG-00 for ; Sun, 26 Oct 2003 13:43:17 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ADkEn-0002bl-00 for ; Sun, 26 Oct 2003 13:43:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ADkCv-0008Ff-KW for emacs-devel@quimby.gnus.org; Sun, 26 Oct 2003 07:41:21 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ADkCP-0008Cf-6Q for emacs-devel@gnu.org; Sun, 26 Oct 2003 07:40:49 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ADkBr-0007ei-FN for emacs-devel@gnu.org; Sun, 26 Oct 2003 07:40:46 -0500 Original-Received: from [217.13.230.178] (helo=yxa.extundo.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1ADkBq-0007Xk-Iv; Sun, 26 Oct 2003 07:40:14 -0500 Original-Received: from latte (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.10/8.12.10) with ESMTP id h9QCe41e002662; Sun, 26 Oct 2003 13:40:05 +0100 Original-To: karl@freefriends.org (Karl Berry) Mail-Copies-To: nobody X-Payment: hashcash 1.2 0:031026:karl@freefriends.org:db37b052394a1dbf X-Hashcash: 0:031026:karl@freefriends.org:db37b052394a1dbf X-Payment: hashcash 1.2 0:031026:emacs-devel@gnu.org:0b265ebc03d3da6a X-Hashcash: 0:031026:emacs-devel@gnu.org:0b265ebc03d3da6a X-Payment: hashcash 1.2 0:031026:dirt@gtk.org:7c4a2dc646453c11 X-Hashcash: 0:031026:dirt@gtk.org:7c4a2dc646453c11 X-Payment: hashcash 1.2 0:031026:alex@gnu.org:38a6e1ab910ddd0b X-Hashcash: 0:031026:alex@gnu.org:38a6e1ab910ddd0b In-Reply-To: <200310261220.h9QCKsb15110@f7.net> (Karl Berry's message of "Sun, 26 Oct 2003 07:20:55 -0500") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17437 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17437 karl@freefriends.org (Karl Berry) writes: > 1) write ANSI terminal escape codes directly in the Info file. (Even on > non-ANSI terminals, if there are any left, these could be translated to > appropriate termcap sequence.) ... > - is one of (1) or (2) significantly easier to implement in Emacs? Rendering ANSI escape sequences in e-mail was recently proposed for Gnus, and thanks to ansi-color.el it is easy to do: just call ansi-color-apply-on-region from ansi-color.el. You only need to make sure the ESC sequence is not destroyed until it reach the decoding code, of course. (autoload 'ansi-color-apply-on-region "ansi-color") (defun article-treat-ansi-sequences () "Translate ANSI SGR control sequences into overlays or extents." (interactive) (save-excursion (when (article-goto-body) (let ((buffer-read-only nil)) (ansi-color-apply-on-region (point) (point-max)))))) PS. Alex, what do you think about the following? Those functions are documented in the top-level comment, and appear to be basic API entry points for the ansi-color.el library, so it might be useful to autoload them. I don't know if adding autoload cookies here and there is considered polluting though. --- ansi-color.el.~1.14.~ 2003-10-07 19:16:00.000000000 +0200 +++ ansi-color.el 2003-10-26 13:37:37.000000000 +0100 @@ -1,6 +1,6 @@ ;;; ansi-color.el --- translate ANSI escape sequences into faces -;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. ;; Author: Alex Schroeder ;; Maintainer: Alex Schroeder @@ -285,6 +285,7 @@ escape sequence.") (make-variable-buffer-local 'ansi-color-context) +;;;###autoload (defun ansi-color-filter-apply (string) "Filter out all SGR control sequences from STRING. @@ -315,6 +316,7 @@ (setq ansi-color-context nil))) result)) +;;;###autoload (defun ansi-color-apply (string) "Translates SGR control sequences into text-properties. @@ -398,6 +400,7 @@ (setq ansi-color-context-region (list nil (match-beginning 0))) (setq ansi-color-context-region nil))))) +;;;###autoload (defun ansi-color-apply-on-region (begin end) "Translates SGR control sequences into overlays or extents.