0

I can bind a function to run when Emacs iconifies a frame

(defun my-handle-iconify-frame()
  ;; I actually do something more useful than this...
  (message "my-handle-iconify-frame")
)
(define-key special-event-map [iconify-frame] (function my-handle-iconify-frame))

This runs my my-handle-iconify-frame function when I use M-x iconify-frame or a key binding that calls that function.

However, it does not run when I use the iconify icon (-) in the window frame.

I also tried adding before advice on iconify-frame but that also is not called when I iconify a frame via the window frame icon.

Is there some other hook or binding where I can set window manager event handlers?

I'm running GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-08-27 on bob.porkrind.org

  • It sounds like a problem with your particular window mgr (or between it and Emacs). On MS Windows (XP, 7, etc.) it works for me to do exactly what you tried: (define-key special-event-map [iconify-frame] 'my-command). I use that in library thumb-frm.el to "thumbify" instead of iconify Emacs frames. (See Fisheye With Thumbs.) – Drew Aug 18 '15 at 2:49
  • This is AskDifferent - I'm running on a MacBook Air ; emacs reports the window-system is 'ns; system-type is 'darwinSo perhaps it is a Mac port problem. – djb Aug 18 '15 at 17:43
  • It might be a porting problem. But it might also be difficult or impossible to DTRT with that window system. Dunno. You can try reporting it to Emacs Dev: M-x report-emacs-bug -- or to whomever ported it. – Drew Aug 18 '15 at 20:21
1

I solved this. I must make the function (interactive):

(defun my-handle-iconify-frame()
  (interactive)
  ;; I actually do something more useful than this...
  (message "in my-handle-iconify-frame")
)

obvious in retrospect, since it is run through a key binding, not as a hook function.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .