emacs-helm / helm-mu

Helm sources for searching emails and contacts using mu
GNU General Public License v3.0
58 stars 9 forks source link

(require 'helm-mu) fails during startup #10

Closed hyOzd closed 10 years ago

hyOzd commented 10 years ago

When I add (require 'helm-mu) to my .emacs file, emacs fails at startup. Here is the backtrace message with --debug-init:

Debugger entered--Lisp error: (wrong-type-argument keymapp nil)
  define-key(nil [menu-bar Tools Helm Tools] ("Tools" keymap "Tools"))
  byte-code(<REMOVEDBINARY>
easy-menu-get-map(nil ("Tools" "Helm" "Tools") nil)
  easy-menu-add-item(nil ("Tools" "Helm" "Tools") ["Mu" helm-mu t])
  eval-buffer(#<buffer  *load*-487371> nil "/home/<username>/helm-mu/helm-mu.el" nil t)  ; Reading at buffer position 5112
  load-with-code-conversion("/home/<username>/helm-mu/helm-mu.el" "/home/<username>/helm-mu/helm-mu.el" nil t)
  require(helm-mu)
  eval-buffer(#<buffer  *load*> nil "/home/<username>/.emacs" nil t)  ; Reading at buffer position 15565
  load-with-code-conversion("/home/<username>/.emacs" "/home/<username>/.emacs" t t)
  load("~/.emacs" t t)
  #[0 <REMOVEDBINARY>
  command-line()
  normal-top-level()

But if I run (require 'helm-mu) from scratch buffer after emacs started, there is no problem. helm-mu works as expected. Using autoload method also works.

Emacs version 24.3.1.

tmalsburg commented 10 years ago

Are you loading helm-mu before helm is configured? If yes, please reverse the order. helm-mu is trying to add an entry to a menu that is created by helm during startup.

hyOzd commented 10 years ago

Adding (require 'helm-config) before helm-mu solved the issue. Thanks.

tmalsburg commented 10 years ago

Great!

t-jones commented 9 years ago

I just hit this same issue. Might be good to add a note to the readme.

xuchunyang commented 9 years ago

How about checking if helm-config is already loaded before adding helm-mu's menus, for example,

(when (featurep 'helm-config)
  (easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu" helm-mu t])
  (easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu contacts" helm-mu-contacts t]))

or

(eval-after-load "helm-config"
  '(progn
     (easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu" helm-mu t])
     (easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu contacts" helm-mu-contacts t])))

or always make sure helm menu is added.

(require 'helm-easymenu)
(easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu" helm-mu t])
(easy-menu-add-item nil '("Tools" "Helm" "Tools") ["Mu contacts" helm-mu-contacts t])
tmalsburg commented 9 years ago

@t-jones Yes. I thought I had added something but that was in fact in the documentation of another helm source.

Thank you @xuchunyang. I think all three solutions look good. However, it's really the user's responsibility to make sure helm is configured properly. So another solution would be to check for (feature-p helm-config) and throw an error if it's absent (fail-fast principle).

tmalsburg commented 9 years ago

@t-jones Added a note in 9bd7e9b605905e9e584f0c689c9c0b87bbeed590.

@xuchunyang Added a version of your first proposal in 164684c64b86ae46db39391f93465ea6b5434715. If (not (featurep 'helm-config)), a warning is dispalyed.

justmytwospence commented 9 years ago

This warning incorrectly fires with a config like this:

(use-package helm-config :ensure helm)
(use-package helm-mu)

It seems like with use-package, the featurep detects helm but not helm-config. Not sure if this is a bug in use-package not, but relevant here.

luxbock commented 8 years ago

Yeah I'd like to include helm-mu as a part of a Spacemacs layer but I've ran into the issue described by @justmytwospence as Spacemac uses use-package to manage its layers.

tmalsburg commented 8 years ago

This sounds like an issue for helm or use-package or both. However, if there is a workaround that we can add to helm-mu, let me know, or even better make a PR.

jschaf commented 8 years ago

I created an issue with spacemacs at https://github.com/syl20bnr/spacemacs/issues/4363

tmalsburg commented 8 years ago

Following Thierry Volpiatto's recommendation, I now require helm-easymenu. I also dropped the warning that was emitted when helm-config was not present. See 5cb7166b88bcd851cabe0ce0007fe59914e1a4df.