--- tex.el.~5.671.~	2010-12-11 12:37:21.000000000 +0100
+++ tex.el	2010-12-11 12:52:13.610875002 +0100
@@ -789,6 +789,11 @@
   :group 'TeX-output
   :type 'boolean)
 
+(defcustom TeX-master-compilation t
+  "Non-nil means compile the master, nil means compile the buffer only."
+  :group 'TeX-command
+  :type 'boolean)
+
 (defun TeX-toggle-debug-bad-boxes ()
   "Toggle if the debugger should display \"bad boxes\" too."
   (interactive)
@@ -803,6 +808,13 @@
   (message (concat "TeX-debug-warnings: "
 		   (if TeX-debug-warnings "on" "off"))))
 
+(defun TeX-toggle-master-compilation ()
+  "Toggle if the compilation should be done on the master or the current buffer."
+  (interactive)
+  (setq TeX-master-compilation (not TeX-master-compilation))
+  (message (concat "TeX-master-compilation: "
+		   (if TeX-master-compilation "on" "off"))))
+
 ;;; Mode names.
 
 (defvar TeX-base-mode-name nil
@@ -3954,6 +3966,7 @@
     (define-key map "\C-c\C-w"       'TeX-toggle-debug-bad-boxes); to be removed
     (define-key map "\C-c\C-t\C-b"   'TeX-toggle-debug-bad-boxes)
     (define-key map "\C-c\C-t\C-w"   'TeX-toggle-debug-warnings)
+    (define-key map "\C-c\C-t\C-m"   'TeX-toggle-master-compilation)
     (define-key map "\C-c\C-v" 'TeX-view)
     ;; From tex-buf.el
     (define-key map "\C-c\C-d" 'TeX-save-document)
