aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2007-10-16 10:52:09 +0000
committerJuanma Barranquero2007-10-16 10:52:09 +0000
commite7a4eaadf2f5ce31a310b8e4be10e2a7346c5e14 (patch)
treeac43723586755a3ee6a9fbfa131135d44c687d02
parentda6658e85d66433b154a0b48cb4f8377e12ceff0 (diff)
downloademacs-e7a4eaadf2f5ce31a310b8e4be10e2a7346c5e14.tar.gz
emacs-e7a4eaadf2f5ce31a310b8e4be10e2a7346c5e14.zip
(bs--window-config-coming-from): Revert 2006-11-09 change.
(bs--restore-window-config): Keep the selected frame. (bs--track-window-changes, bs--remove-hooks): New functions. (bs-mode): Use `define-derived-mode'. Set hook to track window changes. (bs--show-with-configuration): Revert 2006-11-09 change. Don't reuse window unless it is visible on the selected frame. Restore window configuration (possibly in a different frame) before creating any window.
-rw-r--r--lisp/bs.el42
1 files changed, 27 insertions, 15 deletions
diff --git a/lisp/bs.el b/lisp/bs.el
index 4d13c97c2fd..548d1b1cfef 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -445,7 +445,6 @@ defined by current configuration `bs-current-configuration'.")
445 445
446(defvar bs--window-config-coming-from nil 446(defvar bs--window-config-coming-from nil
447 "Window configuration before starting Buffer Selection Menu.") 447 "Window configuration before starting Buffer Selection Menu.")
448(make-variable-frame-local 'bs--window-config-coming-from)
449 448
450(defvar bs--intern-show-never "^ \\|\\*buffer-selection\\*" 449(defvar bs--intern-show-never "^ \\|\\*buffer-selection\\*"
451 "Regular expression specifying which buffers never to show. 450 "Regular expression specifying which buffers never to show.
@@ -614,7 +613,23 @@ actually the line which begins with character in `bs-string-current' or
614 (format "Show buffer by configuration %S" 613 (format "Show buffer by configuration %S"
615 bs-current-configuration))) 614 bs-current-configuration)))
616 615
617(defun bs-mode () 616(defun bs--track-window-changes (frame)
617 "Track window changes to refresh the buffer list.
618Used from `window-size-change-functions'."
619 (let ((win (get-buffer-window "*buffer-selection*" frame)))
620 (when win
621 (with-selected-window win
622 (bs-refresh)
623 (bs--set-window-height)))))
624
625(defun bs--remove-hooks ()
626 "Remove `bs--track-window-changes' and auxiliary hooks."
627 (remove-hook 'window-size-change-functions 'bs--track-window-changes)
628 ;; Remove itself
629 (remove-hook 'kill-buffer-hook 'bs--remove-hooks t)
630 (remove-hook 'change-major-mode-hook 'bs--remove-hooks t))
631
632(define-derived-mode bs-mode ()
618 "Major mode for editing a subset of Emacs' buffers. 633 "Major mode for editing a subset of Emacs' buffers.
619\\<bs-mode-map> 634\\<bs-mode-map>
620Aside from two header lines each line describes one buffer. 635Aside from two header lines each line describes one buffer.
@@ -647,27 +662,24 @@ available Buffer Selection Menu configuration.
647to show always. 662to show always.
648\\[bs-visit-tags-table] -- call `visit-tags-table' on current line's buffer. 663\\[bs-visit-tags-table] -- call `visit-tags-table' on current line's buffer.
649\\[bs-help] -- display this help text." 664\\[bs-help] -- display this help text."
650 (interactive)
651 (kill-all-local-variables)
652 (use-local-map bs-mode-map)
653 (make-local-variable 'font-lock-defaults) 665 (make-local-variable 'font-lock-defaults)
654 (make-local-variable 'font-lock-verbose) 666 (make-local-variable 'font-lock-verbose)
655 (make-local-variable 'font-lock-global-modes) 667 (make-local-variable 'font-lock-global-modes)
656 (buffer-disable-undo) 668 (buffer-disable-undo)
657 (setq major-mode 'bs-mode 669 (setq buffer-read-only t
658 mode-name "Buffer-Selection-Menu"
659 buffer-read-only t
660 truncate-lines t 670 truncate-lines t
661 show-trailing-whitespace nil 671 show-trailing-whitespace nil
662 font-lock-global-modes '(not bs-mode) 672 font-lock-global-modes '(not bs-mode)
663 font-lock-defaults '(bs-mode-font-lock-keywords t) 673 font-lock-defaults '(bs-mode-font-lock-keywords t)
664 font-lock-verbose nil) 674 font-lock-verbose nil))
665 (run-mode-hooks 'bs-mode-hook))
666 675
667(defun bs--restore-window-config () 676(defun bs--restore-window-config ()
668 "Restore window configuration on the current frame." 677 "Restore window configuration on the current frame."
669 (when bs--window-config-coming-from 678 (when bs--window-config-coming-from
670 (set-window-configuration bs--window-config-coming-from) 679 (let ((frame (selected-frame)))
680 (unwind-protect
681 (set-window-configuration bs--window-config-coming-from)
682 (select-frame frame)))
671 (setq bs--window-config-coming-from nil))) 683 (setq bs--window-config-coming-from nil)))
672 684
673(defun bs-kill () 685(defun bs-kill ()
@@ -1429,12 +1441,12 @@ for buffer selection."
1429 (active-window (get-window-with-predicate 1441 (active-window (get-window-with-predicate
1430 (lambda (w) 1442 (lambda (w)
1431 (string= (buffer-name (window-buffer w)) 1443 (string= (buffer-name (window-buffer w))
1432 "*buffer-selection*"))))) 1444 "*buffer-selection*"))
1445 nil (selected-frame))))
1433 (if active-window 1446 (if active-window
1434 (select-window active-window) 1447 (select-window active-window)
1435 (modify-frame-parameters nil 1448 (bs--restore-window-config)
1436 (list (cons 'bs--window-config-coming-from 1449 (setq bs--window-config-coming-from (current-window-configuration))
1437 (current-window-configuration))))
1438 (when (> (window-height (selected-window)) 7) 1450 (when (> (window-height (selected-window)) 7)
1439 (split-window-vertically) 1451 (split-window-vertically)
1440 (other-window 1))) 1452 (other-window 1)))