0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-13 01:39:54 +00:00

org-src: Fix org-edit-src-code for empty blocks and block with just an empty line

* lisp/org-src.el (org-edit-src-code): Use marker with insertion type
t to track end and remove hack requiring delete from beg to (1- end).
This commit is contained in:
Le Wang 2012-11-18 13:39:51 +08:00 committed by Nicolas Goaziou
parent 8783b89311
commit 206257aa7e

View file

@ -215,11 +215,22 @@ buffer."
(setq org-edit-src-saved-temp-window-config (current-window-configuration)))
(let* ((mark (and (org-region-active-p) (mark)))
(case-fold-search t)
(info (org-edit-src-find-region-and-lang))
(info
;; If the src region consists in no lines, we insert a blank
;; line.
(let* ((temp (org-edit-src-find-region-and-lang))
(beg (nth 0 temp))
(end (nth 1 temp)))
(if (>= end beg) temp
(goto-char beg)
(insert "\n")
(org-edit-src-find-region-and-lang))))
(full-info (org-babel-get-src-block-info 'light))
(org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
(beg (make-marker))
(end (make-marker))
;; Move marker with inserted text for case when src block is
;; just one empty line, i.e. beg == end.
(end (copy-marker nil t))
(allow-write-back-p (null code))
block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
begline markline markcol line col transmitted-variables)
@ -689,10 +700,9 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
(kill-buffer buffer))
(goto-char beg)
(when allow-write-back-p
(delete-region beg (max beg (1- end)))
(delete-region beg (max beg end))
(unless (string-match "\\`[ \t]*\\'" code)
(insert code)
(delete-char 1))
(insert code))
(goto-char beg)
(if single (just-one-space)))
(if (memq t (mapcar (lambda (overlay)