From 491c7bb3a592ab637bf794f18b6254b57e42619f Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 5 Nov 2010 11:41:43 +0100 Subject: [PATCH] Rewrite more functions using buffer display specifiers. * electric.el (Electric-pop-up-window): Use buffer display specifiers. * emacs-lisp/elint.el (elint-display-log): Use display-buffer-other-window. * vc/pcvs-util.el (cvs-pop-to-buffer-same-frame): Use buffer display specifiers. * message.el (message-mail-other-window) (message-news-other-window): Pass pop-to-buffer-other-window as switch-function to message-pop-to-buffer. (message-mail-other-frame, message-news-other-frame): Pass pop-to-buffer-other-frame as switch-function to message-pop-to-buffer. * mh-comp.el (mh-send-other-window): Pass t as extra argument to mh-send-sub. (mh-send-sub): New optional argument OTHER-WINDOW. Pass extra argument to mh-read-draft. (mh-read-draft): New optional argument OTHER-WINDOW. Pass it in suitable fashion to pop-to-buffer. --- lisp/ChangeLog | 11 +++++++++++ lisp/electric.el | 10 +++++----- lisp/emacs-lisp/elint.el | 5 ++--- lisp/gnus/ChangeLog | 9 +++++++++ lisp/gnus/message.el | 32 ++++++++------------------------ lisp/mh-e/ChangeLog | 9 +++++++++ lisp/mh-e/mh-comp.el | 19 +++++++++++-------- lisp/vc/pcvs-util.el | 10 +++------- 8 files changed, 58 insertions(+), 47 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a225bcbd165..cdf9ec917d4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2010-11-05 Martin Rudalics + + * electric.el (Electric-pop-up-window): Use buffer display + specifiers. + + * emacs-lisp/elint.el (elint-display-log): Use + display-buffer-other-window. + + * vc/pcvs-util.el (cvs-pop-to-buffer-same-frame): Use buffer + display specifiers. + 2010-11-04 Martin Rudalics * window.el (display-buffer-names, display-buffer-regexps): Make diff --git a/lisp/electric.el b/lisp/electric.el index a0d849bbcca..0c63182b41c 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -152,15 +152,15 @@ (defun Electric-pop-up-window (buffer &optional max-height) (let* ((win (or (get-buffer-window buffer) (selected-window))) (buf (get-buffer buffer)) - (one-window (one-window-p t)) - (pop-up-windows t) - (pop-up-frames nil)) + (one-window (one-window-p t))) (if (not buf) (error "Buffer %s does not exist" buffer) (cond ((and (eq (window-buffer win) buf)) (select-window win)) (one-window - (pop-to-buffer buffer) + (pop-to-buffer + ;; Try to do what the comment above says. + buffer '(same-frame (new-window (selected . below)))) (setq win (selected-window))) (t (switch-to-buffer buf))) @@ -302,7 +302,7 @@ This can be convenient for people who find it easier to hit ) than C-f." #'electric-pair-post-self-insert-function) (remove-hook 'post-self-insert-hook #'electric-pair-post-self-insert-function))) - + (provide 'electric) ;; arch-tag: dae045eb-dc2d-4fb7-9f27-9cc2ce277be8 diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el index b9aa29decd0..274544520da 100644 --- a/lisp/emacs-lisp/elint.el +++ b/lisp/emacs-lisp/elint.el @@ -1036,9 +1036,8 @@ Insert HEADER followed by a blank line if non-nil." (defun elint-display-log () "Display the lint log buffer." - (let ((pop-up-windows t)) - (display-buffer (elint-get-log-buffer)) - (sit-for 0))) + (display-buffer-other-window (elint-get-log-buffer)) + (sit-for 0)) (defvar elint-running) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 2cb1a77107a..7cac6d107e2 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,12 @@ +2010-11-05 Martin Rudalics + + * message.el (message-mail-other-window) + (message-news-other-window): Pass pop-to-buffer-other-window as + switch-function to message-pop-to-buffer. + (message-mail-other-frame, message-news-other-frame): Pass + pop-to-buffer-other-frame as switch-function to + message-pop-to-buffer. + 2010-11-04 Andrew Cohen * nnir.el (gnus-summary-nnir-goto-thread): limiting work done by diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index cc793dfcf9a..ad5574d268f 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -7490,12 +7490,8 @@ you." "Like `message-mail' command, but display mail buffer in another window." (interactive) (unless (message-mail-user-agent) - (let ((pop-up-windows t) - (special-display-buffer-names nil) - (special-display-regexps nil) - (same-window-buffer-names nil) - (same-window-regexps nil)) - (message-pop-to-buffer (message-buffer-name "mail" to)))) + (message-pop-to-buffer + (message-buffer-name "mail" to) 'pop-to-buffer-other-window)) (let ((message-this-is-mail t)) (message-setup `((To . ,(or to "")) (Subject . ,(or subject ""))) nil nil nil 'switch-to-buffer-other-window))) @@ -7505,12 +7501,8 @@ you." "Like `message-mail' command, but display mail buffer in another frame." (interactive) (unless (message-mail-user-agent) - (let ((pop-up-frames t) - (special-display-buffer-names nil) - (special-display-regexps nil) - (same-window-buffer-names nil) - (same-window-regexps nil)) - (message-pop-to-buffer (message-buffer-name "mail" to)))) + (message-pop-to-buffer + (message-buffer-name "mail" to) 'pop-to-buffer-other-frame)) (let ((message-this-is-mail t)) (message-setup `((To . ,(or to "")) (Subject . ,(or subject ""))) nil nil nil 'switch-to-buffer-other-frame))) @@ -7519,12 +7511,8 @@ you." (defun message-news-other-window (&optional newsgroups subject) "Start editing a news article to be sent." (interactive) - (let ((pop-up-windows t) - (special-display-buffer-names nil) - (special-display-regexps nil) - (same-window-buffer-names nil) - (same-window-regexps nil)) - (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups))) + (message-pop-to-buffer + (message-buffer-name "posting" nil newsgroups) 'pop-to-buffer-other-window) (let ((message-this-is-news t)) (message-setup `((Newsgroups . ,(or newsgroups "")) (Subject . ,(or subject "")))))) @@ -7533,12 +7521,8 @@ you." (defun message-news-other-frame (&optional newsgroups subject) "Start editing a news article to be sent." (interactive) - (let ((pop-up-frames t) - (special-display-buffer-names nil) - (special-display-regexps nil) - (same-window-buffer-names nil) - (same-window-regexps nil)) - (message-pop-to-buffer (message-buffer-name "posting" nil newsgroups))) + (message-pop-to-buffer + (message-buffer-name "posting" nil newsgroups) 'pop-to-buffer-other-frame) (let ((message-this-is-news t)) (message-setup `((Newsgroups . ,(or newsgroups "")) (Subject . ,(or subject "")))))) diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 164829c53e8..c3814795ba9 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog @@ -1,3 +1,12 @@ +2010-11-05 Martin Rudalics + + * mh-comp.el (mh-send-other-window): Pass t as extra argument to + mh-send-sub. + (mh-send-sub): New optional argument OTHER-WINDOW. Pass extra + argument to mh-read-draft. + (mh-read-draft): New optional argument OTHER-WINDOW. Pass it in + suitable fashion to pop-to-buffer. + 2010-11-03 Glenn Morris * mh-mime.el (dots, type, ov): Avoid unnecessary declaration. diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el index 762aad86080..9c3d83eda25 100644 --- a/lisp/mh-e/mh-comp.el +++ b/lisp/mh-e/mh-comp.el @@ -169,8 +169,7 @@ TO, CC, and SUBJECT arguments are used." (mh-interactive-read-address "To: ") (mh-interactive-read-address "Cc: ") (mh-interactive-read-string "Subject: "))) - (let ((pop-up-windows t)) - (mh-send-sub to cc subject (current-window-configuration)))) + (mh-send-sub to cc subject (current-window-configuration) t)) (defvar mh-error-if-no-draft nil) ;raise error over using old draft @@ -773,10 +772,11 @@ Optional argument BUFFER can be used to specify the buffer." (t nil)))) -(defun mh-send-sub (to cc subject config) +(defun mh-send-sub (to cc subject config &optional other-window) "Do the real work of composing and sending a letter. Expects the TO, CC, and SUBJECT fields as arguments. -CONFIG is the window configuration before sending mail." +CONFIG is the window configuration before sending mail. +OTHER-WINDOW non-nil means use another window for composing." (let ((folder mh-current-folder) (msg-num (mh-get-msg-num nil))) (message "Composing a message...") @@ -795,7 +795,7 @@ CONFIG is the window configuration before sending mail." (t (error "Can't find %s in %s or %s" mh-comp-formfile mh-user-path mh-lib)))) - nil))) + nil (and other-window t)))) (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc) (goto-char (point-max)) (mh-compose-and-send-mail draft "" folder msg-num @@ -804,7 +804,7 @@ CONFIG is the window configuration before sending mail." (mh-letter-mode-message) (mh-letter-adjust-point)))) -(defun mh-read-draft (use initial-contents delete-contents-file) +(defun mh-read-draft (use initial-contents delete-contents-file &optional other-window) "Read draft file into a draft buffer and make that buffer the current one. USE is a message used for prompting about the intended use of the @@ -812,6 +812,8 @@ message. INITIAL-CONTENTS is filename that is read into an empty buffer, or nil if buffer should not be modified. Delete the initial-contents file if DELETE-CONTENTS-FILE flag is set. +OTHER-WINDOW non-nil means use another window for displaying the +draft file. Returns the draft folder's name. If the draft folder facility is enabled in ~/.mh_profile, a new buffer is used each time and saved in the draft folder. The draft file can @@ -821,14 +823,15 @@ then be reused." (draft-file-name (mh-new-draft-name))) (pop-to-buffer (generate-new-buffer (format "draft-%s" - (file-name-nondirectory draft-file-name)))) + (file-name-nondirectory draft-file-name))) + (and other-window t)) (condition-case () (insert-file-contents draft-file-name t) (file-error)) (setq default-directory orig-default-dir))) (t (let ((draft-name (expand-file-name "draft" mh-user-path))) - (pop-to-buffer "draft") ; Create if necessary + (pop-to-buffer "draft" (and other-window t)) ; Create if necessary (if (buffer-modified-p) (if (y-or-n-p "Draft has been modified; kill anyway? ") (set-buffer-modified-p nil) diff --git a/lisp/vc/pcvs-util.el b/lisp/vc/pcvs-util.el index 595b762b2fa..f3f579bf6a2 100644 --- a/lisp/vc/pcvs-util.el +++ b/lisp/vc/pcvs-util.el @@ -85,13 +85,9 @@ the other elements. The ordering among elements is maintained." "Pop to BUF like `pop-to-buffer' but staying on the same frame. If `pop-to-buffer' would have opened a new frame, this function would try to split a new window instead." - (let ((pop-up-windows (or pop-up-windows pop-up-frames)) - (pop-up-frames nil)) - (or (let ((buf (get-buffer-window buf))) (and buf (select-window buf))) - (and pop-up-windows - (ignore-errors (select-window (split-window-vertically))) - (switch-to-buffer buf)) - (pop-to-buffer (current-buffer))))) + (pop-to-buffer + (current-buffer) '(same-frame (new-window (selected . below)) + (reuse-buffer-window . nil)))) (defun cvs-bury-buffer (buf &optional mainbuf) "Hide the buffer BUF that was temporarily popped up. -- 2.39.5