From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrea Crotti Newsgroups: gmane.emacs.help Subject: Popup last command Date: Wed, 22 Dec 2010 17:16:35 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1293034635 26003 80.91.229.12 (22 Dec 2010 16:17:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 22 Dec 2010 16:17:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 22 17:17:11 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PVRNH-0001hY-EM for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Dec 2010 17:17:11 +0100 Original-Received: from localhost ([127.0.0.1]:34920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PVRNG-0003OE-C5 for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Dec 2010 11:17:10 -0500 Original-Received: from [140.186.70.92] (port=33409 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PVRMv-0003O4-LS for help-gnu-emacs@gnu.org; Wed, 22 Dec 2010 11:16:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PVRMu-0007KZ-Ix for help-gnu-emacs@gnu.org; Wed, 22 Dec 2010 11:16:49 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:47101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PVRMu-0007KI-0N for help-gnu-emacs@gnu.org; Wed, 22 Dec 2010 11:16:48 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PVRMs-0001Rn-DR for help-gnu-emacs@gnu.org; Wed, 22 Dec 2010 17:16:46 +0100 Original-Received: from ip1-201.halifax.rwth-aachen.de ([137.226.108.201]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Dec 2010 17:16:46 +0100 Original-Received: from andrea.crotti.0 by ip1-201.halifax.rwth-aachen.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Dec 2010 17:16:46 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip1-201.halifax.rwth-aachen.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:3Pa+Xw1SLRNQ7IUgys16hI7YDSg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77795 Archived-At: Thanks to the help of some of the presents some timie ago I came up with the following: --8<---------------cut here---------------start------------->8--- (defun growl-popup (msg) "Pop up a growl notification with MSG, or display an Emacs message. The \"growlnotify\" program is used if `window-system' is non-nil and the program is found in `exec-path'; otherwise `message' is used." (interactive) (if (and window-system (executable-find "growlnotify")) (shell-command (concat "growlnotify -a /Applications/Emacs.app/ -m " (shell-quote-argument msg))) (message msg))) (defun popup-last () (interactive) (let ((last-key (key-description (this-command-keys)))) ;; check if we don't have a "stupid" sequence (unless (= (length (this-command-keys-vector)) 1) (growl-popup last-key)))) (setq growl-mode nil) (defun growl () (interactive) (if (not growl-mode) (progn (message "enabling growl mode notification") (add-hook 'pre-command-hook 'popup-last) (setq growl-mode t)) (progn (setq-default pre-command-hook (remq 'popup-last pre-command-hook)) (message "disabling growl mode notification") (setq growl-mode nil)))) --8<---------------cut here---------------end--------------->8--- this function growl combined with growl installed on OSX machines can popup the last command inserted, at the moment only when is at least composed by two keys, thanks to this: (unless (= (length (this-command-keys-vector)) 1) (growl-popup last-key)))) But I'm not yet completely satisfied. Sometimes even commands with only one key are important in some modes, so the idea is maybe that I could instead filter ONLY "self-insert-command", while all the rest could be anyway interesting. But I don't get how I can do that, how can I change the two lines above to get the result desired? And the other thing is that the switch for enabling/disabling growl doesn't work like that. I looked in other code and using a minor-mode it looks much easier, but I don't get why it doesn't work as I did, what's wrong with that solution? Thanks, Andrea