Browse Source

Avoid changing indentation in regions that are external source code.

Carsten Dominik 16 years ago
parent
commit
5dde398b92
2 changed files with 55 additions and 52 deletions
  1. 3 0
      lisp/ChangeLog
  2. 52 52
      lisp/org.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-09-13  Carsten Dominik  <dominik@science.uva.nl>
 2008-09-13  Carsten Dominik  <dominik@science.uva.nl>
 
 
+	* org.el (org-indent-line-function): Do not indent in regions that
+	are external source code.
+
 	* org-agenda.el (org-agenda-todayp): New function.
 	* org-agenda.el (org-agenda-todayp): New function.
 	(org-agenda-get-deadlines, org-agenda-get-scheduled): Use
 	(org-agenda-get-deadlines, org-agenda-get-scheduled): Use
 	`org-agenda-todayp'.
 	`org-agenda-todayp'.

+ 52 - 52
lisp/org.el

@@ -14134,59 +14134,59 @@ which make use of the date at the cursor."
 (defun org-indent-line-function ()
 (defun org-indent-line-function ()
   "Indent line like previous, but further if previous was headline or item."
   "Indent line like previous, but further if previous was headline or item."
   (interactive)
   (interactive)
-  (let* ((pos (point))
-	 (itemp (org-at-item-p))
-	 column bpos bcol tpos tcol bullet btype bullet-type)
-    ;; Find the previous relevant line
-    (beginning-of-line 1)
-    (cond
-     ((looking-at "#") (setq column 0))
-     ((looking-at "\\*+ ") (setq column 0))
-     (t
-      (beginning-of-line 0)
-      (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]"))
-	(beginning-of-line 0))
+  (unless (org-edit-src-find-region-and-lang)
+    (let* ((pos (point))
+	   (itemp (org-at-item-p))
+	   column bpos bcol tpos tcol bullet btype bullet-type)
+      ;; Find the previous relevant line
+      (beginning-of-line 1)
       (cond
       (cond
-       ((looking-at "\\*+[ \t]+")
-	(if (not org-adapt-indentation)
-	    (setq column 0)
-	  (goto-char (match-end 0))
-	  (setq column (current-column))))
-       ((org-in-item-p)
-	(org-beginning-of-item)
-;	(looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
-	(looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
-	(setq bpos (match-beginning 1) tpos (match-end 0)
-	      bcol (progn (goto-char bpos) (current-column))
-	      tcol (progn (goto-char tpos) (current-column))
-	      bullet (match-string 1)
-	      bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
-	(if (> tcol (+ bcol org-description-max-indent))
-	    (setq tcol (+ bcol 5)))
-	(if (not itemp)
-	    (setq column tcol)
-	  (goto-char pos)
-	  (beginning-of-line 1)
-	  (if (looking-at "\\S-")
-	      (progn
-		(looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
-		(setq bullet (match-string 1)
-		      btype (if (string-match "[0-9]" bullet) "n" bullet))
-		(setq column (if (equal btype bullet-type) bcol tcol)))
-	    (setq column (org-get-indentation)))))
-       (t (setq column (org-get-indentation))))))
-    (goto-char pos)
-    (if (<= (current-column) (current-indentation))
-	(org-indent-line-to column)
-      (save-excursion (org-indent-line-to column)))
-    (setq column (current-column))
-    (beginning-of-line 1)
-    (if (looking-at
-	 "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
-	(replace-match (concat "\\1" (format org-property-format
-					     (match-string 2) (match-string 3)))
-		       t nil))
-    (org-move-to-column column)))
+       ((looking-at "#") (setq column 0))
+       ((looking-at "\\*+ ") (setq column 0))
+       (t
+	(beginning-of-line 0)
+	(while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]"))
+	  (beginning-of-line 0))
+	(cond
+	 ((looking-at "\\*+[ \t]+")
+	  (if (not org-adapt-indentation)
+	      (setq column 0)
+	    (goto-char (match-end 0))
+	    (setq column (current-column))))
+	 ((org-in-item-p)
+	  (org-beginning-of-item)
+	  (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
+	  (setq bpos (match-beginning 1) tpos (match-end 0)
+		bcol (progn (goto-char bpos) (current-column))
+		tcol (progn (goto-char tpos) (current-column))
+		bullet (match-string 1)
+		bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
+	  (if (> tcol (+ bcol org-description-max-indent))
+	      (setq tcol (+ bcol 5)))
+	  (if (not itemp)
+	      (setq column tcol)
+	    (goto-char pos)
+	    (beginning-of-line 1)
+	    (if (looking-at "\\S-")
+		(progn
+		  (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
+		  (setq bullet (match-string 1)
+			btype (if (string-match "[0-9]" bullet) "n" bullet))
+		  (setq column (if (equal btype bullet-type) bcol tcol)))
+	      (setq column (org-get-indentation)))))
+	 (t (setq column (org-get-indentation))))))
+      (goto-char pos)
+      (if (<= (current-column) (current-indentation))
+	  (org-indent-line-to column)
+	(save-excursion (org-indent-line-to column)))
+      (setq column (current-column))
+      (beginning-of-line 1)
+      (if (looking-at
+	   "\\([ \t]+\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
+	  (replace-match (concat "\\1" (format org-property-format
+					       (match-string 2) (match-string 3)))
+			 t nil))
+      (org-move-to-column column))))
 
 
 (defun org-set-autofill-regexps ()
 (defun org-set-autofill-regexps ()
   (interactive)
   (interactive)