From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 3/5] emacs: Improve buffer procedures.
Date: Tue, 21 Oct 2014 22:12:20 +0400 [thread overview]
Message-ID: <87ppdl47i3.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 24 bytes --]
Some internal changes.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-emacs-Improve-buffer-procedures.patch --]
[-- Type: text/x-diff, Size: 3477 bytes --]
From 0973be332e0752497c831ad27d44fe6594cb1da8 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Mon, 20 Oct 2014 21:43:33 +0400
Subject: [PATCH 3/5] emacs: Improve buffer procedures.
* emacs/guix-base.el (guix-list-or-info-buffer-p): Delete. Replace with...
(guix-buffer-p): ... this. New procedure.
(guix-buffers): Use it. Add 'modes' argument.
(guix-update-buffer): New procedure.
(guix-update-buffers-maybe): Rename to ...
(guix-update-buffers-maybe-after-operation): this. Use
'guix-update-buffer'.
---
emacs/guix-base.el | 51 ++++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 5b98579..c0a06c7 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -283,33 +283,42 @@ See `guix-buffer-name-function' for details."
'((display-buffer-reuse-window
display-buffer-same-window))))
-(defun guix-list-or-info-buffer-p (&optional buffer)
- "Return non-nil if BUFFER is a Guix 'list' or 'info' buffer.
-If BUFFER is nil, check current buffer."
+(defun guix-buffer-p (&optional buffer modes)
+ "Return non-nil if BUFFER mode is derived from any of the MODES.
+If BUFFER is nil, check current buffer.
+If MODES is nil, use `guix-list-mode' and `guix-info-mode'."
(with-current-buffer (or buffer (current-buffer))
- (derived-mode-p 'guix-list-mode 'guix-info-mode)))
-
-(defun guix-buffers ()
- "Return list of all Guix 'list' and 'info' buffers."
- (cl-remove-if-not #'guix-list-or-info-buffer-p
+ (apply #'derived-mode-p
+ (or modes
+ '(guix-list-mode guix-info-mode)))))
+
+(defun guix-buffers (&optional modes)
+ "Return list of all buffers with major modes derived from MODES.
+If MODES is nil, return list of all Guix 'list' and 'info' buffers."
+ (cl-remove-if-not (lambda (buf)
+ (guix-buffer-p buf modes))
(buffer-list)))
-(defun guix-update-buffers-maybe ()
+(defun guix-update-buffer (buffer)
+ "Update information in a 'list' or 'info' BUFFER."
+ (with-current-buffer buffer
+ (guix-revert-buffer nil t)))
+
+(defun guix-update-buffers-maybe-after-operation ()
"Update buffers after Guix operation if needed.
See `guix-update-after-operation' for details."
- (let ((to-update (and guix-operation-buffer
- (cl-case guix-update-after-operation
- (current (list guix-operation-buffer))
- (all (guix-buffers))))))
+ (let ((to-update
+ (and guix-operation-buffer
+ (cl-case guix-update-after-operation
+ (current (and (buffer-live-p guix-operation-buffer)
+ (guix-buffer-p guix-operation-buffer)
+ (list guix-operation-buffer)))
+ (all (guix-buffers))))))
(setq guix-operation-buffer nil)
- (mapc (lambda (buf)
- (and (buffer-live-p buf)
- (guix-list-or-info-buffer-p buf)
- (with-current-buffer buf
- (guix-revert-buffer nil t))))
- to-update)))
-
-(add-hook 'guix-after-repl-operation-hook 'guix-update-buffers-maybe)
+ (mapc #'guix-update-buffer to-update)))
+
+(add-hook 'guix-after-repl-operation-hook
+ 'guix-update-buffers-maybe-after-operation)
\f
;;; Common definitions for buffer types
--
2.1.2
next reply other threads:[~2014-10-21 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 18:12 Alex Kost [this message]
2014-10-26 18:37 ` [PATCH 3/5] emacs: Improve buffer procedures Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppdl47i3.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.