I would like to add to the eshell-predicate-alist in my ~/.emacs.d/init.el file as described in https://www.masteringemacs.org/article/complete-guide-mastering-eshell and http://www.howardism.org/Technical/Emacs/eshell-fun.html. However, when I do:

(require 'eshell)
(defun eshell/e (file)
  "Open the FILE in the current buffer."
  (find-file file))

(defun eshell/ee (file)
  "Open the FILE in a new buffer."
  (find-file-other-window file))

(defun eshell/clear ()
  "Clear the eshell buffer."
  (let ((inhibit-read-only t))

(defun eshell/x ()
  "Exit the shell."
  (insert "exit")

(defun eshell-org-file-tags ()
  "Help the eshell parse the text the point is currently on, looking for parameters surrounded in single quotes.  Return a function that takes a FILE and return nil if the file given to it does not contain the 'org-mode' #+TAGS: entry specified."

  ;; Step 1. Parse the eshell buffer for our tag between quotes
  ;;         Make sure to move point to the end of the match:
  (if (looking-at "'\\([^)']+\\)'")
      (let* ((tag (match-string 1))
             (reg (concat "^#\\+TAGS:.* " tag "\\b")))
        (goto-char (match-end 0))

        ;; Step 2. Return the predicate function:
        ;;         Careful when accessing the `reg' variable.
        `(lambda (file)
             (insert-file-contents file)
             (re-search-forward ,reg nil t 1))))
    (error "The `T' predicate takes an org-mode tag value in single quotes.")))

(add-to-list 'eshell-predicate-alist '(?T . (eshell-org-file-tags)))

I get an error message on startup of Emacs, that the symbol's definition is void for eshell-predicate-alist.

Emacs version is: GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)

How can I get this to work? At my workplace I have a newer version, where this works without issue, even without the (require eshell) at the top.

1 Answer 1


Try adding

(require 'em-pred)

near the top of your file. I found this by running grep eshell-predicate-alist -r lisp in emacs source tree.

Apparently this library (em-pred) is autoloaded when you run the command eshell, but not when you just (require 'eshell). You probably shouldn't use (require 'eshell) at all, but instead wrap all of your code in (with-eval-after-load 'eshell ...) form.

  • Both of these ways work for me. Now when I do echo $exec-path on eshell, all the paths are there. This solves this specific question. Unfortunately it turns out eshell still does not find the executables in those paths, as if there is something else needed to be done to make it find the executables therein. I still cannot call for example conda create ... from eshell. Feb 11, 2018 at 19:17
  • Note: I think it should be (with-eval-after-load 'em-pred <body>). Feb 17, 2018 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.