From f07435e22b99ccc095c35861dfc76e617ab91d02 Mon Sep 17 00:00:00 2001 From: Matt Spear Date: Mon, 7 Mar 2011 22:40:24 -0800 Subject: [PATCH] add command hook --- bindings.lisp | 3 ++- primitives.lisp | 9 +++++++++ user.lisp | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bindings.lisp b/bindings.lisp index e8d11b6..66e43f8 100644 --- a/bindings.lisp +++ b/bindings.lisp @@ -232,7 +232,8 @@ from most specific groups to most general groups.") "Command mode allows you to type ratpoison commands without needing the @key{C-t} prefix. Keys not bound in StumpWM will still get sent to the current window. To exit command mode, type @key{C-g}." - (message "Press C-g to exit command-mode.") + (setf *in-command-mode* T) + (run-hook-with-args *command-mode-hook* T) (push-top-map *root-map*)) (defcommand set-prefix-key (key) ((:key "Key: ")) diff --git a/primitives.lisp b/primitives.lisp index 10ca8df..ef96629 100644 --- a/primitives.lisp +++ b/primitives.lisp @@ -146,8 +146,17 @@ be an integer.") (defvar *message-window-timer* nil "Keep track of the timer that hides the message window.") +(defvar *in-command-mode* nil + "If T then is in command mode, otherwise nil") + ;;; Hooks +(defvar *command-mode-hook* (list #'(lambda (start) + (when (eq start T) + (message "Press C-g to exit command-mode.")))) + "A hook called whenever command mode is started or exited + it is givet nil on exit, T on start") + (defvar *urgent-window-hook* '() "A hook called whenever a window sets the property indicating that it demands the user's attention") diff --git a/user.lisp b/user.lisp index e9ca71c..ec7bf86 100644 --- a/user.lisp +++ b/user.lisp @@ -213,7 +213,11 @@ such a case, kill the shell command to resume StumpWM." "" ;; This way you can exit from command mode (when (pop-top-map) - (message "Exited."))) + (if *in-command-mode* + (progn + (run-hook-with-args *command-mode-hook* nil) + (setf *in-command-mode* nil)) + (message "Exited.")))) (defcommand-alias abort keyboard-quit) -- 1.7.3.5