diff lisp/files.el @ 290:c9fe270a4101 r21-0b43

Import from CVS: tag r21-0b43
author cvs
date Mon, 13 Aug 2007 10:36:47 +0200
parents e11d67e05968
children afd57c14dfc8
line wrap: on
line diff
--- a/lisp/files.el	Mon Aug 13 10:35:55 2007 +0200
+++ b/lisp/files.el	Mon Aug 13 10:36:47 2007 +0200
@@ -1132,6 +1132,15 @@
 		  "File local-variables error: %s"
 		  (error-message-string err))))))
 
+;; #### This variable sucks in the package model.  There should be a
+;; way for new packages to add their entries to auto-mode-alist in a
+;; clean way.  Per Abrahamsen suggested splitting auto-mode-alist to
+;; several distinct variables such as, in order of precedence,
+;; `user-auto-mode-alist' for users, `package-auto-mode-alist' for
+;; packages and `auto-mode-alist' (which might also be called
+;; `default-auto-mode-alist') for default stuff, such as some of the
+;; entries below.
+
 (defvar auto-mode-alist
   '(("\\.te?xt\\'" . text-mode)
     ("\\.[ch]\\'" . c-mode)
@@ -1165,9 +1174,8 @@
     ("/\\.\\(bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode)
     ("/\\.\\([ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode)
     ("/\\.\\([kz]shenv\\|xsession\\)\\'" . sh-mode)
-;;; The following should come after the ChangeLog pattern
-;;; for the sake of ChangeLog.1, etc.
-;;; and after the .scm.[0-9] pattern too.
+    ;; The following come after the ChangeLog pattern for the sake of
+    ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too.
     ("\\.[12345678]\\'" . nroff-mode)
     ("\\.[tT]e[xX]\\'" . tex-mode)
     ("\\.\\(sty\\|cls\\|bbl\\)\\'" . latex-mode)
@@ -1224,8 +1232,8 @@
 
 (defvar interpreter-mode-alist
   '(("^#!.*csh"	  . sh-mode)
+    ("^#!.*\\b\\(scope\\|wish\\|tcl\\|tclsh\\|expect\\)" . tcl-mode)
     ("^#!.*sh\\b" . sh-mode)
-    ("^#!.*\\b\\(scope\\|wish\\|tcl\\|expect\\)" . tcl-mode)
     ("perl"   . perl-mode)
     ("python" . python-mode)
     ("awk\\b" . awk-mode)
@@ -1246,7 +1254,8 @@
 with the name of the interpreter specified in the first line.
 If it matches, mode MODE is selected.")
 
-(defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'"))
+(defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'"
+						     "\\.tar\\.gz\\'"))
   "List of regexps; if one matches a file name, don't look for `-*-'.")
 
 (defvar inhibit-first-line-modes-suffixes nil
@@ -2405,80 +2414,86 @@
 	;; usual drill.
 	(save-some-buffers-1 arg exiting nil)
       ;; Else, protect the windows.
-      (delete-other-windows)
-      (save-window-excursion
-	(save-some-buffers-1 arg exiting t))
-      ;; Force redisplay.  #### Perhaps this should be handled
-      ;; automatically by `save-window-excursion'.
-      (sit-for 1))))
+      (when (save-window-excursion
+	      (save-some-buffers-1 arg exiting t))
+	;; Force redisplay.
+	(sit-for 0)))))
 
 ;; XEmacs - do not use queried flag
 (defun save-some-buffers-1 (arg exiting switch-buffer)
-  (let ((files-done
-	 (map-y-or-n-p
-	  (lambda (buffer)
-	    (and (buffer-modified-p buffer)
-		 (not (buffer-base-buffer buffer))
-		 ;; XEmacs addition:
-		 (not (symbol-value-in-buffer 'save-buffers-skip buffer))
-		 (or
-		  (buffer-file-name buffer)
-		  (and exiting
-		       (progn
-			 (set-buffer buffer)
-			 (and buffer-offer-save (> (buffer-size) 0)))))
-		 (if arg
-		     t
-		   ;; #### We should provide a per-buffer means to
-		   ;; disable the switching.
-		   (when switch-buffer
-		     ;; #### Consider using `display-buffer' here for 21.1!
-		     ;(display-buffer buffer nil (selected-frame)))
-		     (switch-to-buffer buffer t))
-		   (if (buffer-file-name buffer)
-		       (format "Save file %s? "
-			       (buffer-file-name buffer))
-		     (format "Save buffer %s? "
-			     (buffer-name buffer))))))
-	  (lambda (buffer)
-	    (set-buffer buffer)
-	    (condition-case ()
-		(save-buffer)
-	      (error nil)))
-	  (buffer-list)
-	  '("buffer" "buffers" "save")
-	  ;;instead of this we just say "yes all", "no all", etc.
-	  ;;"save all the rest"
-	  ;;"save only this buffer" "save no more buffers")
-	  ;; this is rather bogus. --ben
-	  ;; (it makes the dialog box too big, and you get an error
-	  ;; "wrong type argument: framep, nil" when you hit q after
-	  ;; choosing the option from the dialog box)
+  (let* ((switched nil)
+	 (files-done
+	  (map-y-or-n-p
+	   (lambda (buffer)
+	     (and (buffer-modified-p buffer)
+		  (not (buffer-base-buffer buffer))
+		  ;; XEmacs addition:
+		  (not (symbol-value-in-buffer 'save-buffers-skip buffer))
+		  (or
+		   (buffer-file-name buffer)
+		   (and exiting
+			(progn
+			  (set-buffer buffer)
+			  (and buffer-offer-save (> (buffer-size) 0)))))
+		  (if arg
+		      t
+		    ;; #### We should provide a per-buffer means to
+		    ;; disable the switching.  For instance, you might
+		    ;; want to turn it off for buffers the contents of
+		    ;; which is meaningless to humans, such as
+		    ;; `.newsrc.eld'.
+		    (when switch-buffer
+		      (unless (one-window-p)
+			(delete-other-windows))
+		      (setq switched t)
+		      ;; #### Consider using `display-buffer' here for 21.1!
+		      ;;(display-buffer buffer nil (selected-frame)))
+		      (switch-to-buffer buffer t))
+		    (if (buffer-file-name buffer)
+			(format "Save file %s? "
+				(buffer-file-name buffer))
+		      (format "Save buffer %s? "
+			      (buffer-name buffer))))))
+	   (lambda (buffer)
+	     (set-buffer buffer)
+	     (condition-case ()
+		 (save-buffer)
+	       (error nil)))
+	   (buffer-list)
+	   '("buffer" "buffers" "save")
+	   ;;instead of this we just say "yes all", "no all", etc.
+	   ;;"save all the rest"
+	   ;;"save only this buffer" "save no more buffers")
+	   ;; this is rather bogus. --ben
+	   ;; (it makes the dialog box too big, and you get an error
+	   ;; "wrong type argument: framep, nil" when you hit q after
+	   ;; choosing the option from the dialog box)
 
-	  ;; We should fix the dialog box rather than disabling
-	  ;; this!  --hniksic
-	  (list (list ?\C-r (lambda (buf)
-			      ;; #### FSF has an EXIT-ACTION argument
-			      ;; to `view-buffer'.
-			      (view-buffer buf)
-			      (setq view-exit-action
-				    (lambda (ignore)
-				      (exit-recursive-edit)))
-			      (recursive-edit)
-			      ;; Return nil to ask about BUF again.
-			      nil)
-		      "display the current buffer"))))
-	(abbrevs-done
-	 (and save-abbrevs abbrevs-changed
-	      (progn
-		(if (or arg
-			(y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name)))
-		    (write-abbrev-file nil))
-		;; Don't keep bothering user if he says no.
-		(setq abbrevs-changed nil)
-		t))))
+	   ;; We should fix the dialog box rather than disabling
+	   ;; this!  --hniksic
+	   (list (list ?\C-r (lambda (buf)
+			       ;; #### FSF has an EXIT-ACTION argument
+			       ;; to `view-buffer'.
+			       (view-buffer buf)
+			       (setq view-exit-action
+				     (lambda (ignore)
+				       (exit-recursive-edit)))
+			       (recursive-edit)
+			       ;; Return nil to ask about BUF again.
+			       nil)
+		       "display the current buffer"))))
+	 (abbrevs-done
+	  (and save-abbrevs abbrevs-changed
+	       (progn
+		 (if (or arg
+			 (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name)))
+		     (write-abbrev-file nil))
+		 ;; Don't keep bothering user if he says no.
+		 (setq abbrevs-changed nil)
+		 t))))
     (or (> files-done 0) abbrevs-done
-	(display-message 'no-log "(No files need saving)"))))
+	(display-message 'no-log "(No files need saving)"))
+    switched))
 
 
 (defun not-modified (&optional arg)