[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tool-bar and multi-tty
From: |
Chong Yidong |
Subject: |
Tool-bar and multi-tty |
Date: |
Thu, 09 Oct 2008 22:30:06 -0400 |
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"))
- Tool-bar and multi-tty,
Chong Yidong <=
- Re: Tool-bar and multi-tty, Eli Zaretskii, 2008/10/10
- Re: Tool-bar and multi-tty, Eli Zaretskii, 2008/10/10
- Re: Tool-bar and multi-tty, Chong Yidong, 2008/10/10
- Re: Tool-bar and multi-tty, Eli Zaretskii, 2008/10/10
- Re: Tool-bar and multi-tty, Chong Yidong, 2008/10/10
- Re: Tool-bar and multi-tty, Chong Yidong, 2008/10/10
- Re: Tool-bar and multi-tty, Eli Zaretskii, 2008/10/10
- Re: Tool-bar and multi-tty, Stefan Monnier, 2008/10/11
- Re: Tool-bar and multi-tty, Chong Yidong, 2008/10/11
- Re: Tool-bar and multi-tty, Andreas Schwab, 2008/10/12