From 949b2cd4c378872345f3f3a026beb5d1a228288d Mon Sep 17 00:00:00 2001
From: Le Wang <le.wang@agworld.com.au>
Date: Fri, 14 Dec 2012 07:31:15 +0800
Subject: [PATCH 5/5] remove extraneous if condition

- We signal org-src-error before ever reaching here.
---
 lisp/org-src.el | 210 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 104 insertions(+), 106 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index ad6ec60..d4747ab 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -244,113 +244,111 @@ buffer."
 	 (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)
-    (if (not info)
-	nil
-      (setq beg (move-marker beg (nth 0 info))
-	    end (move-marker end (nth 1 info))
-	    msg (if allow-write-back-p
-		    (substitute-command-keys
-		     "Edit, then exit with C-c ' (C-c and single quote)")
-		  "Exit with C-c ' (C-c and single quote)")
-	    code (or code (buffer-substring-no-properties beg end))
-	    lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
-                     (nth 2 info))
-	    lang (if (symbolp lang) (symbol-name lang) lang)
-	    single (nth 3 info)
-	    block-nindent (nth 5 info)
-	    lang-f (intern (concat lang "-mode"))
-	    begline (save-excursion (goto-char beg) (org-current-line))
-	    transmitted-variables
-	    `((org-edit-src-content-indentation
-	       ,org-edit-src-content-indentation)
-	      (org-edit-src-force-single-line ,single)
-	      (org-edit-src-from-org-mode ,org-mode-p)
-	      (org-edit-src-allow-write-back-p ,allow-write-back-p)
-	      (org-src-preserve-indentation ,org-src-preserve-indentation)
-	      (org-src-babel-info ,(org-babel-get-src-block-info 'light))
-	      (org-coderef-label-format
-	       ,(or (nth 4 info) org-coderef-label-format))
-	      (org-edit-src-beg-marker ,beg)
-	      (org-edit-src-end-marker ,end)
-	      (org-edit-src-block-indentation ,block-nindent)))
-      (if (and mark (>= mark beg) (<= mark (1+ end)))
-	  (save-excursion (goto-char (min mark end))
-			  (setq markline (org-current-line)
-				markcol (current-column))))
-      (if (equal lang-f 'table.el-mode)
-	  (setq lang-f (lambda ()
-			 (text-mode)
-			 (if (org-bound-and-true-p flyspell-mode)
-			     (flyspell-mode -1))
-			 (table-recognize)
-			 (org-set-local 'org-edit-src-content-indentation 0))))
-      (unless (functionp lang-f)
-	(signal 'org-src-error "No such language mode: %s" lang-f))
-      (save-excursion
-	(if (> (point) end) (goto-char end))
-	(setq line (org-current-line)
-	      col (current-column)))
-      (if (and (setq buffer (org-edit-src-find-buffer beg end))
-	       (or (eq context 'save)
-		   (if org-src-ask-before-returning-to-edit-buffer
-		       (y-or-n-p "Return to existing edit buffer ([n] will revert changes)? ") t)))
-	  (org-src-switch-to-buffer buffer 'return)
-	(when buffer
-	  (with-current-buffer buffer
-	    (if (boundp 'org-edit-src-overlay)
-		(delete-overlay org-edit-src-overlay)))
-	  (kill-buffer buffer))
-	(setq buffer (generate-new-buffer
-		      (or edit-buffer-name
-			  (org-src-construct-edit-buffer-name (buffer-name) lang))))
-	(setq ovl (make-overlay beg end))
-	(overlay-put ovl 'edit-buffer buffer)
-	(overlay-put ovl 'help-echo "Click with mouse-1 to switch to buffer editing this segment")
-	(overlay-put ovl 'face 'secondary-selection)
-	(overlay-put ovl
-		     'keymap
-		     (let ((map (make-sparse-keymap)))
-		       (define-key map [mouse-1] 'org-edit-src-continue)
-		       map))
-	(overlay-put ovl :read-only "Leave me alone")
-	(setq transmitted-variables
-	      (append transmitted-variables `((org-edit-src-overlay ,ovl))))
-	(org-src-switch-to-buffer buffer 'edit)
-	(if (eq single 'macro-definition)
-	    (setq code (replace-regexp-in-string "\\\\n" "\n" code t t)))
-	(insert code)
-	(remove-text-properties (point-min) (point-max)
-				'(display nil invisible nil intangible nil))
-	(unless (cadr (assq 'org-src-preserve-indentation transmitted-variables))
-	  (setq total-nindent (or (org-do-remove-indentation) 0)))
-	(let ((org-inhibit-startup t))
-	  (condition-case e
-	      (funcall lang-f)
-	    (error
-	     (signal 'org-src-error "Language mode `%s' fails with: %S" lang-f (nth 1 e)))))
-	(dolist (pair transmitted-variables)
-	  (org-set-local (car pair) (cadr pair)))
-	;; Remove protecting commas from visible part of buffer.
-	(org-unescape-code-in-region (point-min) (point-max))
-	(when markline
-	  (org-goto-line (1+ (- markline begline)))
-	  (org-move-to-column
-	   (if org-src-preserve-indentation markcol
-	     (max 0 (- markcol total-nindent))))
-	  (push-mark (point) 'no-message t)
-	  (setq deactivate-mark nil))
-	(org-goto-line (1+ (- line begline)))
+    (setq beg (move-marker beg (nth 0 info))
+	  end (move-marker end (nth 1 info))
+	  msg (if allow-write-back-p
+		  (substitute-command-keys
+		   "Edit, then exit with C-c ' (C-c and single quote)")
+		"Exit with C-c ' (C-c and single quote)")
+	  code (or code (buffer-substring-no-properties beg end))
+	  lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
+		   (nth 2 info))
+	  lang (if (symbolp lang) (symbol-name lang) lang)
+	  single (nth 3 info)
+	  block-nindent (nth 5 info)
+	  lang-f (intern (concat lang "-mode"))
+	  begline (save-excursion (goto-char beg) (org-current-line))
+	  transmitted-variables
+	  `((org-edit-src-content-indentation
+	     ,org-edit-src-content-indentation)
+	    (org-edit-src-force-single-line ,single)
+	    (org-edit-src-from-org-mode ,org-mode-p)
+	    (org-edit-src-allow-write-back-p ,allow-write-back-p)
+	    (org-src-preserve-indentation ,org-src-preserve-indentation)
+	    (org-src-babel-info ,(org-babel-get-src-block-info 'light))
+	    (org-coderef-label-format
+	     ,(or (nth 4 info) org-coderef-label-format))
+	    (org-edit-src-beg-marker ,beg)
+	    (org-edit-src-end-marker ,end)
+	    (org-edit-src-block-indentation ,block-nindent)))
+    (if (and mark (>= mark beg) (<= mark (1+ end)))
+	(save-excursion (goto-char (min mark end))
+			(setq markline (org-current-line)
+			      markcol (current-column))))
+    (if (equal lang-f 'table.el-mode)
+	(setq lang-f (lambda ()
+		       (text-mode)
+		       (if (org-bound-and-true-p flyspell-mode)
+			   (flyspell-mode -1))
+		       (table-recognize)
+		       (org-set-local 'org-edit-src-content-indentation 0))))
+    (unless (functionp lang-f)
+      (signal 'org-src-error "No such language mode: %s" lang-f))
+    (save-excursion
+      (if (> (point) end) (goto-char end))
+      (setq line (org-current-line)
+	    col (current-column)))
+    (if (and (setq buffer (org-edit-src-find-buffer beg end))
+	     (or (eq context 'save)
+		 (if org-src-ask-before-returning-to-edit-buffer
+		     (y-or-n-p "Return to existing edit buffer ([n] will revert changes)? ") t)))
+	(org-src-switch-to-buffer buffer 'return)
+      (when buffer
+	(with-current-buffer buffer
+	  (if (boundp 'org-edit-src-overlay)
+	      (delete-overlay org-edit-src-overlay)))
+	(kill-buffer buffer))
+      (setq buffer (generate-new-buffer
+		    (or edit-buffer-name
+			(org-src-construct-edit-buffer-name (buffer-name) lang))))
+      (setq ovl (make-overlay beg end))
+      (overlay-put ovl 'edit-buffer buffer)
+      (overlay-put ovl 'help-echo "Click with mouse-1 to switch to buffer editing this segment")
+      (overlay-put ovl 'face 'secondary-selection)
+      (overlay-put ovl
+		   'keymap
+		   (let ((map (make-sparse-keymap)))
+		     (define-key map [mouse-1] 'org-edit-src-continue)
+		     map))
+      (overlay-put ovl :read-only "Leave me alone")
+      (setq transmitted-variables
+	    (append transmitted-variables `((org-edit-src-overlay ,ovl))))
+      (org-src-switch-to-buffer buffer 'edit)
+      (if (eq single 'macro-definition)
+	  (setq code (replace-regexp-in-string "\\\\n" "\n" code t t)))
+      (insert code)
+      (remove-text-properties (point-min) (point-max)
+			      '(display nil invisible nil intangible nil))
+      (unless (cadr (assq 'org-src-preserve-indentation transmitted-variables))
+	(setq total-nindent (or (org-do-remove-indentation) 0)))
+      (let ((org-inhibit-startup t))
+	(condition-case e
+	    (funcall lang-f)
+	  (error
+	   (signal 'org-src-error "Language mode `%s' fails with: %S" lang-f (nth 1 e)))))
+      (dolist (pair transmitted-variables)
+	(org-set-local (car pair) (cadr pair)))
+      ;; Remove protecting commas from visible part of buffer.
+      (org-unescape-code-in-region (point-min) (point-max))
+      (when markline
+	(org-goto-line (1+ (- markline begline)))
 	(org-move-to-column
-	 (if org-src-preserve-indentation col (max 0 (- col total-nindent))))
-	(org-src-mode)
-	(set-buffer-modified-p nil)
-	(setq buffer-file-name nil)
-	(and org-edit-src-persistent-message
-	     (org-set-local 'header-line-format msg))
-	(let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang))))
-	  (when (fboundp edit-prep-func)
-	    (funcall edit-prep-func full-info))))
-      t)))
+	 (if org-src-preserve-indentation markcol
+	   (max 0 (- markcol total-nindent))))
+	(push-mark (point) 'no-message t)
+	(setq deactivate-mark nil))
+      (org-goto-line (1+ (- line begline)))
+      (org-move-to-column
+       (if org-src-preserve-indentation col (max 0 (- col total-nindent))))
+      (org-src-mode)
+      (set-buffer-modified-p nil)
+      (setq buffer-file-name nil)
+      (and org-edit-src-persistent-message
+	   (org-set-local 'header-line-format msg))
+      (let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang))))
+	(when (fboundp edit-prep-func)
+	  (funcall edit-prep-func full-info))))
+    t))
 
 (defun org-edit-src-continue (e)
   "Continue editing source blocks." ;; Fixme: be more accurate
-- 
1.7.11.4

