From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: <emacs-devel@gnu.org>
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: [PATCH] Simplify Gnus buffer liveness checking and killing
Date: Mon, 20 May 2019 01:10:54 +0100 [thread overview]
Message-ID: <87ef4uq92p.fsf@tcd.ie> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Simplify-Gnus-buffer-liveness-checking-and-killing.patch --]
[-- Type: text/x-diff, Size: 46221 bytes --]
From 70c6410107eb41af145ca51ee0d0231571fb9468 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 5 May 2019 01:28:57 +0100
Subject: [PATCH] Simplify Gnus buffer liveness checking and killing
* lisp/gnus/gnus-agent.el (gnus-agent-synchronize-group-flags):
Fix indentation.
* lisp/gnus/gnus-util.el (gnus-buffer-exists-p): Remove macro.
(gnus-buffer-live-p): If the given argument is or names a live
buffer, return the corresponding buffer object instead of a boolean.
* lisp/gnus/gnus-win.el (gnus-delete-windows-in-gnusey-frames)
(gnus-remove-some-windows): Simplify.
* lisp/gnus/gnus.el (gnus-prune-buffers): Redefine as alias of
gnus-buffers.
(gnus-kill-buffer, gnus-buffers, gnus-group-find-parameter):
* lisp/gnus/gnus-art.el (gnus-kill-sticky-article-buffers)
(gnus-request-article-this-buffer):
* lisp/gnus/gnus-bcklg.el (gnus-backlog-shutdown):
* lisp/gnus/gnus-cus.el (gnus-group-customize)
(gnus-agent-customize-category):
* lisp/gnus/gnus-draft.el (gnus-draft-edit-message):
* lisp/gnus/gnus-group.el (gnus-group-set-mode-line)
(gnus--abort-on-unsaved-message-buffers, gnus-group-compact-group):
* lisp/gnus/gnus-msg.el (gnus-inews-add-send-actions)
(gnus-summary-supersede-article, gnus-copy-article-buffer):
* lisp/gnus/gnus-score.el (gnus-score-edit-current-scores)
(gnus-score-edit-file):
* lisp/gnus/gnus-spec.el (gnus-update-format-specifications):
* lisp/gnus/gnus-srvr.el (gnus-server-compact-server):
* lisp/gnus/gnus-start.el (gnus-clear-system, gnus-dribble-enter)
(gnus-dribble-save, gnus-dribble-clear, gnus-save-newsrc-file):
* lisp/gnus/gnus-sum.el (gnus-summary-setup-buffer)
(gnus-update-summary-mark-positions, gnus-summary-exit)
(gnus-deaden-summary, gnus-kill-or-deaden-summary)
(gnus-summary-next-group):
* lisp/gnus/gnus-win.el (gnus-configure-frame):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/gnus/message.el (message-with-reply-buffer)
(message-with-reply, message-send-and-exit)
(message-send-mail-with-sendmail, message-pop-to-buffer)
(message-do-send-housekeeping, message-forward-make-body-plain)
(message-forward-make-body-mml):
* lisp/gnus/mm-decode.el (mm-display-external, mm-remove-part):
* lisp/gnus/nnbabyl.el (nnbabyl-server-opened)
(nnbabyl-possibly-change-newsgroup, nnbabyl-read-mbox)
(nnbabyl-check-mbox):
* lisp/gnus/nndiary.el (nndiary-save-nov):
* lisp/gnus/nndoc.el (nndoc-close-group)
(nndoc-possibly-change-buffer):
* lisp/gnus/nnfolder.el (nnfolder-close-group, nnfolder-save-nov):
* lisp/gnus/nnimap.el (nnimap-make-process-buffer, nnimap-keepalive)
(nnimap-find-connection):
* lisp/gnus/nnmail.el (nnmail-cache-open, nnmail-cache-close):
* lisp/gnus/nnmbox.el (nnmbox-close-server, nnmbox-server-opened)
(nnmbox-possibly-change-newsgroup, nnmbox-read-mbox):
* lisp/gnus/nnml.el (nnml-save-incremental-nov, nnml-open-nov)
(nnml-save-nov):
* lisp/gnus/nnoo.el (nnoo-server-opened):
* lisp/gnus/nntp.el (nntp-kill-buffer, nntp-make-process-buffer)
(nntp-open-connection, nntp-async-trigger):
* lisp/net/mairix.el (mairix-gnus-fetch-field): Simplify buffer
liveness checking and killing, replacing buffer-name with
buffer-live-p and gnus-buffer-exists-p with gnus-buffer-live-p or
equivalent where applicable.
---
lisp/gnus/gnus-agent.el | 27 +++++++++++++++------------
lisp/gnus/gnus-art.el | 21 ++++++++-------------
lisp/gnus/gnus-bcklg.el | 3 +--
lisp/gnus/gnus-cus.el | 8 +++-----
lisp/gnus/gnus-draft.el | 5 ++---
lisp/gnus/gnus-group.el | 22 +++++++++-------------
lisp/gnus/gnus-msg.el | 9 ++++-----
lisp/gnus/gnus-score.el | 4 ++--
lisp/gnus/gnus-spec.el | 2 +-
lisp/gnus/gnus-srvr.el | 3 +--
lisp/gnus/gnus-start.el | 20 ++++++++------------
lisp/gnus/gnus-sum.el | 18 ++++++++----------
lisp/gnus/gnus-util.el | 11 +++--------
lisp/gnus/gnus-win.el | 32 ++++++++++++--------------------
lisp/gnus/gnus.el | 24 ++++++------------------
lisp/gnus/mail-source.el | 3 +--
lisp/gnus/message.el | 23 ++++++++---------------
lisp/gnus/mm-decode.el | 8 +++-----
lisp/gnus/nnbabyl.el | 15 +++++----------
lisp/gnus/nndiary.el | 2 +-
lisp/gnus/nndoc.el | 9 +++------
lisp/gnus/nnfolder.el | 5 ++---
lisp/gnus/nnimap.el | 6 +++---
lisp/gnus/nnmail.el | 8 +++-----
lisp/gnus/nnmbox.el | 15 +++++----------
lisp/gnus/nnml.el | 8 +++-----
lisp/gnus/nnoo.el | 3 +--
lisp/gnus/nntp.el | 37 ++++++++++++++++++-------------------
lisp/net/mairix.el | 6 ++----
29 files changed, 141 insertions(+), 216 deletions(-)
diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el
index bed480f554..a09b436889 100644
--- a/lisp/gnus/gnus-agent.el
+++ b/lisp/gnus/gnus-agent.el
@@ -1193,7 +1193,7 @@ gnus-agent-fetch-selected-article
;;;
(defun gnus-agent-synchronize-group-flags (group actions server)
-"Update a plugged group by performing the indicated actions."
+ "Update a plugged group by performing the indicated actions."
(let* ((gnus-command-method (gnus-server-to-method server))
(info
;; This initializer is required as gnus-request-set-mark
@@ -1227,18 +1227,21 @@ gnus-agent-synchronize-group-flags
((memq mark '(tick))
(let ((info-marks (assoc mark (gnus-info-marks info))))
(unless info-marks
- (gnus-info-set-marks info (cons (setq info-marks (list mark)) (gnus-info-marks info))))
- (setcdr info-marks (funcall (if (eq what 'add)
- 'gnus-range-add
- 'gnus-remove-from-range)
- (cdr info-marks)
- range))))))))
+ (gnus-info-set-marks
+ info (cons (setq info-marks (list mark))
+ (gnus-info-marks info))))
+ (setcdr info-marks
+ (funcall (if (eq what 'add)
+ 'gnus-range-add
+ 'gnus-remove-from-range)
+ (cdr info-marks)
+ range))))))))
- ;;Marks can be synchronized at any time by simply toggling from
- ;;unplugged to plugged. If that is what is happening right now, make
- ;;sure that the group buffer is up to date.
- (when (gnus-buffer-live-p gnus-group-buffer)
- (gnus-group-update-group group t)))
+ ;; Marks can be synchronized at any time by simply toggling from
+ ;; unplugged to plugged. If that is what is happening right now,
+ ;; make sure that the group buffer is up to date.
+ (when (gnus-buffer-live-p gnus-group-buffer)
+ (gnus-group-update-group group t)))
nil))
(defun gnus-agent-save-active (method &optional groups-p)
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index baa8a244c0..c416266efc 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -4798,11 +4798,10 @@ gnus-kill-sticky-article-buffers
(interactive "P")
(dolist (buf (gnus-buffers))
(with-current-buffer buf
- (when (derived-mode-p 'gnus-sticky-article-mode)
- (if (not arg)
- (gnus-kill-buffer buf)
- (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
- (gnus-kill-buffer buf)))))))
+ (and (derived-mode-p 'gnus-sticky-article-mode)
+ (or (not arg)
+ (yes-or-no-p (format "Kill buffer %s? " buf)))
+ (gnus-kill-buffer buf)))))
;;;
;;; Gnus MIME viewing functions
@@ -6978,9 +6977,7 @@ gnus-request-article-this-buffer
;; doesn't belong in this newsgroup (possibly), so we find its
;; message-id and request it by id instead of number.
(when (and (numberp article)
- gnus-summary-buffer
- (get-buffer gnus-summary-buffer)
- (gnus-buffer-exists-p gnus-summary-buffer))
+ (gnus-buffer-live-p gnus-summary-buffer))
(with-current-buffer gnus-summary-buffer
(let ((header (gnus-summary-article-header article)))
(when (< article 0)
@@ -7014,11 +7011,9 @@ gnus-request-article-this-buffer
(cond
;; Refuse to select canceled articles.
((and (numberp article)
- gnus-summary-buffer
- (get-buffer gnus-summary-buffer)
- (gnus-buffer-exists-p gnus-summary-buffer)
- (eq (cdr (with-current-buffer gnus-summary-buffer
- (assq article gnus-newsgroup-reads)))
+ (gnus-buffer-live-p gnus-summary-buffer)
+ (eq (with-current-buffer gnus-summary-buffer
+ (cdr (assq article gnus-newsgroup-reads)))
gnus-canceled-mark))
nil)
;; We first check `gnus-original-article-buffer'.
diff --git a/lisp/gnus/gnus-bcklg.el b/lisp/gnus/gnus-bcklg.el
index c5a0e3ec4f..f478c39f37 100644
--- a/lisp/gnus/gnus-bcklg.el
+++ b/lisp/gnus/gnus-bcklg.el
@@ -46,8 +46,7 @@ gnus-backlog-buffer
(defun gnus-backlog-shutdown ()
"Clear all backlog variables and buffers."
(interactive)
- (when (get-buffer gnus-backlog-buffer)
- (gnus-kill-buffer gnus-backlog-buffer))
+ (gnus-kill-buffer gnus-backlog-buffer)
(setq gnus-backlog-articles nil))
(defun gnus-backlog-enter-article (group number buffer)
diff --git a/lisp/gnus/gnus-cus.el b/lisp/gnus/gnus-cus.el
index d56066e616..0938d6b6ed 100644
--- a/lisp/gnus/gnus-cus.el
+++ b/lisp/gnus/gnus-cus.el
@@ -369,7 +369,7 @@ gnus-group-customize
(unless (or topic (setq info (gnus-get-info group)))
(error "Killed group; can't be edited"))
;; Ready.
- (gnus-kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
+ (gnus-kill-buffer "*Gnus Customize*")
(switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
(gnus-custom-mode)
(make-local-variable 'gnus-custom-group)
@@ -1021,9 +1021,7 @@ gnus-agent-customize-category
(cons 'agent-low-score gnus-agent-low-score)
(cons 'agent-high-score gnus-agent-high-score))))
- (let ((old (get-buffer "*Gnus Agent Category Customize*")))
- (when old
- (gnus-kill-buffer old)))
+ (gnus-kill-buffer "*Gnus Agent Category Customize*")
(switch-to-buffer (gnus-get-buffer-create
"*Gnus Agent Category Customize*"))
@@ -1051,7 +1049,7 @@ gnus-agent-customize-category
(when (get-buffer gnus-category-buffer)
(switch-to-buffer (get-buffer gnus-category-buffer))
(gnus-category-list)))
- "Done")
+ "Done")
(widget-insert
"\n Note: Empty fields default to the customizable global\
variables.\n\n")
diff --git a/lisp/gnus/gnus-draft.el b/lisp/gnus/gnus-draft.el
index ad1aa62a34..0616dc8fd5 100644
--- a/lisp/gnus/gnus-draft.el
+++ b/lisp/gnus/gnus-draft.el
@@ -94,14 +94,13 @@ gnus-draft-edit-message
(save-restriction
(message-narrow-to-headers)
(message-remove-header "date")))
- (let ((message-draft-headers
- (delq 'Date (copy-sequence message-draft-headers))))
+ (let ((message-draft-headers (remq 'Date message-draft-headers)))
(save-buffer))
(let ((gnus-verbose-backends nil))
(gnus-request-expire-articles (list article) group t))
(push
`((lambda ()
- (when (gnus-buffer-exists-p ,gnus-summary-buffer)
+ (when (gnus-buffer-live-p ,gnus-summary-buffer)
(save-excursion
(set-buffer ,gnus-summary-buffer)
(gnus-cache-possibly-remove-article ,article nil nil nil t)))))
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 4a14de33b0..f49ed16443 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -1743,8 +1743,7 @@ gnus-group-set-mode-line
gnus-tmp-header ;Dummy binding for user-defined formats
;; Get the resulting string.
(modified
- (and gnus-dribble-buffer
- (buffer-name gnus-dribble-buffer)
+ (and (buffer-live-p gnus-dribble-buffer)
(buffer-modified-p gnus-dribble-buffer)
(with-current-buffer gnus-dribble-buffer
(not (zerop (buffer-size))))))
@@ -4362,15 +4361,13 @@ gnus-group-exit
(defun gnus--abort-on-unsaved-message-buffers ()
(dolist (buffer (gnus-buffers))
- (when (gnus-buffer-exists-p buffer)
- (with-current-buffer buffer
- (when (and (derived-mode-p 'message-mode)
- (buffer-modified-p)
- (not (y-or-n-p
- (format "Message buffer %s unsaved, continue exit? "
- (buffer-name)))))
- (error "Gnus exit aborted due to unsaved %s buffer"
- (buffer-name)))))))
+ (with-current-buffer buffer
+ (when (and (derived-mode-p 'message-mode)
+ (buffer-modified-p)
+ (not (y-or-n-p
+ (format "Message buffer %s unsaved, continue exit? "
+ buffer))))
+ (error "Gnus exit aborted due to unsaved buffer %s" buffer)))))
(defun gnus-group-quit ()
"Quit reading news without updating .newsrc.eld or .newsrc.
@@ -4754,8 +4751,7 @@ gnus-group-compact-group
;; Invalidate the "original article" buffer which might be out of date.
;; #### NOTE: Yes, this might be a bit rude, but since compaction
;; #### will not happen very often, I think this is acceptable.
- (let ((original (get-buffer gnus-original-article-buffer)))
- (and original (gnus-kill-buffer original)))
+ (gnus-kill-buffer gnus-original-article-buffer)
;; Update the group line to reflect new information (art number etc).
(gnus-group-update-group-line))))
diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index b7a97f19d0..0ae7fe2efc 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -607,7 +607,7 @@ gnus-inews-add-send-actions
(message-add-action
`(progn
(setq gnus-current-window-configuration ',winconf-name)
- (when (gnus-buffer-exists-p ,buffer)
+ (when (gnus-buffer-live-p ,buffer)
(set-window-configuration ,winconf)))
'exit 'postpone 'kill)
(let ((to-be-marked (cond
@@ -617,7 +617,7 @@ gnus-inews-add-send-actions
(article (if (listp article) article (list article)))
(t nil))))
(message-add-action
- `(when (gnus-buffer-exists-p ,buffer)
+ `(when (gnus-buffer-live-p ,buffer)
(with-current-buffer ,buffer
,(when to-be-marked
(if (eq config 'forward)
@@ -902,7 +902,7 @@ gnus-summary-supersede-article
(message-supersede)
(push
`((lambda ()
- (when (gnus-buffer-exists-p ,gnus-summary-buffer)
+ (when (gnus-buffer-live-p ,gnus-summary-buffer)
(with-current-buffer ,gnus-summary-buffer
(gnus-cache-possibly-remove-article ,article nil nil nil t)
(gnus-summary-mark-as-read ,article gnus-canceled-mark)))))
@@ -922,8 +922,7 @@ gnus-copy-article-buffer
(mm-enable-multibyte))
(let ((article-buffer (or article-buffer gnus-article-buffer))
end beg)
- (if (not (and (get-buffer article-buffer)
- (gnus-buffer-exists-p article-buffer)))
+ (if (not (gnus-buffer-live-p article-buffer))
(error "Can't find any article buffer")
(with-current-buffer article-buffer
(let ((gnus-newsgroup-charset (or gnus-article-charset
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 476c36023e..72fcc64155 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -1098,7 +1098,7 @@ gnus-score-edit-current-scores
(if (not gnus-current-score-file)
(error "No current score file")
(let ((winconf (current-window-configuration)))
- (when (buffer-name gnus-summary-buffer)
+ (when (buffer-live-p gnus-summary-buffer)
(gnus-score-save))
(gnus-make-directory (file-name-directory file))
(setq gnus-score-edit-buffer (find-file-noselect file))
@@ -1126,7 +1126,7 @@ gnus-score-edit-file
(interactive
(list (read-file-name "Edit score file: " gnus-kill-files-directory)))
(gnus-make-directory (file-name-directory file))
- (when (buffer-name gnus-summary-buffer)
+ (when (buffer-live-p gnus-summary-buffer)
(gnus-score-save))
(let ((winconf (current-window-configuration)))
(setq gnus-score-edit-buffer (find-file-noselect file))
diff --git a/lisp/gnus/gnus-spec.el b/lisp/gnus/gnus-spec.el
index b236f0a401..47d722c914 100644
--- a/lisp/gnus/gnus-spec.el
+++ b/lisp/gnus/gnus-spec.el
@@ -150,7 +150,7 @@ gnus-update-format-specifications
(let ((buffer (intern (format "gnus-%s-buffer" type))))
(when (and (boundp buffer)
(setq val (symbol-value buffer))
- (gnus-buffer-exists-p val))
+ (gnus-buffer-live-p val))
(set-buffer val))
(setq new-format (symbol-value
(intern (format "gnus-%s-line-format" type)))))
diff --git a/lisp/gnus/gnus-srvr.el b/lisp/gnus/gnus-srvr.el
index 76a0f7d0fd..972ff28e63 100644
--- a/lisp/gnus/gnus-srvr.el
+++ b/lisp/gnus/gnus-srvr.el
@@ -1086,8 +1086,7 @@ gnus-server-compact-server
;; Invalidate the original article buffer which might be out of date.
;; #### NOTE: Yes, this might be a bit rude, but since compaction
;; #### will not happen very often, I think this is acceptable.
- (let ((original (get-buffer gnus-original-article-buffer)))
- (and original (gnus-kill-buffer original))))))
+ (gnus-kill-buffer gnus-original-article-buffer))))
(defun gnus-server-toggle-cloud-server ()
"Toggle whether the server under point is replicated in the Emacs Cloud."
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index ef07dcd23c..85aefe0f5f 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -720,11 +720,10 @@ gnus-clear-system
;; Kill Gnus buffers.
(do-auto-save t)
(dolist (buffer (gnus-buffers))
- (when (gnus-buffer-exists-p buffer)
- (with-current-buffer buffer
- (set-buffer-modified-p nil)
- (when (local-variable-p 'kill-buffer-hook)
- (setq kill-buffer-hook nil))))
+ (with-current-buffer buffer
+ (set-buffer-modified-p nil)
+ (when (local-variable-p 'kill-buffer-hook)
+ (setq kill-buffer-hook nil)))
(gnus-kill-buffer buffer))
;; Remove Gnus frames.
(gnus-kill-gnus-frames))
@@ -842,8 +841,7 @@ gnus-dribble-enter
"Enter STRING into the dribble buffer.
If REGEXP is given, lines that match it will be deleted."
(when (and (not gnus-dribble-ignore)
- gnus-dribble-buffer
- (buffer-name gnus-dribble-buffer))
+ (buffer-live-p gnus-dribble-buffer))
(let ((obuf (current-buffer)))
(set-buffer gnus-dribble-buffer)
(when regexp
@@ -935,14 +933,13 @@ gnus-dribble-delete-file
(set-buffer-modified-p nil)))))
(defun gnus-dribble-save ()
- (when (and gnus-dribble-buffer
- (buffer-name gnus-dribble-buffer))
+ (when (buffer-live-p gnus-dribble-buffer)
(with-current-buffer gnus-dribble-buffer
(when (> (buffer-size) 0)
(save-buffer)))))
(defun gnus-dribble-clear ()
- (when (gnus-buffer-exists-p gnus-dribble-buffer)
+ (when (gnus-buffer-live-p gnus-dribble-buffer)
(with-current-buffer gnus-dribble-buffer
(erase-buffer)
(set-buffer-modified-p nil)
@@ -2726,8 +2723,7 @@ gnus-save-newsrc-file
(save-excursion
(if (and (or gnus-use-dribble-file gnus-slave)
(not force)
- (or (not gnus-dribble-buffer)
- (not (buffer-name gnus-dribble-buffer))
+ (or (not (buffer-live-p gnus-dribble-buffer))
(zerop (with-current-buffer gnus-dribble-buffer
(buffer-size)))))
(gnus-message 4 "(No changes need to be saved)")
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 31958ff7b0..5d5d2ec464 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -3519,8 +3519,7 @@ gnus-summary-setup-buffer
(dead-name (concat "*Dead Summary "
(gnus-group-decoded-name group) "*")))
;; If a dead summary buffer exists, we kill it.
- (when (gnus-buffer-live-p dead-name)
- (gnus-kill-buffer dead-name))
+ (gnus-kill-buffer dead-name)
(if (get-buffer buffer)
(progn
(set-buffer buffer)
@@ -3622,7 +3621,7 @@ gnus-make-thread-indent-array
(defun gnus-update-summary-mark-positions ()
"Compute where the summary marks are to go."
(save-excursion
- (when (gnus-buffer-exists-p gnus-summary-buffer)
+ (when (gnus-buffer-live-p gnus-summary-buffer)
(set-buffer gnus-summary-buffer))
(let ((spec gnus-summary-line-format-spec)
pos)
@@ -7326,7 +7325,7 @@ gnus-summary-exit
(gnus-summary-update-info))
(gnus-close-group group)
;; Make sure where we were, and go to next newsgroup.
- (when (buffer-live-p (get-buffer gnus-group-buffer))
+ (when (gnus-buffer-live-p gnus-group-buffer)
(set-buffer gnus-group-buffer))
(unless quit-config
(gnus-group-jump-to-group group))
@@ -7501,8 +7500,7 @@ gnus-dead-summary-mode
(defun gnus-deaden-summary ()
"Make the current summary buffer into a dead summary buffer."
;; Kill any previous dead summary buffer.
- (when (and gnus-dead-summary
- (buffer-name gnus-dead-summary))
+ (when (buffer-live-p gnus-dead-summary)
(with-current-buffer gnus-dead-summary
(when gnus-dead-summary-mode
(kill-buffer (current-buffer)))))
@@ -7520,7 +7518,7 @@ gnus-deaden-summary
(defun gnus-kill-or-deaden-summary (buffer)
"Kill or deaden the summary BUFFER."
(save-excursion
- (when (and (buffer-name buffer)
+ (when (and (buffer-live-p buffer)
(not gnus-single-article-buffer))
(with-current-buffer buffer
(gnus-kill-buffer gnus-article-buffer)
@@ -7529,12 +7527,12 @@ gnus-kill-or-deaden-summary
;; Kill the buffer.
(gnus-kill-summary-on-exit
(when (and gnus-use-trees
- (gnus-buffer-exists-p buffer))
+ (gnus-buffer-live-p buffer))
(with-current-buffer buffer
(gnus-tree-close)))
(gnus-kill-buffer buffer))
;; Deaden the buffer.
- ((gnus-buffer-exists-p buffer)
+ ((gnus-buffer-live-p buffer)
(with-current-buffer buffer
(gnus-deaden-summary))))))
@@ -7605,7 +7603,7 @@ gnus-summary-next-group
(and unreads (not (zerop unreads))))
(gnus-summary-read-group
target-group nil no-article
- (and (buffer-name current-buffer) current-buffer)
+ (and (buffer-live-p current-buffer) current-buffer)
nil backward))
(setq entered t)
(setq current-group target-group
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 6b0f29b0af..3ab7c9a1e9 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -108,12 +108,6 @@ gnus-eval-in-buffer-window
(defsubst gnus-goto-char (point)
(and point (goto-char point)))
-(defmacro gnus-buffer-exists-p (buffer)
- `(let ((buffer ,buffer))
- (when buffer
- (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
- buffer))))
-
(defun gnus-delete-first (elt list)
"Delete by side effect the first occurrence of ELT as a member of LIST."
(if (equal (car list) elt)
@@ -561,8 +555,9 @@ gnus-parent-id
(match-string 1 references))))))
(defsubst gnus-buffer-live-p (buffer)
- "Say whether BUFFER is alive or not."
- (and buffer (buffer-live-p (get-buffer buffer))))
+ "If BUFFER names a live buffer, return its object; else nil."
+ (and buffer (buffer-live-p (setq buffer (get-buffer buffer)))
+ buffer))
(defun gnus-horizontal-recenter ()
"Recenter the current buffer horizontally."
diff --git a/lisp/gnus/gnus-win.el b/lisp/gnus/gnus-win.el
index 40c5b42d45..e6906e99bb 100644
--- a/lisp/gnus/gnus-win.el
+++ b/lisp/gnus/gnus-win.el
@@ -270,7 +270,7 @@ gnus-configure-frame
(error "Invalid buffer type: %s" type))
(let ((buf (gnus-get-buffer-create
(gnus-window-to-buffer-helper buffer))))
- (when (buffer-name buf)
+ (when (buffer-live-p buf)
(cond
((eq buf (window-buffer (selected-window)))
(set-buffer buf))
@@ -430,20 +430,13 @@ gnus-configure-windows
(defun gnus-delete-windows-in-gnusey-frames ()
"Do a `delete-other-windows' in all frames that have Gnus windows."
(let ((buffers (gnus-buffers)))
- (mapcar
- (lambda (frame)
- (unless (eq (cdr (assq 'minibuffer
- (frame-parameters frame)))
- 'only)
- (select-frame frame)
- (let (do-delete)
- (walk-windows
- (lambda (window)
- (when (memq (window-buffer window) buffers)
- (setq do-delete t))))
- (when do-delete
- (delete-other-windows)))))
- (frame-list))))
+ (dolist (frame (frame-list))
+ (unless (eq (frame-parameter frame 'minibuffer) 'only)
+ (select-frame frame)
+ (when (get-window-with-predicate
+ (lambda (window)
+ (memq (window-buffer window) buffers)))
+ (delete-other-windows))))))
(defun gnus-all-windows-visible-p (split)
"Say whether all buffers in SPLIT are currently visible.
@@ -491,11 +484,10 @@ gnus-window-top-edge
(nth 1 (window-edges window)))
(defun gnus-remove-some-windows ()
- (let ((buffers (gnus-buffers))
- buf bufs lowest-buf lowest)
+ (let (bufs lowest-buf lowest)
(save-excursion
;; Remove windows on all known Gnus buffers.
- (while (setq buf (pop buffers))
+ (dolist (buf (gnus-buffers))
(when (get-buffer-window buf)
(push buf bufs)
(pop-to-buffer buf)
@@ -506,8 +498,8 @@ gnus-remove-some-windows
(when lowest-buf
(pop-to-buffer lowest-buf)
(set-buffer nntp-server-buffer))
- (mapcar (lambda (b) (delete-windows-on b t))
- (delq lowest-buf bufs)))))
+ (dolist (b (delq lowest-buf bufs))
+ (delete-windows-on b t)))))
(defun gnus-get-buffer-window (buffer &optional frame)
"Return a window currently displaying BUFFER, or nil if none.
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 7538274e15..1c41e081b7 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -665,26 +665,15 @@ gnus-add-buffer
(defmacro gnus-kill-buffer (buffer)
"Kill BUFFER and remove from the list of Gnus buffers."
`(let ((buf ,buffer))
- (when (gnus-buffer-exists-p buf)
+ (when (gnus-buffer-live-p buf)
(kill-buffer buf)
(gnus-prune-buffers))))
-(defun gnus-prune-buffers ()
- (dolist (buf gnus-buffers)
- (unless (buffer-live-p buf)
- (setq gnus-buffers (delete buf gnus-buffers)))))
-
(defun gnus-buffers ()
"Return a list of live Gnus buffers."
- (while (and gnus-buffers
- (not (buffer-name (car gnus-buffers))))
- (pop gnus-buffers))
- (let ((buffers gnus-buffers))
- (while (cdr buffers)
- (if (buffer-name (cadr buffers))
- (pop buffers)
- (setcdr buffers (cddr buffers)))))
- gnus-buffers)
+ (setq gnus-buffers (seq-filter #'buffer-live-p gnus-buffers)))
+
+(defalias 'gnus-prune-buffers #'gnus-buffers)
;;; Splash screen.
@@ -3638,9 +3627,8 @@ gnus-group-find-parameter
If you call this function inside a loop, consider using the faster
`gnus-group-fast-parameter' instead."
- (with-current-buffer (if (buffer-live-p (get-buffer gnus-group-buffer))
- gnus-group-buffer
- (current-buffer))
+ (with-current-buffer (or (gnus-buffer-live-p gnus-group-buffer)
+ (current-buffer))
(if symbol
(gnus-group-fast-parameter group symbol allow-list)
(nconc
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index 7514e64e7c..48a3d89892 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -723,8 +723,7 @@ mail-source-movemail
(buffer-string) result))
(error "%s" (buffer-string)))
(setq to nil)))))))
- (when (and errors
- (buffer-name errors))
+ (when (buffer-live-p errors)
(kill-buffer errors))
;; Return whether we moved successfully or not.
to)))
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 8b72ef88ab..29a8f25f31 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2034,8 +2034,7 @@ message-add-header
(defmacro message-with-reply-buffer (&rest forms)
"Evaluate FORMS in the reply buffer, if it exists."
- `(when (and (bufferp message-reply-buffer)
- (buffer-name message-reply-buffer))
+ `(when (buffer-live-p message-reply-buffer)
(with-current-buffer message-reply-buffer
,@forms)))
@@ -3229,8 +3228,7 @@ message-widen-reply
"Widen the reply to include maximum recipients."
(interactive)
(let ((follow-to
- (and (bufferp message-reply-buffer)
- (buffer-name message-reply-buffer)
+ (and (buffer-live-p message-reply-buffer)
(with-current-buffer message-reply-buffer
(message-get-reply-headers t)))))
(save-excursion
@@ -4027,7 +4025,7 @@ message-send-and-exit
(let ((buf (current-buffer))
(actions message-exit-actions))
(when (and (message-send arg)
- (buffer-name buf))
+ (buffer-live-p buf))
(message-bury buf)
(if message-kill-buffer-on-exit
(kill-buffer buf))
@@ -4740,7 +4738,7 @@ message-send-mail-with-sendmail
(if (not (zerop (buffer-size)))
(error "Sending...failed to %s"
(buffer-string))))))
- (when (bufferp errbuf)
+ (when (buffer-live-p errbuf)
(kill-buffer errbuf)))))
(defun message-send-mail-with-qmail ()
@@ -6377,8 +6375,7 @@ message-buffer-name
(defun message-pop-to-buffer (name &optional switch-function)
"Pop to buffer NAME, and warn if it already exists and is modified."
(let ((buffer (get-buffer name)))
- (if (and buffer
- (buffer-name buffer))
+ (if (buffer-live-p buffer)
(let ((window (get-buffer-window buffer 0)))
(if window
;; Raise the frame already displaying the message buffer.
@@ -6409,7 +6406,7 @@ message-do-send-housekeeping
(>= (length message-buffer-list) message-max-buffers))
;; Kill the oldest buffer -- unless it has been changed.
(let ((buffer (pop message-buffer-list)))
- (when (and (buffer-name buffer)
+ (when (and (buffer-live-p buffer)
(not (buffer-modified-p buffer)))
(kill-buffer buffer))))
;; Rename the buffer.
@@ -7376,9 +7373,7 @@ message-forward-make-body-plain
(unless (multibyte-string-p contents)
(error "Attempt to insert unibyte string from the buffer \"%s\"\
to the multibyte buffer \"%s\""
- (if (bufferp forward-buffer)
- (buffer-name forward-buffer)
- forward-buffer)
+ forward-buffer
(buffer-name)))
(insert (mm-with-multibyte-buffer
(insert contents)
@@ -7440,9 +7435,7 @@ message-forward-make-body-mml
(unless (multibyte-string-p contents)
(error "Attempt to insert unibyte string from the buffer \"%s\"\
to the multibyte buffer \"%s\""
- (if (bufferp forward-buffer)
- (buffer-name forward-buffer)
- forward-buffer)
+ forward-buffer
(buffer-name)))
(insert (mm-with-multibyte-buffer
(insert contents)
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 5b1859e324..eaddfd2445 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -893,8 +893,7 @@ mm-display-external
(if method
(progn
(when (and (boundp 'gnus-summary-buffer)
- (bufferp gnus-summary-buffer)
- (buffer-name gnus-summary-buffer))
+ (buffer-live-p gnus-summary-buffer))
(when attachment-filename
(with-current-buffer mm
(rename-buffer (format "*mm* %s" attachment-filename) t)))
@@ -1152,9 +1151,8 @@ mm-remove-part
(ignore-errors (delete-file (car object)))
(ignore-errors (delete-directory (file-name-directory
(car object)))))
- ((bufferp object)
- (when (buffer-live-p object)
- (kill-buffer object)))))
+ ((buffer-live-p object)
+ (kill-buffer object))))
(mm-handle-set-undisplayer handle nil))))
(defun mm-display-inline (handle)
diff --git a/lisp/gnus/nnbabyl.el b/lisp/gnus/nnbabyl.el
index 3b31645410..0f4f4303cd 100644
--- a/lisp/gnus/nnbabyl.el
+++ b/lisp/gnus/nnbabyl.el
@@ -145,10 +145,8 @@ nnbabyl-close-server
(deffoo nnbabyl-server-opened (&optional server)
(and (nnoo-current-server-p 'nnbabyl server)
- nnbabyl-mbox-buffer
- (buffer-name nnbabyl-mbox-buffer)
- nntp-server-buffer
- (buffer-name nntp-server-buffer)))
+ (buffer-live-p nnbabyl-mbox-buffer)
+ (buffer-live-p nntp-server-buffer)))
(deffoo nnbabyl-request-article (article &optional newsgroup server buffer)
(nnbabyl-possibly-change-newsgroup newsgroup server)
@@ -452,8 +450,7 @@ nnbabyl-possibly-change-newsgroup
(when (and server
(not (nnbabyl-server-opened server)))
(nnbabyl-open-server server))
- (when (or (not nnbabyl-mbox-buffer)
- (not (buffer-name nnbabyl-mbox-buffer)))
+ (unless (buffer-live-p nnbabyl-mbox-buffer)
(save-excursion (nnbabyl-read-mbox)))
(unless nnbabyl-group-alist
(nnmail-activate 'nnbabyl))
@@ -556,8 +553,7 @@ nnbabyl-read-mbox
(nnmail-activate 'nnbabyl)
(nnbabyl-create-mbox)
- (unless (and nnbabyl-mbox-buffer
- (buffer-name nnbabyl-mbox-buffer)
+ (unless (and (buffer-live-p nnbabyl-mbox-buffer)
(with-current-buffer nnbabyl-mbox-buffer
(= (buffer-size) (nnheader-file-size nnbabyl-mbox-file))))
;; This buffer has changed since we read it last. Possibly.
@@ -627,8 +623,7 @@ nnbabyl-check-mbox
(let ((idents (gnus-make-hashtable 1000))
id)
(save-excursion
- (when (or (not nnbabyl-mbox-buffer)
- (not (buffer-name nnbabyl-mbox-buffer)))
+ (unless (buffer-live-p nnbabyl-mbox-buffer)
(nnbabyl-read-mbox))
(set-buffer nnbabyl-mbox-buffer)
(goto-char (point-min))
diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el
index aca29fea57..a2b1efd8cc 100644
--- a/lisp/gnus/nndiary.el
+++ b/lisp/gnus/nndiary.el
@@ -1016,7 +1016,7 @@ nndiary-open-nov
(defun nndiary-save-nov ()
(save-excursion
(while nndiary-nov-buffer-alist
- (when (buffer-name (cdar nndiary-nov-buffer-alist))
+ (when (buffer-live-p (cdar nndiary-nov-buffer-alist))
(set-buffer (cdar nndiary-nov-buffer-alist))
(when (buffer-modified-p)
(nnmail-write-region 1 (point-max) nndiary-nov-buffer-file-name
diff --git a/lisp/gnus/nndoc.el b/lisp/gnus/nndoc.el
index 532ba11fa0..9c8cab597a 100644
--- a/lisp/gnus/nndoc.el
+++ b/lisp/gnus/nndoc.el
@@ -309,8 +309,7 @@ nndoc-request-type
(deffoo nndoc-close-group (group &optional server)
(nndoc-possibly-change-buffer group server)
- (and nndoc-current-buffer
- (buffer-name nndoc-current-buffer)
+ (and (buffer-live-p nndoc-current-buffer)
(kill-buffer nndoc-current-buffer))
(setq nndoc-group-alist (delq (assoc group nndoc-group-alist)
nndoc-group-alist))
@@ -335,8 +334,7 @@ nndoc-possibly-change-buffer
(let (buf)
(cond
;; The current buffer is this group's buffer.
- ((and nndoc-current-buffer
- (buffer-name nndoc-current-buffer)
+ ((and (buffer-live-p nndoc-current-buffer)
(eq nndoc-current-buffer
(setq buf (cdr (assoc group nndoc-group-alist))))))
;; We change buffers by taking an old from the group alist.
@@ -344,8 +342,7 @@ nndoc-possibly-change-buffer
(buf
(setq nndoc-current-buffer buf))
;; It's a totally new group.
- ((or (and (bufferp nndoc-address)
- (buffer-name nndoc-address))
+ ((or (buffer-live-p nndoc-address)
(and (stringp nndoc-address)
(file-exists-p nndoc-address)
(not (file-directory-p nndoc-address))))
diff --git a/lisp/gnus/nnfolder.el b/lisp/gnus/nnfolder.el
index 41963f32ef..6334b1c998 100644
--- a/lisp/gnus/nnfolder.el
+++ b/lisp/gnus/nnfolder.el
@@ -328,8 +328,7 @@ nnfolder-close-group
(delq inf nnfolder-buffer-alist))
(setq nnfolder-current-buffer (cadr inf)
nnfolder-current-group (car inf))))
- (when (and nnfolder-current-buffer
- (buffer-name nnfolder-current-buffer))
+ (when (buffer-live-p nnfolder-current-buffer)
(with-current-buffer nnfolder-current-buffer
;; If the buffer was modified, write the file out now.
(nnfolder-save-buffer)
@@ -1110,7 +1109,7 @@ nnfolder-open-nov
(defun nnfolder-save-nov ()
(save-excursion
(while nnfolder-nov-buffer-alist
- (when (buffer-name (cdar nnfolder-nov-buffer-alist))
+ (when (buffer-live-p (cdar nnfolder-nov-buffer-alist))
(set-buffer (cdar nnfolder-nov-buffer-alist))
(when (buffer-modified-p)
(gnus-make-directory (file-name-directory
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index ac1d28644f..9e52abc1ca 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -346,7 +346,7 @@ nnimap-make-process-buffer
(with-current-buffer
(generate-new-buffer (format " *nnimap %s %s %s*"
nnimap-address nnimap-server-port
- (gnus-buffer-exists-p buffer)))
+ buffer))
(mm-disable-multibyte)
(buffer-disable-undo)
(gnus-add-buffer)
@@ -382,7 +382,7 @@ nnimap-credentials
(defun nnimap-keepalive ()
(let ((now (current-time)))
(dolist (buffer nnimap-process-buffers)
- (when (buffer-name buffer)
+ (when (buffer-live-p buffer)
(with-current-buffer buffer
(when (and nnimap-object
(nnimap-last-command-time nnimap-object)
@@ -1899,7 +1899,7 @@ nnimap-find-connection
"Find the connection delivering to BUFFER."
(let ((entry (assoc buffer nnimap-connection-alist)))
(when entry
- (if (and (buffer-name (cadr entry))
+ (if (and (buffer-live-p (cadr entry))
(get-buffer-process (cadr entry))
(memq (process-status (get-buffer-process (cadr entry)))
'(open run)))
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index 37f6e75b90..ed3d571270 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -1561,8 +1561,7 @@ nnmail-cache-buffer
(defun nnmail-cache-open ()
(if (or (not nnmail-treat-duplicates)
- (and nnmail-cache-buffer
- (buffer-name nnmail-cache-buffer)))
+ (buffer-live-p nnmail-cache-buffer))
() ; The buffer is open.
(with-current-buffer
(setq nnmail-cache-buffer
@@ -1574,9 +1573,8 @@ nnmail-cache-open
(current-buffer))))
(defun nnmail-cache-close ()
- (when (and nnmail-cache-buffer
- nnmail-treat-duplicates
- (buffer-name nnmail-cache-buffer)
+ (when (and nnmail-treat-duplicates
+ (buffer-live-p nnmail-cache-buffer)
(buffer-modified-p nnmail-cache-buffer))
(with-current-buffer nnmail-cache-buffer
;; Weed out the excess number of Message-IDs.
diff --git a/lisp/gnus/nnmbox.el b/lisp/gnus/nnmbox.el
index bba41336dd..110f39a867 100644
--- a/lisp/gnus/nnmbox.el
+++ b/lisp/gnus/nnmbox.el
@@ -131,18 +131,15 @@ nnmbox-open-server
t)))
(deffoo nnmbox-close-server (&optional server)
- (when (and nnmbox-mbox-buffer
- (buffer-name nnmbox-mbox-buffer))
+ (when (buffer-live-p nnmbox-mbox-buffer)
(kill-buffer nnmbox-mbox-buffer))
(nnoo-close-server 'nnmbox server)
t)
(deffoo nnmbox-server-opened (&optional server)
(and (nnoo-current-server-p 'nnmbox server)
- nnmbox-mbox-buffer
- (buffer-name nnmbox-mbox-buffer)
- nntp-server-buffer
- (buffer-name nntp-server-buffer)))
+ (buffer-live-p nnmbox-mbox-buffer)
+ (buffer-live-p nntp-server-buffer)))
(deffoo nnmbox-request-article (article &optional newsgroup server buffer)
(nnmbox-possibly-change-newsgroup newsgroup server)
@@ -463,8 +460,7 @@ nnmbox-possibly-change-newsgroup
(when (and server
(not (nnmbox-server-opened server)))
(nnmbox-open-server server))
- (when (or (not nnmbox-mbox-buffer)
- (not (buffer-name nnmbox-mbox-buffer)))
+ (unless (buffer-live-p nnmbox-mbox-buffer)
(nnmbox-read-mbox))
(when (not nnmbox-group-alist)
(nnmail-activate 'nnmbox))
@@ -622,8 +618,7 @@ nnmbox-create-mbox
(defun nnmbox-read-mbox ()
(nnmail-activate 'nnmbox)
(nnmbox-create-mbox)
- (if (and nnmbox-mbox-buffer
- (buffer-name nnmbox-mbox-buffer)
+ (if (and (buffer-live-p nnmbox-mbox-buffer)
(with-current-buffer nnmbox-mbox-buffer
(= (buffer-size) (nnheader-file-size nnmbox-mbox-file))))
()
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el
index 1d9d166dba..5173056104 100644
--- a/lisp/gnus/nnml.el
+++ b/lisp/gnus/nnml.el
@@ -772,7 +772,7 @@ nnml-incremental-nov-buffer-alist
(defun nnml-save-incremental-nov ()
(save-excursion
(while nnml-incremental-nov-buffer-alist
- (when (buffer-name (cdar nnml-incremental-nov-buffer-alist))
+ (when (buffer-live-p (cdar nnml-incremental-nov-buffer-alist))
(set-buffer (cdar nnml-incremental-nov-buffer-alist))
(when (buffer-modified-p)
(nnmail-write-region (point-min) (point-max)
@@ -838,9 +838,7 @@ nnml-get-nov-buffer
buffer))
(defun nnml-open-nov (group)
- (or (let ((buffer (cdr (assoc group nnml-nov-buffer-alist))))
- (and (buffer-name buffer)
- buffer))
+ (or (gnus-buffer-live-p (cdr (assoc group nnml-nov-buffer-alist)))
(let ((buffer (nnml-get-nov-buffer group)))
(push (cons group buffer) nnml-nov-buffer-alist)
buffer)))
@@ -848,7 +846,7 @@ nnml-open-nov
(defun nnml-save-nov ()
(save-excursion
(while nnml-nov-buffer-alist
- (when (buffer-name (cdar nnml-nov-buffer-alist))
+ (when (buffer-live-p (cdar nnml-nov-buffer-alist))
(set-buffer (cdar nnml-nov-buffer-alist))
(when (buffer-modified-p)
(nnmail-write-region (point-min) (point-max)
diff --git a/lisp/gnus/nnoo.el b/lisp/gnus/nnoo.el
index 0cf2362b36..c65668a719 100644
--- a/lisp/gnus/nnoo.el
+++ b/lisp/gnus/nnoo.el
@@ -269,8 +269,7 @@ nnoo-status-message
(defun nnoo-server-opened (backend server)
(and (nnoo-current-server-p backend server)
- nntp-server-buffer
- (buffer-name nntp-server-buffer)))
+ (buffer-live-p nntp-server-buffer)))
(defmacro nnoo-define-basics (backend)
"Define `close-server', `server-opened' and `status-message'."
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el
index e2fa1d85a3..880a4f1111 100644
--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -400,7 +400,7 @@ nntp-wait-for
(erase-buffer)))))
(defun nntp-kill-buffer (buffer)
- (when (buffer-name buffer)
+ (when (buffer-live-p buffer)
(let ((process (get-buffer-process buffer)))
(when process
(delete-process process)))
@@ -1228,16 +1228,15 @@ nntp-make-process-buffer
(with-current-buffer
(generate-new-buffer
(format " *server %s %s %s*"
- nntp-address nntp-port-number
- (gnus-buffer-exists-p buffer)))
+ nntp-address nntp-port-number buffer))
(mm-disable-multibyte)
- (set (make-local-variable 'after-change-functions) nil)
- (set (make-local-variable 'nntp-process-wait-for) nil)
- (set (make-local-variable 'nntp-process-callback) nil)
- (set (make-local-variable 'nntp-process-to-buffer) nil)
- (set (make-local-variable 'nntp-process-start-point) nil)
- (set (make-local-variable 'nntp-process-decode) nil)
- (set (make-local-variable 'nntp-retrieval-in-progress) nil)
+ (setq-local after-change-functions nil)
+ (setq-local nntp-process-wait-for nil)
+ (setq-local nntp-process-callback nil)
+ (setq-local nntp-process-to-buffer nil)
+ (setq-local nntp-process-start-point nil)
+ (setq-local nntp-process-decode nil)
+ (setq-local nntp-retrieval-in-progress nil)
(current-buffer)))
(defun nntp-open-connection (buffer)
@@ -1290,7 +1289,7 @@ nntp-open-connection
(setq process nil))
(unless process
(nntp-kill-buffer pbuffer))
- (when (and (buffer-name pbuffer)
+ (when (and (buffer-live-p pbuffer)
process)
(when (eq (process-type process) 'network)
;; Use TCP-keepalive so that connections that pass through a NAT router
@@ -1358,17 +1357,17 @@ nntp-after-change-function
(defun nntp-async-trigger (process)
(with-current-buffer (process-buffer process)
(when nntp-process-callback
- ;; do we have an error message?
+ ;; Do we have an error message?
(goto-char nntp-process-start-point)
(if (memq (following-char) '(?4 ?5))
- ;; wants credentials?
- (if (looking-at "480")
+ ;; Wants credentials?
+ (if (looking-at-p "480")
(nntp-handle-authinfo process)
- ;; report error message.
+ ;; Report error message.
(nntp-snarf-error-message)
(nntp-do-callback nil))
- ;; got what we expect?
+ ;; Got what we expect?
(goto-char (point-max))
(when (re-search-backward
nntp-process-wait-for nntp-process-start-point t)
@@ -1376,8 +1375,8 @@ nntp-async-trigger
(with-current-buffer nntp-server-buffer
(setq nntp-process-response response)))
(nntp-async-stop process)
- ;; convert it.
- (when (gnus-buffer-exists-p nntp-process-to-buffer)
+ ;; Convert it.
+ (when (gnus-buffer-live-p nntp-process-to-buffer)
(let ((buf (current-buffer))
(start nntp-process-start-point)
(decode nntp-process-decode))
@@ -1388,7 +1387,7 @@ nntp-async-trigger
(nnheader-insert-buffer-substring buf start)
(when decode
(nntp-decode-text))))))
- ;; report it.
+ ;; Report it.
(goto-char (point-max))
(nntp-do-callback
(buffer-name (get-buffer nntp-process-to-buffer))))))))
diff --git a/lisp/net/mairix.el b/lisp/net/mairix.el
index 07415667e1..0c699c976c 100644
--- a/lisp/net/mairix.el
+++ b/lisp/net/mairix.el
@@ -266,9 +266,7 @@ mairix-rmail-fetch-field
;;; Gnus
-;; For gnus-buffer-exists-p, although it seems that could be replaced by:
-;; (and buffer (get-buffer buffer))
-(eval-when-compile (require 'gnus-util))
+(eval-when-compile (require 'gnus-util)) ; For `gnus-buffer-live-p'.
(defvar gnus-article-buffer)
(declare-function gnus-group-read-ephemeral-group "gnus-group"
(group method &optional activate quit-config
@@ -296,7 +294,7 @@ mairix-gnus-fetch-field
(unless (and (fboundp 'gnus-alive-p)
(gnus-alive-p))
(error "Gnus is not running"))
- (unless (gnus-buffer-exists-p gnus-article-buffer)
+ (unless (gnus-buffer-live-p gnus-article-buffer)
(error "No article buffer available"))
(with-current-buffer gnus-article-buffer
;; gnus-art requires gnus-sum and message.
--
2.20.1
[-- Attachment #2: Type: text/plain, Size: 422 bytes --]
There seems to be overlap in the implementations and usage of
gnus-buffer-exists-p and gnus-buffer-live-p, as well as of gnus-buffers
and gnus-prune-buffers.
The attached patch removes gnus-buffer-exists-p in favour of a modified
gnus-buffer-live-p, aliases gnus-prune-buffers to a simplified
gnus-buffers, and simplifies several call sites pertaining to buffer
liveness checking and killing. WDYT?
Thanks,
--
Basil
next reply other threads:[~2019-05-20 0:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 0:10 Basil L. Contovounesios [this message]
2019-05-20 10:51 ` [PATCH] Simplify Gnus buffer liveness checking and killing Lars Ingebrigtsen
2019-05-20 11:51 ` Basil L. Contovounesios
2019-05-20 11:58 ` Lars Ingebrigtsen
2019-05-20 12:29 ` Basil L. Contovounesios
2019-05-20 21:43 ` Eric Abrahamsen
2019-05-20 22:19 ` Basil L. Contovounesios
2019-05-20 22:48 ` Eric Abrahamsen
2019-05-30 2:21 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ef4uq92p.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).