SiteMap Search ElispArea HowTo Glossary RecentChanges News Problems Suggestions
Eritrea, Independence Day

rebox2

Rebox2

Overview

LeWang’s fork of rebox.el that does seemless box editing and filling.

Comment blocks (consisting of whole line comments) are considered boxes, so you get all the filling and editing functionality in comments automatically.

Where is it?

github

Video walkthru

youtube

Discussion

LeWang – If you put your questions here, I’ll try to address them.

Cycle through styles

Hi Le, thanks for the package.

I find, though, quite inconvenient to mix the fill and commenting functionality. So I leave \M-q as suggested, but use \M-; to easy cycle through the styles I want.

With the following code \M-; ; ; cycles through rebox-comment-syles 3 times:

(defvar rebox-comment-styles '(21 25 13 111)
  "List of styles to use in cycling")
(make-variable-buffer-local 'rebox-comment-styles)
(global-set-key [(meta ?;)] 'rebox-comment-cycle)

(defun rebox-comment-always (style)
  (setq style (rebox-get-style-from-prefix-arg style :ask nil))
  (if (use-region-p)
      (progn
        (rebox-region (region-beginning)
                      (region-end)
                      :style style
                      :refill nil)
        (deactivate-mark))
    (rebox-comment :style style
                   :refill nil)))

(defun rebox-comment-cycle (&optional remove-comment)
  "Sycle through `rebox-comment-styles' and apply each style to the current block.
If bound to [\M-;], repeated invocation of [;] key cycles through
the list of styles. Any other input exits the loop."
  (interactive "P")
  (let* ((comment-auto-fill-only-comments nil)
           (styles rebox-comment-styles)
           (ev last-command-event)
           (com-char  (event-basic-type ev))
           st)
      (if (rebox-line-has-comment)
          (setq styles (cons 111 styles))) ;; first call removes the comment box
      (setq st (pop styles))
      (rebox-comment-always st)
      (while  (eq (event-basic-type (setq ev (read-event))) com-char)
        (unless styles
          (setq styles rebox-comment-styles))
        (setq st (pop styles))
        (rebox-comment-always st))
      (push ev unread-command-events)
      ))

As of 09/2011 the entry system of rebox2 has been revamped to be quite similar to the above. I’ll leave the code here because of the interesting read-event/push combo.

Doxygen-like comments

Hello and thanks for this useful package. I have made my own comment style for C++ like this:

"/************//**"
"    box123456    "
"****************/"

The problem I have found is that in order to move the box, say a bit to the right, I have to move each line individually. This does not happen with the other comment styles. Any ideas what is wrong? Thanks in advance!


CategoryComments