Emacs - 用字符 X 填充一行直到 Y 列

Emacs - fill a line with character X up to column Y

是否有 Emacs 命令可以 "fill" 具有特定字符的行到指定的列?基本上等同于 this question,除了使用 Emacs 而不是 Vim。

例如,假设我开始输入如下所示的行:

/* -- Includes
/* -- Procedure Prototypes
/* -- Procedures 

我想要一个自动用破折号填充行的其余部分(直到我可以指定的列)的命令,而不管光标当前位于哪一列。

/* -- Includes -----------------------------------------------------
/* -- Procedure Prototypes -----------------------------------------
/* -- Procedures ---------------------------------------------------

谢谢。抱歉,如果有人问过这个问题,我找不到 Google.

的任何内容

这里有一些应该有用的东西:

(defun fill-to-end ()
  (interactive)
  (save-excursion
    (end-of-line)
    (while (< (current-column) 80)
      (insert-char ?-))))

在当前行末尾追加-个字符,直到第80列。如果要指定字符,应改为

(defun fill-to-end (char)
  (interactive "cFill Character:")
  (save-excursion
    (end-of-line)
    (while (< (current-column) 80)
      (insert-char char))))
(defun char-fill-to-col (char column &optional start end)
  "Fill region with CHAR, up to COLUMN."
  (interactive "cFill with char: \nnto column: \nr")
  (let ((endm  (copy-marker end)))
    (save-excursion
      (goto-char start)
      (while (and (not (eobp))  (< (point) endm))
        (end-of-line)
        (when (< (current-column) column)
          (insert (make-string (- column (current-column)) char)))
        (forward-line 1)))))

(defun dash-fill-to-col (column &optional start end)
  "Fill region with dashes, up to COLUMN."
  (interactive "nFill with dashes up to column: \nr")
  (char-fill-to-col ?- column start end))