emacs-devel
[Top][All Lists]
Advanced

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

display-buffer vs. current-buffer vs. post-command-hook


From: Ami Fischman
Subject: display-buffer vs. current-buffer vs. post-command-hook
Date: Tue, 04 Oct 2016 09:28:23 +0000

current-buffer returns a stale value immediately after display-buffer returns.

The following snippet (saved in x.el), when loaded in 25.1.1 using [google-emacs -Q -l x.el], generates the message:
*scratch* *scratch* *Help*
demonstrating that (current-buffer) has a stale value after describe-key returns (I expect post to match the [run-at-time 0] value, not the pre value).

(progn
  (setq display-buffer-alist '(("." (lambda (buffer alist) (switch-to-buffer buffer)))))
  (setq pre (current-buffer))
  (describe-key (kbd "SPC"))
  (setq post (current-buffer))
  (run-at-time 0 nil (lambda () (message "%s %s %s" pre post (current-buffer)))))

This is an extremely reduced test case that reproduces the problem that is causing https://github.com/mina86/auto-dim-other-buffers.el/issues/10 (AFAICT).

Cheers,
-a

reply via email to

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