Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded progn. #56

Merged
merged 4 commits into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Devise novel solution, document in changelog
  • Loading branch information
raxod502 committed Dec 22, 2021
commit 966e7e49e0b8074a137b413b34cf6e7555750236
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,29 @@ The format is based on [Keep a Changelog].
* Patch forms were not processed when they appeared inside a vector.
This has been fixed ([#51]).

### Internal changes
* The autoloading mechanism used by `el-patch` has changed, reducing
the amount of work that is done at startup and simplifying the
implementation ([#56]). The user-facing impact is as follows:
* `el-patch--patches` and `el-patch-deftype-alist` are no longer
autoloaded. If you use a compiled init-file, you may need to
recompile it with the new version of `el-patch`; the code
compiled with the old version of `el-patch` will not work at
runtime with the new version of `el-patch`. However, evaluating
patches in a compiled init-file, even one that uses
`el-patch-deftype`, still does not load `el-patch`.
* `el-patch-defun` and analogous functions are now autoloaded,
rather than fully defined at init time. This should not matter
since a compiled init-file would have macroexpanded these into
smaller components that do not have runtime dependencies on
`el-patch`.
* There is a new file `el-patch-stub.el` that needs to be on the
`load-path` for autoloads to work. This should be taken care of
automatically by any of the popular Emacs package managers.

[#50]: https://github.com/raxod502/el-patch/issues/50
[#51]: https://github.com/raxod502/el-patch/issues/51
[#56]: https://github.com/raxod502/el-patch/pull/56

## 2.3.1 (released 2020-07-16)
### Bugs fixed
Expand Down
46 changes: 46 additions & 0 deletions el-patch-stub.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;;; el-patch-stub.el --- Functions loaded separately -*- lexical-binding: t -*-

;; Copyright (C) 2021 Radon Rosborough

;; Author: Radon Rosborough <radon.neon@gmail.com>
;; Created: 21 Dec 2021
;; Homepage: https://github.com/raxod502/el-patch
;; Keywords: extensions
;; Package-Requires: ((emacs "25"))
;; SPDX-License-Identifier: MIT
;; Version: 2.3.1

;;; Commentary:

;; `el-patch-stub' has some utility functions that are used to define
;; stubs that are used only in the middle of the autoloading process.
;; Basically, they allow us to conveniently set up syntax highlighting
;; and indentation correctly for a number of different functions all
;; at once, without a bunch of code duplication.

;; Please see https://github.com/raxod502/el-patch for more
;; information.

;;; Code:

(defun el-patch--deftype-stub-setup ()
"Define `el-patch-deftype' as a minimal version suitable for autoload time.
This temporary replacement for the real functionality just takes
care of the `declare' forms, and leaves everything else for
later."
(unless (fboundp 'el-patch-deftype)
(defmacro el-patch-deftype (type &rest kwargs)
(let ((name (intern (format "el-patch-%S" type)))
(props (plist-get kwargs :declare)))
`(progn
(autoload ',name "el-patch" nil nil t)
(put ',name 'doc-string-elt ',(alist-get 'doc-string props))
(put ',name 'lisp-indent-function ',(alist-get 'indent props)))))))

(provide 'el-patch-stub)

;; Local Variables:
;; indent-tabs-mode: nil
;; End:

;;; el-patch-stub.el ends here
23 changes: 14 additions & 9 deletions el-patch.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ provided by lazy-installed packages, and those packages need to
be installed before the features can be loaded."
:type 'function)

;;;###autoload
(defcustom el-patch-deftype-alist nil
"Alist of types of definitions that can be patched with `el-patch'.
The keys are definition types, like `defun', `define-minor-mode',
Expand Down Expand Up @@ -549,6 +548,8 @@ MACRO-NAME)."
(unless classify
(error "You must specify `:classify' in calls to `el-patch-deftype'"))
`(progn
(unless (bound-and-true-p el-patch-deftype-alist)
(setq el-patch-deftype-alist nil))
(setf (alist-get ',type el-patch-deftype-alist)
;; Make sure we don't accidentally create self-modifying
;; code if somebody decides to mutate
Expand All @@ -562,6 +563,7 @@ The ARGS are the same as for `%S'."
,@(when declare
`((declare ,@declare)))
(list #'el-patch--definition (cl-list* ',type name args)))))
(put 'el-patch-deftype 'el-patch-defined-properly t)

;;;;; Classification functions

Expand Down Expand Up @@ -660,58 +662,61 @@ DEFINITION is a list starting with `defun' or similar."

;;;;; Predefined patch types

;;;###autoload(require 'el-patch-stub)
;;;###autoload(el-patch--deftype-stub-setup)

;; These are alphabetized.

;;;###autoload (autoload 'el-patch-cl-defun "el-patch")
;;;###autoload
(el-patch-deftype cl-defun
:classify el-patch-classify-function
:locate el-patch-locate-function
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-defconst "el-patch")
;;;###autoload
(el-patch-deftype defconst
:classify el-patch-classify-variable
:locate el-patch-locate-variable
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-defcustom "el-patch")
;;;###autoload
(el-patch-deftype defcustom
:classify el-patch-classify-variable
:locate el-patch-locate-variable
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-define-minor-mode "el-patch")
;;;###autoload
(el-patch-deftype define-minor-mode
:classify el-patch-classify-define-minor-mode
:locate el-patch-locate-function
:declare ((doc-string 2)
(indent defun)))

;;;###autoload (autoload 'el-patch-defmacro "el-patch")
;;;###autoload
(el-patch-deftype defmacro
:classify el-patch-classify-function
:locate el-patch-locate-function
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-defsubst "el-patch")
;;;###autoload
(el-patch-deftype defsubst
:classify el-patch-classify-function
:locate el-patch-locate-function
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-defun "el-patch")
;;;###autoload
(el-patch-deftype defun
:classify el-patch-classify-function
:locate el-patch-locate-function
:declare ((doc-string 3)
(indent defun)))

;;;###autoload (autoload 'el-patch-defvar "el-patch")
;;;###autoload
(el-patch-deftype defvar
:classify el-patch-classify-variable
:locate el-patch-locate-variable
Expand Down