[Top][All Lists]

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

Make M-x woman respect display-buffer-alist

From: Kaushal
Subject: Make M-x woman respect display-buffer-alist
Date: Fri, 19 Jun 2015 15:03:13 +0000


I was trying to make the WoMan buffers open as I intend to using display-buffer-alist. But that was not working.

So I dug into the woman.el source and made these edits:

(defun WoMan-find-buffer ()
  "Switch to buffer corresponding to `woman-buffer-number' and return it.
If such a buffer does not exist then remove its association from the
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) ; Edit
            (display-buffer buffer) ; Edit
          ;; Delete alist element:
          (setq woman-buffer-alist (cdr woman-buffer-alist))
    (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) ; Edit
          (display-buffer buffer) ; Edit
        ;; Delete alist element:
        (setcdr prev-ptr (cdr (cdr prev-ptr)))
        (if (>= woman-buffer-number (length woman-buffer-alist))
            (setq woman-buffer-number 0))

(defun woman-really-find-file (filename compressed bufname)
  "Find, decompress, and decode a UN*X man page FILENAME.
If COMPRESSED is non-nil, turn on auto-compression mode to decompress
the file if necessary.  Set buffer name BUFNAME and major mode.
Do not call directly!"
  (let ((WoMan-current-file filename)) ; used for message logging
    (if woman-use-own-frame
(or (and (frame-live-p woman-frame) woman-frame)
    (setq woman-frame (make-frame)))))
    (set-buffer (get-buffer-create bufname))
    (condition-case nil
        ;; (switch-to-buffer (current-buffer)) ; Edit
        (display-buffer (current-buffer)) ; Edit
      (error (pop-to-buffer (current-buffer))))
    (setq buffer-read-only nil)
    (erase-buffer) ; NEEDED for reformat
    (woman-insert-file-contents filename compressed)
    ;; Set buffer's default directory to that of the file.
    (setq default-directory (file-name-directory filename))
    (set (make-local-variable 'backup-inhibited) t)
    (set-visited-file-name "")

The edited lines have the "; Edit" comments.

I simply replaced `switch-to-buffer' with `display-buffer' at 3 places.

If doing so does not have any unexpected bad outcomes, can that change be made in the master?

PS: Not sure if this should have been a bug report; so posted here.

reply via email to

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