unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: 1133@emacsbugs.donarmstrong.com, emacs-devel@gnu.org
Subject: Tool-bar and multi-tty
Date: Thu, 09 Oct 2008 22:30:06 -0400	[thread overview]
Message-ID: <873aj56v2p.fsf@cyd.mit.edu> (raw)

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




             reply	other threads:[~2008-10-10  2:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-10  2:30 Chong Yidong [this message]
2008-10-10  7:50 ` Tool-bar and multi-tty Eli Zaretskii
2008-10-10  7:51 ` Eli Zaretskii
2008-10-10 17:05   ` Chong Yidong
2008-10-10 18:27     ` Eli Zaretskii
2008-10-10 19:43       ` Chong Yidong
2008-10-10 19:51         ` Chong Yidong
2008-10-10 21:32         ` Eli Zaretskii
2008-10-11 16:28         ` Stefan Monnier
2008-10-11 19:49           ` Chong Yidong
2008-10-12  8:28             ` Andreas Schwab
2008-10-12  8:52             ` Andreas Schwab
2008-10-12 13:51               ` Chong Yidong
2008-10-12 14:31                 ` Andreas Schwab
2008-10-12 17:10                   ` Chong Yidong
2008-10-10 17:18   ` Stefan Monnier
2008-10-10 18:27     ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873aj56v2p.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=1133@emacsbugs.donarmstrong.com \
    --cc=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).