Not loading which-key-mode

I added the following to .emacs and got the error at the bottom.

(ivy-mode)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
 enable this if you want `swiper' to use it
(setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)

(define-minor-mode ivy-mode
 "ivy-mode"
 :init-value t)

(use-package counsel
  :demand t
  :bind (("M-x" . counsel-M-x)
         ("C-x b" . counsel-ibuffer)
         ("C-x C-f" . counsel-find-file)
         ("C-M-j" . counsel-switch-buffer)
         ("C-M-l" . counsel-imenu)
         :map minibuffer-local-map
         ("C-r" . 'counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  :config
(setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^

(use-package which-key
  :config
  (which-key-mode)
  (setq which-key-idle 0.3
    which-key-idle-dely 50)
  (which-key-setup-minibuffer))

(define-minor-mode which-key-mode
 "which-key-mode"
 :init-value t)
(use-package counsel
  :demand t
  :bind (("M-x" . counsel-M-x)
         ("C-x b" . counsel-ibuffer)
         ("C-x C-f" . counsel-find-file)
         ("C-M-j" . counsel-switch-buffer)
         ("C-M-l" . counsel-imenu)
         :map minibuffer-local-map
         ("C-r" . 'counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  :config
(setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^

(use-package which-key
  :config
  (which-key-mode)
  (setq which-key-idle 0.3
    which-key-idle-dely 50)
  (which-key-setup-minibuffer))

Error

Debugger entered--Lisp error: (void-variable counsel)
  eval(counsel nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

I am and newbie and have no idea what to do next. It is not loading minor mode which-key-mode globally automatically, I have to add it manually to each window.

@wlloydw

To directly answer your question on which-key-mode, do not do this:

(define-minor-mode which-key-mode
 "which-key-mode"
 :init-value t)

I believe it would override the which-key-mode by redefining your own custom which-key-mode that does not seem to do anything – it’s rather a surprise that you could still use which-key-mode in each buffer/window.

I can see that you are confused… I have some observations, but I’ll save them for now and instead perhaps show you an example of what I think is the configuration you are aiming for. See below. I don’t use use-package so I just aligned everything to a built-in way with setq and friends. I don’t use any of the packages, either, so I cannot test them; if any issue, you can come back here or consult the internet.

I hope you can get going with this.

;; Ivy and Counsel
;; Where are Swiper settings?
(ivy-mode)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
(setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
;; Added here from the `use-package' for counsel below
(global-set-key (kbd "C-x b") 'counsel-ibuffer)
(global-set-key (kbd "C-M-j") 'counsel-switch-buffer)
(global-set-key (kbd "C-M-l") 'counsel-imenu)
;; `counsel-linux-app-format-function' was part of the :custom section
;; Do you know if it needs to be in :custom?
;; For now, I am using `setq' instead, which is equivalent to :config section
(setq counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
(setq ivy-initial-inputs-alist nil) ;; Don't start searches with ^

;; Which-key
(which-key-mode)
(setq which-key-idle 0.3)
(setq which-key-idle-dely 50)
(which-key-setup-minibuffer)

Thank you so much. I did not have opportunity today to add this code, hope to tomorrow. Would value any feedback. I am reading everything I can find to flatten this vertical learning curve. Thanks again. Will update soon.

No worries. Take as much as time you need.

For what it’s worth, I have just uploaded my guide entitled " Zero to Emacs and Org-roam: a step-by-step guide on Windows 10".

Even if you are not on Windows, this chapter’s content might be useful for you. It is about Emac’s basic configuration.

For this version, I chose to go with Selectrum, instead of Ivy, purely because you will need less lines of configuration. You can of course stick with Ivy.

One thing my guide does not cover is Which-key. For it, adding this part of configuration should be enough:

;; Which-key
(which-key-mode)
(setq which-key-idle 0.3)
(setq which-key-idle-dely 50)
(which-key-setup-minibuffer)

Nobiot I added the code above to my .emacs file but still get errors when I run eval and Ivy-mode and which-key-mode must still be added manually for org files. I sent a PM a couple of days ago also. Thanks for your help. Lloyd

Here is the entire .emacs file with you code added.


;; -*- lexical-binding: t; -*-

(global-linum-mode t)
(global-visual-line-mode 1)

(setq inhibit-startup-message t)

(global-set-key (kbd "C-x w") 'elfeed)

(scroll-bar-mode -1)        ; Disable visible scrollbar
(tool-bar-mode -1)          ; Disable the toolbar
(tooltip-mode -1)           ; Disable tooltips

(set-fringe-mode 10)        ; Give some breathing room

;; (menu-bar-mode -1)            ; Disable the menu bar

;; Set up the visible bell
(setq visible-bell t)

;; Theme
(load-theme 'wombat)

;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)

;; The following lines are always needed.  Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

;; Initialize package sources
(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "http://stable.melpa.org/packages/")
(add-to-list 'package-archives
	     '("org" . "https://orgmode.org/elpa/") t)

(package-initialize)

(require 'use-package)
  
(use-package org
  :hook (org-mode . org-mode-setup))

(add-hook 'org-mode-hook 'turn-off-filladapt-mode)

;; Ivy and Counsel
;; Where are Swiper settings?
(ivy-mode)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
(setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
;; Added here from the `use-package' for counsel below
(global-set-key (kbd "C-x b") 'counsel-ibuffer)
(global-set-key (kbd "C-M-j") 'counsel-switch-buffer)
(global-set-key (kbd "C-M-l") 'counsel-imenu)
;; `counsel-linux-app-format-function' was part of the :custom section
;; Do you know if it needs to be in :custom?
;; For now, I am using `setq' instead, which is equivalent to :config section
(setq counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
(setq ivy-initial-inputs-alist nil) ;; Don't start searches with ^

;; Which-key
(which-key-mode)
(setq which-key-idle 0.3)
(setq which-key-idle-dely 50)
(which-key-setup-minibuffer)

(use-package wgrep)

(use-package all-the-icons)

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1)
  :custom ((doom-modeline-height 12)))

(use-package doom-themes)

(defun org-mode-setup ()
  (visual-line-mode 1)

;; elfeed RSS reader
(use-package elfeed
  :commands elfeed
  :config
  (setq elfeed-feeds
    '("https://nullprogram.com/feed/"
      "https://ambrevar.xyz/atom.xml"
      "https://guix.gnu.org/feeds/blog.atom"
      "https://valdyas.org/fading/feed/"
      "https://www.reddit.com/r/emacs/.rss")))