From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: making a toolbar button globaly available Date: Tue, 20 Jan 2009 00:04:13 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1232427891 2054 80.91.229.12 (20 Jan 2009 05:04:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 20 Jan 2009 05:04:51 +0000 (UTC) Cc: Emacs Development To: joakim@verona.se Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 20 06:06:00 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LP8o0-0005h7-Qr for ged-emacs-devel@m.gmane.org; Tue, 20 Jan 2009 06:05:53 +0100 Original-Received: from localhost ([127.0.0.1]:49270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP8mj-000121-63 for ged-emacs-devel@m.gmane.org; Tue, 20 Jan 2009 00:04:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LP8me-00011n-OZ for emacs-devel@gnu.org; Tue, 20 Jan 2009 00:04:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LP8me-00011O-13 for emacs-devel@gnu.org; Tue, 20 Jan 2009 00:04:16 -0500 Original-Received: from [199.232.76.173] (port=60786 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP8md-00011G-US for emacs-devel@gnu.org; Tue, 20 Jan 2009 00:04:15 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:40043) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LP8md-0001ij-KB for emacs-devel@gnu.org; Tue, 20 Jan 2009 00:04:15 -0500 Original-Received: from alfajor.home (vpn-132-204-232-174.acd.umontreal.ca [132.204.232.174]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n0K54Doi028602; Tue, 20 Jan 2009 00:04:14 -0500 Original-Received: by alfajor.home (Postfix, from userid 20848) id D50FA1C167; Tue, 20 Jan 2009 00:04:13 -0500 (EST) In-Reply-To: (joakim@verona.se's message of "Mon, 19 Jan 2009 18:13:14 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3192=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108007 Archived-At: > I've tried these two aproaches, none seem to work. > Is it a bug or just me? > (define-minor-mode pocketcompletion-mode > "Toggle pocketcompletion mode" > ;; The initial value. > :init-value nil > ;; The indicator for the mode line. > :lighter " pocketcompletion" > ;; The minor mode bindings. > :group 'pocketcompletion > :global t > :keymap > '(([tool-bar pocketcompletion] . > (menu-item "pocketcompletion" pocketcompletion > :image (image :type xpm :file "zoom-in.xpm")))) > (message "pocketcompletion minor body %s" pocketcompletion-mode) > ;(pocketcompletion-enable-toolbar-button);2nd aproach, uncomment > ; this and comment out :keymap > ) > (defun pocketcompletion-enable-toolbar-button () > (define-key global-map [tool-bar pocketcompletion] > '(menu-item "pocketcompletion" pocketcompletion > :image (image :type xpm :file "zoom-in.xpm"))) > ) The problem is that whenever you lookup [tool-bar] in global-map (and such a lookup takes place to find the map into which to add the pocketcompletion element), you receive a new keymap, built fresh by tool-bar-make-keymap. So you want to manipulate tool-bar-map directly. Note that tool-bar-map is buffer-local, so you won't be able to add elements truly globally. For that you'll need to advise tool-bar-make-keymap :-( Stefan