From 21c6148bbe60c278abfb0f035c15c030ac0582c6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 15 Oct 2016 12:31:25 +0200 Subject: [PATCH] Handle comments in source blocks with `comment-line' * lisp/org.el (org-comment-or-uncomment-region): Caller is not necessarily `comment-dwim'. Also handle `comment-line'. Reported-by: Xebar Saram --- lisp/org.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 732f7e01f..1f0680a9f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -23526,7 +23526,13 @@ strictly within a source block, use appropriate comment syntax." (skip-chars-backward " \r\t\n") (line-beginning-position)) end))) - (org-babel-do-in-edit-buffer (call-interactively 'comment-dwim)) + ;; Translate region boundaries for the Org buffer to the source + ;; buffer. + (let ((offset (- end beg))) + (save-excursion + (goto-char beg) + (org-babel-do-in-edit-buffer + (comment-or-uncomment-region (point) (+ offset (point)))))) (save-restriction ;; Restrict region (narrow-to-region (save-excursion (goto-char beg)