From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#1133: Tool-bar and multi-tty Date: Thu, 09 Oct 2008 22:30:06 -0400 Message-ID: <873aj56v2p.fsf__2702.54975553161$1223607083$gmane$org@cyd.mit.edu> Reply-To: Chong Yidong , 1133@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1223607017 8734 80.91.229.12 (10 Oct 2008 02:50:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Oct 2008 02:50:17 +0000 (UTC) Cc: 1133@emacsbugs.donarmstrong.com, emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 10 04:51:14 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ko85v-0007Hy-3j for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Oct 2008 04:51:11 +0200 Original-Received: from localhost ([127.0.0.1]:46174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ko84q-0006B4-VJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Oct 2008 22:50:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ko84n-00069w-NT for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2008 22:50:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ko84m-00069S-NX for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2008 22:50:01 -0400 Original-Received: from [199.232.76.173] (port=46015 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ko84m-00069P-HI for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2008 22:50:00 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:37260) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ko84m-0002za-I9 for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2008 22:50:00 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m9A2nw27013359; Thu, 9 Oct 2008 19:49:58 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m9A2Z3hU009912; Thu, 9 Oct 2008 19:35:03 -0700 X-Loop: don@donarmstrong.com Resent-From: Chong Yidong Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 10 Oct 2008 02:35:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1133 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1133-submit@emacsbugs.donarmstrong.com id=B1133.12236057008614 (code B ref 1133); Fri, 10 Oct 2008 02:35:03 +0000 Original-Received: (at 1133) by emacsbugs.donarmstrong.com; 10 Oct 2008 02:28:20 +0000 Original-Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m9A2SGc4008608 for <1133@emacsbugs.donarmstrong.com>; Thu, 9 Oct 2008 19:28:18 -0700 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 281F457E14E; Thu, 9 Oct 2008 22:30:06 -0400 (EDT) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Thu, 09 Oct 2008 22:50:01 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:21366 Archived-At: Bug 1133 notes a problem with tool-bars and multi-tty. Basically, tool-bar-map is not set up if the first frame is on a tty; it is only initialized when the first graphical frame is created. This causes problems for major modes that define their own tool-bar maps. I think the solution is to define a normal hook, tool-bar-setup-hook, to be run after the tool-bar is set up successfully for the first time. Each mode which defines its own tool-bar map will have to check if tool-bar-setup is nil at the time the mode is loaded; if not, it must use this hook to initialize the tool-bar variable when the first graphical frame is created. (Note that we can't load the tool-bar variables ahead of time, because the icons used may depend on X settings which are unavailable until X is initialized.) See the attached patch. Similar changes will have to be made to all modes which use the tool-bar. WDYT? *** trunk/lisp/tool-bar.el.~1.19.~ 2008-10-09 21:52:12.000000000 -0400 --- trunk/lisp/tool-bar.el 2008-10-09 22:02:57.000000000 -0400 *************** *** 260,266 **** --- 260,274 ---- (defvar tool-bar-setup nil "Non-nil if the tool-bar has been set up by `tool-bar-setup'.") + (defvar tool-bar-setup-hook nil + "Normal hook run after `tool-bar-setup' is called successfully.") + (defun tool-bar-setup (&optional frame) + "Set up the tool-bar on frame FRAME. + If FRAME is nil, default to the selected frame. + This does nothing if the variable `tool-bar-setup' is non-nil, or + `tool-bar-mode' is disabled, or FRAME is on a text-only terminal. + Otherwise, set up the tool bar and run `tool-bar-setup-hook'." (unless (or tool-bar-setup (null tool-bar-mode) ;; No-op if the initial frame is on a tty, deferring *************** *** 321,327 **** (popup-menu menu-bar-help-menu)) 'help :help "Pop up the Help menu")) ! (setq tool-bar-setup t)))) (provide 'tool-bar) --- 329,336 ---- (popup-menu menu-bar-help-menu)) 'help :help "Pop up the Help menu")) ! (setq tool-bar-setup t) ! (run-hooks 'tool-bar-setup-hook)))) (provide 'tool-bar) *** trunk/lisp/progmodes/compile.el.~1.478.~ 2008-10-09 11:24:39.000000000 -0400 --- trunk/lisp/progmodes/compile.el 2008-10-09 22:19:14.000000000 -0400 *************** *** 1470,1496 **** "Keymap for compilation log buffers. `compilation-minor-mode-map' is a parent of this.") ! (defvar compilation-mode-tool-bar-map ! (if (display-graphic-p) ! (let ((map (butlast (copy-keymap tool-bar-map))) ! (help (last tool-bar-map))) ;; Keep Help last in tool bar ! (tool-bar-local-item ! "left-arrow" 'previous-error-no-select 'previous-error-no-select map ! :rtl "right-arrow" ! :help "Goto previous error") ! (tool-bar-local-item ! "right-arrow" 'next-error-no-select 'next-error-no-select map ! :rtl "left-arrow" ! :help "Goto next error") ! (tool-bar-local-item ! "cancel" 'kill-compilation 'kill-compilation map ! :enable '(let ((buffer (compilation-find-buffer))) ! (get-buffer-process buffer)) ! :help "Stop compilation") ! (tool-bar-local-item ! "refresh" 'recompile 'recompile map ! :help "Restart compilation") ! (append map help)))) (put 'compilation-mode 'mode-class 'special) --- 1470,1498 ---- "Keymap for compilation log buffers. `compilation-minor-mode-map' is a parent of this.") ! (defvar compilation-mode-tool-bar-map (make-sparse-keymap)) ! ! (defun compilation-tool-bar-setup () ! (let ((map compilation-mode-tool-bar-map) ! (help (last tool-bar-map))) ;; Keep Help last in tool bar ! (setcdr map (cdr (butlast (copy-keymap tool-bar-map)))) ! (tool-bar-local-item ! "left-arrow" 'previous-error-no-select 'previous-error-no-select map ! :rtl "right-arrow" ! :help "Goto previous error") ! (tool-bar-local-item ! "right-arrow" 'next-error-no-select 'next-error-no-select map ! :rtl "left-arrow" ! :help "Goto next error") ! (tool-bar-local-item ! "cancel" 'kill-compilation 'kill-compilation map ! :enable '(let ((buffer (compilation-find-buffer))) ! (get-buffer-process buffer)) ! :help "Stop compilation") ! (tool-bar-local-item ! "refresh" 'recompile 'recompile map ! :help "Restart compilation") ! (append map help))) (put 'compilation-mode 'mode-class 'special) *************** *** 1509,1514 **** --- 1511,1519 ---- (use-local-map compilation-mode-map) ;; Let windows scroll along with the output. (set (make-local-variable 'window-point-insertion-type) t) + (if tool-bar-setup + (compilation-tool-bar-setup) + (add-hook 'tool-bar-setup-hook 'compilation-tool-bar-setup)) (set (make-local-variable 'tool-bar-map) compilation-mode-tool-bar-map) (setq major-mode 'compilation-mode mode-name (or name-of-mode "Compilation"))