summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-11-18 11:36:27 +0300
committerAlex Kost <alezost@gmail.com>2016-01-02 17:25:35 +0300
commit0b9cd3206ab9ba4f8fd55139d42cdf5265c4b0e1 (patch)
treec7ca2b7c5a0845f3ae91634efbd3ba89054e463e
parente86a43d47108688d7412796fb03caa47f87279f0 (diff)
downloadpatches-0b9cd3206ab9ba4f8fd55139d42cdf5265c4b0e1.tar
patches-0b9cd3206ab9ba4f8fd55139d42cdf5265c4b0e1.tar.gz
emacs: Rename internal procedures.
* emacs/guix-list.el (guix-list-get-param-title): Rename to... (guix-list-param-title): ... this. (guix-list-get-column-format): Rename to... (guix-list-format): ... this. (guix-list-get-displayed-params): Rename to... (guix-list-displayed-params): ... this. (guix-list-get-sort-key): Rename to... (guix-list-tabulated-sort-key): ... this. (guix-list-make-tabulated-vector): Rename to... (guix-list-tabulated-vector): ... this. (guix-list-get-list-format): Rename to... (guix-list-tabulated-format): ... this. (guix-list-get-tabulated-entries): Rename to... (guix-list-tabulated-entries): ... this. (guix-list-get-tabulated-entry): Rename to... (guix-list-tabulated-entry): ... this. * emacs/guix-info.el (guix-info-get-displayed-params): Rename to... (guix-info-displayed-params): ... this. * emacs/guix-base.el (guix-get-params-for-receiving): Adjust accordingly. (guix-get-name-spec): Rename to... (guix-package-name-specification): ... this. (guix-get-full-name): Merge this and... (guix-entry-to-specification): ... this into... (guix-package-entry->name-specification): ... this. (guix-get-installed-outputs): Rename to... (guix-package-installed-outputs): ... this. (guix-get-package-id-and-output-by-output-id): Rename to... (guix-package-id-and-output-by-output-id): ... this.
-rw-r--r--emacs/guix-base.el35
-rw-r--r--emacs/guix-info.el14
-rw-r--r--emacs/guix-list.el69
3 files changed, 56 insertions, 62 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 43dec3dca3..91b52db188 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -61,35 +61,31 @@ Each element of the list has a form:
entry-type param)
(guix-symbol-title param)))
-(defun guix-get-name-spec (name version &optional output)
+(defun guix-package-name-specification (name version &optional output)
"Return Guix package specification by its NAME, VERSION and OUTPUT."
(concat name "-" version
(when output (concat ":" output))))
-(defun guix-get-full-name (entry &optional output)
+(defun guix-package-entry->name-specification (entry &optional output)
"Return name specification of the package ENTRY and OUTPUT."
- (guix-get-name-spec (guix-entry-value entry 'name)
- (guix-entry-value entry 'version)
- output))
+ (guix-package-name-specification
+ (guix-entry-value entry 'name)
+ (guix-entry-value entry 'version)
+ (or output (guix-entry-value entry 'output))))
-(defun guix-entry-to-specification (entry)
- "Return name specification by the package or output ENTRY."
- (guix-get-name-spec (guix-entry-value entry 'name)
- (guix-entry-value entry 'version)
- (guix-entry-value entry 'output)))
-
-(defun guix-entries-to-specifications (entries)
+(defun guix-package-entries->name-specifications (entries)
"Return name specifications by the package or output ENTRIES."
- (cl-remove-duplicates (mapcar #'guix-entry-to-specification entries)
+ (cl-remove-duplicates (mapcar #'guix-package-entry->name-specification
+ entries)
:test #'string=))
-(defun guix-get-installed-outputs (entry)
+(defun guix-package-installed-outputs (entry)
"Return list of installed outputs for the package ENTRY."
(mapcar (lambda (installed-entry)
(guix-entry-value installed-entry 'output))
(guix-entry-value entry 'installed)))
-(defun guix-get-package-id-and-output-by-output-id (oid)
+(defun guix-package-id-and-output-by-output-id (oid)
"Return list (PACKAGE-ID OUTPUT) by output id OID."
(cl-multiple-value-bind (pid-str output)
(split-string oid ":")
@@ -567,7 +563,7 @@ If NO-DISPLAY is non-nil, do not switch to the buffer."
(required (symbol-value required-var)))
(unless (equal required 'all)
(cl-union required
- (funcall (guix-get-symbol "get-displayed-params"
+ (funcall (guix-get-symbol "displayed-params"
buffer-type)
entry-type)))))
@@ -596,8 +592,9 @@ See `revert-buffer' for the meaning of NOCONFIRM."
(eq guix-entry-type 'output)))
(progn
(setq search-type 'name
- search-vals (guix-entries-to-specifications
- guix-entries))
+ search-vals
+ (guix-package-entries->name-specifications
+ guix-entries))
(guix-get-entries
guix-profile guix-entry-type
search-type search-vals params))
@@ -902,7 +899,7 @@ ENTRIES is a list of package entries to get info about packages."
(entry (guix-entry-by-id id entries)))
(when entry
(let ((location (guix-entry-value entry 'location)))
- (concat (guix-get-full-name entry)
+ (concat (guix-package-entry->name-specification entry)
(when outputs
(concat ":"
(guix-concat-strings outputs ",")))
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 8cb4e94185..05a8143202 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -187,13 +187,13 @@ Each element of the list should have a form:
The order of displayed parameters is the same as in this list.")
-(defun guix-info-get-insert-methods (entry-type param)
+(defun guix-info-insert-methods (entry-type param)
"Return list of insert methods for parameter PARAM of ENTRY-TYPE.
See `guix-info-insert-methods' for details."
(guix-assq-value guix-info-insert-methods
entry-type param))
-(defun guix-info-get-displayed-params (entry-type)
+(defun guix-info-displayed-params (entry-type)
"Return parameters of ENTRY-TYPE that should be displayed."
(guix-assq-value guix-info-displayed-params
entry-type))
@@ -224,7 +224,7 @@ number of `guix-info-indent' spaces."
guix-info-indent)
(mapc (lambda (param)
(guix-info-insert-param param entry entry-type))
- (guix-info-get-displayed-params entry-type))))
+ (guix-info-displayed-params entry-type))))
(defun guix-info-insert-entry (entry entry-type &optional indent-level)
"Insert ENTRY of ENTRY-TYPE into the current info buffer.
@@ -245,7 +245,7 @@ ENTRY-TYPE is a type of ENTRY."
(let ((val (guix-entry-value entry param)))
(unless (and guix-info-ignore-empty-vals (null val))
(let* ((title (guix-get-param-title entry-type param))
- (insert-methods (guix-info-get-insert-methods entry-type param))
+ (insert-methods (guix-info-insert-methods entry-type param))
(val-method (car insert-methods))
(title-method (cadr insert-methods)))
(guix-info-method-funcall title title-method
@@ -525,7 +525,7 @@ Show package name, version, and `guix-package-info-heading-params'."
(unless (or (memq param '(name version))
(memq param guix-package-info-heading-params))
(guix-info-insert-param param entry 'package)))
- (guix-info-get-displayed-params 'package)))
+ (guix-info-displayed-params 'package)))
(defun guix-package-info-insert-description (desc &optional _)
"Insert description DESC at point."
@@ -601,7 +601,7 @@ If nil, insert installed info in a default way.")
(and (guix-entry-value entry 'non-unique)
(guix-entry-value entry 'installed)
(guix-package-info-insert-non-unique-text
- (guix-get-full-name entry)))
+ (guix-package-entry->name-specification entry)))
(insert "\n")
(mapc (lambda (output)
(guix-package-info-insert-output output entry))
@@ -653,7 +653,7 @@ current OUTPUT is installed (if there is such output in
TYPE is one of the following symbols: `install', `delete', `upgrade'.
ENTRY is an alist with package info."
(let ((type-str (capitalize (symbol-name type)))
- (full-name (guix-get-full-name entry output)))
+ (full-name (guix-package-entry->name-specification entry output)))
(guix-info-insert-action-button
type-str
(lambda (btn)
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index d6045d45cc..5e4df38c0e 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -117,27 +117,19 @@ function is called with 2 arguments: the first one is the value
of the parameter; the second argument is an entry info (alist of
parameters and their values).")
-(defun guix-list-get-param-title (entry-type param)
- "Return title of an ENTRY-TYPE entry parameter PARAM."
+(defun guix-list-param-title (entry-type param)
+ "Return column title of an ENTRY-TYPE parameter PARAM."
(or (guix-assq-value guix-list-column-titles
entry-type param)
(guix-get-param-title entry-type param)))
-(defun guix-list-get-column-format (entry-type)
+(defun guix-list-format (entry-type)
"Return column format for ENTRY-TYPE."
(guix-assq-value guix-list-column-format entry-type))
-(defun guix-list-get-displayed-params (entry-type)
- "Return list of parameters of ENTRY-TYPE that should be displayed."
- (mapcar #'car
- (guix-list-get-column-format entry-type)))
-
-(defun guix-list-get-sort-key (entry-type param &optional invert)
- "Return suitable sort key for `tabulated-list-sort-key'.
-Define column title by ENTRY-TYPE and PARAM. If INVERT is
-non-nil, invert the sort."
- (when (memq param (guix-list-get-displayed-params entry-type))
- (cons (guix-list-get-param-title entry-type param) invert)))
+(defun guix-list-displayed-params (entry-type)
+ "Return a list of ENTRY-TYPE parameters that should be displayed."
+ (mapcar #'car (guix-list-format entry-type)))
(defun guix-list-sort-numerically (column a b)
"Compare COLUMN of tabulated entries A and B numerically.
@@ -169,7 +161,14 @@ See `guix-list-define-numerical-sorter' for details."
(guix-list-define-numerical-sorters 9)
-(defun guix-list-make-tabulated-vector (entry-type fun)
+(defun guix-list-tabulated-sort-key (entry-type param &optional invert)
+ "Return suitable sort key for `tabulated-list-sort-key'.
+Define column title by ENTRY-TYPE and PARAM. If INVERT is
+non-nil, invert the sort."
+ (when (memq param (guix-list-displayed-params entry-type))
+ (cons (guix-list-param-title entry-type param) invert)))
+
+(defun guix-list-tabulated-vector (entry-type fun)
"Call FUN on each column specification for ENTRY-TYPE.
FUN is called with 2 argument: parameter name and column
@@ -179,36 +178,34 @@ Return a vector made of values of FUN calls."
(apply #'vector
(mapcar (lambda (col-spec)
(funcall fun (car col-spec) (cdr col-spec)))
- (guix-list-get-column-format entry-type))))
+ (guix-list-format entry-type))))
-(defun guix-list-get-list-format (entry-type)
+(defun guix-list-tabulated-format (entry-type)
"Return ENTRY-TYPE list specification for `tabulated-list-format'."
- (guix-list-make-tabulated-vector
+ (guix-list-tabulated-vector
entry-type
(lambda (param spec)
- (cons (guix-list-get-param-title entry-type param)
+ (cons (guix-list-param-title entry-type param)
spec))))
(defun guix-list-insert-entries (entries entry-type)
"Display ENTRIES of ENTRY-TYPE in the current list buffer.
ENTRIES should have a form of `guix-entries'."
(setq tabulated-list-entries
- (guix-list-get-tabulated-entries entries entry-type))
+ (guix-list-tabulated-entries entries entry-type))
(tabulated-list-print))
-(defun guix-list-get-tabulated-entries (entries entry-type)
- "Return list of values of ENTRY-TYPE for `tabulated-list-entries'.
-Values are taken from ENTRIES which should have the form of
-`guix-entries'."
+(defun guix-list-tabulated-entries (entries entry-type)
+ "Return a list of ENTRY-TYPE values for `tabulated-list-entries'."
(mapcar (lambda (entry)
(list (guix-entry-id entry)
- (guix-list-get-tabulated-entry entry entry-type)))
+ (guix-list-tabulated-entry entry entry-type)))
entries))
-(defun guix-list-get-tabulated-entry (entry entry-type)
+(defun guix-list-tabulated-entry (entry entry-type)
"Return array of values for `tabulated-list-entries'.
-Parameters are taken from ENTRY of ENTRY-TYPE."
- (guix-list-make-tabulated-vector
+Parameters are taken from ENTRY-TYPE ENTRY."
+ (guix-list-tabulated-vector
entry-type
(lambda (param _)
(let ((val (guix-entry-value entry param))
@@ -472,10 +469,10 @@ This macro defines the following functions:
,(concat "Initial settings for `" mode-str "'.")
,(when sort-key
`(setq tabulated-list-sort-key
- (guix-list-get-sort-key
+ (guix-list-tabulated-sort-key
',entry-type ',sort-key ,invert-sort)))
(setq tabulated-list-format
- (guix-list-get-list-format ',entry-type))
+ (guix-list-tabulated-format ',entry-type))
(setq-local guix-list-mark-alist
(append guix-list-mark-alist ,marks-var))
(tabulated-list-init-header)))))
@@ -595,7 +592,7 @@ be separated with \",\")."
(guix-package-list-marking-check)
(let* ((entry (guix-list-current-entry))
(all (guix-entry-value entry 'outputs))
- (installed (guix-get-installed-outputs entry))
+ (installed (guix-package-installed-outputs entry))
(available (cl-set-difference all installed :test #'string=)))
(or available
(user-error "This package is already installed"))
@@ -611,7 +608,7 @@ be separated with \",\")."
(interactive "P")
(guix-package-list-marking-check)
(let* ((entry (guix-list-current-entry))
- (installed (guix-get-installed-outputs entry)))
+ (installed (guix-package-installed-outputs entry)))
(or installed
(user-error "This package is not installed"))
(guix-package-list-mark-outputs
@@ -626,7 +623,7 @@ be separated with \",\")."
(interactive "P")
(guix-package-list-marking-check)
(let* ((entry (guix-list-current-entry))
- (installed (guix-get-installed-outputs entry)))
+ (installed (guix-package-installed-outputs entry)))
(or installed
(user-error "This package is not installed"))
(when (or (guix-entry-value entry 'obsolete)
@@ -662,7 +659,7 @@ accept an entry as argument."
(lambda (entry)
(apply #'guix-list--mark
'upgrade nil
- (guix-get-installed-outputs entry)))))
+ (guix-package-installed-outputs entry)))))
(defun guix-list-execute-package-actions (fun)
"Perform actions on the marked packages.
@@ -758,7 +755,7 @@ Return nil, if there are no outputs marked with ACTION-TYPE.
The specification is suitable for `guix-process-output-actions'."
(let ((ids (guix-list-get-marked-id-list action-type)))
(and ids (cons action-type
- (mapcar #'guix-get-package-id-and-output-by-output-id
+ (mapcar #'guix-package-id-and-output-by-output-id
ids)))))
(defun guix-output-list-describe (&optional arg)
@@ -773,7 +770,7 @@ Also see `guix-package-info-type'."
(unless arg '(general)))
(list (guix-list-current-id))))
(pids (mapcar (lambda (oid)
- (car (guix-get-package-id-and-output-by-output-id
+ (car (guix-package-id-and-output-by-output-id
oid)))
oids)))
(guix-list-describe-maybe 'package (cl-remove-duplicates pids)))))