summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-12-06 10:45:35 +0100
committerBastien Guerry <bzg@altern.org>2013-12-06 10:45:35 +0100
commit487c74580cdab5417c29ccfbf3b66bffb32cc510 (patch)
tree6d5b0995721d6442d452f844f0e6c304882961d9
parent3a317abc23446ea8c5b4297f25315c08010ae871 (diff)
downloadorg-mode-487c74580cdab5417c29ccfbf3b66bffb32cc510.tar.gz
Fix bug when commenting source code.
* org.el (org-babel-do-in-edit-buffer): Declare. (org-babel-load-file, org-insert-comment) (org-comment-or-uncomment-region): Don't require 'ob-core. (org-mode-map): Remap `comment-dwim' to `org-comment-dwim'. (org-comment-dwim): New command. * ob-core.el (org-babel-do-in-edit-buffer): Make an autoload. See http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00154.html for a discussion about this bug.
-rw-r--r--lisp/ob-core.el1
-rw-r--r--lisp/org.el18
2 files changed, 12 insertions, 7 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d5fa78f..97a203f 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -972,6 +972,7 @@ with a prefix argument then this is passed on to
(org-edit-src-code)
(funcall swap-windows)))
+;;;###autoload
(defmacro org-babel-do-in-edit-buffer (&rest body)
"Evaluate BODY in edit buffer if there is a code block at point.
Return t if a code block was found at point, nil otherwise."
diff --git a/lisp/org.el b/lisp/org.el
index 590248d..21eb3a8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -124,6 +124,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-clock-sum-current-item "org-clock" (&optional tstart))
(declare-function org-babel-tangle-file "ob-tangle" (file &optional target-file lang))
+(declare-function org-babel-do-in-edit-buffer "ob-core" (&rest body))
(declare-function orgtbl-mode "org-table" (&optional arg))
(declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
(declare-function org-beamer-mode "ox-beamer" ())
@@ -201,7 +202,6 @@ and then loads the resulting file using `load-file'. With prefix
arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp
file to byte-code before it is loaded."
(interactive "fFile to load: \nP")
- (require 'ob-core)
(let* ((age (lambda (file)
(float-time
(time-subtract (current-time)
@@ -19215,6 +19215,7 @@ boundaries."
(org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
(org-defkey org-mode-map "\C-c#" 'org-update-statistics-cookies)
(org-defkey org-mode-map [remap open-line] 'org-open-line)
+(org-defkey org-mode-map [remap comment-dwim] 'org-comment-dwim)
(org-defkey org-mode-map [remap forward-paragraph] 'org-forward-paragraph)
(org-defkey org-mode-map [remap backward-paragraph] 'org-backward-paragraph)
(org-defkey org-mode-map "\C-m" 'org-return)
@@ -20502,6 +20503,13 @@ If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
(t
(open-line n))))
+(defun org-comment-dwim (arg)
+ (interactive "*P")
+ "Call `comment-dwim' within a source edit buffer if needed"
+ (if (org-in-src-block-p)
+ (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim))
+ (call-interactively #'comment-dwim)))
+
(defun org-return (&optional indent)
"Goto next table row or insert a newline.
Calls `org-table-next-row' or `newline', depending on context.
@@ -22602,9 +22610,7 @@ major mode."
(skip-chars-backward " \r\t\n")
(line-beginning-position))
(point))))
- (progn
- (require 'ob-core)
- (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim)))
+ (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim))
(beginning-of-line)
(if (looking-at "\\s-*$") (delete-region (point) (point-at-eol))
(open-line 1))
@@ -22628,9 +22634,7 @@ strictly within a source block, use appropriate comment syntax."
(skip-chars-backward " \r\t\n")
(line-beginning-position))
end)))
- (progn
- (require 'ob-core)
- (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim)))
+ (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim))
(save-restriction
;; Restrict region
(narrow-to-region (save-excursion (goto-char beg)