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.