help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use-package: load package on key prefix


From: Emanuel Berg
Subject: Re: use-package: load package on key prefix
Date: Mon, 09 May 2016 02:36:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Joe Riel <joer@san.rr.com> writes:

> I use the p4 (perforce) package which uses C-x p as
> a prefix for its bound keys. Can use-package be
> configured so that it loads the package (which
> presumably assigns the key-bindings) when C-x
> p is pressed?

It can, but unless you load the package somehow else,
the keybinding won't be in effect and if you load it
somehow else, there is no reason for such
a keybinding, is it, as the package is already loaded?

And - why do you want a keyboard shortcut to load
a package anyway? Shortcuts are there to "optimize the
common case", to quote the paleo-sacred scrolls of
techno-techno-science. In this "case" that means you
are benefited from assigning commands to shortcuts,
which are invoked repeatedly and/or frequently!

Perhaps you can describe your situation in human
terms instead?

E.g., do you "refresh" some state associated with the
package by reloading the entire package? If so, in
nine times out of ten, there are better ways to do
that. Take your time to examine the situation and
analyze what part needs to be reset (or set). You are
not on K2 so there is no need to muscle up the
thrice-accursed tent!

But if you still want it, to answer your question, as
you describe the circularity, no, instead you would
want to put the load shortcut in the global keymap:

    (defun load-gnus ()
      "Load probably the best piece of software in the world.
    (But we will have to verify that.)"
      (interactive)
      (load "gnus") )

    (global-set-key "\C-xp" #'load-gnus)

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 26 Blogomatic articles -                   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]