dup-line(2)
コンプリーション - 象徴ヶ淵で作ったものだが、もっと単純に、現在の桁まで一致する行をコピーする挙動にした。以前は、ちょっとずつ変化を付けた場合でも補完できるようにと考えていたが、そのように使うことが少なかった。むしろ今回の挙動の方が良かったと思うことが多かったので変えてみた。
(defun dup-line () (interactive) (labels ((indent () (buffer-substring (save-excursion (progn (goto-bol) (point))) (point)))) (let ((cur-indent (indent)) (column (current-column))) (multiple-value-bind (from to) (save-excursion (values (while (backward-line) (goto-column column) (if (equal (indent) cur-indent) (return (point)))) (progn (scan-buffer "[ -]\\|$" :regexp t :tail t) (point)))) (if from (dolist (x (coerce (buffer-substring from to) 'list)) (overwrite-char x)))))))