bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command


From: Dmitry Safronov
Subject: bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command
Date: Mon, 22 Jan 2018 12:19:00 +0100


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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]