karthink / consult-dir

Insert paths into the minibuffer prompt in Emacs
GNU General Public License v3.0
160 stars 9 forks source link

fasd configuration - Symbol's function definition is void: :name #10

Closed muralikodali closed 3 years ago

muralikodali commented 3 years ago

i have added fasd example given in the README.

it has shown the error Symbol's function definition is void: :name

karthink commented 3 years ago

There was a typo in the code. Please check now?

muralikodali commented 3 years ago

now it gives the following error :

symbol's value as variable is void: consult-dir-sources
karthink commented 3 years ago

Just tested it, it works for me. This error sounds like you ran this code before consult-dir was loaded. Can you try running consult-dir once and then running the fasd integration code?

muralikodali commented 3 years ago

my consult-dir configuration is as shown below :

;; consult-dir -  directory jump
(use-package consult-dir
  :straight t
  :bind (("C-x C-d" . consult-dir)
         :map minibuffer-local-completion-map
         ("C-x C-d" . consult-dir)
         ("C-x C-j" . consult-dir-jump-file)))

(setq consult-dir-project-list-function nil)

;; A function that returns a list of directories
(defun consult-dir--fasd-dirs ()
  "Return list of fasd dirs."
  (split-string (shell-command-to-string "fasd -ld") "\n" t))

; A consult source that calls this function
(defvar consult-dir--source-fasd
 `(:name     "Fasd dirs"
   :narrow   ?f
   :category file
   :face     consult-file
   :history  file-name-history
   :enabled  ,(lambda () (executable-find "fasd"))
   :items    ,#'consult-dir--fasd-dirs)
  "Fasd directory source for `consult-dir'.")

;; Adding to the list of consult-dir sources
(add-to-list 'consult-dir-sources 'consult-dir--source-fasd t)
karthink commented 3 years ago

It looks like you forgot a :config block. Try this:

;; consult-dir -  directory jump
(use-package consult-dir
  :straight t
  :bind (("C-x C-d" . consult-dir)
         :map minibuffer-local-completion-map
         ("C-x C-d" . consult-dir)
         ("C-x C-j" . consult-dir-jump-file))

;; THIS BLOCK TO BE LOADED AFTER LOADING CONSULT-DIR
:config
(setq consult-dir-project-list-function nil)

;; A function that returns a list of directories
(defun consult-dir--fasd-dirs ()
  "Return list of fasd dirs."
  (split-string (shell-command-to-string "fasd -ld") "\n" t))

; A consult source that calls this function
(defvar consult-dir--source-fasd
 `(:name     "Fasd dirs"
   :narrow   ?f
   :category file
   :face     consult-file
   :history  file-name-history
   :enabled  ,(lambda () (executable-find "fasd"))
   :items    ,#'consult-dir--fasd-dirs)
  "Fasd directory source for `consult-dir'.")

;; Adding to the list of consult-dir sources
(add-to-list 'consult-dir-sources 'consult-dir--source-fasd t))
muralikodali commented 3 years ago

thanks for your reply.

it is a configuration problem. After changing configuration as suggested by you, it is working fine now.