emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: terminal escapes in Info files?


From: Simon Josefsson
Subject: Re: terminal escapes in Info files?
Date: Sun, 26 Oct 2003 13:40:02 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

address@hidden (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 <address@hidden>
 ;; Maintainer: Alex Schroeder <address@hidden>
@@ -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.
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]