From bd9076cc360ac3880879975cf0721f8c24c91aec Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 2 Jun 2020 15:22:40 +0900 Subject: [PATCH 1/5] enable lexical-binding, require Emacs 24.4 --- ansi.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansi.el b/ansi.el index 644c1e5..9bbaa5e 100644 --- a/ansi.el +++ b/ansi.el @@ -1,4 +1,4 @@ -;;; ansi.el --- Turn string into ansi strings +;;; ansi.el --- Turn string into ansi strings -*- lexical-binding: t; -*- ;; Copyright (C) 2010-2013 Johan Andersson @@ -7,7 +7,7 @@ ;; Version: 0.4.1 ;; Keywords: color, ansi ;; URL: http://github.com/rejeep/ansi -;; Package-Requires: ((s "1.6.1") (dash "1.5.0")) +;; Package-Requires: ((emacs "24.4") (s "1.6.1") (dash "1.5.0")) ;; This file is NOT part of GNU Emacs. From 59344ae23b12d16224f786c483471bb0fc81bbe4 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 2 Jun 2020 15:23:41 +0900 Subject: [PATCH 2/5] remove outdated complement --- ansi.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ansi.el b/ansi.el index 9bbaa5e..3e3d75e 100644 --- a/ansi.el +++ b/ansi.el @@ -32,14 +32,7 @@ (require 'dash) (require 's) - -(when (version<= "24.3" emacs-version) - (require 'cl-lib)) - -;; Compatability alias for versions before cl-flet was introduced. -(defalias 'ansi--cl-flet (if (version<= "24.3" emacs-version) - 'cl-flet - 'flet)) +(require 'cl-lib) @@ -111,7 +104,7 @@ (defmacro with-ansi (&rest body) "In this block shortcut names (without ansi- prefix) can be used." - `(ansi--cl-flet + `(cl-flet ,(-map (lambda (alias) (let ((fn (intern (format "ansi-%s" (symbol-name alias))))) From 4dab8695fb7b4bcffdab0798dc08f2d412b16ad0 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 2 Jun 2020 15:26:20 +0900 Subject: [PATCH 3/5] add commentary section --- ansi.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ansi.el b/ansi.el index 3e3d75e..de81c93 100644 --- a/ansi.el +++ b/ansi.el @@ -28,6 +28,14 @@ ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. +;;; Commentary: + +;; Turns simple strings to ansi strings. + +;; Turning a string into an ansi string can be to add color to a +;; text, add color in the background of a text or adding a style, +;; such as bold, underscore or italic. + ;;; Code: (require 'dash) From c9b79b4f92cba135419d3aac02e1f392ab918951 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 2 Jun 2020 15:27:38 +0900 Subject: [PATCH 4/5] add terminals to keywords meta information --- ansi.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansi.el b/ansi.el index de81c93..62ed5eb 100644 --- a/ansi.el +++ b/ansi.el @@ -5,7 +5,7 @@ ;; Author: Johan Andersson ;; Maintainer: Johan Andersson ;; Version: 0.4.1 -;; Keywords: color, ansi +;; Keywords: terminals color ansi ;; URL: http://github.com/rejeep/ansi ;; Package-Requires: ((emacs "24.4") (s "1.6.1") (dash "1.5.0")) From f0174a6027e3aadee7bf7c6a680b4f894dfaae08 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 2 Jun 2020 15:30:28 +0900 Subject: [PATCH 5/5] add some comments to satisfy checkdoc --- ansi.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ansi.el b/ansi.el index 62ed5eb..f8ca738 100644 --- a/ansi.el +++ b/ansi.el @@ -90,6 +90,7 @@ (defun ansi--concat (&rest sequences) + "Concat string elements in SEQUENCES." (apply 's-concat (-select 'stringp sequences))) (defun ansi--code (effect) @@ -111,7 +112,7 @@ (apply 'ansi-apply (cons ',effect (cons format-string objects)))))) (defmacro with-ansi (&rest body) - "In this block shortcut names (without ansi- prefix) can be used." + "Shortcut names (without ansi- prefix) can be used in this BODY." `(cl-flet ,(-map (lambda (alias) @@ -125,7 +126,8 @@ ,(cons 'ansi--concat body))) (defun ansi-apply (effect-or-code format-string &rest objects) - "Apply EFFECT-OR-CODE to text." + "Apply EFFECT-OR-CODE to text. +FORMAT-STRING and OBJECTS are processed same as `apply'." (let ((code (if (numberp effect-or-code) effect-or-code (ansi--code effect-or-code)))