unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Execute code in use-package
@ 2016-12-16 16:13 Joe Riel
  2016-12-16 18:12 ` John Mastro
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Riel @ 2016-12-16 16:13 UTC (permalink / raw)
  To: Help GNU Emacs

In my old .emacs file, I auto-load and run a command in
a package by doing

(autoload 'mds "mds" "Restart the Maple Debugger server" t)
(mds) ; start the server

Having converted to use-package, I wrote

(use-package mds
  :commands (mds)
  ;; start the debugger server
  :config (mds))

Alas, that doesn't work.  I have to manually execute the mds command
after launching emacs to start the server.  I've read the documentation 
for use-package, but cannot figure out how to properly do this. 

-- 
Joe Riel




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute code in use-package
  2016-12-16 16:13 Execute code in use-package Joe Riel
@ 2016-12-16 18:12 ` John Mastro
  2016-12-16 19:50   ` Joe Riel
  0 siblings, 1 reply; 4+ messages in thread
From: John Mastro @ 2016-12-16 18:12 UTC (permalink / raw)
  To: Help GNU Emacs

Joe Riel <joer@san.rr.com> wrote:
> In my old .emacs file, I auto-load and run a command in
> a package by doing
>
> (autoload 'mds "mds" "Restart the Maple Debugger server" t)
> (mds) ; start the server
>
> Having converted to use-package, I wrote
>
> (use-package mds
>   :commands (mds)
>   ;; start the debugger server
>   :config (mds))
>
> Alas, that doesn't work.  I have to manually execute the mds command
> after launching emacs to start the server.  I've read the documentation
> for use-package, but cannot figure out how to properly do this.

This should work:

(use-package mds
  :config (mds))

In other words, remove ":commands", which implicitly causes loading (and
thus evaluation of the :config block) to be deferred.

        John



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute code in use-package
  2016-12-16 18:12 ` John Mastro
@ 2016-12-16 19:50   ` Joe Riel
  2016-12-16 20:11     ` John Mastro
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Riel @ 2016-12-16 19:50 UTC (permalink / raw)
  To: John Mastro; +Cc: Help GNU Emacs

On Fri, 16 Dec 2016 10:12:44 -0800
John Mastro <john.b.mastro@gmail.com> wrote:

> Joe Riel <joer@san.rr.com> wrote:
> > In my old .emacs file, I auto-load and run a command in
> > a package by doing
> >
> > (autoload 'mds "mds" "Restart the Maple Debugger server" t)
> > (mds) ; start the server
> >
> > Having converted to use-package, I wrote
> >
> > (use-package mds
> >   :commands (mds)
> >   ;; start the debugger server
> >   :config (mds))
> >
> > Alas, that doesn't work.  I have to manually execute the mds command
> > after launching emacs to start the server.  I've read the documentation
> > for use-package, but cannot figure out how to properly do this.
> 
> This should work:
> 
> (use-package mds
>   :config (mds))
> 
> In other words, remove ":commands", which implicitly causes loading (and
> thus evaluation of the :config block) to be deferred.
> 
>         John

Alas, that doesn't work.  The server does not start and now the mds command
is not assigned so I cannot manually start it.  

What I found that does work is changing :config to :init, that is,

(use-package mds
  :commands (mds)
  :init (mds))

On reflection that might make sense.  What confuses me is that :init runs
code before the package is loaded.  However, I assume that :commands (mds)
ensures that mds is auto-loaded, so the call to (mds) then auto-loads and
runs mds.

-- 
Joe Riel




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute code in use-package
  2016-12-16 19:50   ` Joe Riel
@ 2016-12-16 20:11     ` John Mastro
  0 siblings, 0 replies; 4+ messages in thread
From: John Mastro @ 2016-12-16 20:11 UTC (permalink / raw)
  To: Help GNU Emacs

Joe Riel <joer@san.rr.com> wrote:
>> This should work:
>>
>> (use-package mds
>>   :config (mds))
>>
> Alas, that doesn't work.  The server does not start and now the mds command
> is not assigned so I cannot manually start it.
>
> What I found that does work is changing :config to :init, that is,
>
> (use-package mds
>   :commands (mds)
>   :init (mds))
>
> On reflection that might make sense.  What confuses me is that :init runs
> code before the package is loaded.  However, I assume that :commands (mds)
> ensures that mds is auto-loaded, so the call to (mds) then auto-loads and
> runs mds.

Right - it's essentially equivalent to what you had before
`use-package':

    (autoload 'mds "mds")
    (mds)

However, (use-package mds :config (mds)) really should work too, because
other than some complications for error handling it's morally equivalent
to:

    (require 'mds)
    (mds)

So I'm not sure what's going on there.

        John



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-16 20:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-16 16:13 Execute code in use-package Joe Riel
2016-12-16 18:12 ` John Mastro
2016-12-16 19:50   ` Joe Riel
2016-12-16 20:11     ` John Mastro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).