guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07/12: emacs: Move help variables to "guix-help-vars.el".


From: Alex Kost
Subject: 07/12: emacs: Move help variables to "guix-help-vars.el".
Date: Fri, 14 Aug 2015 08:18:16 +0000

alezost pushed a commit to branch wip-emacs-popup-ui
in repository guix.

commit fd36c7f730671eed184978fd30fc73dd9d4ad7b5
Author: Alex Kost <address@hidden>
Date:   Wed Aug 12 20:32:45 2015 +0300

    emacs: Move help variables to "guix-help-vars.el".
    
    * emacs/guix-pcomplete.el (guix-pcomplete-parse-package-regexp,
      guix-pcomplete-parse-command-regexp,
      guix-pcomplete-parse-long-option-regexp,
      guix-pcomplete-parse-short-option-regexp,
      guix-pcomplete-parse-linter-regexp, guix-pcomplete-parse-regexp-group,
      guix-pcomplete-systems, guix-pcomplete-hash-formats,
      guix-pcomplete-refresh-subsets, guix-pcomplete-key-policies): Move and
      rename to ...
    * emacs/guix-help-vars.el (guix-help-parse-package-regexp,
      guix-help-parse-command-regexp, guix-help-parse-long-option-regexp,
      guix-help-parse-short-option-regexp, guix-help-parse-linter-regexp,
      guix-help-parse-regexp-group, guix-help-system-types,
      guix-help-hash-formats, guix-help-refresh-subsets,
      guix-help-key-policies): ...here.  New file.
      (guix-help-parse-option-regexp, guix-help-source-types,
      guix-help-verify-options, guix-help-elpa-archives): New variables.
    * emacs.am (ELFILES): Add "guix-help-vars.el".
---
 emacs.am                |    3 +-
 emacs/guix-help-vars.el |  107 +++++++++++++++++++++++++++++++++++++++++++++++
 emacs/guix-pcomplete.el |   81 +++++++-----------------------------
 3 files changed, 124 insertions(+), 67 deletions(-)

diff --git a/emacs.am b/emacs.am
index 372b33e..e426653 100644
--- a/emacs.am
+++ b/emacs.am
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2014 Alex Kost <address@hidden>
+# Copyright © 2014, 2015 Alex Kost <address@hidden>
 #
 # This file is part of GNU Guix.
 #
@@ -22,6 +22,7 @@ ELFILES =                                     \
   emacs/guix-backend.el                                \
   emacs/guix-base.el                           \
   emacs/guix-emacs.el                          \
+  emacs/guix-help-vars.el                      \
   emacs/guix-history.el                                \
   emacs/guix-info.el                           \
   emacs/guix-list.el                           \
diff --git a/emacs/guix-help-vars.el b/emacs/guix-help-vars.el
new file mode 100644
index 0000000..d4d6716
--- /dev/null
+++ b/emacs/guix-help-vars.el
@@ -0,0 +1,107 @@
+;;; guix-help-vars.el --- Variables related to --help output
+
+;; Copyright © 2015 Alex Kost <address@hidden>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides regular expressions to parse various "guix
+;; ... --help" outputs and lists of non-receivable items (system types,
+;; hash formats, etc.).
+
+;;; Code:
+
+
+;;; Regexps for parsing "guix ..." outputs
+
+(defvar guix-help-parse-option-regexp
+  (rx bol "  "
+      (zero-or-one (group "-" (not (any "- ")))
+                   ",")
+      (one-or-more " ")
+      (group "--" (one-or-more (or wordchar "-")))
+      (group (zero-or-one "[")
+             (zero-or-one "="))
+      (zero-or-more (not space))
+      (one-or-more space)
+      (group (one-or-more any)))
+  "Common regexp used to find command options.")
+
+(defvar guix-help-parse-command-regexp
+  (rx bol "   "
+      (group wordchar (one-or-more (or wordchar "-"))))
+  "Regexp used to find guix commands.
+'Command' means any option not prefixed with '-'.  For example,
+guix subcommand, system action, importer, etc.")
+
+(defvar guix-help-parse-long-option-regexp
+  (rx (or "  " ", ")
+      (group "--" (one-or-more (or wordchar "-"))
+             (zero-or-one "=")))
+  "Regexp used to find long options.")
+
+(defvar guix-help-parse-short-option-regexp
+  (rx bol (one-or-more blank)
+      "-" (group (not (any "- "))))
+  "Regexp used to find short options.")
+
+(defvar guix-help-parse-package-regexp
+  (rx bol (group (one-or-more (not blank))))
+  "Regexp used to find names of the packages.")
+
+(defvar guix-help-parse-linter-regexp
+  (rx bol "- " (group (one-or-more (or wordchar "-"))))
+  "Regexp used to find 'lint' checkers.")
+
+(defvar guix-help-parse-regexp-group 1
+  "Parenthesized expression of regexps used to find commands and
+options.")
+
+
+;;; Non-receivable lists of system types, hash formats, etc.
+
+(defvar guix-help-system-types
+  '("x86_64-linux" "i686-linux" "armhf-linux" "mips64el-linux")
+  "List of supported systems.")
+
+(defvar guix-help-source-types
+  '("package" "all" "transitive")
+  "List of supported sources types.")
+
+(defvar guix-help-hash-formats
+  '("nix-base32" "base32" "base16" "hex" "hexadecimal")
+  "List of supported hash formats.")
+
+(defvar guix-help-refresh-subsets
+  '("core" "non-core")
+  "List of supported 'refresh' subsets.")
+
+(defvar guix-help-key-policies
+  '("interactive" "always" "never")
+  "List of supported key download policies.")
+
+(defvar guix-help-verify-options
+  '("repair" "contents")
+  "List of supported 'verify' options")
+
+(defvar guix-help-elpa-archives
+  '("gnu" "melpa" "melpa-stable")
+  "List of supported ELPA archives.")
+
+(provide 'guix-help-vars)
+
+;;; guix-help-vars.el ends here
diff --git a/emacs/guix-pcomplete.el b/emacs/guix-pcomplete.el
index fe1b1ef..e86794b 100644
--- a/emacs/guix-pcomplete.el
+++ b/emacs/guix-pcomplete.el
@@ -28,58 +28,7 @@
 (require 'pcmpl-unix)
 (require 'cl-lib)
 (require 'guix-utils)
-
-
-;;; Regexps for parsing various "guix ..." outputs
-
-(defvar guix-pcomplete-parse-package-regexp
-  (rx bol (group (one-or-more (not blank))))
-  "Regexp used to find names of the packages.")
-
-(defvar guix-pcomplete-parse-command-regexp
-  (rx bol "   "
-      (group wordchar (one-or-more (or wordchar "-"))))
-  "Regexp used to find guix commands.
-'Command' means any option not prefixed with '-'.  For example,
-guix subcommand, system action, importer, etc.")
-
-(defvar guix-pcomplete-parse-long-option-regexp
-  (rx (or "  " ", ")
-      (group "--" (one-or-more (or wordchar "-"))
-             (zero-or-one "=")))
-  "Regexp used to find long options.")
-
-(defvar guix-pcomplete-parse-short-option-regexp
-  (rx bol (one-or-more blank)
-      "-" (group (not (any "- "))))
-  "Regexp used to find short options.")
-
-(defvar guix-pcomplete-parse-linter-regexp
-  (rx bol "- " (group (one-or-more (or wordchar "-"))))
-  "Regexp used to find 'lint' checkers.")
-
-(defvar guix-pcomplete-parse-regexp-group 1
-  "Parenthesized expression of regexps used to find commands and
-options.")
-
-
-;;; Non-receivable completions
-
-(defvar guix-pcomplete-systems
-  '("x86_64-linux" "i686-linux" "armhf-linux" "mips64el-linux")
-  "List of supported systems.")
-
-(defvar guix-pcomplete-hash-formats
-  '("nix-base32" "base32" "base16" "hex" "hexadecimal")
-  "List of supported hash formats.")
-
-(defvar guix-pcomplete-refresh-subsets
-  '("core" "non-core")
-  "List of supported 'refresh' subsets.")
-
-(defvar guix-pcomplete-key-policies
-  '("interactive" "always" "never")
-  "List of supported key download policies.")
+(require 'guix-help-vars)
 
 
 ;;; Interacting with guix
@@ -127,7 +76,7 @@ function call is returned."
      (let* ((args '("--help"))
             (args (if command (cons command args) args))
             (res (apply #'guix-pcomplete-run-guix-and-search
-                        ,regexp guix-pcomplete-parse-regexp-group args)))
+                        ,regexp guix-help-parse-regexp-group args)))
        ,(if filter
             `(funcall ,filter res)
           'res))))
@@ -136,23 +85,23 @@ function call is returned."
   "If COMMAND is nil, return a list of available guix commands.
 If COMMAND is non-nil (it should be a string), return available
 subcommands, actions, etc. for this guix COMMAND."
-  guix-pcomplete-parse-command-regexp)
+  guix-help-parse-command-regexp)
 
 (guix-pcomplete-define-options-finder guix-pcomplete-long-options
   "Return a list of available long options for guix COMMAND."
-  guix-pcomplete-parse-long-option-regexp)
+  guix-help-parse-long-option-regexp)
 
 (guix-pcomplete-define-options-finder guix-pcomplete-short-options
   "Return a string with available short options for guix COMMAND."
-  guix-pcomplete-parse-short-option-regexp
+  guix-help-parse-short-option-regexp
   (lambda (list)
     (guix-concat-strings list "")))
 
 (guix-memoized-defun guix-pcomplete-all-packages ()
   "Return a list of all available Guix packages."
   (guix-pcomplete-run-guix-and-search
-   guix-pcomplete-parse-package-regexp
-   guix-pcomplete-parse-regexp-group
+   guix-help-parse-package-regexp
+   guix-help-parse-regexp-group
    "package" "--list-available"))
 
 (guix-memoized-defun guix-pcomplete-installed-packages (&optional profile)
@@ -161,15 +110,15 @@ subcommands, actions, etc. for this guix COMMAND."
                     (list (concat "--profile=" profile))))
          (args (append '("package" "--list-installed") args)))
     (apply #'guix-pcomplete-run-guix-and-search
-           guix-pcomplete-parse-package-regexp
-           guix-pcomplete-parse-regexp-group
+           guix-help-parse-package-regexp
+           guix-help-parse-regexp-group
            args)))
 
 (guix-memoized-defun guix-pcomplete-lint-checkers ()
   "Return a list of all available lint checkers."
   (guix-pcomplete-run-guix-and-search
-   guix-pcomplete-parse-linter-regexp
-   guix-pcomplete-parse-regexp-group
+   guix-help-parse-linter-regexp
+   guix-help-parse-regexp-group
    "lint" "--list-checkers"))
 
 
@@ -275,7 +224,7 @@ INPUT is the current partially completed string."
      ((option? "-L" "--load-path")
       (complete* (pcomplete-dirs)))
      ((string= "--key-download" option)
-      (complete* guix-pcomplete-key-policies))
+      (complete* guix-help-key-policies))
 
      ((command? "package")
       (cond
@@ -304,7 +253,7 @@ INPUT is the current partially completed string."
 
      ((and (command? "archive" "build" "size")
            (option? "-s" "--system"))
-      (complete* guix-pcomplete-systems))
+      (complete* guix-help-system-types))
 
      ((and (command? "build")
            (option? "-r" "--root"))
@@ -316,7 +265,7 @@ INPUT is the current partially completed string."
 
      ((and (command? "hash" "download")
            (option? "-f" "--format"))
-      (complete* guix-pcomplete-hash-formats))
+      (complete* guix-help-hash-formats))
 
      ((and (command? "lint")
            (option? "-c" "--checkers"))
@@ -329,7 +278,7 @@ INPUT is the current partially completed string."
 
      ((and (command? "refresh")
            (option? "-s" "--select"))
-      (complete* guix-pcomplete-refresh-subsets))
+      (complete* guix-help-refresh-subsets))
 
      ((and (command? "size")
            (option? "-m" "--map-file"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]