diff options
author | Juri Linkov <juri@jurta.org> | 2010-04-23 11:33:05 +0300 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2010-04-23 11:33:05 +0300 |
commit | 386d08b0e73666831aa9241d27ec39491b4632f9 (patch) | |
tree | 1cbb91e2003b100716d90b8bf89bff58e0a24853 | |
parent | bda251782971a8b6c35d2006f6e5183430c6c268 (diff) | |
download | emacs-386d08b0e73666831aa9241d27ec39491b4632f9.tar.gz |
Make tabs frame-local.
-rw-r--r-- | lisp/tab-bar.el | 44 | ||||
-rw-r--r-- | lisp/tab.el | 42 |
2 files changed, 50 insertions, 36 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index d36eb94e0d2..b7a6db6af59 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -91,13 +91,16 @@ See `tab-bar-add-item' for conveniently adding tab bar items." (if tab-bar-mode (progn (modify-all-frames-parameters (list (cons 'tab-bar-lines 1))) - (when (<= 1 (length (default-value 'tab-bar-map))) ; not yet setup - (unless (tab-list) - (select-tab (make-tab))) - (tab-bar-setup)) + (dolist (frame (frame-list)) + (when (<= 1 (length (or (cdr (assoc 'tab-bar-map (frame-parameters frame))) + (default-value 'tab-bar-map)))) ; not yet setup + (unless (tab-list frame) + (select-tab (make-tab frame) frame)))) (setq tab-frames (frame-list)) + (add-hook 'after-make-frame-functions 'make-tab-command) (add-hook 'window-configuration-change-hook 'tab-window-configuration-change)) (modify-all-frames-parameters (list (cons 'tab-bar-lines 0))) + (remove-hook 'after-make-frame-functions 'make-tab-command) (remove-hook 'window-configuration-change-hook 'tab-window-configuration-change))) ;;;###autoload @@ -156,10 +159,11 @@ color capability and based on the available image libraries." bind)) (plist-put plist :image image)))) bind)) - tab-bar-map)) + (or (cdr (assoc 'tab-bar-map (frame-parameters))) + (default-value 'tab-bar-map)))) ;;;###autoload -(defun tab-bar-add-item (icon name def key selected &rest props) +(defun tab-bar-add-item (frame icon name def key selected &rest props) "Add an item to the tab bar. ICON names the image, DEF is the key definition and KEY is a symbol for the fake function key in the menu keymap. Remaining arguments @@ -174,7 +178,9 @@ ICON.xbm, using `find-image'. Use this function only to make bindings in the global value of `tab-bar-map'. To define items in any other map, use `tab-bar-local-item'." (apply 'tab-bar-local-item icon name def key - (default-value 'tab-bar-map) selected props)) + (or (cdr (assoc 'tab-bar-map (frame-parameters frame))) + (default-value 'tab-bar-map)) + selected props)) ;;;###autoload (defun tab-bar-local-item (icon name def key map selected &rest props) @@ -221,28 +227,31 @@ ICON.xbm, using `find-image'." ;;; Set up some global items. Additions/deletions up for grabs. -(defun tab-bar-setup () - (setq tab-bar-map (make-sparse-keymap)) - (tab-bar-add-item "tab-left" +(defun tab-bar-setup (&optional frame) + (modify-frame-parameters frame (list (cons 'tab-bar-map (make-sparse-keymap)))) + (tab-bar-add-item frame + "tab-left" "" 'tab-history-back 'tab-history-back nil :enable 'tab-history-back :help "Go back in history") - (tab-bar-add-item "tab-right" + (tab-bar-add-item frame + "tab-right" "" 'tab-history-forward 'tab-history-forward nil :enable 'tab-history-forward :help "Go forward in history") - (let ((selected-tab (selected-tab))) - (dolist (tab (tab-list)) + (let ((selected-tab (selected-tab frame))) + (dolist (tab (tab-list frame)) (let ((tab-id (car tab)) - (tab-name (or (cdr (assoc 'name (nth 1 tab))) (tab-name)))) + (tab-name (or (cdr (assoc 'name (nth 1 tab))) (tab-name frame)))) (when tab-id - (tab-bar-add-item nil + (tab-bar-add-item frame + nil tab-name `(lambda () (interactive) @@ -251,7 +260,8 @@ ICON.xbm, using `find-image'." (eq selected-tab tab-id) :enable `(not (eq (selected-tab) ',tab-id)) :help "Select this tab") - (tab-bar-add-item "tab-delete" + (tab-bar-add-item frame + "tab-delete" "" `(lambda () (interactive) @@ -259,7 +269,7 @@ ICON.xbm, using `find-image'." (intern (concat "delete-" (symbol-name tab-id))) nil :help "Delete this tab"))))) - ;; (redraw-frame (selected-frame)) + ;; (redraw-frame (or frame (selected-frame))) ) (provide 'tab-bar) diff --git a/lisp/tab.el b/lisp/tab.el index 17cc5b09718..bf2fdf076a1 100644 --- a/lisp/tab.el +++ b/lisp/tab.el @@ -52,15 +52,17 @@ If the value is a function, call it and switch to the buffer it returns." :group 'tabs :version "24.1") -(defun tab-name () +(defun tab-name (&optional frame) (cond ((eq tab-name 'window-list) (mapconcat (lambda (w) (buffer-name (window-buffer w))) - (window-list) + (window-list frame) ", ")) ((functionp tab-name) - (funcall tab-name)) + (funcall tab-name frame)) + (frame + (buffer-name (window-buffer (frame-selected-window frame)))) (t (buffer-name)))) @@ -89,7 +91,7 @@ Return a newly created frame displaying the current buffer." (let* ((tab-list (tab-list frame)) (tab-parameters (if (assoc 'name parameters) parameters - (append parameters `((name . ,(tab-name)))))) + (append parameters `((name . ,(tab-name frame)))))) (tab-new (list (tab-gensym) tab-parameters @@ -105,16 +107,16 @@ Return a newly created frame displaying the current buffer." frame (list (cons 'tab-list (append tab-list (list tab-new))))) (tab-initial-buffer) - (tab-bar-setup) + (tab-bar-setup frame) (car tab-new))) ;;;###autoload -(defun make-tab-command () +(defun make-tab-command (&optional frame) "Make a new tab, on the same frame as the selected tab. If the terminal is a text-only terminal, this also selects the new tab." (interactive) - (select-tab (make-tab))) + (select-tab (make-tab frame) frame)) (defun tab-list (&optional frame) "Return a list of all tabs on FRAME. @@ -141,7 +143,7 @@ this function is called. This function returns TAB, or nil if TAB has been deleted." ;; Save current win conf - (let* ((selected-tab (selected-tab)) + (let* ((selected-tab (selected-tab frame)) (tab-list (tab-list frame)) (tab-param (assq selected-tab tab-list)) (tab-name (assq 'name (nth 1 tab-param))) @@ -151,7 +153,7 @@ This function returns TAB, or nil if TAB has been deleted." (setcar (cdr (cddr tab-param)) (point-marker)) (setcar (cddr (cddr tab-param)) tab-history-back) (setcar (cdr (cddr (cddr tab-param))) tab-history-forward) - (if tab-name (setcdr tab-name (tab-name)))) + (if tab-name (setcdr tab-name (tab-name frame)))) (modify-frame-parameters frame (list (cons 'selected-tab tab))) (set-window-configuration (nth 2 tab-new-param)) ;; set-window-configuration does not restore the value @@ -161,7 +163,7 @@ This function returns TAB, or nil if TAB has been deleted." (goto-char (nth 3 tab-new-param))) (setq tab-history-back (nth 4 tab-new-param)) (setq tab-history-forward (nth 5 tab-new-param)) - (tab-bar-setup))) + (tab-bar-setup frame))) (defun delete-tab (&optional tab frame) "Remove TAB from its FRAME. @@ -179,8 +181,8 @@ Signal an error when TAB is the only tab on its frame." (list (cons 'tab-list (assq-delete-all tab tab-list)))) (if (null (tab-list frame)) (tab-bar-mode 0) - (when tab-select (select-tab tab-select)) - (tab-bar-setup)))) + (when tab-select (select-tab tab-select frame)) + (tab-bar-setup frame)))) (defun delete-other-tabs (&optional tab frame) "Delete all tabs except TAB. @@ -196,7 +198,7 @@ FRAME nil or omitted means use the selected frame." (list (cons 'tab-list (list tab-param)))) (if (null (tab-list frame)) (tab-bar-mode 0) - (tab-bar-setup)))) + (tab-bar-setup frame)))) (defun next-tab (&optional tab frame wrap) "Return the next tab in the tab list after TAB. @@ -232,7 +234,7 @@ COUNT is the numeric prefix argument. Return nil." (while (< count 0) (setq tab (previous-tab tab frame t)) (setq count (1+ count))) - (select-tab tab))) + (select-tab tab frame))) (defun select-next-tab (&optional count) "Select the next tab in cyclic order. @@ -264,6 +266,8 @@ The name is made by appending a number to PREFIX, default \"tab-\"." ;;; Tab history. +;; FIXME: add `tab-history-mode'. + (defvar tab-history-back nil "Stack of window configurations user has visited. Each element of the stack is a window configuration.") @@ -289,13 +293,13 @@ Each element of the stack is a window configuration.") (defun tab-history-update () (push (current-window-configuration) tab-history-back)) -(defun tab-name-update () - (let* ((selected-tab (selected-tab)) - (tab-list (tab-list)) +(defun tab-name-update (&optional frame) + (let* ((selected-tab (selected-tab frame)) + (tab-list (tab-list frame)) (tab-param (assq selected-tab tab-list)) (tab-name (assq 'name (nth 1 tab-param)))) - (if tab-name (setcdr tab-name (tab-name))) - (tab-bar-setup))) + (if tab-name (setcdr tab-name (tab-name frame))) + (tab-bar-setup frame))) (defvar tab-frames nil) |