[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/oclosure bca2f165f5: oclosure.el: Prepare to use it for `autoloa
From: |
Stefan Monnier |
Subject: |
scratch/oclosure bca2f165f5: oclosure.el: Prepare to use it for `autoload` |
Date: |
Fri, 14 Jan 2022 18:40:39 -0500 (EST) |
branch: scratch/oclosure
commit bca2f165f56723e1734424e485c6a6d20fe150ba
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
oclosure.el: Prepare to use it for `autoload`
* lisp/loadup.el: Load `oclosure.el` before `loaddefs.el` so it can be
used to define `autoload`.
* lisp/emacs-lisp/oclosure.el (save-some-buffers-function): New type.
* lisp/files.el (save-some-buffers): Use it.
Require `cl-lib` for `cl-typep`.
* lisp/emacs-lisp/cl-macs.el: Don't depend on `define-inline` autoload.
---
lisp/emacs-lisp/cl-macs.el | 4 +++-
lisp/emacs-lisp/oclosure.el | 6 ++++++
lisp/files.el | 11 +++++++----
lisp/loadup.el | 5 +++--
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index dc8d3d6c54..16cca78fdf 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -45,8 +45,10 @@
(require 'cl-lib)
(require 'macroexp)
-;; `gv' is required here because cl-macs can be loaded before loaddefs.el.
+;; `gv' and `inline' are required here because cl-macs can be loaded
+;; before loaddefs.el.
(require 'gv)
+(eval-when-compile (require 'inline))
(defmacro cl--pop2 (place)
(declare (debug edebug-sexps))
diff --git a/lisp/emacs-lisp/oclosure.el b/lisp/emacs-lisp/oclosure.el
index 861afbec15..9e0024a6c7 100644
--- a/lisp/emacs-lisp/oclosure.el
+++ b/lisp/emacs-lisp/oclosure.el
@@ -31,6 +31,7 @@
;; (by putting the no-next-methods into their own class).
;; - OClosure accessor functions, where the type-dispatch is used to
;; dynamically compute the docstring, and also to pretty them.
+;; - `save-some-buffers-function'
;; Here are other cases of "callable objects" where OClosures could be used:
;; - Use the type to distinguish macros from functions.
;; - iterators (generator.el), thunks (thunk.el), streams (stream.el).
@@ -673,5 +674,10 @@ ARGS and BODY are the same as for `lambda'."
(:parent oclosure-documented))
interactive-form)
+;; Ideally, this should be in `files.el', but that file is loaded
+;; before `oclosure.el'.
+(oclosure-define save-some-buffers-function)
+
+
(provide 'oclosure)
;;; oclosure.el ends here
diff --git a/lisp/files.el b/lisp/files.el
index c4587e9c20..a7f3c1c086 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5793,7 +5793,7 @@ This allows you to stop `save-some-buffers' from asking
about certain files that you'd usually rather not save.
This function is called (with no parameters) from the buffer to
-be saved. When the function's symbol has the property
+be saved. When the function is of type
`save-some-buffers-function', the higher-order function is supposed
to return a predicate used to check buffers."
:group 'auto-save
@@ -5836,8 +5836,8 @@ all with no questions.
Optional second argument PRED determines which buffers are considered:
If PRED is nil, all the file-visiting buffers are considered.
If PRED is t, then certain non-file buffers will also be considered.
-If PRED is a zero-argument function, it indicates for each buffer whether
-to consider it or not when called with that buffer current.
+If PRED is a function, it is called with no argument in each buffer and
+should return non-nil if that buffer should be considered.
PRED defaults to the value of `save-some-buffers-default-predicate'.
See `save-some-buffers-action-alist' if you want to
@@ -5845,9 +5845,12 @@ change the additional actions you can take on files."
(interactive "P")
(unless pred
(setq pred save-some-buffers-default-predicate))
+ ;; Can't be required at top-level for bootstrap reasons.
+ (eval-when-compile (require 'cl-lib))
;; Allow `pred' to be a function that returns a predicate
;; with lexical bindings in its original environment (bug#46374).
- (when (and (symbolp pred) (get pred 'save-some-buffers-function))
+ (when (or (and (symbolp pred) (get pred 'save-some-buffers-function))
+ (cl-typep pred 'save-some-buffers-function))
(let ((pred-fun (and (functionp pred) (funcall pred))))
(when (functionp pred-fun)
(setq pred pred-fun))))
diff --git a/lisp/loadup.el b/lisp/loadup.el
index ec1644f2fc..3c59d639a0 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -184,6 +184,9 @@
;; should be updated by overwriting it with an up-to-date copy of
;; loaddefs.el that is not corrupted by local changes.
;; admin/update_autogen can be used to update ldefs-boot.el periodically.
+(load "emacs-lisp/cl-preloaded")
+(load "emacs-lisp/oclosure") ;Used by cl-generic and nadvice
+
(condition-case nil (load "loaddefs.el")
;; In case loaddefs hasn't been generated yet.
(file-error (load "ldefs-boot.el")))
@@ -195,8 +198,6 @@
(setq definition-prefixes new))
(load "button") ;After loaddefs, because of define-minor-mode!
-(load "emacs-lisp/cl-preloaded")
-(load "emacs-lisp/oclosure") ;Used by cl-generic and nadvice
(load "obarray") ;abbrev.el is implemented in terms of obarrays.
(load "abbrev") ;lisp-mode.el and simple.el use define-abbrev-table.
(load "help")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/oclosure bca2f165f5: oclosure.el: Prepare to use it for `autoload`,
Stefan Monnier <=