Commit a4f5efdc authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent 0e4d378b
...@@ -703,16 +703,10 @@ The buffer is not selected, just returned to the caller." ...@@ -703,16 +703,10 @@ The buffer is not selected, just returned to the caller."
(condition-case () (condition-case ()
(insert-file-contents filename t) (insert-file-contents filename t)
(file-error (file-error
(setq error t)
;; Run find-file-not-found-hooks until one returns non-nil. ;; Run find-file-not-found-hooks until one returns non-nil.
(let ((hooks find-file-not-found-hooks)) (or (run-hook-with-args-until-success 'find-file-not-found-hooks)
(while (and hooks ;; If they fail too, set error.
(not (and (funcall (car hooks)) (setq error t))))
;; If a hook succeeded, clear error.
(progn (setq error nil)
;; Also exit the loop.
t))))
(setq hooks (cdr hooks))))))
;; Find the file's truename, and maybe use that as visited name. ;; Find the file's truename, and maybe use that as visited name.
(setq buffer-file-truename truename) (setq buffer-file-truename truename)
(setq buffer-file-number number) (setq buffer-file-number number)
...@@ -787,7 +781,7 @@ Finishes by calling the functions in `find-file-hooks'." ...@@ -787,7 +781,7 @@ Finishes by calling the functions in `find-file-hooks'."
(if (and auto-save-default (not noauto)) (if (and auto-save-default (not noauto))
(auto-save-mode t))) (auto-save-mode t)))
(normal-mode t) (normal-mode t)
(mapcar 'funcall find-file-hooks)) (run-hooks 'find-file-hooks))
(defun normal-mode (&optional find-file) (defun normal-mode (&optional find-file)
"Choose the major mode for this buffer automatically. "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,15 +1629,12 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))
(insert ?\n))) (insert ?\n)))
(let ((hooks (append write-contents-hooks local-write-file-hooks (or (run-hook-with-args-until-success 'write-contents-hooks)
write-file-hooks)) (run-hook-with-args-until-success 'local-write-file-hooks)
(done nil)) (run-hook-with-args-until-success 'write-file-hooks)
(while (and hooks ;; If a hook returned t, file is already "written".
(not (setq done (funcall (car hooks))))) ;; Otherwise, write it the usual way now.
(setq hooks (cdr hooks))) (setq setmodes (basic-save-buffer-1)))
;; If a hook returned t, file is already "written".
(cond ((not done)
(setq setmodes (basic-save-buffer-1)))))
(setq buffer-file-number (nth 10 (file-attributes buffer-file-name))) (setq buffer-file-number (nth 10 (file-attributes buffer-file-name)))
(if setmodes (if setmodes
(condition-case () (condition-case ()
...@@ -2229,12 +2220,7 @@ With prefix arg, silently save all file-visiting buffers, then kill." ...@@ -2229,12 +2220,7 @@ With prefix arg, silently save all file-visiting buffers, then kill."
(or (not active) (or (not active)
(yes-or-no-p "Active processes exist; kill them and exit anyway? ")))) (yes-or-no-p "Active processes exist; kill them and exit anyway? "))))
;; Query the user for other things, perhaps. ;; Query the user for other things, perhaps.
(let ((functions kill-emacs-query-functions) (run-hook-with-args-until-failure 'kill-emacs-query-functions)
(yes t))
(while (and functions yes)
(setq yes (and yes (funcall (car functions))))
(setq functions (cdr functions)))
yes)
(kill-emacs))) (kill-emacs)))
(define-key ctl-x-map "\C-f" 'find-file) (define-key ctl-x-map "\C-f" 'find-file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment