comparison lisp/window.el @ 101167:a4d9fa835dc5

(special-display-buffer-names) (special-display-regexps): Add customization support for function/other-args elements. Rewrite doc-strings. (special-display-function): Rewrite doc-strings (same-window-buffer-names, same-window-regexps): Minor doc-string fixes. (special-display-p): Minor rewrite.
author Martin Rudalics <rudalics@gmx.at>
date Wed, 14 Jan 2009 09:56:11 +0000
parents 407664fb6b9d
children 7eba5f48f79f
comparison
equal deleted inserted replaced
101166:bd632099967a 101167:a4d9fa835dc5
546 :type '(choice 546 :type '(choice
547 (const nil) 547 (const nil)
548 (function :tag "function")) 548 (function :tag "function"))
549 :group 'windows) 549 :group 'windows)
550 550
551 (defcustom special-display-buffer-names nil
552 "List of names of buffers that should be displayed specially.
553 Displaying a buffer with `display-buffer' or `pop-to-buffer', if
554 its name is in this list, displays the buffer in a way specified
555 by `special-display-function'. `special-display-popup-frame'
556 \(the default for `special-display-function') usually displays
557 the buffer in a separate frame made with the parameters specified
558 by `special-display-frame-alist'. If `special-display-function'
559 has been set to some other function, that function is called with
560 the buffer as first, and nil as second argument.
561
562 Alternatively, an element of this list can be specified as
563 \(BUFFER-NAME FRAME-PARAMETERS), where BUFFER-NAME is a buffer
564 name and FRAME-PARAMETERS an alist of \(PARAMETER . VALUE) pairs.
565 `special-display-popup-frame' will interpret such pairs as frame
566 parameters when it creates a special frame, overriding the
567 corresponding values from `special-display-frame-alist'.
568
569 As a special case, if FRAME-PARAMETERS contains (same-window . t)
570 `special-display-popup-frame' displays that buffer in the
571 selected window. If FRAME-PARAMETERS contains (same-frame . t),
572 it displays that buffer in a window on the selected frame.
573
574 If `special-display-function' specifies some other function than
575 `special-display-popup-frame', that function is called with the
576 buffer named BUFFER-NAME as first, and FRAME-PARAMETERS as second
577 argument.
578
579 Finally, an element of this list can be also specified as
580 \(BUFFER-NAME FUNCTION OTHER-ARGS). In that case,
581 `special-display-popup-frame' will call FUNCTION with the buffer
582 named BUFFER-NAME as first argument, and OTHER-ARGS as the
583 second. If `special-display-function' specifies some other
584 function, that function is called with the buffer named
585 BUFFER-NAME as first, and the element's cdr as second argument.
586
587 If this variable appears \"not to work\", because you added a
588 name to it but the corresponding buffer is displayed in the
589 selected window, look at the values of `same-window-buffer-names'
590 and `same-window-regexps'. Those variables take precedence over
591 this one.
592
593 See also `special-display-regexps'."
594 :type '(repeat
595 (choice :tag "Buffer"
596 :value ""
597 (string :format "%v")
598 (cons :tag "With parameters"
599 :format "%v"
600 :value ("" . nil)
601 (string :format "%v")
602 (repeat :tag "Parameters"
603 (cons :format "%v"
604 (symbol :tag "Parameter")
605 (sexp :tag "Value"))))
606 (list :tag "With function"
607 :format "%v"
608 :value ("" . nil)
609 (string :format "%v")
610 (function :tag "Function")
611 (repeat :tag "Arguments" (sexp)))))
612 :group 'windows
613 :group 'frames)
614
615 (defcustom special-display-regexps nil
616 "List of regexps saying which buffers should be displayed specially.
617 Displaying a buffer with `display-buffer' or `pop-to-buffer', if
618 any regexp in this list matches its name, displays it specially
619 using `special-display-function'. `special-display-popup-frame'
620 \(the default for `special-display-function') usually displays
621 the buffer in a separate frame made with the parameters specified
622 by `special-display-frame-alist'. If `special-display-function'
623 has been set to some other function, that function is called with
624 the buffer as first, and nil as second argument.
625
626 Alternatively, an element of this list can be specified as
627 \(REGEXP FRAME-PARAMETERS), where REGEXP is a regexp as above and
628 FRAME-PARAMETERS an alist of (PARAMETER . VALUE) pairs.
629 `special-display-popup-frame' will then interpret these pairs as
630 frame parameters when creating a special frame for a buffer whose
631 name matches REGEXP, overriding the corresponding values from
632 `special-display-frame-alist'.
633
634 As a special case, if FRAME-PARAMETERS contains (same-window . t)
635 `special-display-popup-frame' displays buffers matching REGEXP in
636 the selected window. \(same-frame . t) in FRAME-PARAMETERS means
637 to display such buffers in a window on the selected frame.
638
639 If `special-display-function' specifies some other function than
640 `special-display-popup-frame', that function is called with the
641 buffer whose name matched REGEXP as first, and FRAME-PARAMETERS
642 as second argument.
643
644 Finally, an element of this list can be also specified as
645 \(REGEXP FUNCTION OTHER-ARGS). `special-display-popup-frame'
646 will then call FUNCTION with the buffer whose name matched
647 REGEXP as first, and OTHER-ARGS as second argument. If
648 `special-display-function' specifies some other function, that
649 function is called with the buffer whose name matched REGEXP
650 as first, and the element's cdr as second argument.
651
652 If this variable appears \"not to work\", because you added a
653 name to it but the corresponding buffer is displayed in the
654 selected window, look at the values of `same-window-buffer-names'
655 and `same-window-regexps'. Those variables take precedence over
656 this one.
657
658 See also `special-display-buffer-names'."
659 :type '(repeat
660 (choice :tag "Buffer"
661 :value ""
662 (regexp :format "%v")
663 (cons :tag "With parameters"
664 :format "%v"
665 :value ("" . nil)
666 (regexp :format "%v")
667 (repeat :tag "Parameters"
668 (cons :format "%v"
669 (symbol :tag "Parameter")
670 (sexp :tag "Value"))))
671 (list :tag "With function"
672 :format "%v"
673 :value ("" . nil)
674 (regexp :format "%v")
675 (function :tag "Function")
676 (repeat :tag "Arguments" (sexp)))))
677 :group 'windows
678 :group 'frames)
679
551 (defun special-display-p (buffer-name) 680 (defun special-display-p (buffer-name)
552 "Return non-nil if a buffer named BUFFER-NAME gets a special frame. 681 "Return non-nil if a buffer named BUFFER-NAME gets a special frame.
553 If the value is t, `display-buffer' or `pop-to-buffer' would 682 More precisely, return t if `special-display-buffer-names' or
554 create a special frame for that buffer using the default frame 683 `special-display-regexps' contain a string entry equaling or
555 parameters. 684 matching BUFFER-NAME. If `special-display-buffer-names' or
556 685 `special-display-regexps' contain a list entry whose car equals
557 If the value is a list, it is a list of frame parameters that 686 or matches BUFFER-NAME, the return value is the cdr of that
558 would be used to make a frame for that buffer. The variables 687 entry."
559 `special-display-buffer-names' and `special-display-regexps'
560 control this."
561 (let (tmp)
562 (cond 688 (cond
563 ((not (stringp buffer-name))) 689 ((not (stringp buffer-name)))
564 ;; Make sure to return t in the following two cases.
565 ((member buffer-name special-display-buffer-names) t) 690 ((member buffer-name special-display-buffer-names) t)
566 ((setq tmp (assoc buffer-name special-display-buffer-names)) (cdr tmp)) 691 ((let ((temp (assoc buffer-name special-display-buffer-names)))
692 (cdr temp)))
567 ((catch 'found 693 ((catch 'found
568 (dolist (regexp special-display-regexps) 694 (dolist (regexp special-display-regexps)
569 (cond 695 (cond
570 ((stringp regexp) 696 ((stringp regexp)
571 (when (string-match-p regexp buffer-name) 697 (when (string-match-p regexp buffer-name)
572 (throw 'found t))) 698 (throw 'found t)))
573 ((and (consp regexp) (stringp (car regexp)) 699 ((and (consp regexp) (stringp (car regexp))
574 (string-match-p (car regexp) buffer-name)) 700 (string-match-p (car regexp) buffer-name))
575 (throw 'found (cdr regexp)))))))))) 701 (throw 'found (cdr regexp)))))))))
576
577 (defcustom special-display-buffer-names nil
578 "List of buffer names that should have their own special frames.
579 Displaying a buffer with `display-buffer' or `pop-to-buffer', if
580 its name is in this list, makes a special frame for it using
581 `special-display-function'. See also `special-display-regexps'.
582
583 An element of the list can be a list instead of just a string.
584 There are two ways to use a list as an element:
585 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)
586 In the first case, the FRAME-PARAMETERS are pairs of the form
587 \(PARAMETER . VALUE); these parameter values are used to create
588 the frame. In the second case, FUNCTION is called with BUFFER as
589 the first argument, followed by the OTHER-ARGS--it can display
590 BUFFER in any way it likes. All this is done by the function
591 found in `special-display-function'.
592
593 If the specified frame parameters include (same-window . t), the
594 buffer is displayed in the currently selected window. Otherwise,
595 if they include (same-frame . t), the buffer is displayed in a
596 new window in the currently selected frame.
597
598 If this variable appears \"not to work\", because you add a name to it
599 but that buffer still appears in the selected window, look at the
600 values of `same-window-buffer-names' and `same-window-regexps'.
601 Those variables take precedence over this one."
602 :type '(repeat (choice :tag "Buffer"
603 :value ""
604 (string :format "%v")
605 (cons :tag "With attributes"
606 :format "%v"
607 :value ("" . nil)
608 (string :format "%v")
609 (repeat :tag "Attributes"
610 (cons :format "%v"
611 (symbol :tag "Parameter")
612 (sexp :tag "Value"))))))
613 :group 'frames)
614
615 (defcustom special-display-regexps nil
616 "List of regexps saying which buffers should have their own special frames.
617 When displaying a buffer with `display-buffer' or
618 `pop-to-buffer', if any regexp in this list matches the buffer
619 name, it makes a special frame for the buffer by calling
620 `special-display-function'.
621
622 An element of the list can be a list instead of just a string.
623 There are two ways to use a list as an element:
624 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)
625 In the first case, the FRAME-PARAMETERS are pairs of the form
626 \(PARAMETER . VALUE); these parameter values are used to create
627 the frame. In the second case, FUNCTION is called with BUFFER as
628 the first argument, followed by the OTHER-ARGS--it can display
629 the buffer in any way it likes. All this is done by the function
630 found in `special-display-function'.
631
632 If the specified frame parameters include (same-window . t), the
633 buffer is displayed in the currently selected window. Otherwise,
634 if they include (same-frame . t), the buffer is displayed in a
635 new window in the currently selected frame.
636
637 If this variable appears \"not to work\", because you add a
638 regexp to it but the matching buffers still appear in the
639 selected window, look at the values of `same-window-buffer-names'
640 and `same-window-regexps'. Those variables take precedence over
641 this one."
642 :type '(repeat (choice :tag "Buffer"
643 :value ""
644 (regexp :format "%v")
645 (cons :tag "With attributes"
646 :format "%v"
647 :value ("" . nil)
648 (regexp :format "%v")
649 (repeat :tag "Attributes"
650 (cons :format "%v"
651 (symbol :tag "Parameter")
652 (sexp :tag "Value"))))))
653 :group 'frames)
654 702
655 (defcustom special-display-function 'special-display-popup-frame 703 (defcustom special-display-function 'special-display-popup-frame
656 "Function to call to make a new frame for a special buffer. 704 "Function to call for displaying special buffers.
657 It is called with two arguments, the buffer and optional buffer 705 This function is called with two arguments - the buffer and,
658 specific data, and should return a window displaying that buffer. 706 optionally, a list - and should return a window displaying that
659 The default value normally makes a separate frame for the buffer, 707 buffer. The default value usually makes a separate frame for the
660 using `special-display-frame-alist' to specify the frame 708 buffer using `special-display-frame-alist' to specify the frame
661 parameters. 709 parameters. See the definition of `special-display-popup-frame'
662 710 for how to specify such a function.
663 But if the buffer specific data includes (same-window . t) then 711
664 the buffer is displayed in the currently selected window. 712 A buffer is special when its name is either listed in
665 Otherwise, if it includes (same-frame . t) then the buffer is
666 displayed in a new window in the currently selected frame.
667
668 A buffer is special if it is listed in
669 `special-display-buffer-names' or matches a regexp in 713 `special-display-buffer-names' or matches a regexp in
670 `special-display-regexps'." 714 `special-display-regexps'."
671 :type 'function 715 :type 'function
672 :group 'frames) 716 :group 'frames)
717
718 (defcustom same-window-buffer-names nil
719 "List of names of buffers that should appear in the \"same\" window.
720 `display-buffer' and `pop-to-buffer' show a buffer whose name is
721 on this list in the selected rather than some other window.
722
723 An element of this list can be a cons cell instead of just a
724 string. In that case, the cell's car must be a string specifying
725 the buffer name. This is for compatibility with
726 `special-display-buffer-names'; the cdr of the cons cell is
727 ignored.
728
729 See also `same-window-regexps'."
730 :type '(repeat (string :format "%v"))
731 :group 'windows)
732
733 (defcustom same-window-regexps nil
734 "List of regexps saying which buffers should appear in the \"same\" window.
735 `display-buffer' and `pop-to-buffer' show a buffer whose name
736 matches a regexp on this list in the selected rather than some
737 other window.
738
739 An element of this list can be a cons cell instead of just a
740 string. In that case, the cell's car must be a regexp matching
741 the buffer name. This is for compatibility with
742 `special-display-regexps'; the cdr of the cons cell is ignored.
743
744 See also `same-window-buffer-names'."
745 :type '(repeat (regexp :format "%v"))
746 :group 'windows)
673 747
674 (defun same-window-p (buffer-name) 748 (defun same-window-p (buffer-name)
675 "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window. 749 "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window.
676 This function returns non-nil if `display-buffer' or 750 This function returns non-nil if `display-buffer' or
677 `pop-to-buffer' would show a buffer named BUFFER-NAME in the 751 `pop-to-buffer' would show a buffer named BUFFER-NAME in the
690 (when (or (and (stringp regexp) 764 (when (or (and (stringp regexp)
691 (string-match regexp buffer-name)) 765 (string-match regexp buffer-name))
692 (and (consp regexp) (stringp (car regexp)) 766 (and (consp regexp) (stringp (car regexp))
693 (string-match-p (car regexp) buffer-name))) 767 (string-match-p (car regexp) buffer-name)))
694 (throw 'found t))))))) 768 (throw 'found t)))))))
695
696 (defcustom same-window-buffer-names nil
697 "List of names of buffers that should appear in the \"same\" window.
698 `display-buffer' and `pop-to-buffer' show a buffer whose name is
699 on this list in the selected rather than some other window.
700
701 An element of this list can be a cons cell instead of just a
702 string. In that case the car must be a string specifying the
703 buffer name. This is for compatibility with
704 `special-display-buffer-names'; the cdr of the cons cell is
705 ignored.
706
707 See also `same-window-regexps'."
708 :type '(repeat (string :format "%v"))
709 :group 'windows)
710
711 (defcustom same-window-regexps nil
712 "List of regexps saying which buffers should appear in the \"same\" window.
713 `display-buffer' and `pop-to-buffer' show a buffer whose name
714 matches a regexp on this list in the selected rather than some
715 other window.
716
717 An element of this list can be a cons cell instead of just a
718 string. In that case the car must be a string, which specifies
719 the buffer name. This is for compatibility with
720 `special-display-buffer-names'; the cdr of the cons cell is
721 ignored.
722
723 See also `same-window-buffer-names'."
724 :type '(repeat (regexp :format "%v"))
725 :group 'windows)
726 769
727 (defcustom pop-up-frames nil 770 (defcustom pop-up-frames nil
728 "Whether `display-buffer' should make a separate frame. 771 "Whether `display-buffer' should make a separate frame.
729 If nil, never make a seperate frame. 772 If nil, never make a seperate frame.
730 If the value is `graphic-only', make a separate frame 773 If the value is `graphic-only', make a separate frame