Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
289:6e6992ccc4b6 | 290:c9fe270a4101 |
---|---|
1130 (hack-local-variables (not find-file)) | 1130 (hack-local-variables (not find-file)) |
1131 (error (lwarn 'local-variables 'warning | 1131 (error (lwarn 'local-variables 'warning |
1132 "File local-variables error: %s" | 1132 "File local-variables error: %s" |
1133 (error-message-string err)))))) | 1133 (error-message-string err)))))) |
1134 | 1134 |
1135 ;; #### This variable sucks in the package model. There should be a | |
1136 ;; way for new packages to add their entries to auto-mode-alist in a | |
1137 ;; clean way. Per Abrahamsen suggested splitting auto-mode-alist to | |
1138 ;; several distinct variables such as, in order of precedence, | |
1139 ;; `user-auto-mode-alist' for users, `package-auto-mode-alist' for | |
1140 ;; packages and `auto-mode-alist' (which might also be called | |
1141 ;; `default-auto-mode-alist') for default stuff, such as some of the | |
1142 ;; entries below. | |
1143 | |
1135 (defvar auto-mode-alist | 1144 (defvar auto-mode-alist |
1136 '(("\\.te?xt\\'" . text-mode) | 1145 '(("\\.te?xt\\'" . text-mode) |
1137 ("\\.[ch]\\'" . c-mode) | 1146 ("\\.[ch]\\'" . c-mode) |
1138 ("\\.el\\'" . emacs-lisp-mode) | 1147 ("\\.el\\'" . emacs-lisp-mode) |
1139 ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode) | 1148 ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode) |
1163 ("\\.\\([ckz]?sh\\|shar\\)\\'" . sh-mode) | 1172 ("\\.\\([ckz]?sh\\|shar\\)\\'" . sh-mode) |
1164 ;; #### Unix-specific! | 1173 ;; #### Unix-specific! |
1165 ("/\\.\\(bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode) | 1174 ("/\\.\\(bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode) |
1166 ("/\\.\\([ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode) | 1175 ("/\\.\\([ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode) |
1167 ("/\\.\\([kz]shenv\\|xsession\\)\\'" . sh-mode) | 1176 ("/\\.\\([kz]shenv\\|xsession\\)\\'" . sh-mode) |
1168 ;;; The following should come after the ChangeLog pattern | 1177 ;; The following come after the ChangeLog pattern for the sake of |
1169 ;;; for the sake of ChangeLog.1, etc. | 1178 ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too. |
1170 ;;; and after the .scm.[0-9] pattern too. | |
1171 ("\\.[12345678]\\'" . nroff-mode) | 1179 ("\\.[12345678]\\'" . nroff-mode) |
1172 ("\\.[tT]e[xX]\\'" . tex-mode) | 1180 ("\\.[tT]e[xX]\\'" . tex-mode) |
1173 ("\\.\\(sty\\|cls\\|bbl\\)\\'" . latex-mode) | 1181 ("\\.\\(sty\\|cls\\|bbl\\)\\'" . latex-mode) |
1174 ("\\.bib\\'" . bibtex-mode) | 1182 ("\\.bib\\'" . bibtex-mode) |
1175 ("\\.article\\'" . text-mode) | 1183 ("\\.article\\'" . text-mode) |
1222 calling FUNCTION (if it's not nil), we delete the suffix that matched | 1230 calling FUNCTION (if it's not nil), we delete the suffix that matched |
1223 REGEXP and search the list again for another match.") | 1231 REGEXP and search the list again for another match.") |
1224 | 1232 |
1225 (defvar interpreter-mode-alist | 1233 (defvar interpreter-mode-alist |
1226 '(("^#!.*csh" . sh-mode) | 1234 '(("^#!.*csh" . sh-mode) |
1235 ("^#!.*\\b\\(scope\\|wish\\|tcl\\|tclsh\\|expect\\)" . tcl-mode) | |
1227 ("^#!.*sh\\b" . sh-mode) | 1236 ("^#!.*sh\\b" . sh-mode) |
1228 ("^#!.*\\b\\(scope\\|wish\\|tcl\\|expect\\)" . tcl-mode) | |
1229 ("perl" . perl-mode) | 1237 ("perl" . perl-mode) |
1230 ("python" . python-mode) | 1238 ("python" . python-mode) |
1231 ("awk\\b" . awk-mode) | 1239 ("awk\\b" . awk-mode) |
1232 ("rexx" . rexx-mode) | 1240 ("rexx" . rexx-mode) |
1233 ("scm" . scheme-mode) | 1241 ("scm" . scheme-mode) |
1244 Each alist element looks like (INTERPRETER . MODE). | 1252 Each alist element looks like (INTERPRETER . MODE). |
1245 The car of each element is a regular expression which is compared | 1253 The car of each element is a regular expression which is compared |
1246 with the name of the interpreter specified in the first line. | 1254 with the name of the interpreter specified in the first line. |
1247 If it matches, mode MODE is selected.") | 1255 If it matches, mode MODE is selected.") |
1248 | 1256 |
1249 (defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'")) | 1257 (defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'" |
1258 "\\.tar\\.gz\\'")) | |
1250 "List of regexps; if one matches a file name, don't look for `-*-'.") | 1259 "List of regexps; if one matches a file name, don't look for `-*-'.") |
1251 | 1260 |
1252 (defvar inhibit-first-line-modes-suffixes nil | 1261 (defvar inhibit-first-line-modes-suffixes nil |
1253 "List of regexps for what to ignore, for `inhibit-first-line-modes-regexps'. | 1262 "List of regexps for what to ignore, for `inhibit-first-line-modes-regexps'. |
1254 When checking `inhibit-first-line-modes-regexps', we first discard | 1263 When checking `inhibit-first-line-modes-regexps', we first discard |
2403 (not save-some-buffers-query-display-buffer)) | 2412 (not save-some-buffers-query-display-buffer)) |
2404 ;; If playing with windows is unsafe or undesired, just do the | 2413 ;; If playing with windows is unsafe or undesired, just do the |
2405 ;; usual drill. | 2414 ;; usual drill. |
2406 (save-some-buffers-1 arg exiting nil) | 2415 (save-some-buffers-1 arg exiting nil) |
2407 ;; Else, protect the windows. | 2416 ;; Else, protect the windows. |
2408 (delete-other-windows) | 2417 (when (save-window-excursion |
2409 (save-window-excursion | 2418 (save-some-buffers-1 arg exiting t)) |
2410 (save-some-buffers-1 arg exiting t)) | 2419 ;; Force redisplay. |
2411 ;; Force redisplay. #### Perhaps this should be handled | 2420 (sit-for 0))))) |
2412 ;; automatically by `save-window-excursion'. | |
2413 (sit-for 1)))) | |
2414 | 2421 |
2415 ;; XEmacs - do not use queried flag | 2422 ;; XEmacs - do not use queried flag |
2416 (defun save-some-buffers-1 (arg exiting switch-buffer) | 2423 (defun save-some-buffers-1 (arg exiting switch-buffer) |
2417 (let ((files-done | 2424 (let* ((switched nil) |
2418 (map-y-or-n-p | 2425 (files-done |
2419 (lambda (buffer) | 2426 (map-y-or-n-p |
2420 (and (buffer-modified-p buffer) | 2427 (lambda (buffer) |
2421 (not (buffer-base-buffer buffer)) | 2428 (and (buffer-modified-p buffer) |
2422 ;; XEmacs addition: | 2429 (not (buffer-base-buffer buffer)) |
2423 (not (symbol-value-in-buffer 'save-buffers-skip buffer)) | 2430 ;; XEmacs addition: |
2424 (or | 2431 (not (symbol-value-in-buffer 'save-buffers-skip buffer)) |
2425 (buffer-file-name buffer) | 2432 (or |
2426 (and exiting | 2433 (buffer-file-name buffer) |
2427 (progn | 2434 (and exiting |
2428 (set-buffer buffer) | 2435 (progn |
2429 (and buffer-offer-save (> (buffer-size) 0))))) | 2436 (set-buffer buffer) |
2430 (if arg | 2437 (and buffer-offer-save (> (buffer-size) 0))))) |
2431 t | 2438 (if arg |
2432 ;; #### We should provide a per-buffer means to | 2439 t |
2433 ;; disable the switching. | 2440 ;; #### We should provide a per-buffer means to |
2434 (when switch-buffer | 2441 ;; disable the switching. For instance, you might |
2435 ;; #### Consider using `display-buffer' here for 21.1! | 2442 ;; want to turn it off for buffers the contents of |
2436 ;(display-buffer buffer nil (selected-frame))) | 2443 ;; which is meaningless to humans, such as |
2437 (switch-to-buffer buffer t)) | 2444 ;; `.newsrc.eld'. |
2438 (if (buffer-file-name buffer) | 2445 (when switch-buffer |
2439 (format "Save file %s? " | 2446 (unless (one-window-p) |
2440 (buffer-file-name buffer)) | 2447 (delete-other-windows)) |
2441 (format "Save buffer %s? " | 2448 (setq switched t) |
2442 (buffer-name buffer)))))) | 2449 ;; #### Consider using `display-buffer' here for 21.1! |
2443 (lambda (buffer) | 2450 ;;(display-buffer buffer nil (selected-frame))) |
2444 (set-buffer buffer) | 2451 (switch-to-buffer buffer t)) |
2445 (condition-case () | 2452 (if (buffer-file-name buffer) |
2446 (save-buffer) | 2453 (format "Save file %s? " |
2447 (error nil))) | 2454 (buffer-file-name buffer)) |
2448 (buffer-list) | 2455 (format "Save buffer %s? " |
2449 '("buffer" "buffers" "save") | 2456 (buffer-name buffer)))))) |
2450 ;;instead of this we just say "yes all", "no all", etc. | 2457 (lambda (buffer) |
2451 ;;"save all the rest" | 2458 (set-buffer buffer) |
2452 ;;"save only this buffer" "save no more buffers") | 2459 (condition-case () |
2453 ;; this is rather bogus. --ben | 2460 (save-buffer) |
2454 ;; (it makes the dialog box too big, and you get an error | 2461 (error nil))) |
2455 ;; "wrong type argument: framep, nil" when you hit q after | 2462 (buffer-list) |
2456 ;; choosing the option from the dialog box) | 2463 '("buffer" "buffers" "save") |
2457 | 2464 ;;instead of this we just say "yes all", "no all", etc. |
2458 ;; We should fix the dialog box rather than disabling | 2465 ;;"save all the rest" |
2459 ;; this! --hniksic | 2466 ;;"save only this buffer" "save no more buffers") |
2460 (list (list ?\C-r (lambda (buf) | 2467 ;; this is rather bogus. --ben |
2461 ;; #### FSF has an EXIT-ACTION argument | 2468 ;; (it makes the dialog box too big, and you get an error |
2462 ;; to `view-buffer'. | 2469 ;; "wrong type argument: framep, nil" when you hit q after |
2463 (view-buffer buf) | 2470 ;; choosing the option from the dialog box) |
2464 (setq view-exit-action | 2471 |
2465 (lambda (ignore) | 2472 ;; We should fix the dialog box rather than disabling |
2466 (exit-recursive-edit))) | 2473 ;; this! --hniksic |
2467 (recursive-edit) | 2474 (list (list ?\C-r (lambda (buf) |
2468 ;; Return nil to ask about BUF again. | 2475 ;; #### FSF has an EXIT-ACTION argument |
2469 nil) | 2476 ;; to `view-buffer'. |
2470 "display the current buffer")))) | 2477 (view-buffer buf) |
2471 (abbrevs-done | 2478 (setq view-exit-action |
2472 (and save-abbrevs abbrevs-changed | 2479 (lambda (ignore) |
2473 (progn | 2480 (exit-recursive-edit))) |
2474 (if (or arg | 2481 (recursive-edit) |
2475 (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name))) | 2482 ;; Return nil to ask about BUF again. |
2476 (write-abbrev-file nil)) | 2483 nil) |
2477 ;; Don't keep bothering user if he says no. | 2484 "display the current buffer")))) |
2478 (setq abbrevs-changed nil) | 2485 (abbrevs-done |
2479 t)))) | 2486 (and save-abbrevs abbrevs-changed |
2487 (progn | |
2488 (if (or arg | |
2489 (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name))) | |
2490 (write-abbrev-file nil)) | |
2491 ;; Don't keep bothering user if he says no. | |
2492 (setq abbrevs-changed nil) | |
2493 t)))) | |
2480 (or (> files-done 0) abbrevs-done | 2494 (or (> files-done 0) abbrevs-done |
2481 (display-message 'no-log "(No files need saving)")))) | 2495 (display-message 'no-log "(No files need saving)")) |
2496 switched)) | |
2482 | 2497 |
2483 | 2498 |
2484 (defun not-modified (&optional arg) | 2499 (defun not-modified (&optional arg) |
2485 "Mark current buffer as unmodified, not needing to be saved. | 2500 "Mark current buffer as unmodified, not needing to be saved. |
2486 With prefix arg, mark buffer as modified, so \\[save-buffer] will save. | 2501 With prefix arg, mark buffer as modified, so \\[save-buffer] will save. |