;;; guix-info.el --- 'Info' buffer interface for displaying data -*- lexical-binding: t -*- ;; Copyright © 2014, 2015 Alex Kost ;; Copyright © 2015 Ludovic Courtès ;; 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 . ;;; Commentary: ;; This file provides 'info' (help-like) buffer interface for displaying ;; an arbitrary data. ;;; Code: (require 'guix-buffer) (require 'guix-entry) (require 'guix-utils) (guix-define-buffer-type info) (defface guix-info-heading '((((type tty pc) (class color)) :weight bold) (t :height 1.6 :weight bold :inherit variable-pitch)) "Face for headings." :group 'guix-info-faces) (defface guix-info-param-title '((t :inherit font-lock-type-face)) "Face used for titles of parameters." :group 'guix-info-faces) (defface guix-info-file-name '((t :inherit link)) "Face used for file names." :group 'guix-info-faces) (defface guix-info-url '((t :inherit link)) "Face used for URLs." :group 'guix-info-faces) (defface guix-info-time '((t :inherit font-lock-constant-face)) "Face used for timestamps." :group 'guix-info-faces) (defface guix-info-action-button '((((type x w32 ns) (class color)) :box (:line-width 2 :style released-button) :background "lightgrey" :foreground "black") (t :inherit button)) "Face used for action buttons." :group 'guix-info-faces) (defface guix-info-action-button-mouse '((((type x w32 ns) (class color)) :box (:line-width 2 :style released-button) :background "grey90" :foreground "black") (t :inherit highlight)) "Mouse face used for action buttons." :group 'guix-info-faces) (defcustom guix-info-ignore-empty-values nil "If non-nil, do not display parameters with nil values." :type 'boolean :group 'guix-info) (defcustom guix-info-fill t "If non-nil, fill string parameters to fit the window. If nil, insert text parameters (like synopsis or description) in a raw form." :type 'boolean :group 'guix-info) (defvar guix-info-param-title-format "%-18s: " "String used to format a title of a parameter. It should be a '%s'-sequence. After inserting a title formatted with this string, a value of the parameter is inserted. This string is used by `guix-info-insert-title-format'.") (defvar guix-info-multiline-prefix (make-string (length (format guix-info-param-title-format " ")) ?\s) "String used to format multi-line parameter values. If a value occupies more than one line, this string is inserted in the beginning of each line after the first one. This string is used by `guix-info-insert-value-format'.") (defvar guix-info-indent 2 "Number of spaces used to indent various parts of inserted text.") (defvar guix-info-delimiter "\n\f\n" "String used to separate entries.") ;;; Wrappers for 'info' variables (defvar guix-info-data nil "Alist with 'info' data. This alist is filled by `guix-info-define-interface' macro.") (defun guix-info-value (entry-type symbol) "Return SYMBOL's value for ENTRY-TYPE from `guix-info-data'." (symbol-value (guix-assq-value guix-info-data entry-type symbol))) (defun guix-info-param-title (entry-type param) "Return a title of an ENTRY-TYPE parameter PARAM." (guix-buffer-param-title 'info entry-type param)) (defun guix-info-format (entry-type) "Return 'info' format for ENTRY-TYPE." (guix-info-value entry-type 'format)) (defun guix-info-displayed-params (entry-type) "Return a list of ENTRY-TYPE parameters that should be displayed." (delq nil (mapcar (lambda (spec) (pcase spec (`(,param . ,_) param))) (guix-info-format entry-type)))) ;;; Inserting entries (defvar guix-info-title-aliases '((format . guix-info-insert-title-format) (simple . guix-info-insert-title-simple)) "Alist of aliases and functions to insert titles.") (defvar guix-info-value-aliases '((format . guix-info-insert-value-format) (indent . guix-info-insert-value-indent) (simple . guix-info-insert-value-simple) (time . guix-info-insert-time)) "Alist of aliases and functions to insert values.") (defun guix-info-title-function (fun-or-alias) "Convert FUN-OR-ALIAS into a function to insert a title." (or (guix-assq-value guix-info-title-aliases fun-or-alias) fun-or-alias)) (defun guix-info-value-function (fun-or-alias) "Convert FUN-OR-ALIAS into a function to insert a value." (or (guix-assq-value guix-info-value-aliases fun-or-alias) fun-or-alias)) (defun guix-info-title-method->function (method) "Convert title METHOD into a function to insert a title." (pcase method ((pred null) #'ignore) ((pred symbolp) (guix-info-title-function method)) (`(,fun-or-alias . ,rest-args) (lambda (title) (apply (guix-info-title-function fun-or-alias) title rest-args))) (_ (error "Unknown title method '%S'" method)))) (defun guix-info-value-method->function (method) "Convert value METHOD into a function to insert a value." (pcase method ((pred null) #'ignore) ((pred functionp) method) (`(,fun-or-alias . ,rest-args) (lambda (value _) (apply (guix-info-value-function fun-or-alias) value rest-args))) (_ (error "Unknown value method '%S'" method)))) (defun guix-info-fill-column () "Return fill column for the current window." (min (window-width) fill-column)) (defun guix-info-get-indent (&optional level) "Return `guix-info-indent' \"multiplied\" by LEVEL spaces. LEVEL is 1 by default." (make-string (* guix-info-indent (or level 1)) ?\s)) (defun guix-info-insert-indent (&optional level) "Insert `guix-info-indent' spaces LEVEL times (1 by default)." (insert (guix-info-get-indent level))) (defun guix-info-insert-entries (entries entry-type) "Display ENTRY-TYPE ENTRIES in the current info buffer." (guix-mapinsert (lambda (entry) (guix-info-insert-entry entry entry-type)) entries guix-info-delimiter)) (defun guix-info-insert-entry (entry entry-type &optional indent-level) "Insert ENTRY of ENTRY-TYPE into the current info buffer. If INDENT-LEVEL is non-nil, indent displayed data by this number of `guix-info-indent' spaces." (guix-with-indent (* (or indent-level 0) guix-info-indent) (dolist (spec (guix-info-format entry-type)) (guix-info-insert-entry-unit spec entry entry-type)))) (defun guix-info-insert-entry-unit (format-spec entry entry-type) "Insert title and value of a PARAM at point. ENTRY is alist with parameters and their values. ENTRY-TYPE is a type of ENTRY." (pcase format-spec ((pred functionp) (funcall format-spec entry) (insert "\n")) (`(,param ,title-method ,value-method) (let ((value (guix-entry-value entry param))) (unless (and guix-info-ignore-empty-values (null value)) (let ((title (guix-info-param-title entry-type param)) (insert-title (guix-info-title-method->function title-method)) (insert-value (guix-info-value-method->function value-method))) (funcall insert-title title) (funcall insert-value value entry) (insert "\n"))))) (_ (error "Unknown format specification '%S'" format-spec)))) (defun guix-info-insert-title-simple (title &optional face) "Insert \"TITLE: \" string at point. If FACE is nil, use `guix-info-param2020-07-31file-system: Add mount-may-fail? option....* gnu/system/file-systems.scm (<file-system>): Add a mount-may-fail? field. (file-system->spec): adapt accordingly, (spec->file-system): ditto. * gnu/build/file-systems.scm (mount-file-system): If 'system-error is raised and mount-may-fail? is true, ignore it. Otherwise, re-raise the exception. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Mathieu Othacehe 2020-07-26file-systems: Add NTFS support....* gnu/system/uuid.scm (%ntfs-endianness): New macro, (ntfs-uuid->string): new procedure, (%ntfs-endianness): new variable, (string->ntfs-uuid): new exported procedure, (%uuid-parsers): add NTFS support, (%uuid-printers): add NTFS support. * gnu/build/file-systems.scm (%ntfs-endianness): New macro, (ntfs-superblock?, read-ntfs-superblock, ntfs-superblock-uuid, check-ntfs-file-system): new procedure, (%partition-uuid-readers): add NTFS support, (check-file-system): add NTFS support. Mathieu Othacehe 2020-05-20linux-boot: Refactor boot-system....The --root option can now be omitted, and inferred from the root file system declaration instead. * gnu/build/file-systems.scm (canonicalize-device-spec): Extend to support NFS directly, and... * gnu/build/linux-boot.scm (boot-system): ...remove NFS special casing from here. Remove nested definitions for root-fs-type, root-fs-flags and root-fs-options, and bind those inside the let* instead. Make "--root" take precedence over the device field string representation of the root file system. * doc/guix.texi (Initial RAM Disk): Document that "--root" can be left unspecified. Maxim Cournoyer 2020-05-03file-systems: Fix UTF-16 handling in initrd....Follow-up to f73f4b3a2d7a313a6cb1667bd69205ea4b09f57c. * gnu/build/file-systems.scm (bytevector->u16-list): New procedure. (utf16->string): New procedure. Danny Milosavljevic 2020-05-03file-systems: Fix F2FS volume name accessor....Follow-up to 23b37c3d40d497cc6f07437ab26ab10e60fb6e09. * gnu/build/file-systems.scm (bytevector-utf16-length): New procedure. (null-terminated-utf16->string): New procedure. (f2fs-superblock-volume-name): Use it. Danny Milosavljevic 2020-05-02file-systems: Add support for F2FS....* gnu/build/file-systems.scm (%f2fs-endianness): New syntax. (f2fs-superblock?, read-f2fs-superblock, f2fs-superblock-uuid) (f2fs-superblock-volume-name, check-f2fs-file-system): New procedures. (%partition-label-readers, %partition-uuid-readers, check-file-system): Register them. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> raingloom 2020-03-02build: file-systems: Do not warn about file system check for NFS....* gnu/build/file-systems.scm (check-file-system): Define a dummy checker procedure for NFS that always passes to prevent a warning from being emitted. Maxim Cournoyer 2020-01-05file-systems: Handle LUKS2 header....* gnu/build/file-systems.scm (luks-superblock?): Handle LUKS2 header. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> David Trudgian 2020-01-03file-systems: Add support for JFS....* gnu/build/file-systems.scm (%jfs-endianness): New syntax. (jfs-superblock?, read-jfs-superblock, jfs-superblock-uuid) (jfs-superblock-volume-name, check-jfs-file-system): New procedures. (%partition-label-readers, %partition-uuid-readers, check-file-system): Register them. Tobias Geerinckx-Rice 2019-12-07file-systems: Add support for 'strict-atime' and 'lazy-time' flags....* guix/build/syscalls.scm (MS_LAZYTIME): New variable. * gnu/build/file-systems.scm (mount-flags->bit-mask): Add match rules for 'strict-atime' and 'lazy-time'. * doc/guix.texi (File Systems): Add 'strict-atime' and 'lazy-time' to the list of supported flags. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Guillaume Le Vaillant 2019-11-18file-systems: Fix docstring....* gnu/build/file-systems.scm (mount-file-system): Clean the documentation from the no longer existing parameters (these are now encapsulated within a <file-system> record). Maxim Cournoyer 2019-04-29file-systems: Support the 'no-atime' flag....* guix/build/syscalls.scm (MS_NOATIME): New variable. * gnu/build/file-systems.scm (mount-flags->bit-mask): Support it. * doc/guix.texi (File Systems): Document it and add cross-references to the relevant documentation. Co-authored-by: Ludovic Courtès <ludo@gnu.org> rendaw 2019-01-17file-systems: Add read-luks-partition-uuid....Add a specific procedure to read luks partition uuid. * gnu/build/file-systems.scm (luks-partition-field-reader): New procedure ... (luks-partition-uuid-predicate): ... used here, (read-luks-partition-uuid): new exported procedure. Mathieu Othacehe 2019-01-17file-systems: Export read-partition-label and read-partition-uuid....* gnu/build/file-systems.scm (read-partition-label): Export it, (read-partition-uuid): ditto. Mathieu Othacehe 2018-12-18file-systems: Have the emergency REPL output to /dev/console....This fixes a bug whereby all emergency REPL output would go to /dev/klog and thus, each line would be prefixed by "[12324.432] shepherd[1]: ". * gnu/build/file-systems.scm (check-file-system): Wrap 'start-repl' call in 'with-output-to-file'. Ludovic Courtès 2018-12-18file-systems: Spawn a REPL only when interaction is possible....Fixes <https://bugs.gnu.org/23697>. Reported by Jan Nieuwenhuizen <janneke@gnu.org>. * gnu/build/file-systems.scm (check-file-system): Call 'start-repl' only if current-input-port p