GNU bug report logs -
#27985
[25.2] delete-indentation: restore correct point (and..) [PATCH INCLUDED]
Previous Next
Reported by: Boruch Baum <boruch_baum <at> gmx.com>
Date: Sun, 6 Aug 2017 15:23:02 UTC
Severity: minor
Tags: patch
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27985 in the body.
You can then email your comments to 27985 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#27985
; Package
emacs
.
(Sun, 06 Aug 2017 15:23:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Boruch Baum <boruch_baum <at> gmx.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 06 Aug 2017 15:23:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.16)
of 2017-07-11, modified by Debian
1] Function `delete-indentation' does not preserve point. The attached
patch fixes that for joining lines both forward and backward.
2] Also included is a wrapper function, `my-join-lines' that I'd like to
propose be included in emacs.
2.1] The wrapper function adds the ability to:
2.1.1] Act on regions;
2..1.2] Accept a numeric prefix argument for the number of lines to join
in either direction.
2.2] Lines of the wrapper function annotated on the right with the
string `; ┃' are only necessary if the proposed patch to function
`delete-indentation' is rejected.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
[delete-indentations.patch (text/x-diff, inline)]
(defun delete-indentation (&optional arg)
"Join this line to previous and fix up whitespace at join.
If there is a fill prefix, delete it from the beginning of this line.
With argument, join this line to following line."
(interactive "*P")
(let ((return-point (point))
(return-col (if (not arg) (- (point-at-eol) (point)))))
(beginning-of-line)
(if arg (forward-line 1))
(if (eq (preceding-char) ?\n)
(progn
(delete-region (point) (1- (point)))
;; If the second line started with the fill prefix,
;; delete the prefix.
(if (and fill-prefix
(<= (+ (point) (length fill-prefix)) (point-max))
(string= fill-prefix
(buffer-substring (point)
(+ (point) (length fill-prefix)))))
(delete-region (point) (+ (point) (length fill-prefix))))
(fixup-whitespace)
(if return-col
(goto-char (- (point-at-eol) return-col))
(goto-char return-point))))))
(defun my-join-lines (&optional arg)
"Join multiple lines, forward or backwards.
By default, joins forward one line (the standard `join-lines',
an alias for `delete-indentation', and bound by default to M-^,
joins backward by default).
With a prefix argument joins that number of lines in +/- direction.
With a region selected, joins all lines in the region."
(interactive "p")
(let ((return-point (point)) ; ┃
return-col) ; ┃
(if (use-region-p)
(let ((begin (region-beginning)))
(when (= (point) (region-end)) ; ┃
(setq return-col (- (point-at-eol) (point)))) ; ┃
(goto-char (region-end))
(while (> (point-at-bol) begin)
(join-line)))
(if arg
(if (> arg 0)
(dotimes (i arg) (join-line t))
(setq return-col (- (point-at-eol) (point))) ; ┃
(dotimes (i (- 0 arg)) (join-line)))
(join-line t)))
(if return-col ; ┃
(goto-char (- (point-at-eol) return-col)) ; ┃
(goto-char return-point)))) ; ┃
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#27985
; Package
emacs
.
(Mon, 24 Jun 2019 16:21:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 27985 <at> debbugs.gnu.org (full text, mbox):
Boruch Baum <boruch_baum <at> gmx.com> writes:
> 1] Function `delete-indentation' does not preserve point. The attached
> patch fixes that for joining lines both forward and backward.
I tested the command now, and it seems like it now preserves point. But
it's been completely rewritten from when this bug report was written...
> 2] Also included is a wrapper function, `my-join-lines' that I'd like to
> propose be included in emacs.
>
> 2.1] The wrapper function adds the ability to:
>
> 2.1.1] Act on regions;
>
> 2..1.2] Accept a numeric prefix argument for the number of lines to join
> in either direction.
>
> 2.2] Lines of the wrapper function annotated on the right with the
> string `; ┃' are only necessary if the proposed patch to function
> `delete-indentation' is rejected.
Looking at the new implementation, it seems like it does most of this
now, including the region stuff, so I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug closed, send any further explanations to
27985 <at> debbugs.gnu.org and Boruch Baum <boruch_baum <at> gmx.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 24 Jun 2019 16:21:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 23 Jul 2019 11:24:12 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 276 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.