 ;;; -------------- -------------------------------------------------------
 ;;; C-c =          `bde-insert-define-class-header'
 ;;; C-c -          `bde-insert-declare-class-header'
-;;; C->            `bde-aligh-right-after-point': align text after cursor
-;;;                to the right (for // RETURN or // LOCK)
+;;; C->            `bde-aligh-right-after-point': align text after point
+;;;                to the right. If line ends with a comment such as // RETURN
+;;;                or // LOCK, align the comment.
 ;;; C-c i          `bde-insert-redundant-include-guard'
 ;;; C-c a          `bde-align-functions-arguments'
+;;; C-c f          `bde-align-funcall'
 ;;;
 ;;; Aligh right after point:
 ;;; Before (cursor anywhere after semi-colon):

;;; After:
;;;     return x;                                     // RETURN
;;;
;;; Insert redundant include guard (cursor must be on the line):
;;; Before:
;;;     #include <bsl_iostream.h>
;;; After:

                (return nil)))
         (setq erase-hint nil))))))

(defun bde-guess-class-name ()
  "Return the name of the class or struct that is defined
immediately after the cursor (skipping any previous spaces and
newlines). Return nil if there isn't any struct or class defined."
  (save-excursion
    (beginning-of-line)
    (when (forward-word)
      (backward-word)
      (when (re-search-forward "^\\(class\\|struct\\) " (point-at-eol) t)
        (concat (match-string 1) " " (current-word))))))

(defun bde-insert-define-class-header ()
  "Mini-mode for creating a BDE-style class definition
header (e.g. ===). Exit the mode with enter, or anything that is
not a character, backspace, delete, left or right."
  (interactive)
  (let ((class-name (bde-guess-class-name)))
    (cond (class-name
           (cl-flet ((insert-bar (n)
                       (insert "// ")
                       (dotimes (i n)
                         (insert "="))
                       (insert "\n")))
             (insert-bar (string-width class-name))
             (insert "// " class-name "\n")
             (insert-bar (string-width class-name))
             (previous-line 3)
             (center-line 3)
             ))
          (t
           (bde-insert-class-header ?=)))))

(defun bde-insert-declare-class-header ()
  "Mini-mode for creating a BDE-style class implementation header (e.g. ---).
