Mercurial > emacs
comparison lisp/files.el @ 13832:44e936e550ae
(save-some-buffers): Don't give message if we queried.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Sun, 24 Dec 1995 09:25:19 +0000 |
parents | 881e5c4a01cb |
children | aa5e493a867d |
comparison
equal
deleted
inserted
replaced
13831:2b90a48bb3db | 13832:44e936e550ae |
---|---|
621 (or abbreviated-home-dir | 621 (or abbreviated-home-dir |
622 (setq abbreviated-home-dir | 622 (setq abbreviated-home-dir |
623 (let ((abbreviated-home-dir "$foo")) | 623 (let ((abbreviated-home-dir "$foo")) |
624 (concat "^" (abbreviate-file-name (expand-file-name "~")) | 624 (concat "^" (abbreviate-file-name (expand-file-name "~")) |
625 "\\(/\\|$\\)")))) | 625 "\\(/\\|$\\)")))) |
626 | 626 |
627 ;; If FILENAME starts with the abbreviated homedir, | 627 ;; If FILENAME starts with the abbreviated homedir, |
628 ;; make it start with `~' instead. | 628 ;; make it start with `~' instead. |
629 (if (and (string-match abbreviated-home-dir filename) | 629 (if (and (string-match abbreviated-home-dir filename) |
630 ;; If the home dir is just /, don't change it. | 630 ;; If the home dir is just /, don't change it. |
631 (not (and (= (match-end 0) 1) | 631 (not (and (= (match-end 0) 1) |
632 (= (aref filename 0) ?/))) | 632 (= (aref filename 0) ?/))) |
633 (not (and (or (eq system-type 'ms-dos) | 633 (not (and (or (eq system-type 'ms-dos) |
634 (eq system-type 'windows-nt)) | 634 (eq system-type 'windows-nt)) |
635 (save-match-data | 635 (save-match-data |
636 (string-match "^[a-zA-Z]:/$" filename))))) | 636 (string-match "^[a-zA-Z]:/$" filename))))) |
637 (setq filename | 637 (setq filename |
638 (concat "~" | 638 (concat "~" |
688 find-file-hooks, etc. | 688 find-file-hooks, etc. |
689 This function ensures that none of these modifications will take place." | 689 This function ensures that none of these modifications will take place." |
690 (let ((file-name-handler-alist nil) | 690 (let ((file-name-handler-alist nil) |
691 (format-alist nil) | 691 (format-alist nil) |
692 (after-insert-file-functions nil) | 692 (after-insert-file-functions nil) |
693 (find-buffer-file-type-function | 693 (find-buffer-file-type-function |
694 (if (fboundp 'find-buffer-file-type) | 694 (if (fboundp 'find-buffer-file-type) |
695 (symbol-function 'find-buffer-file-type) | 695 (symbol-function 'find-buffer-file-type) |
696 nil))) | 696 nil))) |
697 (unwind-protect | 697 (unwind-protect |
698 (progn | 698 (progn |
1091 (while keep-going | 1091 (while keep-going |
1092 (setq keep-going nil) | 1092 (setq keep-going nil) |
1093 (let ((alist auto-mode-alist) | 1093 (let ((alist auto-mode-alist) |
1094 (mode nil)) | 1094 (mode nil)) |
1095 ;; Find first matching alist entry. | 1095 ;; Find first matching alist entry. |
1096 (let ((case-fold-search | 1096 (let ((case-fold-search |
1097 (memq system-type '(vax-vms windows-nt)))) | 1097 (memq system-type '(vax-vms windows-nt)))) |
1098 (while (and (not mode) alist) | 1098 (while (and (not mode) alist) |
1099 (if (string-match (car (car alist)) name) | 1099 (if (string-match (car (car alist)) name) |
1100 (if (and (consp (cdr (car alist))) | 1100 (if (and (consp (cdr (car alist))) |
1101 (nth 2 (car alist))) | 1101 (nth 2 (car alist))) |
1163 (read (current-buffer))))) | 1163 (read (current-buffer))))) |
1164 (or (eq key 'mode) | 1164 (or (eq key 'mode) |
1165 (setq result (cons (cons key val) result))) | 1165 (setq result (cons (cons key val) result))) |
1166 (skip-chars-forward " \t;"))) | 1166 (skip-chars-forward " \t;"))) |
1167 (setq result (nreverse result)))) | 1167 (setq result (nreverse result)))) |
1168 | 1168 |
1169 (if (and result | 1169 (if (and result |
1170 (or (eq enable-local-variables t) | 1170 (or (eq enable-local-variables t) |
1171 (and enable-local-variables | 1171 (and enable-local-variables |
1172 (save-window-excursion | 1172 (save-window-excursion |
1173 (condition-case nil | 1173 (condition-case nil |
1207 (save-excursion | 1207 (save-excursion |
1208 (beginning-of-line) | 1208 (beginning-of-line) |
1209 (set-window-start (selected-window) (point))) | 1209 (set-window-start (selected-window) (point))) |
1210 (y-or-n-p (format "Set local variables as specified at end of %s? " | 1210 (y-or-n-p (format "Set local variables as specified at end of %s? " |
1211 (if buffer-file-name | 1211 (if buffer-file-name |
1212 (file-name-nondirectory | 1212 (file-name-nondirectory |
1213 buffer-file-name) | 1213 buffer-file-name) |
1214 (concat "buffer " | 1214 (concat "buffer " |
1215 (buffer-name)))))))))) | 1215 (buffer-name)))))))))) |
1216 (let ((continue t) | 1216 (let ((continue t) |
1217 prefix prefixlen suffix beg | 1217 prefix prefixlen suffix beg |
1830 buffer-file-name))) | 1830 buffer-file-name))) |
1831 (setq tempsetmodes t) | 1831 (setq tempsetmodes t) |
1832 (error "Attempt to save to a file which you aren't allowed to write")))))) | 1832 (error "Attempt to save to a file which you aren't allowed to write")))))) |
1833 (or buffer-backed-up | 1833 (or buffer-backed-up |
1834 (setq setmodes (backup-buffer))) | 1834 (setq setmodes (backup-buffer))) |
1835 (let ((dir (file-name-directory buffer-file-name))) | 1835 (let ((dir (file-name-directory buffer-file-name))) |
1836 (if (and file-precious-flag | 1836 (if (and file-precious-flag |
1837 (file-writable-p dir)) | 1837 (file-writable-p dir)) |
1838 ;; If file is precious, write temp name, then rename it. | 1838 ;; If file is precious, write temp name, then rename it. |
1839 ;; This requires write access to the containing dir, | 1839 ;; This requires write access to the containing dir, |
1840 ;; which is why we don't try it if we don't have that access. | 1840 ;; which is why we don't try it if we don't have that access. |
1854 tempname nil realname | 1854 tempname nil realname |
1855 buffer-file-truename) | 1855 buffer-file-truename) |
1856 (setq succeed t)) | 1856 (setq succeed t)) |
1857 ;; If writing the temp file fails, | 1857 ;; If writing the temp file fails, |
1858 ;; delete the temp file. | 1858 ;; delete the temp file. |
1859 (or succeed | 1859 (or succeed |
1860 (progn | 1860 (progn |
1861 (delete-file tempname) | 1861 (delete-file tempname) |
1862 (set-visited-file-modtime old-modtime)))) | 1862 (set-visited-file-modtime old-modtime)))) |
1863 ;; Since we have created an entirely new file | 1863 ;; Since we have created an entirely new file |
1864 ;; and renamed it, make sure it gets the | 1864 ;; and renamed it, make sure it gets the |
1884 Optional argument (the prefix) non-nil means save all with no questions. | 1884 Optional argument (the prefix) non-nil means save all with no questions. |
1885 Optional second argument EXITING means ask about certain non-file buffers | 1885 Optional second argument EXITING means ask about certain non-file buffers |
1886 as well as about file buffers." | 1886 as well as about file buffers." |
1887 (interactive "P") | 1887 (interactive "P") |
1888 (save-window-excursion | 1888 (save-window-excursion |
1889 (let ((files-done | 1889 (let* ((queried nil) |
1890 (map-y-or-n-p | 1890 (files-done |
1891 (function | 1891 (map-y-or-n-p |
1892 (lambda (buffer) | 1892 (function |
1893 (and (buffer-modified-p buffer) | 1893 (lambda (buffer) |
1894 (not (buffer-base-buffer buffer)) | 1894 (and (buffer-modified-p buffer) |
1895 (or | 1895 (not (buffer-base-buffer buffer)) |
1896 (buffer-file-name buffer) | 1896 (or |
1897 (and exiting | 1897 (buffer-file-name buffer) |
1898 (progn | 1898 (and exiting |
1899 (set-buffer buffer) | 1899 (progn |
1900 (and buffer-offer-save (> (buffer-size) 0))))) | 1900 (set-buffer buffer) |
1901 (if arg | 1901 (and buffer-offer-save (> (buffer-size) 0))))) |
1902 t | 1902 (if arg |
1903 (if (buffer-file-name buffer) | 1903 t |
1904 (format "Save file %s? " | 1904 (setq queried t) |
1905 (buffer-file-name buffer)) | 1905 (if (buffer-file-name buffer) |
1906 (format "Save buffer %s? " | 1906 (format "Save file %s? " |
1907 (buffer-name buffer))))))) | 1907 (buffer-file-name buffer)) |
1908 (function | 1908 (format "Save buffer %s? " |
1909 (lambda (buffer) | 1909 (buffer-name buffer))))))) |
1910 (set-buffer buffer) | 1910 (function |
1911 (save-buffer))) | 1911 (lambda (buffer) |
1912 (buffer-list) | 1912 (set-buffer buffer) |
1913 '("buffer" "buffers" "save") | 1913 (save-buffer))) |
1914 (list (list ?\C-r (lambda (buf) | 1914 (buffer-list) |
1915 (view-buffer buf) | 1915 '("buffer" "buffers" "save") |
1916 (setq view-exit-action | 1916 (list (list ?\C-r (lambda (buf) |
1917 '(lambda (ignore) | 1917 (view-buffer buf) |
1918 (exit-recursive-edit))) | 1918 (setq view-exit-action |
1919 (recursive-edit) | 1919 '(lambda (ignore) |
1920 ;; Return nil to ask about BUF again. | 1920 (exit-recursive-edit))) |
1921 nil) | 1921 (recursive-edit) |
1922 "display the current buffer")))) | 1922 ;; Return nil to ask about BUF again. |
1923 (abbrevs-done | 1923 nil) |
1924 (and save-abbrevs abbrevs-changed | 1924 "display the current buffer")))) |
1925 (progn | 1925 (abbrevs-done |
1926 (if (or arg | 1926 (and save-abbrevs abbrevs-changed |
1927 (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name))) | 1927 (progn |
1928 (write-abbrev-file nil)) | 1928 (if (or arg |
1929 ;; Don't keep bothering user if he says no. | 1929 (y-or-n-p (format "Save abbrevs in %s? " |
1930 (setq abbrevs-changed nil) | 1930 abbrev-file-name))) |
1931 t)))) | 1931 (write-abbrev-file nil)) |
1932 (or (> files-done 0) abbrevs-done | 1932 ;; Don't keep bothering user if he says no. |
1933 (setq abbrevs-changed nil) | |
1934 t)))) | |
1935 (or queried (> files-done 0) abbrevs-done | |
1933 (message "(No files need saving)"))))) | 1936 (message "(No files need saving)"))))) |
1934 | 1937 |
1935 (defun not-modified (&optional arg) | 1938 (defun not-modified (&optional arg) |
1936 "Mark current buffer as unmodified, not needing to be saved. | 1939 "Mark current buffer as unmodified, not needing to be saved. |
1937 With prefix arg, mark buffer as modified, so \\[save-buffer] will save. | 1940 With prefix arg, mark buffer as modified, so \\[save-buffer] will save. |
2030 (if (not parents) | 2033 (if (not parents) |
2031 (make-directory-internal dir) | 2034 (make-directory-internal dir) |
2032 (let ((dir (directory-file-name (expand-file-name dir))) | 2035 (let ((dir (directory-file-name (expand-file-name dir))) |
2033 create-list) | 2036 create-list) |
2034 (while (not (file-exists-p dir)) | 2037 (while (not (file-exists-p dir)) |
2035 (setq create-list (cons dir create-list) | 2038 (setq create-list (cons dir create-list) |
2036 dir (directory-file-name (file-name-directory dir)))) | 2039 dir (directory-file-name (file-name-directory dir)))) |
2037 (while create-list | 2040 (while create-list |
2038 (make-directory-internal (car create-list)) | 2041 (make-directory-internal (car create-list)) |
2039 (setq create-list (cdr create-list)))))))) | 2042 (setq create-list (cdr create-list)))))))) |
2040 | 2043 |
2264 (if files | 2267 (if files |
2265 (map-y-or-n-p "Recover %s? " | 2268 (map-y-or-n-p "Recover %s? " |
2266 (lambda (file) | 2269 (lambda (file) |
2267 (condition-case nil | 2270 (condition-case nil |
2268 (save-excursion (recover-file file)) | 2271 (save-excursion (recover-file file)) |
2269 (error | 2272 (error |
2270 "Failed to recover `%s'" file))) | 2273 "Failed to recover `%s'" file))) |
2271 files | 2274 files |
2272 '("file" "files" "recover")) | 2275 '("file" "files" "recover")) |
2273 (message "No files can be recovered from this session now"))) | 2276 (message "No files can be recovered from this session now"))) |
2274 (kill-buffer buffer)))) | 2277 (kill-buffer buffer)))) |