Skip to content

A bunch of extra use-package keywords that SEEM to work for me.

Notifications You must be signed in to change notification settings

syvlorg/use-package-extras

Repository files navigation

use-package-extras.el

;; Adapted From:
;; Answer: https://emacs.stackexchange.com/a/7381/31428
;; User: https://emacs.stackexchange.com/users/719/adobe
(format-spec ";; Adapted From: https://github.com/jwiegley/use-package/blob/master/use-package-core.el#L1153
;;;###autoload
(defalias 'use-package-normalize/:%n 'use-package-normalize-forms)

;; Adapted From: https://gitlab.com/to1ne/use-package-hydra/-/blob/master/use-package-hydra.el#L79
;;;###autoload
(defun use-package-handler/:%n (name keyword args rest state)
    (use-package-concat (mapcar #'(lambda (def) `(%f ,@def)) args)
    (use-package-process-keywords name rest state)))" `((?n . ,name) (?f . ,func)))
;;; use-package-extras.el --- a simple package                     -*- lexical-binding: t; -*-

;; Copyright (C) 2021  Jeet Ray

;; Author: Jeet Ray <[email protected]>
;; Keywords: lisp
;; Version: 0.0.1

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; A bunch of `use-package' keywords that SEEM to work for me.

;;; Code:


;; Adapted From: https://github.com/jwiegley/use-package#use-package-chords
;; Important: https://github.com/noctuid/general.el/issues/53#issuecomment-307262154
(require 'cl-lib)
(require 'dash)
(require 'f)
(require 'use-package-core)

(defvar meq/var/profiled nil)

;;;###autoload
(defun meq/load-emacs-file (path) (interactive)
    (load (f-full (f-join
            (if meq/var/profiled pre-user-emacs-directory user-emacs-directory)
            "siluam" path))))

;;;###autoload
(defmacro meq/up (&rest args) (interactive)
    (let* ((pkg (car args))
            (args (cdr args)))
        `(use-package
            ,pkg
            :demand ,(unwind-protect (cl-getf args :demand t) (cl-remf args :demand))
            ,@args)))

;;;###autoload
(defmacro meq/upns (&rest args) (interactive)
    (let* ((pkg (car args))
            (args (cdr args)))
        `(use-package
            ,pkg
            ,@(with-eval-after-load 'straight `(:straight ,(unwind-protect (cl-getf args :straight t) (cl-remf args :straight))))
            ,@args)))

;;;###autoload
(defmacro meq/upnsd (&rest args) (interactive)
    (let* ((pkg (car args))
            (args (cdr args)))
        `(use-package
            ,pkg
            :demand ,(unwind-protect (cl-getf args :demand t) (cl-remf args :demand))
            ,@(with-eval-after-load 'straight `(:straight ,(unwind-protect (cl-getf args :straight t) (cl-remf args :straight))))
            ,@args)))

<<leaf>>

<<around-init>>

<<around-config>>

<<alloy>>

<<ex>>

<<which-key>>

(provide 'use-package-extras)
;;; use-package-extras.el ends here

leaf

<<normalize-and-handle(name="leaf", func="leaf")>>

;; TODO: Convert these to an elisp or noweb function

;; Adapted From: https://github.com/noctuid/general.el/blob/master/general.el#L2553
(setq use-package-keywords
    (cl-loop for item in use-package-keywords
        if (eq item :hook)
        collect :hook and collect :leaf
        else
        unless (eq item :leaf)
        collect item))

around init

<<normalize-and-handle(name="init/defun", func="defun")>>

<<normalize-and-handle(name="init/defun*", func="cl-defun")>>

<<normalize-and-handle(name="load-emacs-file-preconfig", func="meq/load-emacs-file")>>

<<normalize-and-handle(name="load-siluam-file-preconfig", func="meq/load-siluam-file")>>

<<normalize-and-handle(name="use-package-preconfig", func="meq/up")>>

<<normalize-and-handle(name="upnsd-preconfig", func="meq/upnsd")>>

;; Adapted From: https://github.com/noctuid/general.el/blob/master/general.el#L2620
(setq use-package-keywords
    (cl-loop for item in use-package-keywords
        if (eq item :commands)
        collect :commands and
        collect :init/defun and
        collect :init/defun* and
        collect :load-emacs-file-preconfig and
        collect :load-siluam-file-preconfig and
        collect :use-package-preconfig and
        collect :upnsd-preconfig
        else
        unless (memq item '(:init/defun
                            :init/defun*
                            :load-emacs-file-preconfig
                            :load-siluam-file-preconfig
                            :use-package-preconfig
                            :upnsd-preconfig))
        collect item))

around config

<<normalize-and-handle(name="config/defun", func="defun")>>

<<normalize-and-handle(name="config/defun*", func="cl-defun")>>

<<normalize-and-handle(name="load-emacs-file-postconfig", func="meq/load-emacs-file")>>

<<normalize-and-handle(name="load-siluam-file-postconfig", func="meq/load-siluam-file")>>

<<normalize-and-handle(name="use-package-postconfig", func="meq/up")>>

<<normalize-and-handle(name="upnsd-postconfig", func="meq/upnsd")>>

(setq use-package-keywords
    (cl-loop for item in use-package-keywords
        if (eq item :load)
        collect :load and
        collect :config/defun and
        collect :config/defun* and
        collect :load-emacs-file-postconfig and
        collect :load-siluam-file-postconfig and
        collect :use-package-postconfig and
        collect :upnsd-postconfig
        else
        unless (memq item '(:config/defun
                            :config/defun*
                            :load-emacs-file-postconfig
                            :load-siluam-file-postconfig
                            :use-package-postconfig
                            :upnsd-postconfig))
        collect item))

alloy

<<normalize-and-handle(name="gsetq", func="alloy-setq")>>

(setq use-package-keywords
    (cl-loop for item in use-package-keywords
        if (eq item :init)
        collect :init and collect :gsetq
        else
        unless (eq item :gsetq)
        collect item))
<<normalize-and-handle(name="gadvice", func="alloy-add-advice")>>

<<normalize-and-handle(name="gradvice", func="alloy-remove-advice")>>

(add-to-list 'use-package-keywords :gadvice t)
(add-to-list 'use-package-keywords :gradvice t)

(with-eval-after-load 'alloy
    <<normalize-and-handle(name="grook", func="alloy-remove-hook")>>

    (setq use-package-keywords
        (cl-loop for item in use-package-keywords
            if (eq item :gfhook)
            collect :gfhook and
            collect :grook
            else
            unless (eq item :grook)
            collect item)))

ex

<<normalize-and-handle(name="evil-ex", func="evil-ex-define-cmd")>>

(add-to-list 'use-package-keywords :evil-ex t)

<<normalize-and-handle(name="aiern-ex", func="aiern-ex-define-cmd")>>

(add-to-list 'use-package-keywords :aiern-ex t)

<<normalize-and-handle(name="both-ex", func="meq/both-ex-define-cmd")>>

(add-to-list 'use-package-keywords :both-ex t)

which-key

<<normalize-and-handle(name="which-key-change", func="meq/which-key-change")>>

(add-to-list 'use-package-keywords :which-key-change t)

<<normalize-and-handle(name="which-key-change-ryo", func="meq/which-key-change-ryo")>>

(add-to-list 'use-package-keywords :which-key-change-ryo t)

<<normalize-and-handle(name="which-key-change-sorrow", func="meq/which-key-change-sorrow")>>

(add-to-list 'use-package-keywords :which-key-change-sorrow t)

About

A bunch of extra use-package keywords that SEEM to work for me.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published