[Top][All Lists]

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

Re: display-buffer-alist simplifications

From: Stefan Monnier
Subject: Re: display-buffer-alist simplifications
Date: Thu, 11 Aug 2011 09:50:15 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Does this approximately describe the current state of affairs?  I've
> deliberately dismissed things I consider sugar like whether methods
> represent functions or just symbols to look up functions, or whether a
> parameter actually is a condition enabling a method (like a window's
> minimum height) rather then ask for some kind of post-action (like
> setting a window's height).

Not quite. Here's my take on display-buffer-alist:

  (defvar display-buffer-alist nil
    "Specifications of user preferences for `display-buffer'.
  This is a list of elements of the form (CONDITION . ACTION)
  where CONDITION is either a regexp matching buffer names, or a function
  that takes a buffer and returns a boolean.
  ACTION is a list of the form (FUNCTION . ALIST) where FUNCTION can be
  either a function or a list of functions.  Those functions will be called
  with 2 arguments: the buffer to display and an ALIST built from the various
  alists specified in the various ACTIONs.  It should either return the
  window used, or nil to fallback to the next function.")

  (defvar display-buffer-default-action (list #'display-buffer-default)
    "Default action to perform to display a buffer.
  This is an ACTION just like in `display-buffer-alist'.")

  (defvar display-buffer-overriding-action '(nil)
    "Overriding action to perform to display a buffer.
  This is an ACTION just like in `display-buffer-alist'.")

  (defun display-buffer (&optional buffer action)
    "Display BUFFER in some window."
    (let* ((user-action
            (assq-regexp (buffer-name buffer) display-buffer-alist))
          (functions (append (car display-buffer-overriding-action)
                             (car user-action)
                             (car action)
                             (car display-buffer-default-action)))
          (alist (append (cdr display-buffer-overriding-action)
                         (cdr user-action)
                         (cdr action)
                         (cdr display-buffer-default-action))))
      (run-with-args-until-success functions buffer alist)))

  (defalias 'display-buffer-default 'emacs23-display-buffer)

  (defun display-buffer-other-window (buffer alist)
    (let ((pop-up-windows t)
          (special-display-buffer-names nil)
          (special-display-regexps nil)
          (same-window-buffer-names nil)
          (same-window-regexps nil))
      (emacs23-display-buffer buffer)))


The code is clearly incorrect and incomplete, but hopefully gives you an
idea of what I expect it to do.


reply via email to

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