Mercurial > emacs
comparison lisp/files.el @ 9196:e537b2e10006
(save-buffers-kill-emacs): Use run-hook-with-args-until-failure.
(find-file-noselect): Use run-hook-with-args-until-success.
(after-find-file): Use run-hooks for find-file-hooks.
(basic-save-buffer): Use run-hook-with-args-until-success.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 30 Sep 1994 20:47:37 +0000 |
parents | 53d02761f5b7 |
children | 61ae93bdc652 |
comparison
equal
deleted
inserted
replaced
9195:70b00615cb75 | 9196:e537b2e10006 |
---|---|
701 (set-buffer buf) | 701 (set-buffer buf) |
702 (erase-buffer) | 702 (erase-buffer) |
703 (condition-case () | 703 (condition-case () |
704 (insert-file-contents filename t) | 704 (insert-file-contents filename t) |
705 (file-error | 705 (file-error |
706 (setq error t) | |
707 ;; Run find-file-not-found-hooks until one returns non-nil. | 706 ;; Run find-file-not-found-hooks until one returns non-nil. |
708 (let ((hooks find-file-not-found-hooks)) | 707 (or (run-hook-with-args-until-success 'find-file-not-found-hooks) |
709 (while (and hooks | 708 ;; If they fail too, set error. |
710 (not (and (funcall (car hooks)) | 709 (setq error t)))) |
711 ;; If a hook succeeded, clear error. | |
712 (progn (setq error nil) | |
713 ;; Also exit the loop. | |
714 t)))) | |
715 (setq hooks (cdr hooks)))))) | |
716 ;; Find the file's truename, and maybe use that as visited name. | 710 ;; Find the file's truename, and maybe use that as visited name. |
717 (setq buffer-file-truename truename) | 711 (setq buffer-file-truename truename) |
718 (setq buffer-file-number number) | 712 (setq buffer-file-number number) |
719 ;; On VMS, we may want to remember which directory in a search list | 713 ;; On VMS, we may want to remember which directory in a search list |
720 ;; the file was found in. | 714 ;; the file was found in. |
785 (message msg) | 779 (message msg) |
786 (or not-serious (sit-for 1 nil t))))) | 780 (or not-serious (sit-for 1 nil t))))) |
787 (if (and auto-save-default (not noauto)) | 781 (if (and auto-save-default (not noauto)) |
788 (auto-save-mode t))) | 782 (auto-save-mode t))) |
789 (normal-mode t) | 783 (normal-mode t) |
790 (mapcar 'funcall find-file-hooks)) | 784 (run-hooks 'find-file-hooks)) |
791 | 785 |
792 (defun normal-mode (&optional find-file) | 786 (defun normal-mode (&optional find-file) |
793 "Choose the major mode for this buffer automatically. | 787 "Choose the major mode for this buffer automatically. |
794 Also sets up any specified local variables of the file. | 788 Also sets up any specified local variables of the file. |
795 Uses the visited file name, the -*- line, and the local variables spec. | 789 Uses the visited file name, the -*- line, and the local variables spec. |
1633 (format "Buffer %s does not end in newline. Add one? " | 1627 (format "Buffer %s does not end in newline. Add one? " |
1634 (buffer-name))))) | 1628 (buffer-name))))) |
1635 (save-excursion | 1629 (save-excursion |
1636 (goto-char (point-max)) | 1630 (goto-char (point-max)) |
1637 (insert ?\n))) | 1631 (insert ?\n))) |
1638 (let ((hooks (append write-contents-hooks local-write-file-hooks | 1632 (or (run-hook-with-args-until-success 'write-contents-hooks) |
1639 write-file-hooks)) | 1633 (run-hook-with-args-until-success 'local-write-file-hooks) |
1640 (done nil)) | 1634 (run-hook-with-args-until-success 'write-file-hooks) |
1641 (while (and hooks | 1635 ;; If a hook returned t, file is already "written". |
1642 (not (setq done (funcall (car hooks))))) | 1636 ;; Otherwise, write it the usual way now. |
1643 (setq hooks (cdr hooks))) | 1637 (setq setmodes (basic-save-buffer-1))) |
1644 ;; If a hook returned t, file is already "written". | |
1645 (cond ((not done) | |
1646 (setq setmodes (basic-save-buffer-1))))) | |
1647 (setq buffer-file-number (nth 10 (file-attributes buffer-file-name))) | 1638 (setq buffer-file-number (nth 10 (file-attributes buffer-file-name))) |
1648 (if setmodes | 1639 (if setmodes |
1649 (condition-case () | 1640 (condition-case () |
1650 (set-file-modes buffer-file-name setmodes) | 1641 (set-file-modes buffer-file-name setmodes) |
1651 (error nil)))) | 1642 (error nil)))) |
2227 (setq active t)) | 2218 (setq active t)) |
2228 (setq processes (cdr processes))) | 2219 (setq processes (cdr processes))) |
2229 (or (not active) | 2220 (or (not active) |
2230 (yes-or-no-p "Active processes exist; kill them and exit anyway? ")))) | 2221 (yes-or-no-p "Active processes exist; kill them and exit anyway? ")))) |
2231 ;; Query the user for other things, perhaps. | 2222 ;; Query the user for other things, perhaps. |
2232 (let ((functions kill-emacs-query-functions) | 2223 (run-hook-with-args-until-failure 'kill-emacs-query-functions) |
2233 (yes t)) | |
2234 (while (and functions yes) | |
2235 (setq yes (and yes (funcall (car functions)))) | |
2236 (setq functions (cdr functions))) | |
2237 yes) | |
2238 (kill-emacs))) | 2224 (kill-emacs))) |
2239 | 2225 |
2240 (define-key ctl-x-map "\C-f" 'find-file) | 2226 (define-key ctl-x-map "\C-f" 'find-file) |
2241 (define-key ctl-x-map "\C-q" 'toggle-read-only) | 2227 (define-key ctl-x-map "\C-q" 'toggle-read-only) |
2242 (define-key ctl-x-map "\C-r" 'find-file-read-only) | 2228 (define-key ctl-x-map "\C-r" 'find-file-read-only) |