Skip to content

Commit

Permalink
Merge pull request #3 from conao3/refactor
Browse files Browse the repository at this point in the history
Fix package-lint/check-doc/byte-compiler errors
  • Loading branch information
conao3 committed Jun 3, 2020
2 parents 12b4c5d + a7595a2 commit 6627bc2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Expand Up @@ -5,11 +5,14 @@ before_install:
- evm install $EVM_EMACS --use --skip
- cask
env:
- EVM_EMACS=emacs-24.1-travis
- EVM_EMACS=emacs-24.2-travis
- EVM_EMACS=emacs-24.3-travis
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-25.1-travis
- EVM_EMACS=emacs-25.2-travis
- EVM_EMACS=emacs-25.3-travis
- EVM_EMACS=emacs-26.1-travis
- EVM_EMACS=emacs-26.2-travis
- EVM_EMACS=emacs-26.3-travis
script:
- emacs --version
- make test
31 changes: 17 additions & 14 deletions ansi.el
@@ -1,13 +1,13 @@
;;; ansi.el --- Turn string into ansi strings
;;; ansi.el --- Turn string into ansi strings -*- lexical-binding: t; -*-

;; Copyright (C) 2010-2013 Johan Andersson

;; Author: Johan Andersson <johan.rejeep@gmail.com>
;; Maintainer: Johan Andersson <johan.rejeep@gmail.com>
;; Version: 0.4.1
;; Keywords: color, ansi
;; Keywords: terminals 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.

Expand All @@ -28,18 +28,19 @@
;; 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)
(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)



Expand Down Expand Up @@ -89,6 +90,7 @@


(defun ansi--concat (&rest sequences)
"Concat string elements in SEQUENCES."
(apply 's-concat (-select 'stringp sequences)))

(defun ansi--code (effect)
Expand All @@ -110,8 +112,8 @@
(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."
`(ansi--cl-flet
"Shortcut names (without ansi- prefix) can be used in this BODY."
`(cl-flet
,(-map
(lambda (alias)
(let ((fn (intern (format "ansi-%s" (symbol-name alias)))))
Expand All @@ -124,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)))
Expand Down

0 comments on commit 6627bc2

Please sign in to comment.