Fix positioning bug when returning from source code editing

This commit is contained in:
Carsten Dominik 2009-06-09 20:19:13 +02:00
parent 95a4be9088
commit a6449c0324
2 changed files with 45 additions and 42 deletions

View File

@ -1,6 +1,8 @@
2009-06-09 Carsten Dominik <carsten.dominik@gmail.com>
* org-src.el (org-src-mode): Renamed from `org-exit-edit-mode'.
(org-edit-src-exit): Better cursor positioning when returning from
editing.
* org-latex.el (org-export-latex-use-verb): New variable.
(org-export-latex-emph-format): Prefer \texttt over \verb when

View File

@ -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."