summaryrefslogtreecommitdiff
path: root/lisp/misc.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-06-22 15:55:19 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2022-06-22 16:03:46 +0200
commit47374d44167ce7a20d78c3c544434f389e0d726e (patch)
treedce8c8f0439c312353872822035559c5e0b8b671 /lisp/misc.el
parent55c2102560751ae05c98fd04120abcf4595d2a57 (diff)
downloademacs-47374d44167ce7a20d78c3c544434f389e0d726e.tar.gz
emacs-47374d44167ce7a20d78c3c544434f389e0d726e.tar.bz2
emacs-47374d44167ce7a20d78c3c544434f389e0d726e.zip
duplicate-line: fix optional argument and add test (bug#46621)
The test assumes that the current semantics are intended and desired, which may or may not be true, but it's better than not having any at all. * lisp/misc.el (duplicate-line): Don't crash if called with no argument. * test/lisp/misc-tests.el (misc--duplicate-line): New test.
Diffstat (limited to 'lisp/misc.el')
-rw-r--r--lisp/misc.el2
1 files changed, 2 insertions, 0 deletions
diff --git a/lisp/misc.el b/lisp/misc.el
index 3fb30e5372f..8a01b51c6d3 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -69,6 +69,8 @@ Also see the `duplicate-line' command."
Interactively, N is the prefix numeric argument, and defaults to 1.
Also see the `copy-from-above-command' command."
(interactive "p")
+ (unless n
+ (setq n 1))
(let ((line (buffer-substring (line-beginning-position) (line-end-position))))
(save-excursion
(forward-line 1)