mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-20 09:48:12 +02:00
Boxes.el: Check that boxes
v2.1.0 is available before using -q "(all)"
(#114)
v2.1.0 is required to run boxes-command-on-region interactively due to requiring support for "-q (all)". The other commands work on all versions.
This commit is contained in:
parent
d62637e6fa
commit
380e7814ac
30
doc/boxes.el
30
doc/boxes.el
@ -77,6 +77,9 @@
|
|||||||
:type '(alist :key-type symbol :value-type string)
|
:type '(alist :key-type symbol :value-type string)
|
||||||
:group 'boxes)
|
:group 'boxes)
|
||||||
|
|
||||||
|
(defconst boxes-minimum-version "2.1.0"
|
||||||
|
"Minimum required version of `boxes' to support querying the available box types.")
|
||||||
|
|
||||||
(defvar boxes-history nil
|
(defvar boxes-history nil
|
||||||
"Boxes types history.")
|
"Boxes types history.")
|
||||||
|
|
||||||
@ -87,12 +90,15 @@
|
|||||||
"List of types available to the current boxes implementation, nil if not set yet.")
|
"List of types available to the current boxes implementation, nil if not set yet.")
|
||||||
|
|
||||||
(defun boxes-types ()
|
(defun boxes-types ()
|
||||||
"Return the list of types available to the current boxes implementation."
|
"Return the list of types available to the current boxes implementation.
|
||||||
|
Signal error if a supported version of `boxes' is not available."
|
||||||
|
(condition-case nil
|
||||||
(or boxes-types-list
|
(or boxes-types-list
|
||||||
(setq boxes-types-list
|
(setq boxes-types-list
|
||||||
(let ((types (process-lines boxes-command "-q" "(all)")))
|
(let ((types (process-lines boxes-command "-q" "(all)")))
|
||||||
(mapcar (lambda(type) (replace-regexp-in-string " *\(alias\) *$" "" type))
|
(mapcar (lambda(type) (replace-regexp-in-string " *\(alias\) *$" "" type))
|
||||||
types)))))
|
types))))
|
||||||
|
(error (error "Please install Boxes %s or later" boxes-minimum-version))))
|
||||||
|
|
||||||
(defun boxes-default-type (mode)
|
(defun boxes-default-type (mode)
|
||||||
"Get the default box type for the given buffer major MODE."
|
"Get the default box type for the given buffer major MODE."
|
||||||
@ -113,12 +119,20 @@
|
|||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun boxes-command-on-region (start end type &optional remove)
|
(defun boxes-command-on-region (start end type &optional remove)
|
||||||
"Create or Remove boxes from a region.
|
"Create or Remove boxes from a region.
|
||||||
To create a box select a region, hit \\[boxes-command-on-region] & enter a box type.
|
|
||||||
Box type selection uses tab completion on the supported types.
|
To create a box select a region, hit \\[boxes-command-on-region]
|
||||||
To remove a box simply prefix a 1 to the call, eg
|
& enter a box type. Box type selection uses tab completion on
|
||||||
M-1 \\[boxes-command-on-region] will remove a box from a region.
|
the supported types.
|
||||||
When calling from Lisp, supply the region START & END and the box TYPE to
|
|
||||||
create a box. Specifying a non-nil value for REMOVE, removes the box."
|
To remove a box simply prefix a 1 to the call, eg M-1
|
||||||
|
\\[boxes-command-on-region] will remove a box from a region.
|
||||||
|
|
||||||
|
Note that interactive use requires `boxes' >= 2.1.0 to support
|
||||||
|
querying the supported types.
|
||||||
|
|
||||||
|
When calling from Lisp, supply the region START & END and the box
|
||||||
|
TYPE to create a box. Specifying a non-nil value for REMOVE,
|
||||||
|
removes the box."
|
||||||
(interactive (let ((string
|
(interactive (let ((string
|
||||||
(completing-read (format "Box type (%s): " boxes-default-type)
|
(completing-read (format "Box type (%s): " boxes-default-type)
|
||||||
(boxes-types) nil t nil 'boxes-history boxes-default-type)))
|
(boxes-types) nil t nil 'boxes-history boxes-default-type)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user