This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+tools/rebox
..
config.el
funcs.el
packages.el
README.org

Rebox layer

Description

This layer adds support for rebox2 package which is a minor-mode allowing to easily add ASCII text boxes to a buffer.

A nice video demonstration by the package author can be found here.

Features

  • Auto-wrap correctly in comments,
  • Auto-fill correctly in comments,
  • Boxes auto-adapt as text is inserted or deleted,
  • S-return to continue a comment on the next line,
  • Kill/yank within the box,
  • Apparently works well with ancient filladpt-mode (see authors video).

Install

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add rebox to the existing dotspacemacs-configuration-layers list in this file.

Configuration

Styles cycling

Box styles are identified by numbers, it is possible to cycle through a list of styles using SPC x b n. This list can be customized by setting the variable rebox-style-loop.

(setq rebox-style-loop '(71 72 73))

Text mode

As text mode usage could surprise some users (e.g., when they enter M-q to fill a paragraph) rebox is not enabled by default in text-mode. To enable it you need to set the layer variable rebox-enable-in-text-mode to t.

(setq-default dotspacemacs-configuration-layers '(
    (rebox :variables rebox-enable-in-text-mode t)))

Style Templates

Standard packaged templates

Comments

These templates are single line comments styles. A # is used here for illustration; however, it will work equally well if the comment character is different (e.g., lisp's ; comment character).

  #box-style 10

  # box style 11

  # box style 12 #
  # ------------ #

  # ------------ #
  # box style 13 #
  # ------------ #

  # box style 14 #
  ################

  ################
  # box style 15 #
  ################

  #,----
  #| box style 16
  #`----

  #,-------------
  #| box style 17
  #`-------------

  ##box style 20

  ## box style 21

  ## box style 22 ##
  ## ------------ ##

  ## ------------ ##
  ## box style 23 ##
  ## ------------ ##

  ## box style 24 ##
  ##################

  ##################
  ## box style 25 ##
  ##################

  ##,----
  ##| box style 26
  ##`----

  ##,-------------
  ##| box style 27
  ##`-------------

  ###box style 30

  # and so on repeating up to styles 5x which have 5 leading comment characters

Text Mode

  box style 111

  | box style 112 |
  +---------------+

  +---------------+
  | box style 113 |
  +---------------+

  | box style 114 |
  *===============*

  *===============*
  | box style 115 |
  *===============*

  -------------
  box style 116
  -------------

  | box style 121 |

  | box style 122 |
  `---------------'

  .---------------.
  | box style 123 |
  `---------------'

  | box style 124 |
  \===============/

  /===============\
  | box style 125 |
  \===============/

  ,----
  | box style 126
  `----

  ,--------------
  | box style 127
  `--------------

  ,----
  | box style 136
  `----

  ,--------------
  | box style 137
  `--------------

  | box style 141

  ** box style 142 *
  ******************

  ******************
  ** box style 143 *
  ******************

  X box style 144 X
  XXXXXXXXXXXXXXXXX

  XXXXXXXXXXXXXXXXX
  X box style 145 X
  XXXXXXXXXXXXXXXXX

C Mode

Note this mode is disabled for now due to bugs in rebox.

  /* box style 111 */

  /* box style 112 */
  /* ------------- */

  /* ------------- */
  /* box style 113 */
  /* ------------- */

  /* box style 114 */
  /* ============= */

  /* ============= */
  /* box style 115 */
  /* ============= */

  /*
     box style 221
   */

  /*          .
   | box style 222 |
   `--------------*/

  /*--------------.
  | box style 223 |
  `--------------*/

  /*              \
  | box style 224 |
  \==============*/

  /*==============\
  | box style 225 |
  \==============*/

  /*
   | box style 231
   */

  /*
   | box style 232 |
   *---------------*/

  /*---------------*
   | box style 233 |
   *---------------*/

  /* box style 234 */
  /*---------------*/

  /*---------------*/
  /* box style 235 */
  /*---------------*/

  /*
   * box style 241
   */

  /*               *
   * box style 242 *
   *****************/

  /*****************
   * box style 243 *
   *****************/

  /* box style 244 */
  /*****************/

  /*****************/
  /* box style 245 */
  /*****************/

  /****************//**
   * box style 246
   ********************/

Additional Templates

These templates are added by the Spacemacs layer.

  #
  # box style 71
  #

  # ------------
  # box style 72
  # ------------

  # ============
  # box style 73
  # ============

  #--------------
  # box style 74
  #--------------

  #--------------+
  # box style 75
  #--------------+

  #==============
  # box style 76
  #==============

  ##
  ## box style 81
  ##

  ## ------------
  ## box style 82
  ## ------------

  ## ============
  ## box style 83
  ## ============

  ##--------------
  ## box style 84
  ##--------------

  ##--------------+
  ## box style 85
  ##--------------+

  ##==============
  ## box style 86
  ##==============

Key bindings

Note: Use a numerical prefix argument to choose a specific style for instance 86 SPC x b b to use the style 86 above.

Keybinding Command
SPC x b > Move box to the right (point must be around left side of the box)
SPC x b < Move box to the left (point must be around left side of the box)
SPC x b b Draw next box defined in rebox-style-loop
SPC x b B Draw previous box defined in rebox-style-loop
SPC x b c Center box (point must be around left side of the box)
S-return rebox-indent-new-line