0

I've get emacs 25 build ppa taken from this ask ubuntu answer

and I have this functions and macro:

(defun remove-lambda-helper (list matcher)
  "function that remove lambda from a list if match the function `matcher'"
  (dolist (item list list)
    (if (and (listp item) (eq (car item) 'lambda))
        (when (funcall matcher item)
          (setq list (delete item list))))))


(defun remove-project-specifics-lambda (name hook)
  "Remove lambda from a hook that have code from `project-specifics'"
  (set hook
       (remove-lambda-helper (symbol-value hook)
                             (lambda (body)
                               (equal (cadr (cadr (caddr body))) name)))))

(defmacro project-specifics (name &rest body)
  (declare (indent 1))
  (let ((item (gensym)))
    `(progn
       (remove-project-specifics-lambda ,name 'find-file-hook)
       (remove-project-specifics-lambda ,name 'dired-after-readin-hook)
       (add-hook 'find-file-hook (lambda ()
                                   (when (string-match-p ,name (buffer-file-name))
                                     ,@body)))
       (add-hook 'dired-after-readin-hook
                 (lambda ()
                   (when (string-match-p ,name (dired-current-directory))
                     ,@body))))))

and I got error (the macro works fine in 24.5.1):

Debugger entered--Lisp error: (void-variable dired-after-readin-hook)

if I try C-h v dired-after-readin-hook, I got [no match]

was that hook removed or replaced with different one? I know that I can use directory specific file, but I want my macro to work, anybody know why this return error?

1

It seems that dired is not enabled by default, I've needed to add:

(require 'dired)
| improve this answer | |
  • emacs -Q --batch --eval "(message \"%S\" (featurep 'dired))" prints nil for me using Emacs 24.5 as well, maybe it's a change in the Ubuntu package. – npostavs Apr 8 '17 at 19:54
  • 1
    @npastavs I also have nil on 24.5, the problem was w3m package that seems to require dired for me. – jcubic Apr 8 '17 at 20:29
  • Ah, well, you might want to look at boundp and/or bound-and-true-p instead of loading dired eagerly. – npostavs Apr 8 '17 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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