help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hooks and let-bound variables


From: Alan Schmitt
Subject: hooks and let-bound variables
Date: Tue, 23 Jun 2015 21:15:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

Hello,

I’m trying to get eshell-autojump to work
(http://www.emacswiki.org/emacs/EshellAutojump) but I’m getting errors
about an undefined variable (curdir). This variable is bound by a let
before a hook is called:

#+begin_src emacs-lisp
      (let ((curdir (eshell/pwd)))
        (unless (equal curdir dired-directory)
          (eshell-add-to-dir-ring curdir))
        (let ((result (cd dired-directory)))
          (and eshell-cd-shows-directory
               (eshell-printn result)))
        (run-hooks 'eshell-directory-change-hook)
        ...
#+end_src

and here is the hook that is called:

#+begin_src emacs-lisp
(defun eshell-autojump-record ()
  "Record the current directory.
`curdir' is set by `eshell/cd'."
  (unless eshell-autojump-map
    (eshell-autojump-load))
  (if (gethash curdir eshell-autojump-map)
      (puthash curdir (1+ (gethash curdir eshell-autojump-map)) 
eshell-autojump-map)
    (puthash curdir 1 eshell-autojump-map)))
#+end_src

I tried to edebug this, and curdir is set before the hook is called, but
it is not set in the called function. Is there a reason why it is not
set?

I'm using emacs 24.5.1.

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Weekly CO₂ average (2015-05-30, Mauna Loa Observatory): 403.41 ppm

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]