From unknown Sun Aug 10 16:51:15 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#63909 <63909@debbugs.gnu.org> To: bug#63909 <63909@debbugs.gnu.org> Subject: Status: [PATCH] home: Add inputrc service. Reply-To: bug#63909 <63909@debbugs.gnu.org> Date: Sun, 10 Aug 2025 23:51:15 +0000 retitle 63909 [PATCH] home: Add inputrc service. reassign 63909 guix-patches submitter 63909 Efraim Flashner severity 63909 normal tag 63909 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 05 08:19:32 2023 Received: (at submit) by debbugs.gnu.org; 5 Jun 2023 12:19:32 +0000 Received: from localhost ([127.0.0.1]:48330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q69BL-0003MG-Iv for submit@debbugs.gnu.org; Mon, 05 Jun 2023 08:19:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:38434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q69BI-0003M6-R4 for submit@debbugs.gnu.org; Mon, 05 Jun 2023 08:19:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q69BF-0001Cj-38 for guix-patches@gnu.org; Mon, 05 Jun 2023 08:19:28 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q69BC-0000UR-N4 for guix-patches@gnu.org; Mon, 05 Jun 2023 08:19:24 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f730c1253fso15083625e9.1 for ; Mon, 05 Jun 2023 05:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685967561; x=1688559561; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=z+w1EIm+JkVk3uX1q6j1vUHiTmy2iURlBZ4bKKFARlQ=; b=NWIkJSqTB8CEPU3J5ZKQdAQOSYu3fSCTSygbzJqX81v2p0W4Jo4nFhgubdXB0MKGTy 9OcVMF96yZB5ErgA+OWacXoo7pjfk4LiEqfleo7vnsOKM3Ceyw2naeAFJfuc3SJxJdTb WwKdoHi1h//C2zdRsmtn/35K7ZFEkzF8YL3zQHbqnhZHT/F/2v/0GE0ACcxd9NJhjwPI UREIsgnLTx+5BwAe+YdvzTBBi3rSPrsf2VyHlrtCcEkveWY5vvGT4PPKZ0pnYB6Sm2G6 EgduvPizrqY/E8vDpPTzZX2t5YsykLk2p7ngCCLxEHsFD6uhKmBMXuKymy2e4dFUXon3 yvCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685967561; x=1688559561; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z+w1EIm+JkVk3uX1q6j1vUHiTmy2iURlBZ4bKKFARlQ=; b=MgVx1Tiy4Osaf75Suvdkm88F5Sk4APgyTwu9vD31rsxv/l58SLzmf3aasyoD3jDktd dXXJDOaxvDXnr9zwptFuDj4PgVfThnR8TeN6g1dL5eMhA7gnYYoGpVntkFMmtZgSmnl5 fPKxIU3TknrF6I6F8HRdlxkJSdBRyJ/bBCYCVrH7w+OLlp4HlwqoAU2nq5xJdmrtEK6k J5fxhPf4BZMAUdNpiRxfwq5NCGQBReyP7OrdgV+3bNkxVsFgXB2aFjHxrviDG6Mx0dYU nSz2yfO12trW1LUUaX3P/WXKd3Yr2bEiUCgfZL1OOHQQkuk/hxNy+lx3vL/5w8BWZoZK q8gw== X-Gm-Message-State: AC+VfDyuZZ1u6lGxwKyoM810q1Gs3ZuL+HrojX+P0N3jbeDjdLtSPmt0 RmZRnw83G6E9S6bS//H2WkeTDiiHDwu92Q== X-Google-Smtp-Source: ACHHUZ4GCUMYxyCoJFUY6clpMGmOXia94OJB+9dbPA0Ii3z9yEbPHQM658Ky6q0g3AelnDLpO5ZN9g== X-Received: by 2002:a7b:cd96:0:b0:3f7:7211:5317 with SMTP id y22-20020a7bcd96000000b003f772115317mr2232094wmj.31.1685967560893; Mon, 05 Jun 2023 05:19:20 -0700 (PDT) Received: from localhost ([37.46.46.3]) by smtp.gmail.com with ESMTPSA id 8-20020a05600c230800b003f6cf9afc25sm14374718wmo.40.2023.06.05.05.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 05:19:20 -0700 (PDT) From: Efraim Flashner To: guix-patches@gnu.org Subject: [PATCH] home: Add inputrc service. Date: Mon, 5 Jun 2023 15:19:24 +0300 Message-Id: <29f421343373bc3655abb9961f254880a295f6f7.1685967547.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Debbugs-Cc: ( , Andrew Tropin , Ludovic Courtès Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit Cc: Efraim Flashner X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) * gnu/home/services/shells.scm (home-inputrc-service-type, home-inputrc-configuration): New variables. (serialize-inputrc-key-bindings, serialize-inputrc-variables, serialize-inputrc-conditional-constructs, serialize-inputrc-extra-content, generate-home-inputrc-documentation): New procedures. --- gnu/home/services/shells.scm | 145 ++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index f05f2221d6..bc3daf7a21 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -44,7 +45,10 @@ (define-module (gnu home services shells) home-fish-service-type home-fish-configuration - home-fish-extension)) + home-fish-extension + + home-inputrc-service-type + home-inputrc-configuration)) ;;; Commentary: ;;; @@ -626,6 +630,138 @@ (define home-fish-service-type (description "\ Install and configure Fish, the friendly interactive shell."))) + +;;; +;;; Readline. +;;; + +(define (serialize-inputrc-key-bindings field-name val) + #~(string-append + #$@(map + (match-lambda + ((key . value) + #~(string-append #$key ": " #$value "\n"))) + val))) + +(define (serialize-inputrc-variables field-name val) + #~(string-append + #$@(map + (match-lambda + ((key . #f) + #~(string-append "set " #$key " off\n")) + ((key . #t) + #~(string-append "set " #$key " on\n")) + ((key . value) + #~(string-append "set " #$key " " #$value "\n"))) + val))) + +(define (serialize-inputrc-conditional-constructs field-name val) + #~(string-append + #$@(map + (match-lambda + (("$endif" . _) + "$endif\n") + (("$include" . value) + #~(string-append "$include " #$value "\n")) + ;; TODO: key can only be "$if" or "$else". + ((key . value) + #~(string-append #$key "\n" + #$(serialize-configuration + value + home-inputrc-configuration-fields)))) + val))) + +(define (serialize-inputrc-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +(define-configuration home-inputrc-configuration + (key-bindings + (alist '()) + "Association list of readline key bindings to be added to the @code{.inputrc} +file. This is where code like this: + +@lisp +'((\"Control-l\" . \"clear-screen\")) +@end lisp + +turns into + +@example +Control-l: clear-screen +@end example" + (serializer serialize-inputrc-key-bindings)) + (variables + (alist '()) + "Association list of readline variables to set. This is where configuration +options like this: + +@lisp +'((\"bell-style\" . \"visible\") + (\"colored-completion-prefix\" . #t)) +@end lisp + +turns into + +@example +set bell-style visible +set colored-completion-prefix on +@end example" + (serializer serialize-inputrc-variables)) + (conditional-constructs + (alist '()) + "Association list of conditionals to add to the intialization file. This +includes @command{$if}, @command{else}, @command{endif} and @{include} and they +receive a value of another @command{home-inputrc-configuration}. + +@lisp +(conditional-constructs + `((\"$if mode=vi\" . + ,(home-inputrc-configuration + (variables + `((\"show-mode-in-prompt\" . #t))))) + (\"$else\" . + ,(home-inputrc-configuration + (key-bindings + `((\"Control-l\" . \"clear-screen\"))))) + (\"$endif\" . #t))) +@end lisp + +turns into + +@example +$if mode=vi +set show-mode-in-prompt on +$else +Control-l: clear-screen +$endif +@end example" + (serializer serialize-inputrc-conditional-constructs)) + (extra-content + (string "") + "Extra content appended as-is to the configuration file. Run @command{man +readline} for more information about all the configuration options." + (serializer serialize-inputrc-extra-content))) + +(define (home-inputrc-files config) + (list + `(".inputrc" + ,(mixed-text-file "inputrc" + (serialize-configuration + config + home-inputrc-configuration-fields))))) + +(define home-inputrc-service-type + (service-type (name 'inputrc) + (extensions + (list (service-extension home-files-service-type + home-inputrc-files))) + (default-value (home-inputrc-configuration)) + (description "Configure readline in @code{.inputrc}."))) + + +;;; +;;; Documentation. +;;; (define (generate-home-shell-profile-documentation) (generate-documentation @@ -662,3 +798,10 @@ (define (generate-home-fish-documentation) `((home-fish-extension ,home-fish-extension-fields)) 'home-fish-extension))) + +(define (generate-home-inputrc-documentation) + (string-append + (generate-documentation + `((home-inputrc-configuration + ,home-inputrc-configuration-fields)) + 'home-inputrc-configuration))) base-commit: 940665301de4effd065d24c167f619286f2adf4c -- Efraim Flashner רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 16 09:40:20 2023 Received: (at 63909) by debbugs.gnu.org; 16 Jun 2023 13:40:20 +0000 Received: from localhost ([127.0.0.1]:48798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qA9ga-0000vX-B4 for submit@debbugs.gnu.org; Fri, 16 Jun 2023 09:40:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qA9gY-0000vI-N9 for 63909@debbugs.gnu.org; Fri, 16 Jun 2023 09:40:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qA9gS-00007i-9Q; Fri, 16 Jun 2023 09:40:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=dIFzSKlYYgl1I6px9YA2U/xY+VZ8shfbocpFAyElgA4=; b=AZ6muGJ+hgY32ZoySv/s fD+YqydWE5Dzp1Uzypp9ejwpqCe/2D4FiNbzFs8Ye4nHtUhNhM0RMDJV8vBNOFv3KWa7PZNZkq1hT 1b4SjEN+80cl+1AxWzOi+HoIwWLb7e9Jf82iUUrCk6LS1Ehq3clDeySrZ9omduB1nfL+waor8y3z1 QVo0VMyKxyr5bXeSxp1culNjAA/FH2vbUoGfloqQdb4cG+5b9oaLhUFFUhYgb2zO6VLxHdYXmFMaB jXZ7JXM7FZ8JNzXpRx0tYz2kS3scuPBh0S2lQvBO2jFxMP6WV+bMVPpHAs7ph827aMdQN0qa1ViK/ 3FTooeHdogPctg==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qA9gR-0004K9-RM; Fri, 16 Jun 2023 09:40:12 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Efraim Flashner Subject: Re: bug#63909: [PATCH] home: Add inputrc service. References: <29f421343373bc3655abb9961f254880a295f6f7.1685967547.git.efraim@flashner.co.il> Date: Fri, 16 Jun 2023 15:40:09 +0200 In-Reply-To: <29f421343373bc3655abb9961f254880a295f6f7.1685967547.git.efraim@flashner.co.il> (Efraim Flashner's message of "Mon, 5 Jun 2023 15:19:24 +0300") Message-ID: <87pm5vseyu.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63909 Cc: paren@disroot.org, 63909@debbugs.gnu.org, Andrew Tropin X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! Efraim Flashner skribis: > * gnu/home/services/shells.scm (home-inputrc-service-type, > home-inputrc-configuration): New variables. > (serialize-inputrc-key-bindings, serialize-inputrc-variables, > serialize-inputrc-conditional-constructs, > serialize-inputrc-extra-content, generate-home-inputrc-documentation): > New procedures. Nice! I=E2=80=99d like Andrew and ( to chime in more often :-) but here=E2=80=99s= my take. > + > +;;; > +;;; Documentation. > +;;; >=20=20 > (define (generate-home-shell-profile-documentation) > (generate-documentation > @@ -662,3 +798,10 @@ (define (generate-home-fish-documentation) > `((home-fish-extension > ,home-fish-extension-fields)) > 'home-fish-extension))) > + > +(define (generate-home-inputrc-documentation) > + (string-append > + (generate-documentation > + `((home-inputrc-configuration > + ,home-inputrc-configuration-fields)) > + 'home-inputrc-configuration))) I don=E2=80=99t think we need to keep these procedures in the file. Overall it LGTM, except for one thing: could you add it to =E2=80=98doc/guix.texi=E2=80=99? (The usual template is: an intro giving c= ontext and a cross-reference to the upstream manual, one or two configuration examples with an explanation, and then the reference.) Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 18 04:50:01 2023 Received: (at 63909) by debbugs.gnu.org; 18 Jun 2023 08:50:01 +0000 Received: from localhost ([127.0.0.1]:53164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAo6i-0005Cb-Ey for submit@debbugs.gnu.org; Sun, 18 Jun 2023 04:50:01 -0400 Received: from mail-wm1-f51.google.com ([209.85.128.51]:45104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAo6b-0005Bz-NP for 63909@debbugs.gnu.org; Sun, 18 Jun 2023 04:49:55 -0400 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-3f8fb0e7709so17918505e9.2 for <63909@debbugs.gnu.org>; Sun, 18 Jun 2023 01:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687078187; x=1689670187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=cYUsGkRe2rKsTrlSLm9OKezfz3JDQcrXjsDwAiQi+9Q=; b=oRJylU7OlFndtjjiLf1bWFQ/zuyGXrb5kpwFprKWFBH1OlwOw1GNLwbUTfXlz0F6Y0 Bwcl4fUTeT3sfLjw3draeUozzaeIG9Vxa+CRyzWWg3lA0Q6sVmc05LfGmdBFAqXbC0h4 AMira2h4lVlEgWBCeWKlFv5kWISxBiOHENWeDjjfPDJb4VtFYrd2QSzvYYnskuiRkszL UO6jKh3n5bJsK6oNQqnf9tuEf6kfOLHS3z4jo3d21p9Sm7cYYBFUwR/8GJfF/GlLd2yM p1I5BmS2FrzUe6m4YH567cXnuut6lRLmEpL81ItbWUWZB1STFOpWdeX94wXDZ9Rk0t99 VBSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687078187; x=1689670187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cYUsGkRe2rKsTrlSLm9OKezfz3JDQcrXjsDwAiQi+9Q=; b=d6axEzxSzzLc26hfHgEsJFhYUqjTmFByLYuJd7jq+9zGL/+vEK8gI6BGv5wInHWz5b /OqZcC++dmGUtv0j4GOlnDZ90oSUqO95wR08B3/rCIN/nmMHhPuVxPiFWxsFKGDuSxQr 4fmSEW3IZ+OeSD61qh/UAU+WHttj2+0LnBjQF8zLKFZp4Fj2LWOIFhR8q4RYF1DX5UWE rZEy+5/k0I4jQuBc1RTfXCoIibCNr4VS1toTOcPeCgIJ34tuHc/xx3KqrcWS4ky+W4XS GRpnrBfz4vjUeO28EMWszw1ApmKUrSlbEE2W91/gJnh30ydGGigoIX4T9TtVWhAHYO6q Q1qw== X-Gm-Message-State: AC+VfDzYjIx7emrgBkLhfHJIfWEvbUQIfnfEu1pDY4si9JRMWlStDJjH La4Tj1Au7Eknj8ukYdZbejfsbBWn23gNUw== X-Google-Smtp-Source: ACHHUZ6SHapk94J0lalH0hlNEAMiUZCr0461xWub0WC8oQN+fjA6/aTEIWMF2GYDsfmpeXb2u0QEQA== X-Received: by 2002:a1c:f718:0:b0:3f7:e65b:5252 with SMTP id v24-20020a1cf718000000b003f7e65b5252mr5505773wmh.1.1687078187374; Sun, 18 Jun 2023 01:49:47 -0700 (PDT) Received: from localhost ([37.46.46.3]) by smtp.gmail.com with ESMTPSA id t8-20020a7bc3c8000000b003f6129d2e30sm7233892wmj.1.2023.06.18.01.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 01:49:46 -0700 (PDT) From: Efraim Flashner To: guix-patches@gnu.org, =?UTF-8?q?Ludovic=20Court=C3=A8s?= Subject: [PATCH v2] home: Add inputrc service. Date: Sun, 18 Jun 2023 11:49:15 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: <87pm5vseyu.fsf@gnu.org> References: <87pm5vseyu.fsf@gnu.org> MIME-Version: 1.0 X-Debbugs-Cc: ( , Andrew Tropin , Ludovic Courtès Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 63909 Cc: paren@disroot.org, 63909@debbugs.gnu.org, Efraim Flashner , Andrew Tropin X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) * gnu/home/services/shells.scm (home-inputrc-service-type, home-inputrc-configuration): New variables. (serialize-inputrc-key-bindings, serialize-inputrc-variables, serialize-inputrc-conditional-constructs, serialize-inputrc-extra-content): New procedures. * doc/guix.texi (Shells Home Services): Document it. --- doc/guix.texi | 129 +++++++++++++++++++++++++++++++++ gnu/home/services/shells.scm | 134 ++++++++++++++++++++++++++++++++++- 2 files changed, 262 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9232c82b4b..72ab941243 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42797,6 +42797,135 @@ Shells Home Services @end deftp +@subsubheading Inputrc Profile Service +@cindex inputrc +@cindex readline + +The @uref{https://tiswww.cwru.edu/php/chet/readline/rltop.html, GNU +Readline package} includes Emacs and vi editing modes, with the ability +to customize the configuration with settings in the @file{~/.inputrc} +file. With the @code{gnu home services shells} module, you can setup +your readline configuration in a predictable manner, as shown below. +For more information about configuring an @file{~/.inputrc} file, +@pxref{Readline Init File,,, readline, GNU Readline}. + +@defvar home-inputrc-service-type + +This is the service to setup various @file{.inputrc} configurations. The +settings in @file{.inputrc} are read by all programs which are linked +with GNU Readline. + +Here is an example of a service and its configuration that you could add +to the @code{services} field of your @code{home-environment}: + +@lisp +(service home-inputrc-service-type + (home-inputrc-configuration + (key-bindings + `(("Control-l" . "clear-screen"))) + (variables + `(("bell-style" . "visible") + ("colored-completion-prefix" . #t) + ("editing-mode" . "vi") + ("show-mode-in-prompt" . #t))) + (conditional-constructs + `(("$if mode=vi" . + ,(home-inputrc-configuration + (variables + `(("colored-stats" . #t) + ("enable-bracketed-paste" . #t))))) + ("$else" . + ,(home-inputrc-configuration + (variables + `(("show-all-if-ambiguous" . #t))))) + ("endif" . #t) + ("$include" . "/etc/inputrc") + ("$include" . ,(file-append + (specification->package "readline") + "/etc/inputrc")))))) +@end lisp + +The example above starts with a combination of @code{key-bindings} and +@code{variables}. The @code{conditional-constructs} show how it is +possible to add conditionals and includes. In the example above +@code{colored-stats} is only enabled if the editing mode is @code{vi} +style, and it also reads any additional configuration located in +@file{/etc/inputrc} or in @file{/gnu/store/@dots{}-readline/etc/inputrc}. + +The value associated with a @code{home-inputrc-service-type} instance +must be a @code{home-inputrc-configuration} record, as described below. + +@end defvar + +@anchor{home-inputrc-configuration} +@deftp {Data Type} home-inputrc-configuration +Available @code{home-inputrc-configuration} fields are: + +@table @asis +@item @code{key-bindings} (default: @code{'()}) (type: alist) +Association list of readline key bindings to be added to the +@file{~/.inputrc} file. + +@lisp +'((\"Control-l\" . \"clear-screen\")) +@end lisp + +turns into + +@example +Control-l: clear-screen +@end example + +@item @code{variables} (default: @code{'()}) (type: alist) +Association list of readline variables to set. + +@lisp +'((\"bell-style\" . \"visible\") + (\"colored-completion-prefix\" . #t)) +@end lisp + +turns into + +@example +set bell-style visible +set colored-completion-prefix on +@end example + +@item @code{conditional-constructs} (default: @code{'()}) (type: alist) +Association list of conditionals to add to the initialization file. This +includes @command{$if}, @command{else}, @command{endif} and @command{include} +and they receive a value of another @command{home-inputrc-configuration}. + +@lisp +(conditional-constructs + `((\"$if mode=vi\" . + ,(home-inputrc-configuration + (variables + `((\"show-mode-in-prompt\" . #t))))) + (\"$else\" . + ,(home-inputrc-configuration + (key-bindings + `((\"Control-l\" . \"clear-screen\"))))) + (\"$endif\" . #t))) +@end lisp + +turns into + +@example +$if mode=vi +set show-mode-in-prompt on +$else +Control-l: clear-screen +$endif +@end example + +@item @code{extra-content} (default: @code{""}) (type: text-config) +Extra content appended as-is to the configuration file. Run @command{man +readline} for more information about all the configuration options. + +@end table +@end deftp + @node Mcron Home Service @subsection Scheduled User's Job Execution diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index f05f2221d6..415b5470c5 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2023 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -44,7 +45,10 @@ (define-module (gnu home services shells) home-fish-service-type home-fish-configuration - home-fish-extension)) + home-fish-extension + + home-inputrc-service-type + home-inputrc-configuration)) ;;; Commentary: ;;; @@ -626,6 +630,134 @@ (define home-fish-service-type (description "\ Install and configure Fish, the friendly interactive shell."))) + +;;; +;;; Readline. +;;; + +(define (serialize-inputrc-key-bindings field-name val) + #~(string-append + #$@(map + (match-lambda + ((key . value) + #~(string-append #$key ": " #$value "\n"))) + val))) + +(define (serialize-inputrc-variables field-name val) + #~(string-append + #$@(map + (match-lambda + ((key . #f) + #~(string-append "set " #$key " off\n")) + ((key . #t) + #~(string-append "set " #$key " on\n")) + ((key . value) + #~(string-append "set " #$key " " #$value "\n"))) + val))) + +(define (serialize-inputrc-conditional-constructs field-name val) + #~(string-append + #$@(map + (match-lambda + (("$endif" . _) + "$endif\n") + (("$include" . value) + #~(string-append "$include " #$value "\n")) + ;; TODO: key can only be "$if" or "$else". + ((key . value) + #~(string-append #$key "\n" + #$(serialize-configuration + value + home-inputrc-configuration-fields)))) + val))) + +(define (serialize-inputrc-extra-content field-name value) + #~(if (string=? #$value "") "" (string-append #$value "\n"))) + +(define-configuration home-inputrc-configuration + (key-bindings + (alist '()) + "Association list of readline key bindings to be added to the +@code{~/.inputrc} file. This is where code like this: + +@lisp +'((\"Control-l\" . \"clear-screen\")) +@end lisp + +turns into + +@example +Control-l: clear-screen +@end example" + (serializer serialize-inputrc-key-bindings)) + (variables + (alist '()) + "Association list of readline variables to set. This is where configuration +options like this: + +@lisp +'((\"bell-style\" . \"visible\") + (\"colored-completion-prefix\" . #t)) +@end lisp + +turns into + +@example +set bell-style visible +set colored-completion-prefix on +@end example" + (serializer serialize-inputrc-variables)) + (conditional-constructs + (alist '()) + "Association list of conditionals to add to the initialization file. This +includes @command{$if}, @command{else}, @command{endif} and @command{include} +and they receive a value of another @command{home-inputrc-configuration}. + +@lisp +(conditional-constructs + `((\"$if mode=vi\" . + ,(home-inputrc-configuration + (variables + `((\"show-mode-in-prompt\" . #t))))) + (\"$else\" . + ,(home-inputrc-configuration + (key-bindings + `((\"Control-l\" . \"clear-screen\"))))) + (\"$endif\" . #t))) +@end lisp + +turns into + +@example +$if mode=vi +set show-mode-in-prompt on +$else +Control-l: clear-screen +$endif +@end example" + (serializer serialize-inputrc-conditional-constructs)) + (extra-content + (string "") + "Extra content appended as-is to the configuration file. Run @command{man +readline} for more information about all the configuration options." + (serializer serialize-inputrc-extra-content))) + +(define (home-inputrc-files config) + (list + `(".inputrc" + ,(mixed-text-file "inputrc" + (serialize-configuration + config + home-inputrc-configuration-fields))))) + +(define home-inputrc-service-type + (service-type (name 'inputrc) + (extensions + (list (service-extension home-files-service-type + home-inputrc-files))) + (default-value (home-inputrc-configuration)) + (description "Configure readline in @code{.inputrc}."))) + (define (generate-home-shell-profile-documentation) (generate-documentation base-commit: e4087930f3ad60918689be5f4bca4ce3e22429f5 -- Efraim Flashner רנשלפ םירפא GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 06 09:22:00 2023 Received: (at 63909-done) by debbugs.gnu.org; 6 Jul 2023 13:22:00 +0000 Received: from localhost ([127.0.0.1]:40399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHOvn-0008Bt-LS for submit@debbugs.gnu.org; Thu, 06 Jul 2023 09:22:00 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]:44060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHOvk-0008BM-6n; Thu, 06 Jul 2023 09:21:58 -0400 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3fbc77e769cso7387115e9.0; Thu, 06 Jul 2023 06:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688649710; x=1691241710; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=3VseDBvTF0rV8cXWANcJWXUCjBxMJC+S62WHHKYDt04=; b=e13ZEzDMzZA7ZqfTS1jO1keCSur7FsBJTOCQCEvoK+7rFWo9JvZHft+CH8xtWygHNj HWjoaxq0q1axvmG73hRAtZbqJk9bl5anK1X1j1mDiDo9IGc/LkXCYuWDBbbrWeEcZxHq EDRWdKOHt+uByRkoLTpiTjrg4q+6z+zHcVt2hM9xl5iQE9fo/eqpcsQSC5wQLVDc62d/ Ki6ngcQ/IXcLE8b8Icrr5qcqCpoJINaSsJ8E1GuPsA8ugaRjRgCwrV9N5k2wFUKZMIkb Y/ZaWz/y87cQSlScvhOFVHNSlC0hylBfwX6KwdMd2W0H6ZCRtICPiAU+NUFM39FrT1iL hEIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688649710; x=1691241710; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3VseDBvTF0rV8cXWANcJWXUCjBxMJC+S62WHHKYDt04=; b=Fpz5wkQaHdU9PgAomG5Mab3QEuQgIVACyScuMZF9MOk1U6q7htWJTi57LmtHUFtMYT s5fHTb6UirIlcMS41NB+9Z9PfEneYB2kLDGTODW/Gue7ZyVnTmy+plNKKm9v4UbZ/9o4 fqEYj4av/6rhQW/8a8tuDUNZMM0NO19ckW7c3fgl5X6ivCHeY/P5YKAnWgCltIx9vb+A LeBuWRfC/N7Fqw1ANwqZMp+c3kqbGX2ySIuCmxZ5SOuIukJ44SkT+J8+NqRvP1uGJXsJ UEB+5o0GvA0jH8Qmca5doBD2bCklJWrqNfpZLNgEBK/WtLHS3yHnqsKLYx+JrutXdtQ1 RvVg== X-Gm-Message-State: ABy/qLbNawj/8yy4ZBigJUcY29aTFi+B1+iiYdessrQEV1YM/yx9SFGf m9j/jiDRyxe1kW4tB3VVTMaoj+Rk3BXG9g== X-Google-Smtp-Source: APBJJlGlNe8XqxdhQjsyqM1YrhQIu4zKBdXvOVoiW7oUdq9hPw3ZI6kP6xEbnshZL/HQzM+vYUgtNw== X-Received: by 2002:a1c:7318:0:b0:3fb:b61f:c719 with SMTP id d24-20020a1c7318000000b003fbb61fc719mr1364430wmb.33.1688649710253; Thu, 06 Jul 2023 06:21:50 -0700 (PDT) Received: from localhost ([2a02:ed3:914:7600:b62e:99ff:fef0:7bc0]) by smtp.gmail.com with ESMTPSA id x16-20020a1c7c10000000b003fbe4cecc3bsm5088936wmc.16.2023.07.06.06.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 06:21:49 -0700 (PDT) Date: Thu, 6 Jul 2023 16:21:48 +0300 From: Efraim Flashner To: 64148-done@debbugs.gnu.org, 63909-done@debbugs.gnu.org Subject: Re: bug#64148: Acknowledgement ([PATCH v2] home: Add inputrc service.) Message-ID: Mail-Followup-To: Efraim Flashner , 64148-done@debbugs.gnu.org, 63909-done@debbugs.gnu.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="k3L8l+eCTOi5/MGO" Content-Disposition: inline In-Reply-To: X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 63909-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) --k3L8l+eCTOi5/MGO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Patch pushed --=20 Efraim Flashner =D7=A8=D7=A0=D7=A9=D7=9C=D7=A4 = =D7=9D=D7=99=D7=A8=D7=A4=D7=90 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --k3L8l+eCTOi5/MGO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmSmv+wACgkQQarn3Mo9 g1HoehAAoWfcKllstQgJgsSDBe6wc/JA2qDDisgtlKkWVqXqDWsaO5p6KVkQCcI7 euTt+HERrtJkYFTCeQf/QBMkE05HWI9AqignJZCw/LgjWhCT45KIOhHZBU00ScIS PWtH28RVVOVgLMQoSU+PakHsb3tpHbYy4L6v8r5PQcM9PH7PXKbFak1CZkOSM2FS WVoLipfq/wspxM1csFT7qCLpgXHfQGpdC2zDgLUS1ef/zBBlrp4nAdt+/Rcq1ajF unwe6X4IgHgXeCWb5Jpg42cbhy+9psKPabbCy2e+hFdlU9iPqWCRIMBIbTqcBxZU EDou9Bcq0CEWscI8egusbP1sQicY2uqEe47bNEVz6FKBzFncBsT+2eyawRFM9AiT mlRCtLeLhMZ1dMQ1vR8n3iOnlNySVgrWu1ot8bj3ytd6w4Z9sAdJdz4b1SOwzh69 njy0PhgtT43M6jvA3HgtCYOgpfN8cl7lY1KpZdl89XihBoZAYarqrN25wIENY7A7 TY/UMoWydhT/HNPlzs73uPs5dVPoC0XTKO8pD6vNFJCTL5zBp0G9ExElV0M1MdTl 8YtUaXyO6l+nvV7mRSXmQU03pXIpECRlW7ccsPEcegR81Xkf6IWzTIa95k26P+Y1 cM4vehBR7d6KWjGW5lkB8k51qlpWIaefnlQL86NkjkWoSK5BcmY= =7AsR -----END PGP SIGNATURE----- --k3L8l+eCTOi5/MGO-- From unknown Sun Aug 10 16:51:15 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 04 Aug 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator