emacs: Simplify defining parameter titles.

* emacs/guix-utils.el (guix-symbol-title): New procedure.
* emacs/guix-base.el (guix-get-param-title): Use it.
  (guix-param-titles): Remove most titles as they are automatically
  defined by 'guix-symbol-title'.
master
Alex Kost 2015-11-17 22:19:14 +03:00
parent 73ce3c19c4
commit ceea647c72
2 changed files with 14 additions and 41 deletions

View File

@ -41,48 +41,14 @@
(defvar guix-param-titles (defvar guix-param-titles
'((package '((package
(id . "ID") (home-url . "Home page"))
(name . "Name")
(version . "Version")
(source . "Source")
(license . "License")
(synopsis . "Synopsis")
(description . "Description")
(home-url . "Home page")
(outputs . "Outputs")
(inputs . "Inputs")
(native-inputs . "Native inputs")
(propagated-inputs . "Propagated inputs")
(location . "Location")
(installed . "Installed"))
(installed (installed
(path . "Installed path") (path . "Installed path"))
(dependencies . "Dependencies")
(output . "Output"))
(output (output
(id . "ID")
(name . "Name")
(version . "Version")
(source . "Source")
(license . "License")
(synopsis . "Synopsis")
(description . "Description")
(home-url . "Home page") (home-url . "Home page")
(output . "Output") (path . "Installed path"))
(inputs . "Inputs")
(native-inputs . "Native inputs")
(propagated-inputs . "Propagated inputs")
(location . "Location")
(installed . "Installed")
(path . "Installed path")
(dependencies . "Dependencies"))
(generation (generation
(id . "ID") (prev-number . "Previous number")))
(number . "Number")
(prev-number . "Previous number")
(current . "Current")
(path . "Path")
(time . "Time")))
"List for defining titles of entry parameters. "List for defining titles of entry parameters.
Titles are used for displaying information about entries. Titles are used for displaying information about entries.
Each element of the list has a form: Each element of the list has a form:
@ -93,9 +59,7 @@ Each element of the list has a form:
"Return title of an ENTRY-TYPE entry parameter PARAM." "Return title of an ENTRY-TYPE entry parameter PARAM."
(or (guix-assq-value guix-param-titles (or (guix-assq-value guix-param-titles
entry-type param) entry-type param)
(prog1 (symbol-name param) (guix-symbol-title param)))
(message "Couldn't find title for '%S %S'."
entry-type param))))
(defun guix-get-name-spec (name version &optional output) (defun guix-get-name-spec (name version &optional output)
"Return Guix package specification by its NAME, VERSION and OUTPUT." "Return Guix package specification by its NAME, VERSION and OUTPUT."

View File

@ -165,6 +165,15 @@ This function is similar to `shell-quote-argument', but less strict."
(replace-regexp-in-string (replace-regexp-in-string
(rx (not (any alnum "-=,./\n"))) "\\\\\\&" argument)))) (rx (not (any alnum "-=,./\n"))) "\\\\\\&" argument))))
(defun guix-symbol-title (symbol)
"Return SYMBOL's name, a string.
This is like `symbol-name', but fancier."
(if (eq symbol 'id)
"ID"
(let ((str (replace-regexp-in-string "-" " " (symbol-name symbol))))
(concat (capitalize (substring str 0 1))
(substring str 1)))))
(defun guix-command-symbol (&optional args) (defun guix-command-symbol (&optional args)
"Return symbol by concatenating 'guix' and ARGS (strings)." "Return symbol by concatenating 'guix' and ARGS (strings)."
(intern (guix-concat-strings (cons "guix" args) "-"))) (intern (guix-concat-strings (cons "guix" args) "-")))