diff options
| author | Stefan Monnier | 2008-11-18 18:26:08 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-11-18 18:26:08 +0000 |
| commit | 35b05a7793f3e0f702ee8cd5aec68b2acbe815cd (patch) | |
| tree | d253f382172c734760345c710f21e242cafcdea4 | |
| parent | d0414e3656d63bbf5640c832cf6f630281bc23be (diff) | |
| download | emacs-35b05a7793f3e0f702ee8cd5aec68b2acbe815cd.tar.gz emacs-35b05a7793f3e0f702ee8cd5aec68b2acbe815cd.zip | |
(confirm-nonexistent-file-or-buffer):
Rename from find-file-confirm-nonexistent-file.
(read-buffer-to-switch): Use it.
| -rw-r--r-- | doc/emacs/files.texi | 14 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 28 |
4 files changed, 31 insertions, 22 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 28d9765a4b2..93a6161d782 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -240,14 +240,14 @@ moves or copies the file into the displayed directory. For details, | |||
| 240 | see @ref{Drag and Drop}, and @ref{Misc Dired Features}. | 240 | see @ref{Drag and Drop}, and @ref{Misc Dired Features}. |
| 241 | 241 | ||
| 242 | @cindex creating files | 242 | @cindex creating files |
| 243 | @vindex find-file-confirm-nonexistent-file | 243 | @vindex confirm-nonexistent-file-or-buffer |
| 244 | What if you want to create a new file? Just visit it. Emacs | 244 | What if you want to create a new file? Just visit it. |
| 245 | displays @samp{(New file)} in the echo area, but in other respects | ||
| 246 | behaves as if you had visited an existing empty file. If you make | ||
| 247 | changes and save them, the file is created. If you change the | ||
| 248 | variable @code{find-file-confirm-nonexistent-file} to @code{t}, then | ||
| 249 | Emacs prompts you for confirmation before visiting a non-existent | 245 | Emacs prompts you for confirmation before visiting a non-existent |
| 250 | file. | 246 | file, and displays @samp{(New file)} in the echo area, but in other |
| 247 | respects behaves as if you had visited an existing empty file. If you | ||
| 248 | make changes and save them, the file is created. If you change the | ||
| 249 | variable @code{confirm-nonexistent-file-or-buffer} to @code{nil}, then | ||
| 250 | Emacs will not even prompt you for confirmation. | ||
| 251 | 251 | ||
| 252 | @kindex C-x C-v | 252 | @kindex C-x C-v |
| 253 | @findex find-alternate-file | 253 | @findex find-alternate-file |
| @@ -499,8 +499,9 @@ matches a regexp. | |||
| 499 | The mode bits can be specified in symbolic notation, like with GNU | 499 | The mode bits can be specified in symbolic notation, like with GNU |
| 500 | Coreutils, in addition to an octal number. | 500 | Coreutils, in addition to an octal number. |
| 501 | +++ | 501 | +++ |
| 502 | *** If you set find-file-confirm-nonexistent-file to t, then C-x C-f | 502 | *** Emacs requires confirmation before opening a non-existent file or buffer. |
| 503 | requires confirmation before opening a non-existent file. | 503 | You can recover the previous behavior by setting |
| 504 | confirm-nonexistent-file-or-buffer to nil. | ||
| 504 | 505 | ||
| 505 | *** `next-error-recenter' specifies how next-error should recenter the | 506 | *** `next-error-recenter' specifies how next-error should recenter the |
| 506 | visited source file. Its value can be a number (for example, 0 for | 507 | visited source file. Its value can be a number (for example, 0 for |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8f871362adb..0d76f444be9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-11-18 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files.el (confirm-nonexistent-file-or-buffer): | ||
| 4 | Rename from find-file-confirm-nonexistent-file. | ||
| 5 | (read-buffer-to-switch): Use it. | ||
| 6 | |||
| 1 | 2008-11-18 Juanma Barranquero <lekktu@gmail.com> | 7 | 2008-11-18 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 8 | ||
| 3 | * server.el (server-temp-file-p): Use `string-match-p'. | 9 | * server.el (server-temp-file-p): Use `string-match-p'. |
diff --git a/lisp/files.el b/lisp/files.el index b36b0af8322..5ed3ffae29a 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1102,6 +1102,13 @@ use with M-x." | |||
| 1102 | (rename-file encoded new-encoded ok-if-already-exists) | 1102 | (rename-file encoded new-encoded ok-if-already-exists) |
| 1103 | newname)) | 1103 | newname)) |
| 1104 | 1104 | ||
| 1105 | (defcustom confirm-nonexistent-file-or-buffer t | ||
| 1106 | "If non-nil, confirmation is requested before visiting a new file or buffer. | ||
| 1107 | This affects commands like `switch-to-buffer' and `find-file'." | ||
| 1108 | :group 'find-file | ||
| 1109 | :version "23.1" | ||
| 1110 | :type 'boolean) | ||
| 1111 | |||
| 1105 | (defun read-buffer-to-switch (prompt) | 1112 | (defun read-buffer-to-switch (prompt) |
| 1106 | "Read the name of a buffer to switch to and return as a string. | 1113 | "Read the name of a buffer to switch to and return as a string. |
| 1107 | It is intended for `switch-to-buffer' family of commands since they | 1114 | It is intended for `switch-to-buffer' family of commands since they |
| @@ -1110,7 +1117,8 @@ and default values." | |||
| 1110 | (let ((rbts-completion-table (internal-complete-buffer-except))) | 1117 | (let ((rbts-completion-table (internal-complete-buffer-except))) |
| 1111 | (minibuffer-with-setup-hook | 1118 | (minibuffer-with-setup-hook |
| 1112 | (lambda () (setq minibuffer-completion-table rbts-completion-table)) | 1119 | (lambda () (setq minibuffer-completion-table rbts-completion-table)) |
| 1113 | (read-buffer prompt (other-buffer (current-buffer)))))) | 1120 | (read-buffer prompt (other-buffer (current-buffer)) |
| 1121 | (if confirm-nonexistent-file-or-buffer 'confirm-only))))) | ||
| 1114 | 1122 | ||
| 1115 | (defun switch-to-buffer-other-window (buffer &optional norecord) | 1123 | (defun switch-to-buffer-other-window (buffer &optional norecord) |
| 1116 | "Select buffer BUFFER in another window. | 1124 | "Select buffer BUFFER in another window. |
| @@ -1192,12 +1200,6 @@ Recursive uses of the minibuffer will not be affected." | |||
| 1192 | ,@body) | 1200 | ,@body) |
| 1193 | (remove-hook 'minibuffer-setup-hook ,hook))))) | 1201 | (remove-hook 'minibuffer-setup-hook ,hook))))) |
| 1194 | 1202 | ||
| 1195 | (defcustom find-file-confirm-nonexistent-file nil | ||
| 1196 | "If non-nil, `find-file' requires confirmation before visiting a new file." | ||
| 1197 | :group 'find-file | ||
| 1198 | :version "23.1" | ||
| 1199 | :type 'boolean) | ||
| 1200 | |||
| 1201 | (defun find-file-read-args (prompt mustmatch) | 1203 | (defun find-file-read-args (prompt mustmatch) |
| 1202 | (list (let ((find-file-default | 1204 | (list (let ((find-file-default |
| 1203 | (and buffer-file-name | 1205 | (and buffer-file-name |
| @@ -1230,7 +1232,7 @@ To visit a file without any kind of conversion and without | |||
| 1230 | automatically choosing a major mode, use \\[find-file-literally]." | 1232 | automatically choosing a major mode, use \\[find-file-literally]." |
| 1231 | (interactive | 1233 | (interactive |
| 1232 | (find-file-read-args "Find file: " | 1234 | (find-file-read-args "Find file: " |
| 1233 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1235 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1234 | (let ((value (find-file-noselect filename nil nil wildcards))) | 1236 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 1235 | (if (listp value) | 1237 | (if (listp value) |
| 1236 | (mapcar 'switch-to-buffer (nreverse value)) | 1238 | (mapcar 'switch-to-buffer (nreverse value)) |
| @@ -1250,7 +1252,7 @@ Interactively, or if WILDCARDS is non-nil in a call from Lisp, | |||
| 1250 | expand wildcards (if any) and visit multiple files." | 1252 | expand wildcards (if any) and visit multiple files." |
| 1251 | (interactive | 1253 | (interactive |
| 1252 | (find-file-read-args "Find file in other window: " | 1254 | (find-file-read-args "Find file in other window: " |
| 1253 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1255 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1254 | (let ((value (find-file-noselect filename nil nil wildcards))) | 1256 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 1255 | (if (listp value) | 1257 | (if (listp value) |
| 1256 | (progn | 1258 | (progn |
| @@ -1273,7 +1275,7 @@ Interactively, or if WILDCARDS is non-nil in a call from Lisp, | |||
| 1273 | expand wildcards (if any) and visit multiple files." | 1275 | expand wildcards (if any) and visit multiple files." |
| 1274 | (interactive | 1276 | (interactive |
| 1275 | (find-file-read-args "Find file in other frame: " | 1277 | (find-file-read-args "Find file in other frame: " |
| 1276 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1278 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1277 | (let ((value (find-file-noselect filename nil nil wildcards))) | 1279 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 1278 | (if (listp value) | 1280 | (if (listp value) |
| 1279 | (progn | 1281 | (progn |
| @@ -1298,7 +1300,7 @@ Like \\[find-file], but marks buffer as read-only. | |||
| 1298 | Use \\[toggle-read-only] to permit editing." | 1300 | Use \\[toggle-read-only] to permit editing." |
| 1299 | (interactive | 1301 | (interactive |
| 1300 | (find-file-read-args "Find file read-only: " | 1302 | (find-file-read-args "Find file read-only: " |
| 1301 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1303 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1302 | (unless (or (and wildcards find-file-wildcards | 1304 | (unless (or (and wildcards find-file-wildcards |
| 1303 | (not (string-match "\\`/:" filename)) | 1305 | (not (string-match "\\`/:" filename)) |
| 1304 | (string-match "[[*?]" filename)) | 1306 | (string-match "[[*?]" filename)) |
| @@ -1315,7 +1317,7 @@ Like \\[find-file-other-window], but marks buffer as read-only. | |||
| 1315 | Use \\[toggle-read-only] to permit editing." | 1317 | Use \\[toggle-read-only] to permit editing." |
| 1316 | (interactive | 1318 | (interactive |
| 1317 | (find-file-read-args "Find file read-only other window: " | 1319 | (find-file-read-args "Find file read-only other window: " |
| 1318 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1320 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1319 | (unless (or (and wildcards find-file-wildcards | 1321 | (unless (or (and wildcards find-file-wildcards |
| 1320 | (not (string-match "\\`/:" filename)) | 1322 | (not (string-match "\\`/:" filename)) |
| 1321 | (string-match "[[*?]" filename)) | 1323 | (string-match "[[*?]" filename)) |
| @@ -1332,7 +1334,7 @@ Like \\[find-file-other-frame], but marks buffer as read-only. | |||
| 1332 | Use \\[toggle-read-only] to permit editing." | 1334 | Use \\[toggle-read-only] to permit editing." |
| 1333 | (interactive | 1335 | (interactive |
| 1334 | (find-file-read-args "Find file read-only other frame: " | 1336 | (find-file-read-args "Find file read-only other frame: " |
| 1335 | (if find-file-confirm-nonexistent-file 'confirm-only))) | 1337 | (if confirm-nonexistent-file-or-buffer 'confirm-only))) |
| 1336 | (unless (or (and wildcards find-file-wildcards | 1338 | (unless (or (and wildcards find-file-wildcards |
| 1337 | (not (string-match "\\`/:" filename)) | 1339 | (not (string-match "\\`/:" filename)) |
| 1338 | (string-match "[[*?]" filename)) | 1340 | (string-match "[[*?]" filename)) |