From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Toon Claes Newsgroups: gmane.emacs.devel Subject: [ELPA] New package: use-package-hydra Date: Sat, 18 Aug 2018 10:35:18 +0200 Message-ID: <877eko5ayh.fsf@iotcl.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1534581252 911 195.159.176.226 (18 Aug 2018 08:34:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Aug 2018 08:34:12 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 18 10:34:08 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqwgR-0008Vf-9T for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 10:34:07 +0200 Original-Received: from localhost ([::1]:38074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqwiV-0003yb-PJ for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 04:36:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqwhq-0003yK-Sd for emacs-devel@gnu.org; Sat, 18 Aug 2018 04:35:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqwhn-0005ph-OC for emacs-devel@gnu.org; Sat, 18 Aug 2018 04:35:34 -0400 Original-Received: from smtp.soverin.net ([94.130.159.241]:59878 helo=g02sm02.soverin.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqwhn-0005ma-AK for emacs-devel@gnu.org; Sat, 18 Aug 2018 04:35:31 -0400 Original-Received: from soverin.net by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=iotcl.com; s=default; t=1534581328; bh=dKCSTeSlMlSxwQM7eqdUB2Z8Nsjp/nsEDNqv+9i1CYY=; h=From:To:Subject:Date:From; b=DrUBi4yYuL/b1IQSPf8Oi/YwCY+CmHS8EBNbEN6Wh9nKLfESk+YMfT+1J7aijpulb qMNj4IpBTCvpIhDr0y3jMV2vArCTA1Chod3cDgq4ddj8NxyQ33EsoZxwhCADoG3ThF dDrgLtYQfI1ItMQKqHXJsU7vNlRJRuAW15PKjJOs= X-Virus-Scanned: clamav-milter 0.99.2 at g02sm02 X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 94.130.159.241 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228655 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hi, I'd like to request adding use-package-hydra to ELPA. It uses the powers of hydra, and adds them to use-package. See https://elpa.gnu.org/packages/hydra.html for info about hydra. use-package isn't on ELPA, but it might be one day. See https://github.com/jwiegley/use-package At the bottom is the README of the package. There are still some feature I'd like to add in the future, but I think users can benefit from the current version as-is. And I'm also hoping to attract contributors by publishing this on ELPA. Any comment is welcome. -- Toon --- * use-package-hydra This package adds the =:hydra= keyword to the =use-package= macro. ** Usage You can define [[https://github.com/abo-abo/hydra][Hydras]] directly in the =use-package= definition. The =:hydra= keyword expects the same arguments as =defhydra= does. You can define a single hydra, or a list of hydras. Binding a key to a hydra is similar as with =defhydra=. You can specify the map and the key in the hydra itself, or you can use the =use-package= =:bind= keyword to bind a key to the =/body= function. ** Examples #+begin_src emacs-lisp :tangle yes (use-package yasnippet :after hydra :bind (:map yas-minor-mode-map ("" . hydra-yas/body)) :hydra (hydra-yas (:color blue :hint nil) " ^YASnippets^ -------------------------------------------- Modes: Load/Visit: Actions: _g_lobal _d_irectory _i_nsert _m_inor _f_ile _t_ryout _e_xtra _l_ist _n_ew _a_ll " ("d" yas-load-directory) ("e" yas-activate-extra-mode) ("i" yas-insert-snippet) ("f" yas-visit-snippet-file :color blue) ("n" yas-new-snippet) ("t" yas-tryout-snippet) ("l" yas-describe-tables) ("g" yas/global-mode) ("m" yas/minor-mode) ("a" yas-reload-all))) #+end_src ** Installation You can use =use-package= itself to install this extension. #+begin_src emacs-lisp :tangle yes (use-package use-package-hydra :ensure t) #+end_src --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=use-package-hydra.el Content-Transfer-Encoding: quoted-printable Content-Description: use-package-hydra package ;;; use-package-hydra.el --- Adds :hydra keyword to use-package macro ;; Copyright (C) 2018 Toon Claes ;; Author: Toon Claes ;; Maintainer: Toon Claes ;; Created: 6 Jan 2018 ;; Modified: 18 Aug 2018 ;; Version: 0.1 ;; Package-Requires: ((emacs "24.3") (use-package "2.4")) ;; Keywords: dotemacs startup speed config package hydra keychords ;; URL: https://gitlab.com/to1ne/use-package-hydra ;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; Provides support for the :hydra keyword, which is made available by ;; default by requiring `use-package'. ;;; Code: (require 'use-package-core) (defun use-package-hydra--name (name) "Build hydra name for the package NAME." (cl-gentemp (concat "hydra-" (symbol-name name)))) ;;;###autoload (defun use-package-hydra--normalize (name _keyword args) "Normalize the ARGS to be a list hydras. It accepts a single hydra, or a list of hydras. It is optional provide a name for the hydra, if so there is a name generated from NAME." (let (name result*) (while args (cond ;; single named hydra ((symbolp (car args)) (setq result* (nconc result* (list args)) args nil)) ;; single unnamed hydra with docstring ((stringp (nth 2 args)) (setq name (use-package-hydra--name name) result* (nconc result* (list (cons name args))) args nil)) ;; TODO single unnamed hydra without docstring ;; list of hydras ((listp (car args)) (setq result* (nconc result* (use-package-hydra--normalize name _keyword (c= ar args))) args (cdr args))) ;; Error! (t (use-package-error (concat (symbol-name name) " wants arguments acceptable to the `defhydra' macro," " or a list of such values"))))) result*)) ;;;###autoload (defalias 'use-package-normalize/:hydra 'use-package-hydra--normalize "Normalize for the definition of one or more hydras.") ;;;###autoload (defun use-package-handler/:hydra (name keyword args rest state) "Generate defhydra code for hydra keyword." (use-package-concat (mapcar #'(lambda (def) `(defhydra ,@def)) args) (use-package-process-keywords name rest state))) (add-to-list 'use-package-keywords :hydra t) (provide 'use-package-hydra) ;;; use-package-hydra.el ends here --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEqpqkV/lEuXKD1KF3MRQ6gtMrOJcFAlt32kYACgkQMRQ6gtMr OJfO2A//ace+rpWn938bvgONPODLj7UQUjCxsNljRPSHZVNZGn3L8lh/USRDl7Mh 5aBjwJAmwnFnskJaHTQgSLnUsfMzleuMr/QPRjLB47yvvWF8v4y/tyLuSZ6cI4b9 wvKQQApjT90G+zaz39SR0/BO9r8ncsoRRfEH13mf0AKwWg5mYsxqnIjC3q+4BzT2 9Mt7peTdXF7vqJZtBAMGN7KaO+NLRL3grvXqyVL2ktRwCSLvK8n6GCx+jSkFnjIk LreaA6x9IhK2hQZpYduL6Qa4HC23YTJVl3+29i5oEvboeyctngToXPBKIgzIb4WD 0+WNsU1gzR06wtLAlpdP5fg+nmaXNnYCGAsZCFVnpdL9ciiP93N1yBERNdLAXWjg M+7X2GXslHs4qN/rC545y5Y6oyQDrIg+bS5tpRqcA3qTSfJSsgwDsCOXcFW17/Ft 4MsObg2Y5RLanjebd5tS2gyZ06yjjMtzEh5OiP+wNA0IRCXRmMHy2xH8bWJ6fEno Uyty/7BfoRzrZ4b4lvvzebs+lrU6SDrgXA+tkC4ZJ84p8IHUDTLgwoRvODQ52av0 NaDT7Nm/oBfxojvzmsuNRkGZd3ZZuBKxY3OO15wN8toRmsFOevqh8xFxU97pZuzC vxZmHLTICw0OIumkmjIvVvC6i/hcPuZDaidXnlMXRONE58Bo5DA= =l6ZG -----END PGP SIGNATURE----- --==-=-=--