all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command
@ 2018-01-22 11:19 Dmitry Safronov
  2018-02-18 15:11 ` Noam Postavsky
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dmitry Safronov @ 2018-01-22 11:19 UTC (permalink / raw)
  To: 30209

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-11  2:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-22 11:19 bug#30209: Fix wrong behavior of 'outline-headers-as-kill' command Dmitry Safronov
2018-02-18 15:11 ` Noam Postavsky
2018-02-21  0:09 ` Noam Postavsky
2018-02-21  0:31   ` Noam Postavsky
2018-03-11  2:06 ` Noam Postavsky

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.