Subject: RE: bug#45177: 27.1; Access to invoking top level command in minibuffer

From: Drew Adams <[email-masked]>
Date: Fri, 11 Dec 2020 09:35:25 -0800 (PST)

> For command based settings it would be nice to be able to have
> access to the top level command from which the current minibuffer
> session was invoked from. This should also work with multiple minibuffer
> invokations during a command. Using `minibuffer-setup-hook' to save
> `real-this-command' does not work, for example with:

FWIW, `icicle-mode' puts this on `pre-command-hook':

(defun icicle-top-level-prep ()
  "Do top-level stuff.  Used in `pre-command-hook'."
  (unless (> (minibuffer-depth) 0)
    ;; ... <other stuff>
    (unless (memq this-command 
                  '(minibuffer-complete-and-exit
                    icicle-minibuffer-complete-and-exit
                    exit-minibuffer
                    icicle-exit-minibuffer))
      (setq icicle-last-top-level-command  this-command))
    ;; ... <other stuff>
    ))

(defvar icicle-last-top-level-command nil
  "Last top-level command used.")