unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1133: Tool-bar and multi-tty
@ 2008-10-10  2:30 Chong Yidong
  0 siblings, 0 replies; 17+ messages in thread
From: Chong Yidong @ 2008-10-10  2:30 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: 1133, emacs-devel

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"))






^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-10-12 17:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <873aj56v2p.fsf@cyd.mit.edu>
2008-10-10  7:50 ` bug#1133: Tool-bar and multi-tty Eli Zaretskii
2008-10-10  7:51 ` Eli Zaretskii
     [not found] ` <uy70wj3aa.fsf@gnu.org>
2008-10-10 17:05   ` Chong Yidong
2008-10-10 17:18   ` Stefan Monnier
     [not found]   ` <jwvej2omkrv.fsf-monnier+emacsbugreports@gnu.org>
2008-10-10 18:27     ` Chong Yidong
     [not found]   ` <87prm8fkjn.fsf@cyd.mit.edu>
2008-10-10 18:27     ` Eli Zaretskii
     [not found]     ` <uljwwi9vc.fsf@gnu.org>
2008-10-10 19:43       ` Chong Yidong
     [not found]       ` <873aj48cd9.fsf@cyd.mit.edu>
2008-10-10 19:51         ` Chong Yidong
2008-10-10 21:32         ` Eli Zaretskii
2008-10-11 16:28         ` Stefan Monnier
     [not found]         ` <jwvbpxrkshx.fsf-monnier+emacsbugreports@gnu.org>
2008-10-11 19:49           ` Chong Yidong
     [not found]           ` <877i8edi9l.fsf@cyd.mit.edu>
2008-10-12  8:28             ` Andreas Schwab
2008-10-12  8:52             ` Andreas Schwab
     [not found]             ` <je1vym2o1m.fsf@sykes.suse.de>
2008-10-12 13:51               ` Chong Yidong
     [not found]               ` <87abd96hwo.fsf@cyd.mit.edu>
2008-10-12 14:31                 ` Andreas Schwab
     [not found]                 ` <jefxn128c4.fsf@sykes.suse.de>
2008-10-12 17:10                   ` Chong Yidong
2008-10-10  2:30 Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).