File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -117,14 +117,24 @@ This command does the inverse of `fill-paragraph'."
117117 , rc/frame-transparency ))
118118 (set-frame-parameter nil 'alpha '(100 100 )))))
119119
120- (defun rc/duplicate-line ()
120+ (defun rc/duplicate-line (&optional count )
121121 " Duplicate current line"
122- (interactive )
123- (move-beginning-of-line 1 )
124- (kill-line )
125- (yank )
126- (newline )
127- (yank ))
122+ (interactive (list (or current-prefix-arg 1 )))
123+ (let ((cur-line (buffer-substring (point-at-bol ) (1+ (point-at-eol ))))
124+ (count (or count 1 )))
125+ (if (or (not (integerp count))
126+ (< count 0 ))
127+ (user-error " %S is not positive integer" count)
128+ (save-excursion
129+ (forward-line )
130+ (insert (cond
131+ ((= count 1 )
132+ cur-line)
133+ ((= count 0 )
134+ " " )
135+ (t (thread-last cur-line
136+ (make-list count)
137+ (apply 'concat )))))))))
128138
129139(global-set-key (kbd " C-," ) 'rc/duplicate-line )
130140
You can’t perform that action at this time.
0 commit comments