aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-09-30 20:47:37 +0000
committerRichard M. Stallman1994-09-30 20:47:37 +0000
commita4f5efdceaee151aa6430dd831edfeae168adce0 (patch)
treeef1d71b28251ee7541eb6634a711d018fb78467d
parent0e4d378b326194711ca81e445fd3d8b498be9c80 (diff)
downloademacs-a4f5efdceaee151aa6430dd831edfeae168adce0.tar.gz
emacs-a4f5efdceaee151aa6430dd831edfeae168adce0.zip
(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.
-rw-r--r--lisp/files.el36
1 files changed, 11 insertions, 25 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 8f5727ee6cc..691d3dae790 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -703,16 +703,10 @@ The buffer is not selected, just returned to the caller."
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)
@@ -787,7 +781,7 @@ Finishes by calling the functions in `find-file-hooks'."
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.
@@ -1635,15 +1629,12 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
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 ()
@@ -2229,12 +2220,7 @@ With prefix arg, silently save all file-visiting buffers, then kill."
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)