Function: mh-defun-show-buffer

mh-defun-show-buffer is a macro defined in mh-show.el.gz.

Signature

(mh-defun-show-buffer FUNCTION ORIGINAL-FUNCTION &optional DONT-RETURN)

Documentation

Define FUNCTION to run ORIGINAL-FUNCTION in folder buffer.

If the buffer we start in is still visible and DONT-RETURN is nil then switch to it after that.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-show.el.gz
;; Infrastructure to generate show-buffer functions from folder functions.
;; Should we be restoring the mark in the folder buffer after the
;; operation has been carried out?
(defmacro mh-defun-show-buffer (function original-function
                                         &optional dont-return)
  "Define FUNCTION to run ORIGINAL-FUNCTION in folder buffer.
If the buffer we start in is still visible and DONT-RETURN is nil
then switch to it after that."
  `(defun ,function ()
     ,(format "Calls %s from the message's folder.\n%s\nSee `%s' for more info.\n"
              original-function
              (if dont-return ""
                "When function completes, returns to the show buffer if it is
still visible.\n")
              original-function)
     (interactive)
     (when (buffer-live-p (get-buffer mh-show-folder-buffer))
       (let ((config (current-window-configuration))
             (folder-buffer mh-show-folder-buffer)
             (normal-exit nil)
             ,@(if dont-return () '((cur-buffer-name (buffer-name)))))
         (pop-to-buffer mh-show-folder-buffer nil)
         (unless (equal (buffer-name
                         (window-buffer (frame-first-window (selected-frame))))
                        folder-buffer)
           (delete-other-windows))
         (mh-goto-cur-msg t)
         (deactivate-mark)
         (unwind-protect
             (prog1 (call-interactively (function ,original-function))
               (setq normal-exit t))
           (deactivate-mark)
           (when (eq major-mode 'mh-folder-mode)
             (when (fboundp 'hl-line-highlight)
               (hl-line-highlight)))
           (cond ((not normal-exit)
                  (set-window-configuration config))
                 ,(if dont-return
                      '(t (setq mh-previous-window-config config))
                    '((and (get-buffer cur-buffer-name)
                           (window-live-p (get-buffer-window
                                           (get-buffer cur-buffer-name))))
                      (pop-to-buffer (get-buffer cur-buffer-name) nil)))))))))