aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el42
1 files changed, 25 insertions, 17 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index d4ae5ebb1f9..7878272ec90 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -593,25 +593,33 @@ When called from Lisp code, ARG may be a prefix string to copy."
593 (indent-to col 0) 593 (indent-to col 0)
594 (goto-char pos))) 594 (goto-char pos)))
595 595
596(defun delete-indentation (&optional arg) 596(defun delete-indentation (&optional arg beg end)
597 "Join this line to previous and fix up whitespace at join. 597 "Join this line to previous and fix up whitespace at join.
598If there is a fill prefix, delete it from the beginning of this line. 598If there is a fill prefix, delete it from the beginning of this
599With argument, join this line to following line." 599line. With prefix ARG, join the current line to the following line.
600 (interactive "*P") 600With the region active, join lines in the region. If both the
601argument is set and the region is active, the region is ignored."
602 (interactive "*P\nr")
603 (if arg (forward-line 1)
604 (if (use-region-p)
605 (goto-char end)))
601 (beginning-of-line) 606 (beginning-of-line)
602 (if arg (forward-line 1)) 607 (while (eq (preceding-char) ?\n)
603 (if (eq (preceding-char) ?\n) 608 (progn
604 (progn 609 (delete-region (point) (1- (point)))
605 (delete-region (point) (1- (point))) 610 ;; If the second line started with the fill prefix,
606 ;; If the second line started with the fill prefix, 611 ;; delete the prefix.
607 ;; delete the prefix. 612 (if (and fill-prefix
608 (if (and fill-prefix 613 (<= (+ (point) (length fill-prefix)) (point-max))
609 (<= (+ (point) (length fill-prefix)) (point-max)) 614 (string= fill-prefix
610 (string= fill-prefix 615 (buffer-substring (point)
611 (buffer-substring (point) 616 (+ (point) (length fill-prefix)))))
612 (+ (point) (length fill-prefix))))) 617 (delete-region (point) (+ (point) (length fill-prefix))))
613 (delete-region (point) (+ (point) (length fill-prefix)))) 618 (fixup-whitespace)
614 (fixup-whitespace)))) 619 (if (and beg
620 (not arg)
621 (< beg (point-at-bol)))
622 (beginning-of-line)))))
615 623
616(defalias 'join-line #'delete-indentation) ; easier to find 624(defalias 'join-line #'delete-indentation) ; easier to find
617 625