Przeglądaj źródła

Merge branch 'ded-org-src' of git://repo.or.cz/org-mode/babel

Carsten Dominik 15 lat temu
rodzic
commit
c879026b49
1 zmienionych plików z 11 dodań i 2 usunięć
  1. 11 2
      lisp/org-src.el

+ 11 - 2
lisp/org-src.el

@@ -148,6 +148,12 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
 (defvar org-edit-src-overlay nil)
 (defvar org-edit-src-block-indentation nil)
 
+(defvar org-src-ask-before-returning-to-edit-buffer t
+  "If nil, when org-edit-src code is used on a block that already
+  has an active edit buffer, it will switch to that edit buffer
+  immediately; otherwise it will ask whether you want to return
+  to the existing edit buffer.")
+
 (define-minor-mode org-src-mode
   "Minor mode for language major mode buffers generated by org.
 This minor mode is turned on in two situations:
@@ -191,6 +197,7 @@ the edited version."
 	(error "No such language mode: %s" lang-f))
       (org-goto-line line)
       (if (and (setq buffer (org-edit-src-find-buffer beg end))
+	       org-src-ask-before-returning-to-edit-buffer
 	       (y-or-n-p "Return to existing edit buffer? [n] will revert changes: "))
 	  (switch-to-buffer buffer)
 	(when buffer
@@ -229,6 +236,7 @@ the edited version."
 	(when org-mode-p
 	  (goto-char (point-min))
 	  (while (re-search-forward "^," nil t)
+	    (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent)))
 	    (replace-match "")))
 	(org-goto-line (1+ (- line begline)))
 	(org-move-to-column
@@ -463,7 +471,7 @@ the language, a switch telling if the content should be in a single line."
 	 (total-nindent (+ (or org-edit-src-block-indentation 0)
 			   org-edit-src-content-indentation))
 	 (preserve-indentation org-src-preserve-indentation)
-	 code line col indent)
+	 (delta 0) code line col indent)
     (untabify (point-min) (point-max))
     (save-excursion
       (goto-char (point-min))
@@ -490,6 +498,7 @@ the language, a switch telling if the content should be in a single line."
       (goto-char (point-min))
       (while (re-search-forward
 	      (if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
+	(if (eq (org-current-line) line) (setq delta (1+ delta)))
 	(replace-match ",\\1")))
     (when (org-bound-and-true-p org-edit-src-picture)
       (setq preserve-indentation nil)
@@ -514,7 +523,7 @@ the language, a switch telling if the content should be in a single line."
     (goto-char beg)
     (if single (just-one-space))
     (org-goto-line (1- (+ (org-current-line) line)))
-    (org-move-to-column (if preserve-indentation col (+ col total-nindent)))
+    (org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))
     (move-marker beg nil)
     (move-marker end nil)))