From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Edward Knyshov Newsgroups: gmane.emacs.help Subject: Re: req-package Date: Fri, 14 Aug 2015 14:54:42 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1439564136 11169 80.91.229.3 (14 Aug 2015 14:55:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Aug 2015 14:55:36 +0000 (UTC) Cc: help-gnu-emacs To: Alexander Shukaev , Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 14 16:55:36 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZQGON-0004mw-As for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Aug 2015 16:55:35 +0200 Original-Received: from localhost ([::1]:46638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQGOM-0001uk-Ss for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Aug 2015 10:55:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQGNp-0001Nf-A2 for help-gnu-emacs@gnu.org; Fri, 14 Aug 2015 10:55:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQGNi-000363-Ut for help-gnu-emacs@gnu.org; Fri, 14 Aug 2015 10:55:01 -0400 Original-Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:35417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQGNi-00035o-HZ for help-gnu-emacs@gnu.org; Fri, 14 Aug 2015 10:54:54 -0400 Original-Received: by lbcbn3 with SMTP id bn3so46741385lbc.2 for ; Fri, 14 Aug 2015 07:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=GeoVmGv8rzBGBtJuUEVt0SABHhJrHDvV1yeeiUMex4w=; b=gdSmi7hocoTs1BNoEEP/A0yi+W2S1N+Pbya9jZZRh+WPrH1U8efp3Fmtd59Xs6z+tN 8k0NNfBX1a/UqA++3BV5jvt7Oon5LitERaI+McRSUtlKGcYO+zkTcdyzMJEpUfgSAToQ CigtAKnBkmHjo4zh/YDvMpK6IRtM82HYqX6jflMzOkfE1BwU1edV1r5SVkbGdAWu1Re+ hS+dWvir3AdVpc4yTMHb5OYq3RctBREPX9k9yF+iPXlTePJrK/83sgKm9j7NFuKRVPan PODeComvUjTY4TjdNlUW/JlpngXwCnYMAal532+MNUjjuFywUWEUepRO1IGXuY0dZ1H4 AJuw== X-Received: by 10.152.29.200 with SMTP id m8mr39708109lah.44.1439564092300; Fri, 14 Aug 2015 07:54:52 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::234 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106589 Archived-At: It's a good idea Alexander. It sounds good. I'm not sure about pull requesting to use package, because its author wanted to keep use package simple, last time I talked to him. That's why req-package was created. But I will really consider adding this improvement to req-package. Could you, please, create an issue at http://github.com/edvorg/req-package ? Edward. On Fri, Aug 14, 2015 at 5:40 PM Alexander Shukaev wrote: > >> In this case you should remove dependency from evil config. > > > > But if you remove the ":require recentf" the code will still fail > > since (evil-make-overriding-map recentf-dialog-mode-map 'motion) will > > signal an error if recentf is not loaded. > > Exactly, and that's what I wanted to point out as design flaw, but I > see one good solution which I believe could improve `req-package' even > further. > > Why not do the following: > > (req-package evil > :config > ;; Here we configure only `evil' itself, e.g.: > (let ((keymap evil-emacs-state-map)) > (setcdr keymap nil) > (define-key keymap (read-kbd-macro evil-toggle-key) > #'evil-exit-emacs-state)) > (setq-default evil-ex-commands nil) > (evil-ex-define-cmd "w[rite]" #'evil-write) > :config recentf > ;; Here we configure what is related to `recentf' (plus `evil' of > course). > ;; It's kind of `:require recentf' (in a sense that it should also > manage dependencies as > ;; `:require recentf' does), but it also includes corresponding > configuration as well. The benefit is > ;; that if `recentf' is not available, then this code is simply > disabled/ignored (similar to how > ;; `with-eval-after-load' functions). This is more general and > flexible approach then `:require'. > (evil-make-overriding-map recentf-dialog-mode-map 'motion) > (evil-set-initial-state 'recentf-dialog-mode 'motion) > (evil-ex-define-cmd "rfm[enu]" #'recentf-open-files) > :config help > ;; Again the same concept as with `recentf'. > (let ((keymap evil-emacs-state-map)) > (define-key keymap (kbd "C-?") #'help)) > (evil-ex-define-cmd "h[elp]" #'help) > :config (my minibuffer) > ;; Again the same concept as with `recentf', but now two packages > are prerequisites. > (my-add-hook 'minibuffer-setup-hook #'evil-insert-state)) > > Furthermore, those `:config' forms should execute exactly in the order > they appear in the code. Why is it important? Consider > `(setq-default evil-ex-commands nil)', this erases all of the default > Evil's ex-commands, then we add our own `(evil-ex-define-cmd "w[rite]" > #'evil-write)'. However, later on, if `recentf' is present, then > `(evil-ex-define-cmd "rfm[enu]" #'recentf-open-files)' should run and > it should definitely run after `(setq-default evil-ex-commands nil)'. > By the way, the same applies to how `evil-emacs-state-map' is managed > (first reset and then gradually repopulated). > > To conclude, I think the above approach is next-level evolution step > for `req-package' and possibly can be pull-requested to `use-package' > at some point. Edward, do you see the potential here to extend > `req-package' accordingly? >