bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8851: 24.0.50; regression: special-display-frame is no longer dedica


From: Drew Adams
Subject: bug#8851: 24.0.50; regression: special-display-frame is no longer dedicated
Date: Mon, 13 Jun 2011 11:41:17 -0700

> Does the patch below fix it?

Thanks for your quick reply, Martin.  No, I'm afraid it doesn't change anything
wrt this bug.

I didn't download the latest source files to apply your patch, but the build I'm
using is supposedly from today.  I applied your patch manually to its source
code, which means that I eval'ed these two updated definitions (below).  That
didn't help.

(defun display-buffer-in-window (buffer window specifiers)
  "Display BUFFER in WINDOW and raise its frame if needed.
WINDOW must be a live window and defaults to the selected one.
Return WINDOW.

SPECIFIERS must be a list of buffer display specifiers, see the
documentation of `display-buffer-alist' for a description."
  (setq buffer (normalize-live-buffer buffer))
  (setq window (normalize-live-window window))
  (let* ((old-frame (selected-frame))
         (new-frame (window-frame window))
         (dedicated (cdr (assq 'dedicated specifiers)))
         (no-other-window (cdr (assq 'no-other-window specifiers))))
    ;; Show BUFFER in WINDOW.
    ;;---- (set-window-dedicated-p window nil)
    (set-window-buffer window buffer)
    (when dedicated
      (set-window-dedicated-p window dedicated))
    (when no-other-window
      (set-window-parameter window 'no-other-window t))
    (unless (eq old-frame new-frame)
      (display-buffer-select-window window))
    ;; Return window.
    window))

(defun display-buffer-reuse-window (buffer method &optional specifiers)
  "Display BUFFER in an existing window.
METHOD must be a list in the form of the cdr of a `reuse-window'
buffer display specifier, see `display-buffer-alist' for an
explanation.  The first element must specifiy the window to use,
and can be either nil, `same', `other', or a live window.  The
second element must specify the window's buffer and can be either
nil, `same', `other', or a live buffer.  The third element is the
frame to use - either nil, 0, `visible', `other', t, or a live
frame.

Optional argument SPECIFIERS must be a list of valid display
specifiers.  Return the window chosen to display BUFFER, nil if
none was found."
  (let* ((method-window (nth 0 method))
         (method-buffer (nth 1 method))
         (method-frame (nth 2 method))
         (reuse-dedicated (assq 'reuse-window-dedicated specifiers))
         windows other-frame dedicated time best-window best-time)
    (when (eq method-frame 'other)
      ;; `other' is not handled by `window-list-1'.
      (setq other-frame t)
      (setq method-frame t))
    (dolist (window (window-list-1 nil 'nomini method-frame))
      (let ((window-buffer (window-buffer window)))
        (when (and (not (window-minibuffer-p window))
                   ;; Don't reuse a side window.
                   (or (not (eq (window-parameter window 'window-side) 'side))
                       (eq window-buffer buffer))
                   (or (not method-window)
                       (and (eq method-window 'same)
                            (eq window (selected-window)))
                       (and (eq method-window 'other)
                            (not (eq window (selected-window))))
                       ;; Special case for applications that specifiy
                       ;; the window explicitly.
                       (eq method-window window))
                   (or (not method-buffer)
                       (and (eq method-buffer 'same)
                            (eq window-buffer buffer))
                       (and (eq method-buffer 'other)
                            (not (eq window-buffer buffer)))
                       ;; Special case for applications that specifiy
                       ;; the window's buffer explicitly.
                       (eq method-buffer window-buffer))
                   (or (not other-frame)
                       (not (eq (window-frame window) (selected-frame))))
                   ;; Handle dedicatedness.
                   (or (eq window-buffer buffer)
                       ;; The window does not show the same buffer.
                       (not (setq dedicated (window-dedicated-p window)))
                       ;; If the window is weakly dedicated to its
                       ;; buffer, reuse-dedicated must be non-nil.
                       (and (not (eq dedicated t)) reuse-dedicated)
                       ;; If the window is strongly dedicated to its
                       ;; buffer, reuse-dedicated must be t.
                       (eq reuse-dedicated t)))
          (setq windows (cons window windows)))))

    (if (eq method-buffer 'same)
        ;; When reusing a window on the same buffer use the lru one.
        (dolist (window windows)
          (setq time (window-use-time window))
          (when (or (not best-window) (< time best-time))
            (setq best-window window)
            (setq best-time time)))
      ;; Otherwise, sort windows according to their use-time.
      (setq windows
            (sort windows
                  #'(lambda (window-1 window-2)
                      (<= (window-use-time window-1)
                          (window-use-time window-2)))))
      (setq best-window
            ;; Try to get a full-width window (this is silly and can
            ;; get us to another frame but let's ignore these issues
            ;; for the moment).
            (catch 'found
              (dolist (window windows)
                (when (window-full-width-p window)
                  (throw 'found window)))
              ;; If there's no full-width window return the lru window.
              (car windows))))

    (when best-window
      (display-buffer-even-window-sizes best-window specifiers)
      ;; Never change the quit-restore parameter of a window here.
      (if (eq (window-buffer best-window) buffer)
          (setq display-buffer-window
                (cons best-window 'reuse-buffer-window))
        (setq display-buffer-window
              (cons best-window 'reuse-other-window))
        (unless (window-parameter best-window 'quit-restore)
          ;; Don't overwrite an existing quit-restore entry.
          (set-window-parameter
           best-window 'quit-restore
           (list (window-buffer best-window) (window-start best-window)
                 (window-point best-window) buffer
                 (window-total-size best-window) (selected-window)))))
      ;; Reset dedicated status of best-window here.
      (set-window-dedicated-p best-window nil)
      (display-buffer-in-window buffer best-window specifiers))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]