diff options
| author | Martin Rudalics | 2011-07-19 09:05:51 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2011-07-19 09:05:51 +0200 |
| commit | f5aae37c886455ae59fa1ae203821385d45bdcac (patch) | |
| tree | 6c8aaf5b5d21559f47c044db3e2a34332d35f55a | |
| parent | 15e3a074a6ebdcefd828a1ba14a5a12ff9921034 (diff) | |
| download | emacs-f5aae37c886455ae59fa1ae203821385d45bdcac.tar.gz emacs-f5aae37c886455ae59fa1ae203821385d45bdcac.zip | |
Rewrite display-buffer-alist-set to handle Emacs 23 options more accurately.
* window.el (display-buffer-alist-of-strings-p)
(display-buffer-alist-set-1, display-buffer-alist-set-2): New
functions.
(display-buffer-alist-set): Rewrite to handle Emacs 23 options
more accurately.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/window.el | 352 |
2 files changed, 187 insertions, 173 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0ea3d94a01f..50e4cd49f4c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-07-19 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (display-buffer-alist-of-strings-p) | ||
| 4 | (display-buffer-alist-set-1, display-buffer-alist-set-2): New | ||
| 5 | functions. | ||
| 6 | (display-buffer-alist-set): Rewrite to handle Emacs 23 options | ||
| 7 | more accurately. | ||
| 8 | |||
| 1 | 2011-07-18 Alan Mackenzie <acm@muc.de> | 9 | 2011-07-18 Alan Mackenzie <acm@muc.de> |
| 2 | 10 | ||
| 3 | Fontify declarators properly when, e.g., a jit-lock chunk begins | 11 | Fontify declarators properly when, e.g., a jit-lock chunk begins |
diff --git a/lisp/window.el b/lisp/window.el index b4b900287e1..12c9da85d57 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -6588,6 +6588,15 @@ split." | |||
| 6588 | 6588 | ||
| 6589 | ;; Functions for converting Emacs 23 buffer display options to buffer | 6589 | ;; Functions for converting Emacs 23 buffer display options to buffer |
| 6590 | ;; display specifiers. | 6590 | ;; display specifiers. |
| 6591 | (defun display-buffer-alist-of-strings-p (list) | ||
| 6592 | "Return t if LIST is a non-empty list of strings." | ||
| 6593 | (when list | ||
| 6594 | (catch 'failed | ||
| 6595 | (dolist (item list) | ||
| 6596 | (unless (stringp item) | ||
| 6597 | (throw 'failed nil))) | ||
| 6598 | t))) | ||
| 6599 | |||
| 6591 | (defun display-buffer-alist-add (identifiers specifiers &optional no-custom) | 6600 | (defun display-buffer-alist-add (identifiers specifiers &optional no-custom) |
| 6592 | "Helper function for `display-buffer-alist-set'." | 6601 | "Helper function for `display-buffer-alist-set'." |
| 6593 | (unless identifiers | 6602 | (unless identifiers |
| @@ -6602,6 +6611,40 @@ split." | |||
| 6602 | 'display-buffer-alist | 6611 | 'display-buffer-alist |
| 6603 | (cons (cons identifiers specifiers) display-buffer-alist)))) | 6612 | (cons (cons identifiers specifiers) display-buffer-alist)))) |
| 6604 | 6613 | ||
| 6614 | (defun display-buffer-alist-set-1 () | ||
| 6615 | "Helper function for `display-buffer-alist-set'." | ||
| 6616 | (progn ;; with-no-warnings | ||
| 6617 | (append | ||
| 6618 | '(reuse-window (reuse-window nil same 0)) | ||
| 6619 | `(pop-up-frame (pop-up-frame t) | ||
| 6620 | ,(append '(pop-up-frame-alist) | ||
| 6621 | special-display-frame-alist)) | ||
| 6622 | '((dedicate . weak))))) | ||
| 6623 | |||
| 6624 | (defun display-buffer-alist-set-2 (args) | ||
| 6625 | "Helper function for `display-buffer-alist-set'." | ||
| 6626 | (progn ;; with-no-warnings | ||
| 6627 | (if (and (listp args) (symbolp (car args))) | ||
| 6628 | `(function (function ,(car args) ,(cdr args))) | ||
| 6629 | (append | ||
| 6630 | '(reuse-window (reuse-window nil same 0)) | ||
| 6631 | (when (and (listp args) (cdr (assq 'same-window args))) | ||
| 6632 | '(reuse-window | ||
| 6633 | (reuse-window same nil nil) (reuse-window-dedicated . weak))) | ||
| 6634 | (when (and (listp args) | ||
| 6635 | (or (cdr (assq 'same-frame args)) | ||
| 6636 | (cdr (assq 'same-window args)))) | ||
| 6637 | '(pop-up-window (pop-up-window (largest . nil) (lru . nil)))) | ||
| 6638 | (when (and (listp args) | ||
| 6639 | (or (cdr (assq 'same-frame args)) | ||
| 6640 | (cdr (assq 'same-window args)))) | ||
| 6641 | '(reuse-window (reuse-window nil nil nil))) | ||
| 6642 | `(pop-up-frame (pop-up-frame t) | ||
| 6643 | ,(append '(pop-up-frame-alist) | ||
| 6644 | (when (listp args) args) | ||
| 6645 | special-display-frame-alist)) | ||
| 6646 | '((dedicate . weak)))))) | ||
| 6647 | |||
| 6605 | (defun display-buffer-alist-set (&optional no-custom add) | 6648 | (defun display-buffer-alist-set (&optional no-custom add) |
| 6606 | "Set `display-buffer-alist' from Emacs 23 buffer display options. | 6649 | "Set `display-buffer-alist' from Emacs 23 buffer display options. |
| 6607 | Optional argument NO-CUSTOM nil means use `customize-set-variable' | 6650 | Optional argument NO-CUSTOM nil means use `customize-set-variable' |
| @@ -6611,201 +6654,164 @@ means to use `setq' instead. | |||
| 6611 | Optional argument ADD nil means to replace the actual value of | 6654 | Optional argument ADD nil means to replace the actual value of |
| 6612 | `display-buffer-alist' with the value calculated here. ADD | 6655 | `display-buffer-alist' with the value calculated here. ADD |
| 6613 | non-nil means prepend the value calculated here to the current | 6656 | non-nil means prepend the value calculated here to the current |
| 6614 | value of `display-buffer-alist'." | 6657 | value of `display-buffer-alist'. Return `display-buffer-alist'." |
| 6615 | (unless add | 6658 | (unless add |
| 6616 | (if no-custom | 6659 | (if no-custom |
| 6617 | (setq display-buffer-alist nil) | 6660 | (setq display-buffer-alist nil) |
| 6618 | (customize-set-variable 'display-buffer-alist nil))) | 6661 | (customize-set-variable 'display-buffer-alist nil))) |
| 6619 | 6662 | ||
| 6620 | ;; Disable warnings, there are too many obsolete options here. | 6663 | ;; Disable warnings, there are too many obsolete options here. |
| 6621 | (with-no-warnings | 6664 | (progn ;; with-no-warnings |
| 6622 | ;; `pop-up-windows' | 6665 | `other-window-means-other-frame' |
| 6623 | (display-buffer-alist-add | 6666 | (when pop-up-frames |
| 6624 | nil | 6667 | (display-buffer-alist-add |
| 6625 | (let ((fun (unless (eq split-window-preferred-function | 6668 | nil '(pop-up-frame |
| 6626 | 'split-window-sensibly) | 6669 | (other-window-means-other-frame . t)) no-custom)) |
| 6627 | ;; `split-window-sensibly' has been merged into the | ||
| 6628 | ;; `display-buffer-split-window' code as `nil'. | ||
| 6629 | split-window-preferred-function)) | ||
| 6630 | (min-height | ||
| 6631 | (if (numberp split-height-threshold) | ||
| 6632 | (/ split-height-threshold 2) | ||
| 6633 | ;; Undocumented hack. | ||
| 6634 | 1.0)) | ||
| 6635 | (min-width | ||
| 6636 | (if (numberp split-width-threshold) | ||
| 6637 | (/ split-width-threshold 2) | ||
| 6638 | ;; Undocumented hack. | ||
| 6639 | 1.0))) | ||
| 6640 | (list | ||
| 6641 | 'pop-up-window | ||
| 6642 | (when pop-up-windows | ||
| 6643 | (list | ||
| 6644 | 'pop-up-window | ||
| 6645 | (cons 'largest fun) | ||
| 6646 | (cons 'lru fun))) | ||
| 6647 | (cons 'pop-up-window-min-height min-height) | ||
| 6648 | (cons 'pop-up-window-min-width min-width))) | ||
| 6649 | no-custom) | ||
| 6650 | 6670 | ||
| 6651 | ;; `pop-up-frames' | 6671 | ;; `reuse-window-even-sizes' |
| 6652 | (display-buffer-alist-add | 6672 | (when even-window-heights |
| 6653 | nil | 6673 | (display-buffer-alist-add |
| 6654 | (list | 6674 | nil '(reuse-window (reuse-window-even-sizes . t)) no-custom)) |
| 6655 | 'pop-up-frame | 6675 | |
| 6656 | (when pop-up-frames | 6676 | ;; `dedicate' |
| 6657 | (list 'pop-up-frame pop-up-frames)) | 6677 | (when display-buffer-mark-dedicated |
| 6658 | (when pop-up-frame-function | 6678 | (display-buffer-alist-add |
| 6659 | (cons 'pop-up-frame-function pop-up-frame-function)) | 6679 | nil '(dedicate (display-buffer-mark-dedicated . t)) no-custom)) |
| 6660 | (when pop-up-frame-alist | 6680 | |
| 6661 | (cons 'pop-up-frame-alist pop-up-frame-alist))) | 6681 | ;; `pop-up-window' group |
| 6662 | no-custom) | 6682 | (let ((fun (unless (eq split-window-preferred-function |
| 6683 | 'split-window-sensibly) | ||
| 6684 | split-window-preferred-function)) | ||
| 6685 | (min-height | ||
| 6686 | (if (numberp split-height-threshold) | ||
| 6687 | (/ split-height-threshold 2) | ||
| 6688 | 1.0)) | ||
| 6689 | (min-width | ||
| 6690 | (if (numberp split-width-threshold) | ||
| 6691 | (/ split-width-threshold 2) | ||
| 6692 | 1.0))) | ||
| 6693 | (display-buffer-alist-add | ||
| 6694 | nil | ||
| 6695 | (list | ||
| 6696 | 'pop-up-window | ||
| 6697 | ;; `pop-up-window' | ||
| 6698 | (when pop-up-windows | ||
| 6699 | (list 'pop-up-window (cons 'largest fun) (cons 'lru fun))) | ||
| 6700 | ;; `pop-up-window-min-height' | ||
| 6701 | (cons 'pop-up-window-min-height min-height) | ||
| 6702 | ;; `pop-up-window-min-width' | ||
| 6703 | (cons 'pop-up-window-min-width min-width)) | ||
| 6704 | no-custom)) | ||
| 6705 | |||
| 6706 | ;; `pop-up-frame' group | ||
| 6707 | (when (or pop-up-frames | ||
| 6708 | (not (equal pop-up-frame-function | ||
| 6709 | '(lambda nil | ||
| 6710 | (make-frame pop-up-frame-alist)))) | ||
| 6711 | pop-up-frame-alist) | ||
| 6712 | (display-buffer-alist-add | ||
| 6713 | nil | ||
| 6714 | (list | ||
| 6715 | 'pop-up-frame | ||
| 6716 | (when pop-up-frames | ||
| 6717 | ;; `pop-up-frame' | ||
| 6718 | (list 'pop-up-frame | ||
| 6719 | (when (eq pop-up-frames 'graphic-only) | ||
| 6720 | t))) | ||
| 6721 | (unless (equal pop-up-frame-function | ||
| 6722 | '(lambda nil | ||
| 6723 | (make-frame pop-up-frame-alist))) | ||
| 6724 | ;; `pop-up-frame-function' | ||
| 6725 | (cons 'pop-up-frame-function pop-up-frame-function)) | ||
| 6726 | (when pop-up-frame-alist | ||
| 6727 | ;; `pop-up-frame-alist' | ||
| 6728 | (cons 'pop-up-frame-alist pop-up-frame-alist))) | ||
| 6729 | no-custom)) | ||
| 6663 | 6730 | ||
| 6664 | ;; `special-display-regexps' | 6731 | ;; `special-display-regexps' |
| 6665 | (dolist (entry special-display-regexps) | 6732 | (if (display-buffer-alist-of-strings-p special-display-regexps) |
| 6666 | (cond | 6733 | ;; Handle case where `special-display-regexps' is a plain list |
| 6667 | ((stringp entry) | 6734 | ;; of strings specially. |
| 6668 | ;; Plain string. | 6735 | (let (list) |
| 6669 | (display-buffer-alist-add | 6736 | (dolist (regexp special-display-regexps) |
| 6670 | `((regexp . ,entry)) | 6737 | (setq list (cons (cons 'regexp regexp) list))) |
| 6671 | (list | 6738 | (setq list (nreverse list)) |
| 6672 | 'function | 6739 | (display-buffer-alist-add |
| 6673 | (list 'function special-display-function | 6740 | list (display-buffer-alist-set-1) no-custom)) |
| 6674 | special-display-frame-alist)) | 6741 | ;; Else iterate over the entries. |
| 6675 | no-custom)) | 6742 | (dolist (item special-display-regexps) |
| 6676 | ((consp entry) | 6743 | (if (stringp item) |
| 6677 | (let ((name (car entry)) | 6744 | (display-buffer-alist-add |
| 6678 | (rest (cdr entry))) | 6745 | `((regexp . ,item)) (display-buffer-alist-set-1) |
| 6679 | (cond | 6746 | no-custom) |
| 6680 | ((functionp (car rest)) | 6747 | (display-buffer-alist-add |
| 6681 | ;; A function. | 6748 | `((regexp . ,(car item))) |
| 6682 | (display-buffer-alist-add | 6749 | (display-buffer-alist-set-2 (cdr item)) |
| 6683 | `((name . ,name)) | 6750 | no-custom)))) |
| 6684 | (list | ||
| 6685 | 'function | ||
| 6686 | ;; Weary. | ||
| 6687 | (list 'function (car rest) (cadr rest))) | ||
| 6688 | no-custom)) | ||
| 6689 | ((listp rest) | ||
| 6690 | ;; A list of parameters. | ||
| 6691 | (cond | ||
| 6692 | ((assq 'same-window rest) | ||
| 6693 | (display-buffer-alist-add | ||
| 6694 | `((name . ,name)) | ||
| 6695 | (list 'reuse-window | ||
| 6696 | (list 'reuse-window 'same) | ||
| 6697 | (list 'reuse-window-dedicated 'weak)) | ||
| 6698 | no-custom)) | ||
| 6699 | ((assq 'same-frame rest) | ||
| 6700 | (display-buffer-alist-add | ||
| 6701 | `((name . ,name)) (list 'same-frame) no-custom)) | ||
| 6702 | (t | ||
| 6703 | (display-buffer-alist-add | ||
| 6704 | `((name . ,name)) | ||
| 6705 | (list | ||
| 6706 | 'function | ||
| 6707 | (list 'function special-display-function | ||
| 6708 | special-display-frame-alist)) | ||
| 6709 | no-custom))))))))) | ||
| 6710 | 6751 | ||
| 6711 | ;; `special-display-buffer-names' | 6752 | ;; `special-display-buffer-names' |
| 6712 | (dolist (entry special-display-buffer-names) | 6753 | (if (display-buffer-alist-of-strings-p special-display-buffer-names) |
| 6713 | (cond | 6754 | ;; Handle case where `special-display-buffer-names' is a plain |
| 6714 | ((stringp entry) | 6755 | ;; list of strings specially. |
| 6715 | ;; Plain string. | 6756 | (let (list) |
| 6716 | (display-buffer-alist-add | 6757 | (dolist (name special-display-buffer-names) |
| 6717 | `((name . ,entry)) | 6758 | (setq list (cons (cons 'name name) list))) |
| 6718 | (list | 6759 | (setq list (nreverse list)) |
| 6719 | 'function | 6760 | (display-buffer-alist-add |
| 6720 | (list 'function special-display-function | 6761 | list (display-buffer-alist-set-1) no-custom)) |
| 6721 | special-display-frame-alist)) | 6762 | ;; Else iterate over the entries. |
| 6722 | no-custom)) | 6763 | (dolist (item special-display-buffer-names) |
| 6723 | ((consp entry) | 6764 | (if (stringp item) |
| 6724 | (let ((name (car entry)) | 6765 | (display-buffer-alist-add |
| 6725 | (rest (cdr entry))) | 6766 | `((name . ,item)) (display-buffer-alist-set-1) |
| 6726 | (cond | 6767 | no-custom) |
| 6727 | ((functionp (car rest)) | 6768 | (display-buffer-alist-add |
| 6728 | ;; A function. | 6769 | `((name . ,(car item))) |
| 6729 | (display-buffer-alist-add | 6770 | (display-buffer-alist-set-2 (cdr item)) |
| 6730 | `((name . ,name)) | 6771 | no-custom)))) |
| 6731 | (list | ||
| 6732 | 'function | ||
| 6733 | ;; Weary. | ||
| 6734 | (list 'function (car rest) (cadr rest))) | ||
| 6735 | no-custom)) | ||
| 6736 | ((listp rest) | ||
| 6737 | ;; A list of parameters. | ||
| 6738 | (cond | ||
| 6739 | ((assq 'same-window rest) | ||
| 6740 | (display-buffer-alist-add | ||
| 6741 | `((name . ,name)) | ||
| 6742 | (list 'reuse-window | ||
| 6743 | (list 'reuse-window 'same) | ||
| 6744 | (list 'reuse-window-dedicated 'weak)) | ||
| 6745 | no-custom)) | ||
| 6746 | ((assq 'same-frame rest) | ||
| 6747 | (display-buffer-alist-add | ||
| 6748 | `((name . ,name)) (list 'same-frame) no-custom)) | ||
| 6749 | (t | ||
| 6750 | (display-buffer-alist-add | ||
| 6751 | `((name . ,name)) | ||
| 6752 | (list | ||
| 6753 | 'function | ||
| 6754 | (list 'function special-display-function | ||
| 6755 | special-display-frame-alist)) | ||
| 6756 | no-custom))))))))) | ||
| 6757 | 6772 | ||
| 6758 | ;; `same-window-regexps' | 6773 | ;; `same-window-regexps' |
| 6759 | (dolist (entry same-window-regexps) | 6774 | (if (display-buffer-alist-of-strings-p same-window-regexps) |
| 6760 | (cond | 6775 | ;; Handle case where `same-window-regexps' is a plain list of |
| 6761 | ((stringp entry) | 6776 | ;; strings specially. |
| 6762 | (display-buffer-alist-add | 6777 | (let (list) |
| 6763 | `((regexp . ,entry)) | 6778 | (dolist (regexp same-window-regexps) |
| 6764 | (list 'reuse-window (list 'reuse-window 'same)) | 6779 | (setq list (cons (cons 'regexp regexp) list))) |
| 6765 | no-custom)) | 6780 | (setq list (nreverse list)) |
| 6766 | ((consp entry) | 6781 | (display-buffer-alist-add |
| 6782 | list '(reuse-window (reuse-window same nil nil)) no-custom)) | ||
| 6783 | (dolist (entry same-window-regexps) | ||
| 6767 | (display-buffer-alist-add | 6784 | (display-buffer-alist-add |
| 6768 | `((regexp . ,(car entry))) | 6785 | `((regexp . ,(if (stringp entry) entry (car entry)))) |
| 6769 | (list 'reuse-window (list 'reuse-window 'same)) | 6786 | '(reuse-window (reuse-window same nil nil)) no-custom))) |
| 6770 | no-custom)))) | ||
| 6771 | 6787 | ||
| 6772 | ;; `same-window-buffer-names' | 6788 | ;; `same-window-buffer-names' |
| 6773 | (dolist (entry same-window-buffer-names) | 6789 | (if (display-buffer-alist-of-strings-p same-window-buffer-names) |
| 6774 | (cond | 6790 | ;; Handle case where `same-window-buffer-names' is a plain list |
| 6775 | ((stringp entry) | 6791 | ;; of strings specially. |
| 6792 | (let (list) | ||
| 6793 | (dolist (name same-window-buffer-names) | ||
| 6794 | (setq list (cons (cons 'name name) list))) | ||
| 6795 | (setq list (nreverse list)) | ||
| 6796 | (display-buffer-alist-add | ||
| 6797 | list '(reuse-window (reuse-window same nil nil)) no-custom)) | ||
| 6798 | (dolist (entry same-window-buffer-names) | ||
| 6776 | (display-buffer-alist-add | 6799 | (display-buffer-alist-add |
| 6777 | `((name . ,entry)) | 6800 | `((name . ,(if (stringp entry) entry (car entry)))) |
| 6778 | (list 'reuse-window (list 'reuse-window 'same)) | 6801 | '(reuse-window (reuse-window same nil nil)) no-custom))) |
| 6779 | no-custom)) | ||
| 6780 | ((consp entry) | ||
| 6781 | (display-buffer-alist-add | ||
| 6782 | `((name . ,(car entry))) | ||
| 6783 | (list 'reuse-window (list 'reuse-window 'same)) | ||
| 6784 | no-custom)))) | ||
| 6785 | 6802 | ||
| 6786 | ;; `reuse-window' | 6803 | ;; `reuse-window' |
| 6787 | (display-buffer-alist-add | 6804 | (display-buffer-alist-add |
| 6788 | nil | 6805 | nil `(reuse-window |
| 6789 | (list | 6806 | (reuse-window |
| 6790 | 'reuse-window | 6807 | nil same |
| 6791 | (list 'reuse-window nil 'same | 6808 | ,(when (or display-buffer-reuse-frames pop-up-frames) |
| 6792 | (when (or display-buffer-reuse-frames pop-up-frames) | 6809 | ;; "0" (all visible and iconified frames) is |
| 6793 | ;; "0" (all visible and iconified frames) is hardcoded in | 6810 | ;; hardcoded in Emacs 23. |
| 6794 | ;; Emacs 23. | 6811 | 0))) |
| 6795 | 0)) | ||
| 6796 | (when even-window-heights | ||
| 6797 | (cons 'reuse-window-even-sizes t))) | ||
| 6798 | no-custom) | 6812 | no-custom) |
| 6799 | 6813 | ||
| 6800 | ;; `display-buffer-mark-dedicated' | 6814 | display-buffer-alist)) |
| 6801 | (when display-buffer-mark-dedicated | ||
| 6802 | (display-buffer-alist-add | ||
| 6803 | nil | ||
| 6804 | (list | ||
| 6805 | (cons 'dedicate display-buffer-mark-dedicated)) | ||
| 6806 | no-custom))) | ||
| 6807 | |||
| 6808 | display-buffer-alist) | ||
| 6809 | 6815 | ||
| 6810 | (defun set-window-text-height (window height) | 6816 | (defun set-window-text-height (window height) |
| 6811 | "Set the height in lines of the text display area of WINDOW to HEIGHT. | 6817 | "Set the height in lines of the text display area of WINDOW to HEIGHT. |