|
@@ -407,53 +407,54 @@ the language, a switch telling of the content should be in a single line."
|
|
|
(interactive)
|
|
|
(unless (string-match "\\`*Org Edit " (buffer-name (current-buffer)))
|
|
|
(error "This is not an sub-editing buffer, something is wrong..."))
|
|
|
- (let ((line (if (org-bound-and-true-p org-edit-src-force-single-line)
|
|
|
- 1
|
|
|
- (org-current-line)))
|
|
|
- (beg org-edit-src-beg-marker)
|
|
|
+ (let ((beg org-edit-src-beg-marker)
|
|
|
(end org-edit-src-end-marker)
|
|
|
(ovl org-edit-src-overlay)
|
|
|
(buffer (current-buffer))
|
|
|
(nindent org-edit-src-nindent)
|
|
|
- code)
|
|
|
- (goto-char (point-min))
|
|
|
- (if (looking-at "[ \t\n]*\n") (replace-match ""))
|
|
|
- (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))
|
|
|
- (when (org-bound-and-true-p org-edit-src-force-single-line)
|
|
|
- (goto-char (point-min))
|
|
|
- (while (re-search-forward "\n" nil t)
|
|
|
- (replace-match " "))
|
|
|
- (goto-char (point-min))
|
|
|
- (if (looking-at "\\s-*") (replace-match " "))
|
|
|
- (if (re-search-forward "\\s-+\\'" nil t)
|
|
|
- (replace-match "")))
|
|
|
- (when (org-bound-and-true-p org-edit-src-from-org-mode)
|
|
|
- (goto-char (point-min))
|
|
|
- (while (re-search-forward
|
|
|
- (if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
|
|
|
- (replace-match ",\\1")))
|
|
|
- (when (org-bound-and-true-p org-edit-src-picture)
|
|
|
- (untabify (point-min) (point-max))
|
|
|
- (goto-char (point-min))
|
|
|
- (while (re-search-forward "^" nil t)
|
|
|
- (replace-match ": ")))
|
|
|
- (when nindent
|
|
|
- (setq nindent (make-string (+ org-edit-src-content-indentation nindent)
|
|
|
- ?\ ))
|
|
|
- (goto-char (point-min))
|
|
|
- (while (re-search-forward "^" nil t)
|
|
|
+ code line)
|
|
|
+ (save-excursion
|
|
|
+ (goto-char (point-min))
|
|
|
+ (if (looking-at "[ \t\n]*\n") (replace-match ""))
|
|
|
+ (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match "")))
|
|
|
+ (setq line (if (org-bound-and-true-p org-edit-src-force-single-line)
|
|
|
+ 1
|
|
|
+ (org-current-line)))
|
|
|
+ (when (org-bound-and-true-p org-edit-src-force-single-line)
|
|
|
+ (goto-char (point-min))
|
|
|
+ (while (re-search-forward "\n" nil t)
|
|
|
+ (replace-match " "))
|
|
|
+ (goto-char (point-min))
|
|
|
+ (if (looking-at "\\s-*") (replace-match " "))
|
|
|
+ (if (re-search-forward "\\s-+\\'" nil t)
|
|
|
+ (replace-match "")))
|
|
|
+ (when (org-bound-and-true-p org-edit-src-from-org-mode)
|
|
|
+ (goto-char (point-min))
|
|
|
+ (while (re-search-forward
|
|
|
+ (if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
|
|
|
+ (replace-match ",\\1")))
|
|
|
+ (when (org-bound-and-true-p org-edit-src-picture)
|
|
|
+ (untabify (point-min) (point-max))
|
|
|
+ (goto-char (point-min))
|
|
|
+ (while (re-search-forward "^" nil t)
|
|
|
+ (replace-match ": ")))
|
|
|
+ (when nindent
|
|
|
+ (setq nindent (make-string (+ org-edit-src-content-indentation nindent)
|
|
|
+ ?\ ))
|
|
|
+ (goto-char (point-min))
|
|
|
+ (while (re-search-forward "^" nil t)
|
|
|
(replace-match nindent)))
|
|
|
- (setq code (buffer-string))
|
|
|
- (switch-to-buffer (marker-buffer beg))
|
|
|
- (kill-buffer buffer)
|
|
|
- (goto-char beg)
|
|
|
- (org-delete-overlay ovl)
|
|
|
- (delete-region beg end)
|
|
|
- (insert code)
|
|
|
- (goto-char beg)
|
|
|
- (goto-line (1- (+ (org-current-line) line)))
|
|
|
- (move-marker beg nil)
|
|
|
- (move-marker end nil)))
|
|
|
+ (setq code (buffer-string))
|
|
|
+ (switch-to-buffer (marker-buffer beg))
|
|
|
+ (kill-buffer buffer)
|
|
|
+ (goto-char beg)
|
|
|
+ (org-delete-overlay ovl)
|
|
|
+ (delete-region beg end)
|
|
|
+ (insert code)
|
|
|
+ (goto-char beg)
|
|
|
+ (goto-line (1- (+ (org-current-line) line)))
|
|
|
+ (move-marker beg nil)
|
|
|
+ (move-marker end nil)))
|
|
|
|
|
|
(defun org-edit-src-save ()
|
|
|
"Save parent buffer with current state source-code buffer."
|