diff options
Diffstat (limited to 'lisp/misc.el')
-rw-r--r-- | lisp/misc.el | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/lisp/misc.el b/lisp/misc.el index d85f889ffd3..28c5d6e07f5 100644 --- a/lisp/misc.el +++ b/lisp/misc.el @@ -33,7 +33,9 @@ "Copy characters from previous nonblank line, starting just above point. Copy ARG characters, but not past the end of that line. If no argument given, copy the entire rest of the line. -The characters copied are inserted in the buffer before point." +The characters copied are inserted in the buffer before point. + +Also see the `duplicate-line' command." (interactive "P") (let ((cc (current-column)) n @@ -61,18 +63,41 @@ The characters copied are inserted in the buffer before point." (+ n (point))))))) (insert string))) +;;;###autoload +(defun duplicate-line (&optional n) + "Duplicate the current line N times. +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) + (unless (bolp) + (insert "\n")) + (dotimes (_ n) + (insert line "\n"))))) + ;; Variation of `zap-to-char'. ;;;###autoload -(defun zap-up-to-char (arg char) +(defun zap-up-to-char (arg char &optional interactive) "Kill up to, but not including ARGth occurrence of CHAR. +When run interactively, the argument INTERACTIVE is non-nil. Case is ignored if `case-fold-search' is non-nil in the current buffer. Goes backward if ARG is negative; error if CHAR not found. -Ignores CHAR at point." +Ignores CHAR at point. +If called interactively, do a case sensitive search if CHAR +is an upper-case character." (interactive (list (prefix-numeric-value current-prefix-arg) (read-char-from-minibuffer "Zap up to char: " - nil 'read-char-history))) - (let ((direction (if (>= arg 0) 1 -1))) + nil 'read-char-history) + t)) + (let ((direction (if (>= arg 0) 1 -1)) + (case-fold-search (if (and interactive (char-uppercase-p char)) + nil + case-fold-search))) (kill-region (point) (progn (forward-char direction) @@ -126,7 +151,7 @@ ripples outward, changing the flow of the eddy currents in the upper atmosphere. These cause momentary pockets of higher-pressure air to form, which act as lenses that deflect incoming cosmic rays, focusing them to strike the drive platter and flip the desired bit. -You can type `M-x butterfly C-M-c' to run it. This is a permuted +You can type \\`M-x butterfly C-M-c' to run it. This is a permuted variation of `C-x M-c M-butterfly' from url `https://xkcd.com/378/'." (interactive) (if (yes-or-no-p "Do you really want to unleash the powers of the butterfly? ") |