emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113091: lisp/ansi-color.el: Convert to lexical bind


From: Juanma Barranquero
Subject: [Emacs-diffs] trunk r113091: lisp/ansi-color.el: Convert to lexical binding.
Date: Thu, 20 Jun 2013 01:04:07 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113091
revision-id: address@hidden
parent: address@hidden
committer: Juanma Barranquero <address@hidden>
branch nick: trunk
timestamp: Thu 2013-06-20 03:03:57 +0200
message:
  lisp/ansi-color.el: Convert to lexical binding.
  (ansi-colors): Fix URL.
  (ansi-color-context, ansi-color-context-region): Use defvar-local.
  (ansi-color-apply-sequence, ansi-color-map): Fix typos in docstrings.
  (ansi-color-make-color-map): Rename local var ansi-color-map to map.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/ansi-color.el             
ansicolor.el-20091113204419-o5vbwnq5f7feedwu-1328
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-06-20 00:39:59 +0000
+++ b/lisp/ChangeLog    2013-06-20 01:03:57 +0000
@@ -1,5 +1,11 @@
 2013-06-20  Juanma Barranquero  <address@hidden>
 
+       * ansi-color.el: Convert to lexical binding.
+       (ansi-colors): Fix URL.
+       (ansi-color-context, ansi-color-context-region): Use defvar-local.
+       (ansi-color-apply-sequence, ansi-color-map): Fix typos in docstrings.
+       (ansi-color-make-color-map): Rename local var ansi-color-map to map.
+
        * progmodes/prog-mode.el (prettify-symbols-mode)
        (global-prettify-symbols-mode, prog-mode): Remove autoload cookies.
 

=== modified file 'lisp/ansi-color.el'
--- a/lisp/ansi-color.el        2013-01-01 09:11:05 +0000
+++ b/lisp/ansi-color.el        2013-06-20 01:03:57 +0000
@@ -1,4 +1,4 @@
-;;; ansi-color.el --- translate ANSI escape sequences into faces
+;;; ansi-color.el --- translate ANSI escape sequences into faces -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
 
@@ -84,8 +84,9 @@
 This translation effectively colorizes strings and regions based upon
 SGR control sequences embedded in the text.  SGR (Select Graphic
 Rendition) control sequences are defined in section 8.3.117 of the
-ECMA-48 standard \(identical to ISO/IEC 6429), which is freely available
-as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>."
+ECMA-48 standard (identical to ISO/IEC 6429), which is freely available
+at <URL:http://www.ecma-international.org/publications/standards/Ecma-048.htm>
+as a PDF file."
   :version "21.1"
   :group 'processes)
 
@@ -119,7 +120,7 @@
   ["black" "red" "green" "yellow" "blue" "magenta" "cyan" "white"]
   "Colors used for SGR control sequences determining a color.
 This vector holds the colors used for SGR control sequences parameters
-30 to 37 \(foreground colors) and 40 to 47 (background colors).
+30 to 37 (foreground colors) and 40 to 47 (background colors).
 
 Parameter  Color
   30  40   black
@@ -234,14 +235,13 @@
   'font-lock-default-unfontify-region "24.1")
 
 ;; Working with strings
-(defvar ansi-color-context nil
+(defvar-local ansi-color-context nil
   "Context saved between two calls to `ansi-color-apply'.
 This is a list of the form (CODES FRAGMENT) or nil.  CODES
 represents the state the last call to `ansi-color-apply' ended
 with, currently a list of ansi codes, and FRAGMENT is a string
 starting with an escape sequence, possibly the start of a new
 escape sequence.")
-(make-variable-buffer-local 'ansi-color-context)
 
 (defun ansi-color-filter-apply (string)
   "Filter out all ANSI control sequences from STRING.
@@ -324,7 +324,8 @@
       (setq codes (ansi-color-apply-sequence escape-sequence codes)))
     ;; if the rest of the string should have a face, put it there
     (when codes
-      (put-text-property start (length string) 'font-lock-face 
(ansi-color--find-face codes) string))
+      (put-text-property start (length string)
+                         'font-lock-face (ansi-color--find-face codes) string))
     ;; save context, add the remainder of the string to the result
     (let (fragment)
       (if (string-match "\033" string start)
@@ -337,14 +338,13 @@
 
 ;; Working with regions
 
-(defvar ansi-color-context-region nil
+(defvar-local ansi-color-context-region nil
   "Context saved between two calls to `ansi-color-apply-on-region'.
 This is a list of the form (CODES MARKER) or nil.  CODES
 represents the state the last call to `ansi-color-apply-on-region'
 ended with, currently a list of ansi codes, and MARKER is a
 buffer position within an escape sequence or the last position
 processed.")
-(make-variable-buffer-local 'ansi-color-context-region)
 
 (defun ansi-color-filter-region (begin end)
   "Filter out all ANSI control sequences from region BEGIN to END.
@@ -461,7 +461,7 @@
   "Return a face with PROPERTY set to COLOR.
 PROPERTY can be either symbol `foreground' or symbol `background'.
 
-For Emacs, we just return the cons cell \(PROPERTY . COLOR).
+For Emacs, we just return the cons cell (PROPERTY . COLOR).
 For XEmacs, we create a temporary face and return it."
   (if (featurep 'xemacs)
       (let ((face (make-face (intern (concat color "-" (symbol-name property)))
@@ -530,9 +530,10 @@
     (nreverse codes)))
 
 (defun ansi-color-apply-sequence (escape-sequence codes)
-  "Apply ESCAPE-SEQ to CODES and return the new list of codes.
+  "Apply ESCAPE-SEQUENCE to CODES and return the new list of codes.
 
-ESCAPE-SEQ is an escape sequence parsed by `ansi-color-parse-sequence'.
+ESCAPE-SEQUENCE is an escape sequence parsed by
+`ansi-color-parse-sequence'.
 
 For each new code, the following happens: if it is 1-7, add it to
 the list of codes; if it is 21-25 or 27, delete appropriate
@@ -577,19 +578,19 @@
 
 The face definitions are based upon the variables
 `ansi-color-faces-vector' and `ansi-color-names-vector'."
-  (let ((ansi-color-map (make-vector 50 nil))
+  (let ((map (make-vector 50 nil))
         (index 0))
     ;; miscellaneous attributes
     (mapc
      (function (lambda (e)
-                 (aset ansi-color-map index e)
+                 (aset map index e)
                  (setq index (1+ index)) ))
      ansi-color-faces-vector)
     ;; foreground attributes
     (setq index 30)
     (mapc
      (function (lambda (e)
-                 (aset ansi-color-map index
+                 (aset map index
                       (ansi-color-make-face 'foreground
                                              (if (consp e) (car e) e)))
                  (setq index (1+ index)) ))
@@ -598,12 +599,12 @@
     (setq index 40)
     (mapc
      (function (lambda (e)
-                 (aset ansi-color-map index
+                 (aset map index
                       (ansi-color-make-face 'background
                                              (if (consp e) (cdr e) e)))
                  (setq index (1+ index)) ))
      ansi-color-names-vector)
-    ansi-color-map))
+    map))
 
 (defvar ansi-color-map (ansi-color-make-color-map)
   "A brand new color map suitable for `ansi-color-get-face'.
@@ -613,9 +614,9 @@
 numbers included in an SGR control sequences point to the correct
 foreground or background colors.
 
-Example: The sequence \033[34m specifies a blue foreground.  Therefore:
+Example: The sequence \\033[34m specifies a blue foreground.  Therefore:
      (aref ansi-color-map 34)
-          => \(foreground-color . \"blue\")")
+          => (foreground-color . \"blue\")")
 
 (defun ansi-color-map-update (symbol value)
   "Update `ansi-color-map'.


reply via email to

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