From 66ffa2470f7fae22b88c03c27aa7f0baf6906915 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 2 Nov 2024 17:58:37 +0100 Subject: refactor(modules/legacy/less): Migrate to `by-name` --- modules/by-name/le/less/command.less | 127 +++++++++++++++++++++++++++ modules/by-name/le/less/env.less | 2 + modules/by-name/le/less/line-edit.less | 29 ++++++ modules/by-name/le/less/module.nix | 32 +++++++ modules/home.legacy/conf/default.nix | 1 - modules/home.legacy/conf/less/command.less | 127 --------------------------- modules/home.legacy/conf/less/default.nix | 18 ---- modules/home.legacy/conf/less/env.less | 2 - modules/home.legacy/conf/less/line-edit.less | 29 ------ 9 files changed, 190 insertions(+), 177 deletions(-) create mode 100644 modules/by-name/le/less/command.less create mode 100644 modules/by-name/le/less/env.less create mode 100644 modules/by-name/le/less/line-edit.less create mode 100644 modules/by-name/le/less/module.nix delete mode 100644 modules/home.legacy/conf/less/command.less delete mode 100644 modules/home.legacy/conf/less/default.nix delete mode 100644 modules/home.legacy/conf/less/env.less delete mode 100644 modules/home.legacy/conf/less/line-edit.less (limited to 'modules') diff --git a/modules/by-name/le/less/command.less b/modules/by-name/le/less/command.less new file mode 100644 index 00000000..95b79b02 --- /dev/null +++ b/modules/by-name/le/less/command.less @@ -0,0 +1,127 @@ +#command +\r forw-line +\n forw-line +e forw-line +t forw-line +\kd forw-line +ˆE forw-line +ˆN forw-line +n back-line +y back-line +ˆY back-line +ˆK back-line +ˆP back-line +T forw-line-force +N back-line-force +Y back-line-force +d forw-scroll +ˆD forw-scroll +u back-scroll +ˆU back-scroll +\40 forw-screen +f forw-screen +ˆF forw-screen +ˆV forw-screen +\kD forw-screen +b back-screen +ˆB back-screen +\ev back-screen +\kU back-screen +z forw-window +w back-window +\e\40 forw-screen-force +F forw-forever +\eF forw-until-hilite +R repaint-flush +r repaint +ˆR repaint +ˆL repaint +\en undo-hilite +\eU clear-search +g goto-line +\kh goto-line +< goto-line +\e< goto-line +p percent +% percent +\e[ left-scroll +\e] right-scroll +\e( left-scroll +\e) right-scroll +\kl left-scroll +\kr right-scroll +\e{ no-scroll +\e} end-scroll +{ forw-bracket {} +} back-bracket {} +( forw-bracket () +) back-bracket () +[ forw-bracket [] +] back-bracket [] +\eˆF forw-bracket +\eˆB back-bracket +G goto-end +\e> goto-end +> goto-end +\ke goto-end +\eG goto-end-buffered += status +ˆG status +:f status +/ forw-search +? back-search +\e/ forw-search * +\e? back-search * +l repeat-search +\el repeat-search-all +L reverse-search +\eL reverse-search-all +& filter +m set-mark +M set-mark-bottom +\em clear-mark +' goto-mark +ˆXˆX goto-mark +E examine +:e examine +ˆXˆV examine +:n next-file +:p prev-file +j next-tag +J prev-tag +:x index-file +:d remove-file +- toggle-option +:t toggle-option t +s toggle-option o + ## Use a long option name by starting the + ## extra string with ONE dash; eg: + ## s toggle-option -log-file\n +_ display-option +| pipe +v visual +! shell +# pshell ++ firstcmd +H help +h help +V version +0 digit +1 digit +2 digit +3 digit +4 digit +5 digit +6 digit +7 digit +8 digit +9 digit +q quit +Q quit +:q quit +:Q quit +ZZ quit + +# Stop processing (and ignore less' default values) +# (// FIXME: This stopped working and thus we just comment it out <2024-08-03> ) +# stop diff --git a/modules/by-name/le/less/env.less b/modules/by-name/le/less/env.less new file mode 100644 index 00000000..30f7645d --- /dev/null +++ b/modules/by-name/le/less/env.less @@ -0,0 +1,2 @@ +#env +LESS = -R --use-color --incsearch --modelines=2 --save-marks --wordwrap --status-line diff --git a/modules/by-name/le/less/line-edit.less b/modules/by-name/le/less/line-edit.less new file mode 100644 index 00000000..a7e889db --- /dev/null +++ b/modules/by-name/le/less/line-edit.less @@ -0,0 +1,29 @@ +#line-edit +\t forw-complete +\17 back-complete +\e\t back-complete +ˆL expand +ˆV literal +ˆA literal +\es right +\kr right +\eh left +\kl left +\eb word-left +\e\kl word-left +\ew word-right +\e\kr word-right +\ei insert +\ex delete +\kx delete +\eX word-delete +\ekx word-delete +\e\b word-backspace +\e0 home +\kh home +\e$ end +\ke end +\en up +\ku up +\et down +ˆG abort diff --git a/modules/by-name/le/less/module.nix b/modules/by-name/le/less/module.nix new file mode 100644 index 00000000..f2475b73 --- /dev/null +++ b/modules/by-name/le/less/module.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + ... +}: let + cfg = config.soispha.programs.less; +in { + options.soispha.programs.less = { + enable = lib.mkEnableOption "less"; + }; + + config = lib.mkIf cfg.enable { + home-manager.users.soispha = { + home.sessionVariables = { + PAGER = "less"; + MANPAGER = "less --color=d+r --color=u+b"; + + # These are added here because adding them in the lesskey file somehow doesn't work. + LESSHISTSIZE = 10000; + LESSHISTFILE = "${config.home-manager.users.soispha.xdg.dataHome}/less/history"; + }; + + programs.less = { + enable = true; + keys = + builtins.readFile ./command.less + + builtins.readFile ./line-edit.less + + builtins.readFile ./env.less; + }; + }; + }; +} diff --git a/modules/home.legacy/conf/default.nix b/modules/home.legacy/conf/default.nix index 39ae1cd3..138e2080 100644 --- a/modules/home.legacy/conf/default.nix +++ b/modules/home.legacy/conf/default.nix @@ -14,7 +14,6 @@ ./iamb ./keepassxc ./latexindent - ./less ./mail ./mako ./mbsync diff --git a/modules/home.legacy/conf/less/command.less b/modules/home.legacy/conf/less/command.less deleted file mode 100644 index 95b79b02..00000000 --- a/modules/home.legacy/conf/less/command.less +++ /dev/null @@ -1,127 +0,0 @@ -#command -\r forw-line -\n forw-line -e forw-line -t forw-line -\kd forw-line -ˆE forw-line -ˆN forw-line -n back-line -y back-line -ˆY back-line -ˆK back-line -ˆP back-line -T forw-line-force -N back-line-force -Y back-line-force -d forw-scroll -ˆD forw-scroll -u back-scroll -ˆU back-scroll -\40 forw-screen -f forw-screen -ˆF forw-screen -ˆV forw-screen -\kD forw-screen -b back-screen -ˆB back-screen -\ev back-screen -\kU back-screen -z forw-window -w back-window -\e\40 forw-screen-force -F forw-forever -\eF forw-until-hilite -R repaint-flush -r repaint -ˆR repaint -ˆL repaint -\en undo-hilite -\eU clear-search -g goto-line -\kh goto-line -< goto-line -\e< goto-line -p percent -% percent -\e[ left-scroll -\e] right-scroll -\e( left-scroll -\e) right-scroll -\kl left-scroll -\kr right-scroll -\e{ no-scroll -\e} end-scroll -{ forw-bracket {} -} back-bracket {} -( forw-bracket () -) back-bracket () -[ forw-bracket [] -] back-bracket [] -\eˆF forw-bracket -\eˆB back-bracket -G goto-end -\e> goto-end -> goto-end -\ke goto-end -\eG goto-end-buffered -= status -ˆG status -:f status -/ forw-search -? back-search -\e/ forw-search * -\e? back-search * -l repeat-search -\el repeat-search-all -L reverse-search -\eL reverse-search-all -& filter -m set-mark -M set-mark-bottom -\em clear-mark -' goto-mark -ˆXˆX goto-mark -E examine -:e examine -ˆXˆV examine -:n next-file -:p prev-file -j next-tag -J prev-tag -:x index-file -:d remove-file -- toggle-option -:t toggle-option t -s toggle-option o - ## Use a long option name by starting the - ## extra string with ONE dash; eg: - ## s toggle-option -log-file\n -_ display-option -| pipe -v visual -! shell -# pshell -+ firstcmd -H help -h help -V version -0 digit -1 digit -2 digit -3 digit -4 digit -5 digit -6 digit -7 digit -8 digit -9 digit -q quit -Q quit -:q quit -:Q quit -ZZ quit - -# Stop processing (and ignore less' default values) -# (// FIXME: This stopped working and thus we just comment it out <2024-08-03> ) -# stop diff --git a/modules/home.legacy/conf/less/default.nix b/modules/home.legacy/conf/less/default.nix deleted file mode 100644 index 9991ebef..00000000 --- a/modules/home.legacy/conf/less/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{config, ...}: { - home.sessionVariables = { - PAGER = "less"; - MANPAGER = "less --color=d+r --color=u+b"; - - # These are added here because adding them in the lesskey file somehow doesn't work. - LESSHISTSIZE = 10000; - LESSHISTFILE = "${config.xdg.dataHome}/less/history"; - }; - - programs.less = { - enable = true; - keys = - builtins.readFile ./command.less - + builtins.readFile ./line-edit.less - + builtins.readFile ./env.less; - }; -} diff --git a/modules/home.legacy/conf/less/env.less b/modules/home.legacy/conf/less/env.less deleted file mode 100644 index 30f7645d..00000000 --- a/modules/home.legacy/conf/less/env.less +++ /dev/null @@ -1,2 +0,0 @@ -#env -LESS = -R --use-color --incsearch --modelines=2 --save-marks --wordwrap --status-line diff --git a/modules/home.legacy/conf/less/line-edit.less b/modules/home.legacy/conf/less/line-edit.less deleted file mode 100644 index a7e889db..00000000 --- a/modules/home.legacy/conf/less/line-edit.less +++ /dev/null @@ -1,29 +0,0 @@ -#line-edit -\t forw-complete -\17 back-complete -\e\t back-complete -ˆL expand -ˆV literal -ˆA literal -\es right -\kr right -\eh left -\kl left -\eb word-left -\e\kl word-left -\ew word-right -\e\kr word-right -\ei insert -\ex delete -\kx delete -\eX word-delete -\ekx word-delete -\e\b word-backspace -\e0 home -\kh home -\e$ end -\ke end -\en up -\ku up -\et down -ˆG abort -- cgit 1.4.1