From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#27985: [25.2] delete-indentation: restore correct point (and..) [PATCH INCLUDED] Date: Sun, 6 Aug 2017 11:22:20 -0400 Message-ID: <20170806152220.jtziel2qf6swtce5@E15-2016.optimum.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5ijnmfhkk2f6cfvj" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502032998 2892 195.159.176.226 (6 Aug 2017 15:23:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 6 Aug 2017 15:23:18 +0000 (UTC) User-Agent: NeoMutt/20170609 (1.8.3) To: 27985@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 06 17:23:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deNOY-0000LF-EQ for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Aug 2017 17:23:10 +0200 Original-Received: from localhost ([::1]:33469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deNOe-0001yj-Ij for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Aug 2017 11:23:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deNOT-0001x6-Rf for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deNOQ-000261-MW for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1deNOQ-00025t-IJ for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1deNOQ-0000SM-CJ for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Aug 2017 15:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27985 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Reporting Original-Received: via spool by submit@debbugs.gnu.org id=B.15020329671714 (code B ref -1); Sun, 06 Aug 2017 15:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Aug 2017 15:22:47 +0000 Original-Received: from localhost ([127.0.0.1]:44870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deNOB-0000RY-Fz for submit@debbugs.gnu.org; Sun, 06 Aug 2017 11:22:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1deNO8-0000RH-VX for submit@debbugs.gnu.org; Sun, 06 Aug 2017 11:22:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deNO2-0001nC-HQ for submit@debbugs.gnu.org; Sun, 06 Aug 2017 11:22:39 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:40326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1deNO2-0001n5-Em for submit@debbugs.gnu.org; Sun, 06 Aug 2017 11:22:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deNO1-0001tQ-0q for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:22:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deNNx-0001ko-Sm for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:22:37 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:49691) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1deNNx-0001k4-Fs for bug-gnu-emacs@gnu.org; Sun, 06 Aug 2017 11:22:33 -0400 Original-Received: from E15-2016.optimum.net ([108.6.168.221]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MY7ZA-1e9Bvp1c3c-00UuXU for ; Sun, 06 Aug 2017 17:22:29 +0200 Content-Disposition: inline X-Provags-ID: V03:K0:02UoSxg5wDyPpfPxqx4GvWD42aH6Ro2iC67oISK1BJln5ZV0uj/ QfpC0jWoAmFfXsa5iYheK05f9WavjQRtfL85NFAY3wW9UkAoVmMnFgN4Daw6nboUTumsZBu X9F64mUWFjtGw3eW79R1IDIPJC6plqKaR44mwBLpmBgSJ8rLFsG379RzR1f2a0I4LSN6QSb 4kIeKrbxy9o8yjoUSRtCQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:upaUzKcEMTM=:1TThWF/QfSvxhO2P1aNfn9 X6qcDd1sYr2c2Nn7fhcwkdHRb/X8y54mwJe5y2r3h1Q90dH83WCuQeOrTr9EVs2GDufwh4Knd ceGHpzsx+5JttEn+Gil9qrfl4FktRitifKFS73AVQ94phYtx+r3MVIHF2resqzDfOhYGx3q7g WjID4gXlv7IGk2qUUfUuINjUfrHxyPxXBMJOzWKsdONspHQG6AsQmtwRFX7/X63Yfglfwbsls zO0Q3Qb662G9p3DsA9Nj42Q9/s+uzJ2Y2+gZizXhuymtoP+kWFZp9bitCyQ94XgvAe8438M+E fIOgj47UFDHvDOargZZfgFEa1Ua6U6073mnnWyKVrvRhTTICsokdGWSRDzcdXU1n1ATDNfPHd SKI6XLwmOyZO//Z87c8erDc0owhrfho3Hc5kXfodGkS7Aa0o5S11vhvwnAtdC3EMznyl9IEcP MBlYxLL61QNXj9tsP+BMpv2WlT80P3hrfDp5ewAh9n035iWwwrWjn7d8IlabqbO4nzHvZFUXd qWCDgEE8UM8Mh895/tct3WQEGsUIW15u27DLXmC4vBgHFtEwSbws5OZK3gvBO10RZAyi8s2uA 9135sj+Z/VXOV+gngr+hlDgIArmgLHVHTMiwmCiVtPAB2OOVlPbrlSTI480Yl/HYcLvJ+289K eBL6DLoyGNal8uAX7Saow+Aj292LVfEc7lHztxOjUcUWjMZ1ttWH0KlVSPd6pddEUu83mRXpA Rfn0pMd3sZ3ggNRUYuC8tYg5EiiBkpkEGbzbY6NrXiqMVodX3F/ScfGJsB/8ienb9btAGTiZ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135496 Archived-At: --5ijnmfhkk2f6cfvj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 --5ijnmfhkk2f6cfvj Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename="delete-indentations.patch" Content-Transfer-Encoding: 8bit (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)))) ; ┃ --5ijnmfhkk2f6cfvj--