From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Safronov Newsgroups: gmane.emacs.bugs Subject: bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command Date: Mon, 22 Jan 2018 12:19:00 +0100 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c095610cfd50a05635b98aa" X-Trace: blaine.gmane.org 1516637526 2506 195.159.176.226 (22 Jan 2018 16:12:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 22 Jan 2018 16:12:06 +0000 (UTC) To: 30209@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 22 17:12:02 2018 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 1edehL-0008Gi-WC for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Jan 2018 17:11:52 +0100 Original-Received: from localhost ([::1]:50528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edejM-000828-Cw for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Jan 2018 11:13:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edehY-0006YE-LI for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 11:12:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edehX-0001uo-9U for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 11:12:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edehX-0001ub-4E for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 11:12:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1edehW-0000IY-V2 for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 11:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Safronov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Jan 2018 16:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 30209 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15166375221134 (code B ref -1); Mon, 22 Jan 2018 16:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jan 2018 16:12:02 +0000 Original-Received: from localhost ([127.0.0.1]:38333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edehV-0000I8-GK for submit@debbugs.gnu.org; Mon, 22 Jan 2018 11:12:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eda8C-0008Cl-8G for submit@debbugs.gnu.org; Mon, 22 Jan 2018 06:19:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eda85-0002qe-Q1 for submit@debbugs.gnu.org; Mon, 22 Jan 2018 06:19:11 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eda85-0002qY-Lg for submit@debbugs.gnu.org; Mon, 22 Jan 2018 06:19:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eda84-0001Cq-7b for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 06:19:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eda7x-0002o0-Tx for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 06:19:08 -0500 Original-Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:45696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eda7x-0002nf-NB for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2018 06:19:01 -0500 Original-Received: by mail-oi0-x22e.google.com with SMTP id j129so5644456oib.12 for ; Mon, 22 Jan 2018 03:19:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=KMbF9xxvBhplsB1oMhpSfnGkli06ycRHJ3dwCVYcPNk=; b=eBknbzIP/Sqt7aHUmZApWKZNe7LqUDHxcPWRm/9QQjZqn1/tpLW1tIAvsRZGURy8l0 C2Nc9tiveFiNkRmuDSixcwiJrVBA3yK2iv9nF0phQCdLuQKvAbkcolKcIGExeVgkoMN8 qm2DEVs9m9vSnCj4OcYaqBoq/oqoH88IjT9PJCrQnHPlvhx6a+hjruhiEsujYLrA81zk IYlQXBQ11kWZA2VwGlBjkFn6/rSnzQfwPB01M+iZH96k9G0EH1vvALV1TmULuNgOTVaw 34ZZTeGobDsxA5wNvrr27DMA0aC/5zYDbKIdCVMbC+OA//7GFvSMsC/AELDPC0K0B2Vh z1ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=KMbF9xxvBhplsB1oMhpSfnGkli06ycRHJ3dwCVYcPNk=; b=l3l8dE93YWKMgsNo0JiG+IC68phd5SMDiG0KIc6wW24bLW3X2UZa9AOMrNKgFmV5QA GidfJvAD5Gz5crz1vOf1UtW+/PdQ9ZRK6sngriPVyCVcZg+iiuE/8+PKknIIZdEGfCOX m3mHAH4ojlOCMj1bE4NAgQfoBW8kuiVhQp0gV3zTc2ZHmni0fjDECZPEODapWE5mAf4F 80fzZW95Dd3D9zLB5p2VuG2Q8U4UEx1+MyDkZ9OB2YZMs5dfADbQTPtn8apYh3pwiECK tzGRHZxPeHlShtZ0R9Z6bVIvi2PdmOWsOdz5ik5hRHQtpbu1XVcMM8s5EerjDrndHn6w /7Vw== X-Gm-Message-State: AKwxytfM9e3C1NT7M/3+gh8XpRghN39e2Nbol16dlVy8zIQl60pcJ09Z obdSoJJGNgjH99fDtZTPNAj6aivhTB7S2k87ZDWlNg== X-Google-Smtp-Source: AH8x2256bnSZR+t2Gv4SZQZheqBIJ0RsVjasPWdGq5ksSXDHiboyM5cI2ALjQYDzCl1LL8wBIRX9gODOkYTdqy+9F8M= X-Received: by 10.202.240.2 with SMTP id o2mr3797278oih.145.1516619940483; Mon, 22 Jan 2018 03:19:00 -0800 (PST) Original-Received: by 10.157.44.244 with HTTP; Mon, 22 Jan 2018 03:19:00 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Mon, 22 Jan 2018 11:12:00 -0500 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:142381 Archived-At: --94eb2c095610cfd50a05635b98aa Content-Type: text/plain; charset="UTF-8" Problem: Issuing 'outline-headers-as-kill' command in Outline mode on following region * Heading 1 ** Heading 2 *** Heading 3 leads to duplication of the first heading in the current buffer when region starts on this heading: * Heading 1* Heading 1 ** Heading 2 *** Heading 3 Following patch will fix this behavior: --- outline.el 2018-01-22 11:29:20.563650997 +0100 +++ outline_new.el 2018-01-22 11:35:00.959648171 +0100 @@ -1100,28 +1100,26 @@ (defun outline-headers-as-kill (beg end) (save-restriction (narrow-to-region beg end) (goto-char (point-min)) - (let ((buffer (current-buffer)) - start end) - (with-temp-buffer - (with-current-buffer buffer - ;; Boundary condition: starting on heading: - (when (outline-on-heading-p) - (outline-back-to-heading) - (setq start (point) - end (progn (outline-end-of-heading) - (point))) - (insert-buffer-substring buffer start end) - (insert "\n\n"))) - (let ((temp-buffer (current-buffer))) - (with-current-buffer buffer - (while (outline-next-heading) - (unless (outline-invisible-p) - (setq start (point) - end (progn (outline-end-of-heading) (point))) - (with-current-buffer temp-buffer - (insert-buffer-substring buffer start end) - (insert "\n\n")))))) - (kill-new (buffer-string))))))) + (let ((buffer (current-buffer)) start end) + (with-temp-buffer + (let ((temp-buffer (current-buffer))) + (with-current-buffer buffer + ;; Boundary condition: starting on heading: + (when (outline-on-heading-p) + (outline-back-to-heading) + (setq start (point) + end (progn (outline-end-of-heading) (point))) + (with-current-buffer temp-buffer + (insert-buffer-substring buffer start end) + (insert "\n\n"))) + (while (outline-next-heading) + (unless (outline-invisible-p) + (setq start (point) + end (progn (outline-end-of-heading) (point))) + (with-current-buffer temp-buffer + (insert-buffer-substring buffer start end) + (insert "\n\n")))))) + (kill-new (buffer-string))))))) (provide 'outline) (provide 'noutline) ChangeLog entry: 2018-01-22 Dmitry Safronov * outline.el (outline-headers-as-kill): Fix heading duplication. --94eb2c095610cfd50a05635b98aa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Problem:

Issu= ing 'outline-headers-as-kill' command in Outline mode on following = region


* Heading 1

** Heading 2

*** Heading 3

=

leads to duplication of the first heading in the = current buffer when region starts on this heading:


* Heading 1* Heading 1


<= div>
** Heading 2

*** Heading 3


Following patch will fix this behavior:=


--- outline.el 2018-01-22 11:29:20.5636= 50997 +0100
+++ outline_new.el 2018-01-22 11:35:00.959648171 +0100
@@ -1100,28 +1100,26 @@ (defun outline-headers-as-kill (beg end)
=C2=A0 =C2=A0 =C2=A0(save-restriction
=C2=A0 =C2=A0 =C2=A0= =C2=A0(narrow-to-region beg end)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(got= o-char (point-min))
- =C2=A0 =C2=A0 =C2=A0(let ((buffer (current-= buffer))
- =C2=A0 =C2=A0start end)
- (with-temp-buffer
- = =C2=A0(with-current-buffer buffer
- =C2=A0 =C2=A0;; Boundary conditio= n: starting on heading:
- =C2=A0 =C2=A0(when (outline-on-heading-p)
- <= /span> =C2=A0 =C2=A0 =C2=A0(outline-back-to-heading)
- =C2=A0 =C2=A0 = =C2=A0(setq start (point)
- =C2=A0 =C2=A0end (progn (outline-end-of-= heading)
- =C2=A0 =C2=A0 =C2=A0 (point)))
- =C2=A0 =C2=A0 =C2= =A0(insert-buffer-substring buffer start end)
- =C2=A0 =C2=A0 =C2=A0(= insert "\n\n")))
- =C2=A0(let ((temp-buffer (current-buffer= )))
- =C2=A0 =C2=A0(with-current-buffer buffer
- =C2=A0 =C2=A0 = =C2=A0(while (outline-next-heading)
- (unless (outline-invisible-p)
- = =C2=A0(setq start (point)
- end (progn (outline-end-of-headi= ng) (point)))
- =C2=A0(with-current-buffer temp-buffer
- =C2= =A0 =C2=A0(insert-buffer-substring buffer start end)
- =C2=A0 =C2=A0= (insert "\n\n"))))))
- =C2=A0(kill-new (buffer-string))))))= )
+ =C2=A0 =C2=A0 =C2=A0(let ((buffer (current-buffer)) start end= )
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-temp-buffer
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((temp-buffer (current-buffer)))
<= div>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-current-buffer buffer<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Boundary con= dition: starting on heading:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0(when (outline-on-heading-p)
+ =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(outline-back-to-heading)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq start (point)<= /div>
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0end (progn (outline-end-of-heading) (point)))
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-current-buffer te= mp-buffer
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(insert-buffer-substring buffer start end)
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert "\n\n"= ;)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (ou= tline-next-heading)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(unless (outline-invisible-p)
+ =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq start (point)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0end (progn (outline-end-of-heading) (point)))
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-current-buffer= temp-buffer
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(insert-buffer-substring buffer start end)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(inser= t "\n\n"))))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(kil= l-new (buffer-string)))))))
=C2=A0
=C2=A0(provide '= outline)
=C2=A0(provide 'noutline)

<= br>
ChangeLog entry:

2018-01-22 =C2=A0Dm= itry Safronov =C2=A0<saf-dmitry@= gmail.com>

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0* outline.el (outline-headers-as-kill): Fix heading duplication.<= /div>

--94eb2c095610cfd50a05635b98aa--