Subject: 25.0.50; Make M-x woman respect display-buffer-alist

From: Kaushal <[email-masked]>
Date: Mon, 13 Jul 2015 15:06:10 +0000

Hi,

This was posted on the emacs-devel list a while back and it was suggested
that this be posted on bug-gnu-emacs.

The aim of this patch is that opening M-x woman buffers be controlled using
display-buffer-alist. Using display-buffer function instead of
switch-to-buffer function will allow the user to control how they want to
open the WoMan buffers (same window, other window, popup, etc)

The patch is below:

Date: Mon, 13 Jul 2015 11:00:39 -0400
Subject: [PATCH] Allow display-buffer-alist to control woman bufs

---
 lisp/woman.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/woman.el b/lisp/woman.el
index 75c3d2e..e903caa 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1651,7 +1651,7 @@ Do not call directly!"
      (setq woman-frame (make-frame)))))
     (set-buffer (get-buffer-create bufname))
     (condition-case nil
-        (switch-to-buffer (current-buffer))
+        (display-buffer (current-buffer))
       (error (pop-to-buffer (current-buffer))))
     (buffer-disable-undo)
     (setq buffer-read-only nil)
@@ -2061,14 +2061,14 @@ alist in `woman-buffer-alist' and return nil."
   (if (zerop woman-buffer-number)
       (let ((buffer (get-buffer (cdr (car woman-buffer-alist)))))
  (if buffer
-    (switch-to-buffer buffer)
+    (display-buffer buffer)
   ;; Delete alist element:
   (setq woman-buffer-alist (cdr woman-buffer-alist))
   nil))
     (let* ((prev-ptr (nthcdr (1- woman-buffer-number) woman-buffer-alist))
    (buffer (get-buffer (cdr (car (cdr prev-ptr))))))
       (if buffer
-  (switch-to-buffer buffer)
+  (display-buffer buffer)
  ;; Delete alist element:
  (setcdr prev-ptr (cdr (cdr prev-ptr)))
  (if (>= woman-buffer-number (length woman-buffer-alist))
-- 
1.9.2

On Wed, Jun 24, 2015 at 12:03 PM Michael Heerdegen <[email-masked]>
wrote:

> Hi Kaushal,
>
> > I was trying to make the WoMan buffers open as I intend to using
> > display-buffer-alist. But that was not working.
>
> I guess your message got lost here, better make a bug report, and
> better include a patch than the whole changed code.
>
> > can that change be made in the master?
>
> I think it would be an improvement.
>
> The very same applies to eww:
>
> --8<---------------cut here---------------start------------->8---
> (defun eww-setup-buffer ()
>   (switch-to-buffer (get-buffer-create "*eww*")) ; <-----
>   (let ((inhibit-read-only t))
>     (remove-overlays)
>     (erase-buffer))
>   (unless (eq major-mode 'eww-mode)
>     (eww-mode)))
> --8<---------------cut here---------------end--------------->8---
>
> Maybe there are more cases.  It's surely worth discussing.
>
>
> Regards,
>
> Michael.
>