* [PATCH 0/2] emacs: Use full profile name in Guix buffer names.
@ 2016-04-02 21:05 Alex Kost
2016-04-02 21:05 ` [PATCH 1/2] emacs: Factorize code for " Alex Kost
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alex Kost @ 2016-04-02 21:05 UTC (permalink / raw)
To: guix-devel
Currently names of buffers with Guix packages may look mysterious.
If you call "M-x guix-installed-user-package", you get:
*Guix Package List: guix-profile*
If you call "M-x guix-installed-system-packages", you get:
*Guix Package List: profile*
It is not obvious what "guix-profile" and "profile" stand for. The
answer is: it is just a last part of profile name:
/var/guix/profiles/per-user/<user>/guix-profile → guix-profile
/var/guix/profiles/system/profile → profile
I think it will be more user-friendly if a default buffer name contains
a full profile name. The result buffer name may be a bit long, but at
least it is clear, WDYT?
These patches do this change. To return to the old style of buffer
names, one can use this setting:
(setq guix-ui-buffer-name-function 'guix-ui-buffer-name-short)
[PATCH 1/2] emacs: Factorize code for buffer names.
[PATCH 2/2] emacs: Use full profile name in Guix buffer names.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] emacs: Factorize code for buffer names.
2016-04-02 21:05 [PATCH 0/2] emacs: Use full profile name in Guix buffer names Alex Kost
@ 2016-04-02 21:05 ` Alex Kost
2016-04-14 17:38 ` Ludovic Courtès
2016-04-02 21:05 ` [PATCH 2/2] emacs: Use full profile name in Guix " Alex Kost
2016-04-14 17:37 ` [PATCH 0/2] " Ludovic Courtès
2 siblings, 1 reply; 6+ messages in thread
From: Alex Kost @ 2016-04-02 21:05 UTC (permalink / raw)
To: guix-devel
* emacs/guix-ui.el (guix-ui-buffer-name-default): Extract the code to
compose buffer name and move to...
* emacs/guix-utils.el (guix-compose-buffer-name): ... here. New procedure.
---
emacs/guix-ui.el | 22 +++-------------------
emacs/guix-utils.el | 28 +++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/emacs/guix-ui.el b/emacs/guix-ui.el
index 9a88efc..47773de 100644
--- a/emacs/guix-ui.el
+++ b/emacs/guix-ui.el
@@ -1,6 +1,6 @@
;;; guix-ui.el --- Common code for Guix package management interface -*- lexical-binding: t -*-
-;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
;; This file is part of GNU Guix.
@@ -117,26 +117,10 @@ The function is called with 2 arguments: BASE-NAME and PROFILE."
"Return BASE-NAME."
base-name)
-;; TODO separate '*...*' logic from the real profile appending. Also add
-;; another function to return '*Guix ...: /full/path/to/profile*' name.
(defun guix-ui-buffer-name-default (base-name profile)
"Return buffer name by appending BASE-NAME and PROFILE's base file name."
- (let ((profile-name (file-name-base (directory-file-name profile)))
- (re (rx string-start
- (group (? "*"))
- (group (*? any))
- (group (? "*"))
- string-end)))
- (or (string-match re base-name)
- (error "Unexpected error in defining guix buffer name"))
- (let ((first* (match-string 1 base-name))
- (name-body (match-string 2 base-name))
- (last* (match-string 3 base-name)))
- ;; Handle the case when buffer name is wrapped by '*'.
- (if (and (string= "*" first*)
- (string= "*" last*))
- (concat "*" name-body ": " profile-name "*")
- (concat base-name ": " profile-name)))))
+ (guix-compose-buffer-name base-name
+ (file-name-base (directory-file-name profile))))
(defun guix-ui-buffer-name (base-name profile)
"Return Guix buffer name based on BASE-NAME and profile.
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index 8c1a5b4..ea9933f 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -1,6 +1,6 @@
;;; guix-utils.el --- General utility functions -*- lexical-binding: t -*-
-;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>
;; This file is part of GNU Guix.
@@ -223,6 +223,32 @@ If NO-MESSAGE? is non-nil, do not display a message about it."
See also `guix-copy-as-kill'."
(guix-copy-as-kill (guix-command-string args) no-message?))
+(defun guix-compose-buffer-name (base-name postfix)
+ "Return buffer name by appending BASE-NAME and POSTFIX.
+
+In a simple case the result is:
+
+ BASE-NAME: POSTFIX
+
+If BASE-NAME is wrapped by '*', then the result is:
+
+ *BASE-NAME: POSTFIX*"
+ (let ((re (rx string-start
+ (group (? "*"))
+ (group (*? any))
+ (group (? "*"))
+ string-end)))
+ (or (string-match re base-name)
+ (error "Unexpected error in defining buffer name"))
+ (let ((first* (match-string 1 base-name))
+ (name-body (match-string 2 base-name))
+ (last* (match-string 3 base-name)))
+ ;; Handle the case when buffer name is wrapped by '*'.
+ (if (and (string= "*" first*)
+ (string= "*" last*))
+ (concat "*" name-body ": " postfix "*")
+ (concat base-name ": " postfix)))))
+
(defun guix-completing-read (prompt table &optional predicate
require-match initial-input
hist def inherit-input-method)
--
2.7.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] emacs: Use full profile name in Guix buffer names.
2016-04-02 21:05 [PATCH 0/2] emacs: Use full profile name in Guix buffer names Alex Kost
2016-04-02 21:05 ` [PATCH 1/2] emacs: Factorize code for " Alex Kost
@ 2016-04-02 21:05 ` Alex Kost
2016-04-14 17:38 ` Ludovic Courtès
2016-04-14 17:37 ` [PATCH 0/2] " Ludovic Courtès
2 siblings, 1 reply; 6+ messages in thread
From: Alex Kost @ 2016-04-02 21:05 UTC (permalink / raw)
To: guix-devel
* emacs/guix-ui.el (guix-ui-buffer-name-default): Rename to...
(guix-ui-buffer-name-short): ... this.
(guix-ui-buffer-name-full): New procedure.
(guix-ui-buffer-name-function): Set it as default.
---
emacs/guix-ui.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/emacs/guix-ui.el b/emacs/guix-ui.el
index 47773de..1b69631 100644
--- a/emacs/guix-ui.el
+++ b/emacs/guix-ui.el
@@ -105,10 +105,11 @@ If `all', update all Guix buffers (not recommended)."
:group 'guix-ui)
(defcustom guix-ui-buffer-name-function
- #'guix-ui-buffer-name-default
+ #'guix-ui-buffer-name-full
"Function used to define a name of a Guix buffer.
The function is called with 2 arguments: BASE-NAME and PROFILE."
- :type '(choice (function-item guix-ui-buffer-name-default)
+ :type '(choice (function-item guix-ui-buffer-name-full)
+ (function-item guix-ui-buffer-name-short)
(function-item guix-ui-buffer-name-simple)
(function :tag "Other function"))
:group 'guix-ui)
@@ -117,11 +118,15 @@ The function is called with 2 arguments: BASE-NAME and PROFILE."
"Return BASE-NAME."
base-name)
-(defun guix-ui-buffer-name-default (base-name profile)
+(defun guix-ui-buffer-name-short (base-name profile)
"Return buffer name by appending BASE-NAME and PROFILE's base file name."
(guix-compose-buffer-name base-name
(file-name-base (directory-file-name profile))))
+(defun guix-ui-buffer-name-full (base-name profile)
+ "Return buffer name by appending BASE-NAME and PROFILE's full name."
+ (guix-compose-buffer-name base-name profile))
+
(defun guix-ui-buffer-name (base-name profile)
"Return Guix buffer name based on BASE-NAME and profile.
See `guix-ui-buffer-name-function' for details."
--
2.7.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] emacs: Use full profile name in Guix buffer names.
2016-04-02 21:05 [PATCH 0/2] emacs: Use full profile name in Guix buffer names Alex Kost
2016-04-02 21:05 ` [PATCH 1/2] emacs: Factorize code for " Alex Kost
2016-04-02 21:05 ` [PATCH 2/2] emacs: Use full profile name in Guix " Alex Kost
@ 2016-04-14 17:37 ` Ludovic Courtès
2 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-04-14 17:37 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> Currently names of buffers with Guix packages may look mysterious.
> If you call "M-x guix-installed-user-package", you get:
>
> *Guix Package List: guix-profile*
>
> If you call "M-x guix-installed-system-packages", you get:
>
> *Guix Package List: profile*
>
> It is not obvious what "guix-profile" and "profile" stand for. The
> answer is: it is just a last part of profile name:
>
> /var/guix/profiles/per-user/<user>/guix-profile → guix-profile
> /var/guix/profiles/system/profile → profile
>
> I think it will be more user-friendly if a default buffer name contains
> a full profile name. The result buffer name may be a bit long, but at
> least it is clear, WDYT?
It’s going to be a bit long, indeed, but that sounds reasonable.
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] emacs: Factorize code for buffer names.
2016-04-02 21:05 ` [PATCH 1/2] emacs: Factorize code for " Alex Kost
@ 2016-04-14 17:38 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-04-14 17:38 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> * emacs/guix-ui.el (guix-ui-buffer-name-default): Extract the code to
> compose buffer name and move to...
> * emacs/guix-utils.el (guix-compose-buffer-name): ... here. New procedure.
OK.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] emacs: Use full profile name in Guix buffer names.
2016-04-02 21:05 ` [PATCH 2/2] emacs: Use full profile name in Guix " Alex Kost
@ 2016-04-14 17:38 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-04-14 17:38 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> scribes:
> * emacs/guix-ui.el (guix-ui-buffer-name-default): Rename to...
> (guix-ui-buffer-name-short): ... this.
> (guix-ui-buffer-name-full): New procedure.
> (guix-ui-buffer-name-function): Set it as default.
OK, thanks!
Ludo'.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-04-14 17:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-02 21:05 [PATCH 0/2] emacs: Use full profile name in Guix buffer names Alex Kost
2016-04-02 21:05 ` [PATCH 1/2] emacs: Factorize code for " Alex Kost
2016-04-14 17:38 ` Ludovic Courtès
2016-04-02 21:05 ` [PATCH 2/2] emacs: Use full profile name in Guix " Alex Kost
2016-04-14 17:38 ` Ludovic Courtès
2016-04-14 17:37 ` [PATCH 0/2] " Ludovic Courtès
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.