aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorƁukasz Stelmach2019-03-15 22:06:16 +0100
committerEli Zaretskii2019-03-22 11:47:36 +0300
commit8fa94a1ecc18a41ca2738f438b3fbc817c9fdc82 (patch)
tree8b95453244ce2e7a65e252aa8140786bb8bce140 /lisp
parent09d746dad36e4780d379f975a84b1b076da78c50 (diff)
downloademacs-8fa94a1ecc18a41ca2738f438b3fbc817c9fdc82.tar.gz
emacs-8fa94a1ecc18a41ca2738f438b3fbc817c9fdc82.zip
If the region is active, join all the lines it spans
* lisp/simple.el (delete-indentation): Join lines in the active region. (Bug#34796) * doc/misc/org.texi: Describe the arguments of delete-indentation. * etc/NEWS: Mention region support in delete-indentation.
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