all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Safronov <saf.dmitry@gmail.com>
To: 30209@debbugs.gnu.org
Subject: bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command
Date: Mon, 22 Jan 2018 12:19:00 +0100	[thread overview]
Message-ID: <CAGMQXKnMUFACU2OufcNto6RkUo8W=XvuYTBYCSe0XHxE7uxnUw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2496 bytes --]

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  <saf-dmitry@gmail.com>

           * outline.el (outline-headers-as-kill): Fix heading duplication.

[-- Attachment #2: Type: text/html, Size: 5351 bytes --]

             reply	other threads:[~2018-01-22 11:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 11:19 Dmitry Safronov [this message]
2018-02-18 15:11 ` bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command Noam Postavsky
2018-02-21  0:09 ` Noam Postavsky
2018-02-21  0:31   ` Noam Postavsky
2018-03-11  2:06 ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGMQXKnMUFACU2OufcNto6RkUo8W=XvuYTBYCSe0XHxE7uxnUw@mail.gmail.com' \
    --to=saf.dmitry@gmail.com \
    --cc=30209@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.