aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2009-01-14 09:56:11 +0000
committerMartin Rudalics2009-01-14 09:56:11 +0000
commit56f31926ae22417c417e3e92e7c141e154a35382 (patch)
tree92399d17754c6ea24e6f4b3211d2d3274d5fe8c6
parent38934f763b8ba984549e2b26a15529d6c605800d (diff)
downloademacs-56f31926ae22417c417e3e92e7c141e154a35382.tar.gz
emacs-56f31926ae22417c417e3e92e7c141e154a35382.zip
(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.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/window.el303
2 files changed, 183 insertions, 130 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 08c3ef5fa3e..7bb06fd8494 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12009-01-14 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (special-display-buffer-names)
4 (special-display-regexps): Add customization support for
5 function/other-args elements. Rewrite doc-strings.
6 (special-display-function): Rewrite doc-strings
7 (same-window-buffer-names, same-window-regexps): Minor
8 doc-string fixes.
9 (special-display-p): Minor rewrite.
10
12009-01-14 Glenn Morris <rgm@gnu.org> 112009-01-14 Glenn Morris <rgm@gnu.org>
2 12
3 * textmodes/bibtex.el (bibtex-copy-field-as-kill): Doc fix. 13 * textmodes/bibtex.el (bibtex-copy-field-as-kill): Doc fix.
diff --git a/lisp/window.el b/lisp/window.el
index fc76ea96d6e..3b894a0b823 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -548,22 +548,148 @@ Commands such as `switch-to-buffer-other-window' and
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.
553Displaying a buffer with `display-buffer' or `pop-to-buffer', if
554its name is in this list, displays the buffer in a way specified
555by `special-display-function'. `special-display-popup-frame'
556\(the default for `special-display-function') usually displays
557the buffer in a separate frame made with the parameters specified
558by `special-display-frame-alist'. If `special-display-function'
559has been set to some other function, that function is called with
560the buffer as first, and nil as second argument.
561
562Alternatively, an element of this list can be specified as
563\(BUFFER-NAME FRAME-PARAMETERS), where BUFFER-NAME is a buffer
564name and FRAME-PARAMETERS an alist of \(PARAMETER . VALUE) pairs.
565`special-display-popup-frame' will interpret such pairs as frame
566parameters when it creates a special frame, overriding the
567corresponding values from `special-display-frame-alist'.
568
569As a special case, if FRAME-PARAMETERS contains (same-window . t)
570`special-display-popup-frame' displays that buffer in the
571selected window. If FRAME-PARAMETERS contains (same-frame . t),
572it displays that buffer in a window on the selected frame.
573
574If `special-display-function' specifies some other function than
575`special-display-popup-frame', that function is called with the
576buffer named BUFFER-NAME as first, and FRAME-PARAMETERS as second
577argument.
578
579Finally, 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
582named BUFFER-NAME as first argument, and OTHER-ARGS as the
583second. If `special-display-function' specifies some other
584function, that function is called with the buffer named
585BUFFER-NAME as first, and the element's cdr as second argument.
586
587If this variable appears \"not to work\", because you added a
588name to it but the corresponding buffer is displayed in the
589selected window, look at the values of `same-window-buffer-names'
590and `same-window-regexps'. Those variables take precedence over
591this one.
592
593See 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.
617Displaying a buffer with `display-buffer' or `pop-to-buffer', if
618any regexp in this list matches its name, displays it specially
619using `special-display-function'. `special-display-popup-frame'
620\(the default for `special-display-function') usually displays
621the buffer in a separate frame made with the parameters specified
622by `special-display-frame-alist'. If `special-display-function'
623has been set to some other function, that function is called with
624the buffer as first, and nil as second argument.
625
626Alternatively, an element of this list can be specified as
627\(REGEXP FRAME-PARAMETERS), where REGEXP is a regexp as above and
628FRAME-PARAMETERS an alist of (PARAMETER . VALUE) pairs.
629`special-display-popup-frame' will then interpret these pairs as
630frame parameters when creating a special frame for a buffer whose
631name matches REGEXP, overriding the corresponding values from
632`special-display-frame-alist'.
633
634As a special case, if FRAME-PARAMETERS contains (same-window . t)
635`special-display-popup-frame' displays buffers matching REGEXP in
636the selected window. \(same-frame . t) in FRAME-PARAMETERS means
637to display such buffers in a window on the selected frame.
638
639If `special-display-function' specifies some other function than
640`special-display-popup-frame', that function is called with the
641buffer whose name matched REGEXP as first, and FRAME-PARAMETERS
642as second argument.
643
644Finally, an element of this list can be also specified as
645\(REGEXP FUNCTION OTHER-ARGS). `special-display-popup-frame'
646will then call FUNCTION with the buffer whose name matched
647REGEXP as first, and OTHER-ARGS as second argument. If
648`special-display-function' specifies some other function, that
649function is called with the buffer whose name matched REGEXP
650as first, and the element's cdr as second argument.
651
652If this variable appears \"not to work\", because you added a
653name to it but the corresponding buffer is displayed in the
654selected window, look at the values of `same-window-buffer-names'
655and `same-window-regexps'. Those variables take precedence over
656this one.
657
658See 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.
553If the value is t, `display-buffer' or `pop-to-buffer' would 682More precisely, return t if `special-display-buffer-names' or
554create a special frame for that buffer using the default frame 683`special-display-regexps' contain a string entry equaling or
555parameters. 684matching BUFFER-NAME. If `special-display-buffer-names' or
556 685`special-display-regexps' contain a list entry whose car equals
557If the value is a list, it is a list of frame parameters that 686or matches BUFFER-NAME, the return value is the cdr of that
558would be used to make a frame for that buffer. The variables 687entry."
559`special-display-buffer-names' and `special-display-regexps'
560control 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
@@ -572,135 +698,31 @@ control this."
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.
579Displaying a buffer with `display-buffer' or `pop-to-buffer', if
580its name is in this list, makes a special frame for it using
581`special-display-function'. See also `special-display-regexps'.
582
583An element of the list can be a list instead of just a string.
584There are two ways to use a list as an element:
585 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)
586In the first case, the FRAME-PARAMETERS are pairs of the form
587\(PARAMETER . VALUE); these parameter values are used to create
588the frame. In the second case, FUNCTION is called with BUFFER as
589the first argument, followed by the OTHER-ARGS--it can display
590BUFFER in any way it likes. All this is done by the function
591found in `special-display-function'.
592
593If the specified frame parameters include (same-window . t), the
594buffer is displayed in the currently selected window. Otherwise,
595if they include (same-frame . t), the buffer is displayed in a
596new window in the currently selected frame.
597
598If this variable appears \"not to work\", because you add a name to it
599but that buffer still appears in the selected window, look at the
600values of `same-window-buffer-names' and `same-window-regexps'.
601Those 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.
617When displaying a buffer with `display-buffer' or
618`pop-to-buffer', if any regexp in this list matches the buffer
619name, it makes a special frame for the buffer by calling
620`special-display-function'.
621
622An element of the list can be a list instead of just a string.
623There are two ways to use a list as an element:
624 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)
625In the first case, the FRAME-PARAMETERS are pairs of the form
626\(PARAMETER . VALUE); these parameter values are used to create
627the frame. In the second case, FUNCTION is called with BUFFER as
628the first argument, followed by the OTHER-ARGS--it can display
629the buffer in any way it likes. All this is done by the function
630found in `special-display-function'.
631
632If the specified frame parameters include (same-window . t), the
633buffer is displayed in the currently selected window. Otherwise,
634if they include (same-frame . t), the buffer is displayed in a
635new window in the currently selected frame.
636
637If this variable appears \"not to work\", because you add a
638regexp to it but the matching buffers still appear in the
639selected window, look at the values of `same-window-buffer-names'
640and `same-window-regexps'. Those variables take precedence over
641this 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.
657It is called with two arguments, the buffer and optional buffer 705This function is called with two arguments - the buffer and,
658specific data, and should return a window displaying that buffer. 706optionally, a list - and should return a window displaying that
659The default value normally makes a separate frame for the buffer, 707buffer. The default value usually makes a separate frame for the
660using `special-display-frame-alist' to specify the frame 708buffer using `special-display-frame-alist' to specify the frame
661parameters. 709parameters. See the definition of `special-display-popup-frame'
662 710for how to specify such a function.
663But if the buffer specific data includes (same-window . t) then 711
664the buffer is displayed in the currently selected window. 712A buffer is special when its name is either listed in
665Otherwise, if it includes (same-frame . t) then the buffer is
666displayed in a new window in the currently selected frame.
667
668A 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)
673 717
674(defun same-window-p (buffer-name)
675 "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window.
676This function returns non-nil if `display-buffer' or
677`pop-to-buffer' would show a buffer named BUFFER-NAME in the
678selected rather than \(as usual\) some other window. See
679`same-window-buffer-names' and `same-window-regexps'."
680 (cond
681 ((not (stringp buffer-name)))
682 ;; The elements of `same-window-buffer-names' can be buffer
683 ;; names or cons cells whose cars are buffer names.
684 ((member buffer-name same-window-buffer-names))
685 ((assoc buffer-name same-window-buffer-names))
686 ((catch 'found
687 (dolist (regexp same-window-regexps)
688 ;; The elements of `same-window-regexps' can be regexps
689 ;; or cons cells whose cars are regexps.
690 (when (or (and (stringp regexp)
691 (string-match regexp buffer-name))
692 (and (consp regexp) (stringp (car regexp))
693 (string-match-p (car regexp) buffer-name)))
694 (throw 'found t)))))))
695
696(defcustom same-window-buffer-names nil 718(defcustom same-window-buffer-names nil
697 "List of names of buffers that should appear in the \"same\" window. 719 "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 720`display-buffer' and `pop-to-buffer' show a buffer whose name is
699on this list in the selected rather than some other window. 721on this list in the selected rather than some other window.
700 722
701An element of this list can be a cons cell instead of just a 723An element of this list can be a cons cell instead of just a
702string. In that case the car must be a string specifying the 724string. In that case, the cell's car must be a string specifying
703buffer name. This is for compatibility with 725the buffer name. This is for compatibility with
704`special-display-buffer-names'; the cdr of the cons cell is 726`special-display-buffer-names'; the cdr of the cons cell is
705ignored. 727ignored.
706 728
@@ -715,15 +737,36 @@ matches a regexp on this list in the selected rather than some
715other window. 737other window.
716 738
717An element of this list can be a cons cell instead of just a 739An element of this list can be a cons cell instead of just a
718string. In that case the car must be a string, which specifies 740string. In that case, the cell's car must be a regexp matching
719the buffer name. This is for compatibility with 741the buffer name. This is for compatibility with
720`special-display-buffer-names'; the cdr of the cons cell is 742`special-display-regexps'; the cdr of the cons cell is ignored.
721ignored.
722 743
723See also `same-window-buffer-names'." 744See also `same-window-buffer-names'."
724 :type '(repeat (regexp :format "%v")) 745 :type '(repeat (regexp :format "%v"))
725 :group 'windows) 746 :group 'windows)
726 747
748(defun same-window-p (buffer-name)
749 "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window.
750This function returns non-nil if `display-buffer' or
751`pop-to-buffer' would show a buffer named BUFFER-NAME in the
752selected rather than \(as usual\) some other window. See
753`same-window-buffer-names' and `same-window-regexps'."
754 (cond
755 ((not (stringp buffer-name)))
756 ;; The elements of `same-window-buffer-names' can be buffer
757 ;; names or cons cells whose cars are buffer names.
758 ((member buffer-name same-window-buffer-names))
759 ((assoc buffer-name same-window-buffer-names))
760 ((catch 'found
761 (dolist (regexp same-window-regexps)
762 ;; The elements of `same-window-regexps' can be regexps
763 ;; or cons cells whose cars are regexps.
764 (when (or (and (stringp regexp)
765 (string-match regexp buffer-name))
766 (and (consp regexp) (stringp (car regexp))
767 (string-match-p (car regexp) buffer-name)))
768 (throw 'found t)))))))
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.
729If nil, never make a seperate frame. 772If nil, never make a seperate frame.