From: Thomas Walker Lynch Date: Fri, 7 Nov 2025 10:21:40 +0000 (+0000) Subject: initial commit X-Git-Url: https://git.reasoningtechnology.com/style/static/git-logo.png?a=commitdiff_plain;h=6b4d12ca58f54d6bea69c67c80e421b3db7181a9;p=subu-incommon%2F.git initial commit --- 6b4d12ca58f54d6bea69c67c80e421b3db7181a9 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..937dfaa --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ + +# no hidden files in the incommon project +.* + +# well accept for the .git stuff +!.gitignore +!.gitattributes +!.gitmodules +!.gitkeep + +# If you use GitHub workflows, uncomment these: +# !.github/ +# !.github/** + +# Emacs, nano, etc. +*~ +.elc +.auto-save-list +.tramp +.#* + +.bak + +__pycache__/ +*.py[cod] +*$py.class + +# VS Code +.vscode/ + +# JetBrains +.idea/ + diff --git a/Authorization b/Authorization new file mode 100644 index 0000000..e69de29 diff --git a/XCompose b/XCompose new file mode 100644 index 0000000..0964a42 --- /dev/null +++ b/XCompose @@ -0,0 +1,243 @@ +# Author: Thomas Walker Lynch +# 2023-10-24 +# MIT license + +# I purposely left out prior definitions so as to support namespaces as noted below. +# include "/usr/share/X11/locale/en_US.UTF-8/Compose" + +# The goal here is not to include all of unicode. That would be silly, as +# typing compose characters is cumbersome. If a person wants to use a +# different script, that person should change the keyboard layout setting. +# This file is for supporting math and science writing in English, and +# for supporting accents. + + +#-------------------------------------------------------------------------------- +# all the special characters have as their origins tricks played on +# manual typewriters. Thus this .Xcompose file defines each sepcial +# character by the character we start with, followed by a description +# of what we do with it. As examples, double striking letters, turning +# them upside down, typing a slash through it, etc. +# +# ... : # comment +# +# Be starting with a namespace character we reduce the problem of potential +# aliasing to that namespace. By ending each sequence with a , by +# hitting the space bar, we may make a prefix sequence to a longer sequence +# unique. In this manner we may add more than one typesetting trick to a +# single character. +# + +#-------------------------------------------------------------------------------- +# name spaces +# L - Latin +# G - Greek +# m - math +# + +#-------------------------------------------------------------------------------- +# typesetting instructions +# +# ' : add accent +# ` : add accent agui +# : : place double dot over +# +# d : doublstrike +# +# u : upside down +# r : rotate right +# l : rotate left +# b : backwards +# o : occlusion (originally typed by placing another piece of paper to chop part off) +# +# / : strike through +# - : overstrike with a - (underscore is used for subscript) +# s : put a square around it +# c : put a circle around it +# +# ^ : superscript +# _ : subscript + +#-------------------------------------------------------------------------------- +# Latin + +# Double struck + : "𝔸" U1D538 # double-struck capital A + : "𝔹" U1D539 # double-struck capital B + : "ℂ" U2102 # double-struck capital C + : "𝔻" U1D53B # double-struck capital D + : "𝔼" U1D53C # double-struck capital E + : "𝔽" U1D53D # double-struck capital F + : "𝔾" U1D53E # double-struck capital G + : "ℍ" U210D # double-struck capital H + : "𝕀" U1D540 # double-struck capital I + : "𝕁" U1D541 # double-struck capital J + : "𝕂" U1D542 # double-struck capital K + : "𝕃" U1D543 # double-struck capital L + : "𝕄" U1D544 # double-struck capital M + : "ℕ" U2115 # double-struck capital N + : "𝕆" U1D546 # double-struck capital O +

: "𝕡" U1D561 # double-struck lowercase p + : "𝕢" U1D562 # double-struck lowercase q + : "𝕣" U1D563 # double-struck lowercase r + : "𝕤" U1D564 # double-struck lowercase s + : "𝕥" U1D565 # double-struck lowercase t + : "𝕦" U1D566 # double-struck lowercase u + : "𝕧" U1D567 # double-struck lowercase v + : "𝕨" U1D568 # double-struck lowercase w + : "𝕩" U1D569 # double-struck lowercase x + : "𝕪" U1D56A # double-struck lowercase y + : "𝕫" U1D56B # double-struck lowercase z + +# accented letters + : "á" U00E1 # lowercase a with acute accent + : "à" U00E0 # lowercase a with grave accent + : "ä" U00E4 # lowercase a with umlaut + : "â" U00E2 # lowercase a with circumflex + : "ã" U00E3 # lowercase a with tilde + : "æ" U00E6 # lowercase ae diphthong + : "ç" U00E7 # lowercase c with cedilla + : "é" U00E9 # lowercase e with acute accent + : "è" U00E8 # lowercase e with grave accent + : "ë" U00EB # lowercase e with umlaut + : "ê" U00EA # lowercase e with circumflex + : "í" U00ED # lowercase i with acute accent + : "ì" U00EC # lowercase i with grave accent + : "ï" U00EF # lowercase i with umlaut + : "î" U00EE # lowercase i with circumflex + : "ñ" U00F1 # lowercase n with tilde + : "ó" U00F3 # lowercase o with acute accent + : "ò" U00F2 # lowercase o with grave accent + : "ö" U00F6 # lowercase o with umlaut + : "ô" U00F4 # lowercase o with circumflex + : "õ" U00F5 # lowercase o with tilde + : "œ" U0153 # lowercase oe diphthong + + +# #-------------------------------------------------------------------------------- +# Greek + + : "Α" U0391 # greek capital letter alpha + : "Β" U0392 # greek capital letter beta + : "Γ" U0393 # greek capital letter gamma + : "Δ" U0394 # greek capital letter delta + : "Ε" U0395 # greek capital letter epsilon + : "Ζ" U0396 # greek capital letter zeta + : "Η" U0397 # greek capital letter eta + : "Θ" U0398 # greek capital letter theta + : "Ι" U0399 # greek capital letter iota + : "Κ" U039A # greek capital letter kappa + : "Λ" U039B # greek capital letter lamda + : "Μ" U039C # greek capital letter mu + : "Ν" U039D # greek capital letter nu + : "Ξ" U039E # greek capital letter xi + : "Ο" U039F # greek capital letter omicron +

: "Π" U03A0 # greek capital letter pi + : "Ρ" U03A1 # greek capital letter rho + : "Σ" U03A3 # greek capital letter sigma + : "Τ" U03A4 # greek capital letter tau + : "Υ" U03A5 # greek capital letter upsilon + : "Φ" U03A6 # greek capital letter phi + : "Χ" U03A7 # greek capital letter chi + : "Ψ" U03A8 # greek capital letter psi + : "Ω" U03A9 # greek capital letter omega + + : "α" u03b1 # greek small letter alpha + : "β" u03b2 # greek small letter beta + : "γ" u03b3 # greek small letter gamma + : "δ" u03b4 # greek small letter delta + : "ε" u03b5 # greek small letter epsilon + : "ζ" u03b6 # greek small letter zeta + : "η" u03b7 # greek small letter eta + : "θ" u03b8 # greek small letter theta + : "ι" u03b9 # greek small letter iota + : "κ" u03ba # greek small letter kappa + : "λ" u03bb # greek small letter lamda + : "μ" u03bc # greek small letter mu + : "ν" u03bd # greek small letter nu + : "ξ" u03be # greek small letter xi + : "ο" u03bf # greek small letter omicron +

: "π" u03c0 # greek small letter pi + : "ρ" u03c1 # greek small letter rho + : "σ" u03c3 # greek small letter sigma + : "τ" u03c4 # greek small letter tau + : "υ" u03c5 # greek small letter upsilon + : "φ" u03c6 # greek small letter phi + : "χ" u03c7 # greek small letter chi + : "ψ" u03c8 # greek small letter psi + : "ω" u03c9 # greek small letter omega + +# -------------------------------------------------------------------------------- +# math + + : "×" U00D7 # multiplication sign + : "·" U00B7 # middle dot + : "⊡" U22A1 # squared dot operator + + : "≠" U2260 # not equal to + + : "≤" U2264 # less-than or equal to + : "≥" U2265 # greater-than or equal to + <0> : "∅" U2205 # empty set + + + : "∈" U2208 # element of + : "∉" U2209 # not an element of + + : "∪" U222A # union + : "⋂" U22C2 # n-ary interesection + : "⊂" U2282 # subset of + : "⊆" U2286 # subset of or equal to + : "⊃" U2283 # superset of + : "⊇" U2287 # superset of or equal to + + : "∩" U2229 # intersection + : "∁" U2201 # complement + + : "∃" U2203 # there exists + : "∄" U2204 # there does not exist + : "∀" U2200 # for all + + : "¬" U00AC # not sign + + : "⋁" U2228 # big vee, n-ary logical or + : "⋀" U22C0 # big wedge n-ary LOGICAL AND + + : "∨" U2228 # little vee logical or + : "∧" U2227 # little weddge logical and + : "⊼" U22BC # NAND + : "➜" U27A0 # implies + <=> : "⇒" U21D2 # implies + <=> : "⇔" U21D4 # if and only if + + : "⟳" U27F3 # clockwise gapped circle arrow, 'do' or 'for' operator + : "◨" U25E8 # square with right inked 'rightmost' 'maximum' operator + : "◧" U25E7 # square with left inked 'leftmost' 'minimum' operator + : "☥" U2625 # ankh diff --git a/executable/2025-06-13_subu.sh b/executable/2025-06-13_subu.sh new file mode 100644 index 0000000..f734616 --- /dev/null +++ b/executable/2025-06-13_subu.sh @@ -0,0 +1,43 @@ + +#!/bin/bash +# set -x + +subu="$1" +if [ -z "$subu" ]; then + echo "No subuser name supplied" + exit 1 +fi + +# actual subu user name and subu home directory +subu_user="Thomas-$subu" +subu_dir="/home/Thomas/subu_data/$subu" + +# detect current display and authority +display_val="${DISPLAY:-:0}" +authority_val="${XAUTHORITY:-$HOME/.Xauthority}" + +# construct guest's authority path (destination) +subu_Xauthority_path="$HOME/subu/$subu/.Xauthority" + +if [ "$XDG_SESSION_TYPE" = "wayland" ]; then + # Wayland/XWayland uses a temporary XAUTHORITY file (already in $XAUTHORITY) + echo "Wayland session detected" + xhost +SI:localuser:"$subu_user" +else + # X11 session – extract the proper cookie + echo "X11 session detected" + mkdir -p "$(dirname "$subu_Xauthority_path")" + touch "$subu_Xauthority_path" + xauth extract "$subu_Xauthority_path" "$display_val" +fi + +# allow guest processes to outlive login +sudo loginctl enable-linger "$subu_user" + +# Launch the subuser shell with DISPLAY and XAUTHORITY +sudo machinectl shell "$subu_user"@ /bin/bash -c " + export DISPLAY='$display_val'; + export XAUTHORITY='$subu_Xauthority_path'; + umask 077 + exec \"\$SHELL\" -l +" diff --git a/executable/Z b/executable/Z new file mode 100755 index 0000000..7b77248 --- /dev/null +++ b/executable/Z @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/date -u +"%Y-%m-%d %H:%M:%SZ" diff --git a/executable/cat_named b/executable/cat_named new file mode 100755 index 0000000..3f208fc --- /dev/null +++ b/executable/cat_named @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# cat_named — print a header + filename + UTC mtime, then file contents + +set -euo pipefail + +hr() { printf '%*s\n' 80 '' | tr ' ' '-'; } + +if [[ $# -eq 0 ]]; then + echo "usage: $0 " >&2 + exit 1 +fi + +for f in "$@"; do + if [[ ! -f "$f" ]]; then + echo "skip (not a regular file): $f" >&2 + continue + fi + ts="$(date -u -r "$f" +'%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || stat -c '%y' "$f" 2>/dev/null)" + hr + printf '%s %s\n\n' "$f" "$ts" + cat -- "$f" + printf '\n' +done diff --git a/executable/echo b/executable/echo new file mode 100755 index 0000000..48db1eb --- /dev/null +++ b/executable/echo @@ -0,0 +1,163 @@ +#!/usr/bin/env python3 +""" +echo replacement in Python + +Options: + -n do not output the trailing newline + -e enable interpretation of backslash escapes + -E disable interpretation of backslash escapes (default) + -v vertical list (one argument per line) + -s sort arguments (locale-aware, like ls) + +Combinations: + -vs / -sv sort arguments, then print vertically + -s (alone) sorted, multi-column output (like ls) +""" + +import math +import shutil +import sys +import codecs +import locale + + +def decode_escapes(s): + """ + Interpret C-style backslash escapes, similar to `echo -e`. + Uses Python's unicode_escape; handles \\n, \\t, \\xNN, \\0NNN, etc. + """ + try: + return codecs.decode(s, "unicode_escape") + except Exception: + return s + + +def format_columns(items, width): + """ + Format a list of strings into multi-column text, roughly like `ls`. + Returns a single string with embedded newlines but no trailing newline. + """ + if not items: + return "" + + maxlen = max(len(s) for s in items) + col_width = maxlen + 2 + + if width <= 0: + width = 80 + + cols = max(1, width // col_width) + rows = (len(items) + cols - 1) // cols + + lines = [] + for r in range(rows): + row_items = [] + for c in range(cols): + i = c * rows + r + if i >= len(items): + continue + s = items[i] + if c == cols - 1 or i + rows >= len(items): + row_items.append(s) + else: + row_items.append(s.ljust(col_width)) + lines.append("".join(row_items)) + + return "\n".join(lines) + + +def echo(args, interpret_escapes, no_newline, vertical, sort_items): + """ + Core echo implementation. + Writes to stdout and returns an exit status code. + """ + if interpret_escapes: + args = [decode_escapes(a) for a in args] + + if sort_items: + # Locale-aware sort, to match ls behavior under current locale + args = sorted(args, key=locale.strxfrm) + + if vertical: + out = "\n".join(args) + elif sort_items: + width = shutil.get_terminal_size(fallback=(80, 24)).columns + out = format_columns(args, width) + else: + out = " ".join(args) + + if no_newline: + sys.stdout.write(out) + sys.stdout.flush() + else: + sys.stdout.write(out + "\n") + sys.stdout.flush() + + return 0 + + +def CLI(argv): + """ + Command-line interface: parse argv, then call echo(). + """ + # Use environment locale for collation, like ls + try: + locale.setlocale(locale.LC_COLLATE, "") + except locale.Error: + # If locale is broken, we just fall back to C collation + pass + + interpret_escapes = False + no_newline = False + vertical = False + sort_items = False + + args = [] + stop_opts = False + i = 1 + + while i < len(argv): + arg = argv[i] + + if stop_opts: + args.append(arg) + i += 1 + continue + + if arg == "--": + stop_opts = True + i += 1 + continue + + if arg.startswith("-") and len(arg) > 1: + unknown = False + for ch in arg[1:]: + if ch == "n": + no_newline = True + elif ch == "e": + interpret_escapes = True + elif ch == "E": + interpret_escapes = False + elif ch == "v": + vertical = True + elif ch == "s": + sort_items = True + else: + unknown = True + break + + if unknown: + args.append(arg) + stop_opts = True + + i += 1 + continue + + args.append(arg) + i += 1 + + return echo(args, interpret_escapes, no_newline, vertical, sort_items) + + +if __name__ == "__main__": + raise SystemExit(CLI(sys.argv)) diff --git a/executable/gen_email b/executable/gen_email new file mode 100755 index 0000000..a1057d9 --- /dev/null +++ b/executable/gen_email @@ -0,0 +1,99 @@ +#!/usr/bin/python3 + +#-------------------------------------------------------------------------------- +# generate a random string length n of form +# "" | [A-Za-z^IloO] | [A-Za-z^IloO][0-9A-Za-z_-^IloO01]*[A-Za-z^IloO] +# + +import sys +import random + +# note missing IloO01. +# period and comman might be difficult, light period might be missed +# capital I in san-serif font looks like number 1. +# email addresses are not case sensitive +# these are not all the legal characters, but rather the ones we think are legal and legible +legal_chars_end = "abcdefghijkmnpqrstuvwxz" +legal_chars = "23456789abcdefghijkmnpqrstuvwxz" + +def index(): + return random.randrange(0 ,len(legal_chars)) + +def index_end(): + return random.randrange(0 ,len(legal_chars_end)) + +def char(): + return legal_chars[index()] + +def char_end(): + return legal_chars_end[index_end()] + +def string(n=6): + if n < 0 : raise Exception("string called with negative length") + if n == 0 : return "" + + result = char_end() + if n == 1: return result + + for _ in range(n-2): result += char() + result += char_end() + + return result + +def test_0(): + limit = 1e7 # surely by then + i = 0 + c = char() + while c != '~' and i < limit: + i += 1 + c = char() + print(i) + return i < limit + +def test_1(): + limit = 1e7 # surely by then + i = 0 + c = char() + while c != '0' and i < limit: + i += 1 + c = char() + print(i) + return i < limit + +def test_2(): + limit = 1e7 # surely by then + i = 0 + c = char_end() + while c != 'z' and i < limit: + i += 1 + c = char_end() + print(i) + return i < limit + +def test_3 (): + limit = 1e7 # surely by then + i = 0 + c = char_end() + while c != 'A' and i < limit: + i += 1 + c = char_end() + print(i) + return i < limit + +def test_4(): + s0 = string() + s1 = string(10) + s2 = string(100) + + print(s0) + print(s1) + print(s2) + + return len(s0)==6 and len(s1)==10 and len(s2)==100 + + +n=6 +if len(sys.argv) > 1: + n = int(sys.argv[1]) +print(string(n)) + diff --git a/executable/gen_passwd b/executable/gen_passwd new file mode 100755 index 0000000..d7cc5d4 --- /dev/null +++ b/executable/gen_passwd @@ -0,0 +1,96 @@ +#!/usr/bin/python3 + +#-------------------------------------------------------------------------------- +# generate a random string length n of form +# "" | [A-Za-z^IloO] | [A-Za-z^IloO][0-9A-Za-z_-^IloO01]*[A-Za-z^IloO] +# + +import sys +import random + +#debug = True +debug = False + +# note missing IloO01. +# period and comman might be difficult, light period might be missed +# capital I in san-serif font looks like number 1. +# zero and oh of course +# SNCF does not take an & as a special hmm. +chars_alpha_small = "abcdefghijkmnpqrstuvwxz" +chars_alpha_big = "ABCDEFGHJKLMNPQRSTUVWXYZ" +chars_special = "+-_$.,;?" +chars_numeric = "23456789" + +sets_leftmost=[chars_alpha_small ,chars_alpha_big] +sets_standard=[chars_alpha_small ,chars_alpha_big ,chars_special ,chars_numeric] +sets_rightmost=[chars_alpha_small ,chars_alpha_big ,chars_numeric] + +def set_psets(sets): + len_sum = sum(len(x) for x in sets) + psets = [len(x)/len_sum + 1e-7 for x in sets] + if debug: print("psets" ,psets ,"sum:" ,sum(psets)) + return psets + +def choose_set(sets): + psets = set_psets(sets) + x = random.random() + if debug: print("x:" ,x) + if len(psets) == 0: return 0 + p = psets[0] + choice = len(psets) - 1 + i = 0 + while i != len(psets) - 1: + if x <= p : + choice = i + break + i += 1 + p += psets[i] + if debug: print("choice:" ,choice) + return choice + +def get_char_set(set): + index = random.randrange(0 ,len(set)) + return set[index] + +def get_char(sets): + set = sets[choose_set(sets)] + return get_char_set(set) + +def get_string(n): + if n < 0 : raise Exception("string called with negative length") + if n == 0: return "" + if n == 1: return get_char_set(chars_alpha) + + result = "" + result += get_char(sets_leftmost) + for _ in range(n-2): result += get_char(sets_standard) + result += get_char(sets_rightmost) + + return result + +def get_passwd(n ,strict): + s = get_string(n) + while strict: + has_special = any(i in s for i in chars_special) + has_numeric = any(i in s for i in chars_numeric) + if debug: print("strict:" ,has_special ,has_numeric) + if has_special and has_numeric: + break + s = get_string(n) + return s + +strict = False +n=9 +for arg in sys.argv[1:]: + if arg.isdigit(): n = int(arg) + if arg == "strict": strict = True + +if debug: + print("n:" ,n) + print("strict:" ,strict) + +pw = get_passwd(n ,strict) +print(pw) +sys.exit(0) + + diff --git a/executable/gen_sig b/executable/gen_sig new file mode 100755 index 0000000..c6b254b --- /dev/null +++ b/executable/gen_sig @@ -0,0 +1,96 @@ +#!/usr/bin/python3 + +#-------------------------------------------------------------------------------- +# generate a random string length n of form +# + +import sys +import random + +# note missing IloO01. +# period and comman might be difficult, light period might be missed +# capital I in san-serif font looks like number 1. +legal_chars_end = "abcdefghjkmnpqrstuvwxz" +legal_chars = "23456789abcdefghijkmnpqrstuvwxz" + +def index(): + return random.randrange(0 ,len(legal_chars)) + +def index_end(): + return random.randrange(0 ,len(legal_chars_end)) + +def char(): + return legal_chars[index()] + +def char_end(): + return legal_chars_end[index_end()] + +def string(n=6): + if n < 0 : raise Exception("string called with negative length") + if n == 0 : return "" + + result = char_end() + if n == 1: return result + + for _ in range(n-2): result += char() + result += char_end() + + return result + +def test_0(): + limit = 1e7 # surely by then + i = 0 + c = char() + while c != '~' and i < limit: + i += 1 + c = char() + print(i) + return i < limit + +def test_1(): + limit = 1e7 # surely by then + i = 0 + c = char() + while c != '0' and i < limit: + i += 1 + c = char() + print(i) + return i < limit + +def test_2(): + limit = 1e7 # surely by then + i = 0 + c = char_end() + while c != 'z' and i < limit: + i += 1 + c = char_end() + print(i) + return i < limit + +def test_3 (): + limit = 1e7 # surely by then + i = 0 + c = char_end() + while c != 'A' and i < limit: + i += 1 + c = char_end() + print(i) + return i < limit + +def test_4(): + s0 = string() + s1 = string(10) + s2 = string(100) + + print(s0) + print(s1) + print(s2) + + return len(s0)==6 and len(s1)==10 and len(s2)==100 + + +n=16 +if len(sys.argv) > 1: + n = int(sys.argv[1]) +print(string(n)) + diff --git a/executable/home b/executable/home new file mode 100755 index 0000000..569a200 Binary files /dev/null and b/executable/home differ diff --git a/executable/printenv b/executable/printenv new file mode 100755 index 0000000..c266c97 --- /dev/null +++ b/executable/printenv @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +""" +printenv replacement in Python + +Behavior: + - With no NAME arguments: print all environment variables as NAME=value, + sorted by NAME. + - With one or more NAME arguments: print only their values (one per line), + in the order given. + +Options: + -0, --null separate entries with NUL instead of newline + -q, --quote-newlines print embedded newlines as literal "\\n" + -h, --help show usage +""" + +import os +import sys +from textwrap import dedent + + +def usage(prog): + return dedent(f"""\ + Usage: {prog} [OPTION]... [NAME]... + + With no NAME arguments, print all environment variables as NAME=value, + sorted by NAME. + + With one or more NAME arguments, print only their values (one per line), + in the order given. + + Options: + -0, --null separate entries with NUL instead of newline + -q, --quote-newlines print embedded newlines as literal "\\n" + -h, --help display this help and exit + + Notes: + - This implementation sorts variables by NAME by default. + - The original system printenv is usually at /usr/bin/printenv + if you ever need the unsorted version. + """) + + +def printenv(null_terminate, quote_newlines, names, prog): + """ + Core printenv implementation. + Uses os.environ directly, writes to stdout, returns exit status. + """ + sep = "\0" if null_terminate else "\n" + + def fmt_value(val): + if quote_newlines: + return val.replace("\n", "\\n") + return val + + if names: + for name in names: + if name in os.environ: + out = fmt_value(os.environ[name]) + sys.stdout.write(out) + sys.stdout.write(sep) + return 0 + + items = sorted(os.environ.items(), key=lambda kv: kv[0]) + + for name, val in items: + line = f"{name}={fmt_value(val)}" + sys.stdout.write(line) + sys.stdout.write(sep) + + return 0 + + +def CLI(argv): + """ + Command-line interface: parse argv, then call printenv(). + """ + prog = argv[0] if argv else "printenv" + + null_terminate = False + quote_newlines = False + names = [] + + args = argv[1:] + i = 0 + + while i < len(args): + arg = args[i] + + if arg == "--": + names.extend(args[i + 1 :]) + break + + if arg in ("-h", "--help"): + sys.stdout.write(usage(prog)) + return 0 + + if arg in ("-0", "--null"): + null_terminate = True + i += 1 + continue + + if arg in ("-q", "--quote-newlines"): + quote_newlines = True + i += 1 + continue + + if arg.startswith("-") and len(arg) > 1: + sys.stderr.write(f"{prog}: unknown option: {arg}\n") + sys.stderr.write(f"Try '{prog} --help' for more information.\n") + return 1 + + names.append(arg) + names.extend(args[i + 1 :]) + break + + return printenv(null_terminate, quote_newlines, names, prog) + + +if __name__ == "__main__": + raise SystemExit(CLI(sys.argv)) diff --git a/executable/share_directory b/executable/share_directory new file mode 100755 index 0000000..ea80f0c --- /dev/null +++ b/executable/share_directory @@ -0,0 +1,29 @@ +#!/bin/bash + +# Fix permissions script +# Usage: ./fix_permissions.sh +# Recursively makes the directory and its contents group readable +# and if user executable, also group executable. + +# Check if argument is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Directory to fix +target_dir="$1" + +# Check if the directory exists +if [ ! -d "$target_dir" ]; then + echo "Error: Directory '$target_dir' does not exist." + exit 1 +fi + +# Fix permissions +echo "Fixing permissions for directory: $target_dir" +find "$target_dir" -type f -exec chmod g+r {} \; # Make files group-readable +find "$target_dir" -type d -exec chmod g+rx {} \; # Make directories group-readable and executable +find "$target_dir" -perm -u+x -exec chmod g+x {} \; # Make group executable if user executable + +echo "Permissions fixed for '$target_dir'." diff --git a/executable/subu_login b/executable/subu_login new file mode 100755 index 0000000..ca28743 --- /dev/null +++ b/executable/subu_login @@ -0,0 +1,135 @@ +#!/bin/bash +# launch_subu.sh — Start a subuser shell (console or GUI-aware, with systemd user session) + +set -euo pipefail +umask 0077 + +subu="$1" +if [ -z "$subu" ]; then + echo "❌ No subuser name supplied" + exit 1 +fi + +subu_user="Thomas-$subu" +if ! id "$subu_user" &>/dev/null; then + echo "❌ User $subu_user does not exist" + exit 1 +fi + +# Check required commands +error_flag=0 +for cmd in machinectl xauth xhost dbus-run-session; do + if ! command -v "$cmd" &>/dev/null; then + echo "❌ $cmd not found" + error_flag=1 + fi +done +if [ "$error_flag" -eq 1 ]; then + exit 1 +fi + +# don't use sudo -v, because it will echo the password into the emacs shell +sudo echo >& /dev/null + + +# Something broke when I turned this off. What was it. Will have to turn it off again and +# test. +# +# Enable lingering so user services can persist +sudo loginctl enable-linger "$subu_user" + +# Decide how to set the use_xauth and use_xhost flags. +# +# As of the time of this writing, on my machines, Wayland insists on +# xauth, while my X11 is refuses to use it, thus it needs xhost control. +# So this is how I determine how to set the flags here. +# + +# bash will evaluate this variables inside a quoted if even when the +# gate is falase, so everything needs to be initialized, whether used +# or not. +subu_Xauthority_path="" +use_xauth=0 +use_xhost=0 +if [[ -n "${WAYLAND_DISPLAY:-}" ]]; then + has_display=true + XDG_SESSION_TYPE="wayland" + subu_Xauthority_path="$HOME/subu/$subu/.Xauthority" + use_xauth=1 + use_xhost=0 + echo "🌀 Wayland session - Using xauth for access control" + +elif [[ -n "${DISPLAY:-}" ]]; then + has_display=true + XDG_SESSION_TYPE="x11" + use_xauth=0 + use_xhost=1 + echo "🧱 X11 session - Using xhost for access control" + +else + has_display=false + XDG_SESSION_TYPE="tty" + use_xauth=0 + use_xhost=0 + echo "🖳 Console session (no X detected)" +fi + +if [[ "$use_xhost" -eq 1 ]]; then + xhost +SI:localuser:"$subu_user" +fi +if [[ "$use_xauth" -eq 1 ]]; then + mkdir -p "$(dirname "$subu_Xauthority_path")" + touch "$subu_Xauthority_path" + xauth extract "$subu_Xauthority_path" "$DISPLAY" +fi + +if $has_display; then + + + sudo machinectl shell "$subu_user"@ /bin/bash -c " + + # --- session env from parent --- + export DISPLAY=\"${DISPLAY:-${WAYLAND_DISPLAY}}\"; + export XDG_RUNTIME_DIR='/run/user/$(id -u "$subu_user")'; + export XDG_SESSION_TYPE=\"$XDG_SESSION_TYPE\"; + export XDG_SESSION_CLASS=\"user\"; + export XDG_DATA_DIRS=\"/usr/share/gnome:/usr/local/share/:/usr/share/\"; + export USE_XAUTH=$use_xauth + + # Only set XAUTHORITY when we actually prepared it (Wayland/xauth case) + if [[ \"\$USE_XAUTH\" -eq 1 ]]; then + export XAUTHORITY=\"$subu_Xauthority_path\" + fi + + if command -v /usr/bin/gnome-keyring-daemon &>/dev/null; then + eval \$(/usr/bin/gnome-keyring-daemon --start) + export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID + fi + + # WirePlumber: ignore logind (subuser isn't the active seat) + systemctl --user set-environment WIREPLUMBER_DISABLE_PLUGINS=logind + systemctl --user import-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY XDG_RUNTIME_DIR XDG_SESSION_TYPE + + # Bring up audio (sockets first, then services) + systemctl --user enable --now pipewire.socket pipewire-pulse.socket >/dev/null 2>&1 || true + systemctl --user restart wireplumber pipewire pipewire-pulse + + exec dbus-run-session -- bash -l + " + +else + + # Console mode with DBus session (give it audio too) + sudo machinectl shell "$subu_user"@ /bin/bash -c " + export XDG_RUNTIME_DIR='/run/user/$(id -u "$subu_user")}'; + + systemctl --user set-environment WIREPLUMBER_DISABLE_PLUGINS=logind + systemctl --user import-environment XDG_RUNTIME_DIR + systemctl --user enable --now pipewire.socket pipewire-pulse.socket >/dev/null 2>&1 || true + systemctl --user restart wireplumber pipewire pipewire-pulse + + exec dbus-run-session -- bash -l + " +fi + + diff --git a/executable/subu_orig b/executable/subu_orig new file mode 100644 index 0000000..0c8d838 --- /dev/null +++ b/executable/subu_orig @@ -0,0 +1,47 @@ +#!/bin/bash +# launch_subu.sh — Start a subuser shell (console or GUI-aware) + +set -euo pipefail + +subu="$1" +if [ -z "$subu" ]; then + echo "❌ No subuser name supplied" + exit 1 +fi + +subu_user="Thomas-$subu" +subu_dir="/home/Thomas/subu_data/$subu" + +# Enable lingering to survive logout +sudo loginctl enable-linger "$subu_user" + +# Check for X11 or Wayland +has_display=false +if [[ "${DISPLAY:-}" != "" ]]; then + has_display=true + echo "🖥 Graphical session detected: $DISPLAY" +else + echo "🖳 Console session (no X detected)" +fi + +if $has_display; then + # Start subuser shell with full GUI + DBus + user session + sudo machinectl shell "$subu_user"@ /bin/bash -c " + export DISPLAY='$DISPLAY'; + if [[ $use_xauth -eq 1 ]]; then + export XAUTHORITY='$subu_Xauthority_path'; + fi + + export XDG_RUNTIME_DIR='/run/user/$(id -u "$subu_user")'; + + if command -v /usr/bin/gnome-keyring-daemon &>/dev/null; then + eval \$(/usr/bin/gnome-keyring-daemon --start) + export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID + fi + + exec dbus-run-session -- bash -l + " +else + # Start subuser shell without X env + sudo machinectl shell "$subu_user"@ /bin/bash -l +fi diff --git a/executable/subu_setup b/executable/subu_setup new file mode 100644 index 0000000..42c2343 --- /dev/null +++ b/executable/subu_setup @@ -0,0 +1,72 @@ + +# alsactl init seemed to be required, though sound is already working +# for Thomas. +root@Stanley:/home/Thomas-masu# alsactl init + +Found hardware: "HDA-Intel" "ATI R6xx HDMI" "HDA:1002aa01,00aa0100,00100700" "0x1002" "0x1637" +Hardware is initialized using a generic method +Found hardware: "HDA-Intel" "Realtek ALC294" "HDA:10ec0294,104311af,00100004" "0x1043" "0x11af" +Hardware is initialized using a generic method +Found hardware: "USB-Audio" "USB Mixer" "USB046d:0a8f" "" "" +Hardware is initialized using a generic method + +dnf reinstall pipewire-alsa + + + + +#!/bin/bash +set -e + +# Check for subuser name +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +SUBU_NAME=$1 +SUBU_USER="Thomas-$SUBU_NAME" +SUBU_HOME="/home/$SUBU_USER" + +# Check if the subuser exists +if ! id "$SUBU_USER" &>/dev/null; then + echo "Error: Subuser $SUBU_USER does not exist!" + exit 1 +fi + +echo "Setting up subuser: $SUBU_USER" + +# 1. Enable linger for the subuser +echo "Enabling linger for $SUBU_USER..." +sudo loginctl enable-linger "$SUBU_USER" + +# 2. Enable pipewire services for the subuser +echo "Enabling pipewire services for $SUBU_USER..." +sudo -u "$SUBU_USER" systemctl --user enable pipewire +sudo -u "$SUBU_USER" systemctl --user enable pipewire-pulse + +# 3. Set up X11 access (XAUTHORITY) +echo "Setting up X11 access for $SUBU_USER..." +XAUTH_PATH="$SUBU_HOME/.Xauthority" +if [ ! -f "$XAUTH_PATH" ]; then + sudo -u "$SUBU_USER" touch "$XAUTH_PATH" +fi + +# Generate a trusted X11 cookie +echo "Generating trusted X11 cookie..." +xauth generate "$DISPLAY" . trusted +xauth extract - "$DISPLAY" | sudo -u "$SUBU_USER" xauth merge - + +# 4. Set up a basic .bashrc if not already present +echo "Setting up .bashrc for $SUBU_USER..." +BASHRC_PATH="$SUBU_HOME/.bashrc" +if [ ! -f "$BASHRC_PATH" ]; then + sudo -u "$SUBU_USER" cp /etc/skel/.bashrc "$BASHRC_PATH" + echo "# Custom settings for $SUBU_USER" | sudo -u "$SUBU_USER" tee -a "$BASHRC_PATH" +fi + +# 5. Adjust permissions for the subuser home directory (optional) +echo "Ensuring correct permissions for $SUBU_HOME..." +sudo chown -R "$SUBU_USER:$SUBU_USER" "$SUBU_HOME" + +echo "Subuser setup complete for $SUBU_USER!" diff --git a/executable/user b/executable/user new file mode 100755 index 0000000..15e1bcb Binary files /dev/null and b/executable/user differ diff --git a/executable/user-stem b/executable/user-stem new file mode 100755 index 0000000..3df796e Binary files /dev/null and b/executable/user-stem differ diff --git a/executable/user-subu b/executable/user-subu new file mode 100755 index 0000000..2712e78 Binary files /dev/null and b/executable/user-subu differ diff --git a/library/TTCA.elisp b/library/TTCA.elisp new file mode 100644 index 0000000..15fdff7 --- /dev/null +++ b/library/TTCA.elisp @@ -0,0 +1,70 @@ +;;-------------------------------------------------------------------------------- +;; TTCA + + (global-set-key [f1] 'help-command) + (global-set-key "\C-h" 'nil) + (define-key key-translation-map (kbd "M-S") (kbd "§")) + + ;; extended character set moved to XCompose, done on the compose key + ;; for ibus driver for the US keyboard instead of in Emacs + + ; ;; extended character set for programming examples in the TTCA book + ; ;; + ; ;; preferable to have keys for the characters, but the keyboard is already overloaded .. + ; ;; (define-key key-translation-map (kbd " p") (kbd "¬")) + ; ;; (set-input-method “latin-9-prefix) + ; (global-set-key [f1] 'help-command) + ; (global-set-key "\C-h" 'nil) + ; (define-key key-translation-map (kbd "M-S") (kbd "§")) + + ; (global-set-key (kbd "C-x g phi SPC") [?φ]) ; phi for phase + ; (global-set-key (kbd "C-x g Phi SPC") [?Φ]) + + ; (global-set-key (kbd "C-x g d SPC") [?δ]) + ; (global-set-key (kbd "C-x g D SPC") [?Δ]) ; this is 'delta' is not 'increment'! + ; (global-set-key (kbd "C-x g delta SPC") [?δ]) + ; (global-set-key (kbd "C-x g Delta SPC") [?Δ]) ; this is 'delta' is not 'increment'! + + ; (global-set-key (kbd "C-x g g SPC") [?γ]) + ; (global-set-key (kbd "C-x g G SPC") [?Γ]) + ; (global-set-key (kbd "C-x g gamma SPC") [?γ]) + ; (global-set-key (kbd "C-x g Gamma SPC") [?Γ]) + + ; (global-set-key (kbd "C-x g l SPC") [?λ]) + ; (global-set-key (kbd "C-x g L SPC") [?Λ]) + ; (global-set-key (kbd "C-x g lambda SPC") [?λ]) + ; (global-set-key (kbd "C-x g Lambda SPC") [?Λ]) + + ; (global-set-key (kbd "C-x g p SPC") [?π]) + ; (global-set-key (kbd "C-x g P SPC") [?Π]) + ; (global-set-key (kbd "C-x g pi SPC") [?π]) + ; (global-set-key (kbd "C-x g Pi SPC") [?Π]) + + ; (global-set-key (kbd "C-x g > = SPC") [?≥]) + ; (global-set-key (kbd "C-x g < = SPC") [?≤]) + ; (global-set-key (kbd "C-x g ! = SPC") [?≠]) + ; (global-set-key (kbd "C-x g neq SPC") [?≠]) + + ; (global-set-key (kbd "C-x g nil SPC") [?∅]) + + ; (global-set-key (kbd "C-x g not SPC") [?¬]) + + ; (global-set-key (kbd "C-x g and SPC") [?∧]) + ; (global-set-key (kbd "C-x g or SPC") [?∨]) + + ; (global-set-key (kbd "C-x g exists SPC") [?∃]) + ; (global-set-key (kbd "C-x g all SPC") [?∀]) + + ; (global-set-key (kbd "C-x g do SPC") [?⟳]) ; do + ; (global-set-key (kbd "C-x g rm SPC") [?◨]) + ; (global-set-key (kbd "C-x g lm SPC") [?◧]) + + ; (global-set-key (kbd "C-x g cont SPC") [?➜]) ; continue + ; (global-set-key (kbd "C-x g thread SPC") [?☥]) ; thread + + ; (global-set-key (kbd "C-x g in SPC") [?∈]) ; set membership + + ; (global-set-key (kbd "C-x g times SPC") [?×]) ; set membership + + ; (global-set-key (kbd "C-x g cdot SPC") [?·]) ; scoping sepearator for gcc C + ; (global-set-key (kbd "C-x g inc SPC") [?⊡]) ; a b + a + b diff --git a/library/XCompose b/library/XCompose new file mode 100644 index 0000000..0964a42 --- /dev/null +++ b/library/XCompose @@ -0,0 +1,243 @@ +# Author: Thomas Walker Lynch +# 2023-10-24 +# MIT license + +# I purposely left out prior definitions so as to support namespaces as noted below. +# include "/usr/share/X11/locale/en_US.UTF-8/Compose" + +# The goal here is not to include all of unicode. That would be silly, as +# typing compose characters is cumbersome. If a person wants to use a +# different script, that person should change the keyboard layout setting. +# This file is for supporting math and science writing in English, and +# for supporting accents. + + +#-------------------------------------------------------------------------------- +# all the special characters have as their origins tricks played on +# manual typewriters. Thus this .Xcompose file defines each sepcial +# character by the character we start with, followed by a description +# of what we do with it. As examples, double striking letters, turning +# them upside down, typing a slash through it, etc. +# +# ... : # comment +# +# Be starting with a namespace character we reduce the problem of potential +# aliasing to that namespace. By ending each sequence with a , by +# hitting the space bar, we may make a prefix sequence to a longer sequence +# unique. In this manner we may add more than one typesetting trick to a +# single character. +# + +#-------------------------------------------------------------------------------- +# name spaces +# L - Latin +# G - Greek +# m - math +# + +#-------------------------------------------------------------------------------- +# typesetting instructions +# +# ' : add accent +# ` : add accent agui +# : : place double dot over +# +# d : doublstrike +# +# u : upside down +# r : rotate right +# l : rotate left +# b : backwards +# o : occlusion (originally typed by placing another piece of paper to chop part off) +# +# / : strike through +# - : overstrike with a - (underscore is used for subscript) +# s : put a square around it +# c : put a circle around it +# +# ^ : superscript +# _ : subscript + +#-------------------------------------------------------------------------------- +# Latin + +# Double struck + : "𝔸" U1D538 # double-struck capital A + : "𝔹" U1D539 # double-struck capital B + : "ℂ" U2102 # double-struck capital C + : "𝔻" U1D53B # double-struck capital D + : "𝔼" U1D53C # double-struck capital E + : "𝔽" U1D53D # double-struck capital F + : "𝔾" U1D53E # double-struck capital G + : "ℍ" U210D # double-struck capital H + : "𝕀" U1D540 # double-struck capital I + : "𝕁" U1D541 # double-struck capital J + : "𝕂" U1D542 # double-struck capital K + : "𝕃" U1D543 # double-struck capital L + : "𝕄" U1D544 # double-struck capital M + : "ℕ" U2115 # double-struck capital N + : "𝕆" U1D546 # double-struck capital O +

: "ℙ" U2119 # double-struck capital P + : "ℚ" U211A # double-struck capital Q + : "ℝ" U211D # double-struck capital R + : "𝕊" U1D54A # double-struck capital S + : "𝕋" U1D54B # double-struck capital T + : "𝕌" U1D54C # double-struck capital U + : "𝕍" U1D54D # double-struck capital V + : "𝕎" U1D54E # double-struck capital W + : "𝕏" U1D54F # double-struck capital X + : "𝕐" U1D550 # double-struck capital Y + : "ℤ" U2124 # double-struck capital Z + + : "𝕒" U1D552 # double-struck lowercase a + : "𝕓" U1D553 # double-struck lowercase b + : "𝕔" U1D554 # double-struck lowercase c + : "𝕕" U1D555 # double-struck lowercase d + : "𝕖" U1D556 # double-struck lowercase e + : "𝕗" U1D557 # double-struck lowercase f + : "𝕘" U1D558 # double-struck lowercase g + : "𝕙" U1D559 # double-struck lowercase h + : "𝕚" U1D55A # double-struck lowercase i + : "𝕛" U1D55B # double-struck lowercase j + : "𝕜" U1D55C # double-struck lowercase k + : "𝕝" U1D55D # double-struck lowercase l + : "𝕞" U1D55E # double-struck lowercase m + : "𝕟" U1D55F # double-struck lowercase n + : "𝕠" U1D560 # double-struck lowercase o +

: "𝕡" U1D561 # double-struck lowercase p + : "𝕢" U1D562 # double-struck lowercase q + : "𝕣" U1D563 # double-struck lowercase r + : "𝕤" U1D564 # double-struck lowercase s + : "𝕥" U1D565 # double-struck lowercase t + : "𝕦" U1D566 # double-struck lowercase u + : "𝕧" U1D567 # double-struck lowercase v + : "𝕨" U1D568 # double-struck lowercase w + : "𝕩" U1D569 # double-struck lowercase x + : "𝕪" U1D56A # double-struck lowercase y + : "𝕫" U1D56B # double-struck lowercase z + +# accented letters + : "á" U00E1 # lowercase a with acute accent + : "à" U00E0 # lowercase a with grave accent + : "ä" U00E4 # lowercase a with umlaut + : "â" U00E2 # lowercase a with circumflex + : "ã" U00E3 # lowercase a with tilde + : "æ" U00E6 # lowercase ae diphthong + : "ç" U00E7 # lowercase c with cedilla + : "é" U00E9 # lowercase e with acute accent + : "è" U00E8 # lowercase e with grave accent + : "ë" U00EB # lowercase e with umlaut + : "ê" U00EA # lowercase e with circumflex + : "í" U00ED # lowercase i with acute accent + : "ì" U00EC # lowercase i with grave accent + : "ï" U00EF # lowercase i with umlaut + : "î" U00EE # lowercase i with circumflex + : "ñ" U00F1 # lowercase n with tilde + : "ó" U00F3 # lowercase o with acute accent + : "ò" U00F2 # lowercase o with grave accent + : "ö" U00F6 # lowercase o with umlaut + : "ô" U00F4 # lowercase o with circumflex + : "õ" U00F5 # lowercase o with tilde + : "œ" U0153 # lowercase oe diphthong + + +# #-------------------------------------------------------------------------------- +# Greek + + : "Α" U0391 # greek capital letter alpha + : "Β" U0392 # greek capital letter beta + : "Γ" U0393 # greek capital letter gamma + : "Δ" U0394 # greek capital letter delta + : "Ε" U0395 # greek capital letter epsilon + : "Ζ" U0396 # greek capital letter zeta + : "Η" U0397 # greek capital letter eta + : "Θ" U0398 # greek capital letter theta + : "Ι" U0399 # greek capital letter iota + : "Κ" U039A # greek capital letter kappa + : "Λ" U039B # greek capital letter lamda + : "Μ" U039C # greek capital letter mu + : "Ν" U039D # greek capital letter nu + : "Ξ" U039E # greek capital letter xi + : "Ο" U039F # greek capital letter omicron +

: "Π" U03A0 # greek capital letter pi + : "Ρ" U03A1 # greek capital letter rho + : "Σ" U03A3 # greek capital letter sigma + : "Τ" U03A4 # greek capital letter tau + : "Υ" U03A5 # greek capital letter upsilon + : "Φ" U03A6 # greek capital letter phi + : "Χ" U03A7 # greek capital letter chi + : "Ψ" U03A8 # greek capital letter psi + : "Ω" U03A9 # greek capital letter omega + + : "α" u03b1 # greek small letter alpha + : "β" u03b2 # greek small letter beta + : "γ" u03b3 # greek small letter gamma + : "δ" u03b4 # greek small letter delta + : "ε" u03b5 # greek small letter epsilon + : "ζ" u03b6 # greek small letter zeta + : "η" u03b7 # greek small letter eta + : "θ" u03b8 # greek small letter theta + : "ι" u03b9 # greek small letter iota + : "κ" u03ba # greek small letter kappa + : "λ" u03bb # greek small letter lamda + : "μ" u03bc # greek small letter mu + : "ν" u03bd # greek small letter nu + : "ξ" u03be # greek small letter xi + : "ο" u03bf # greek small letter omicron +

: "π" u03c0 # greek small letter pi + : "ρ" u03c1 # greek small letter rho + : "σ" u03c3 # greek small letter sigma + : "τ" u03c4 # greek small letter tau + : "υ" u03c5 # greek small letter upsilon + : "φ" u03c6 # greek small letter phi + : "χ" u03c7 # greek small letter chi + : "ψ" u03c8 # greek small letter psi + : "ω" u03c9 # greek small letter omega + +# -------------------------------------------------------------------------------- +# math + + : "×" U00D7 # multiplication sign + : "·" U00B7 # middle dot + : "⊡" U22A1 # squared dot operator + + : "≠" U2260 # not equal to + + : "≤" U2264 # less-than or equal to + : "≥" U2265 # greater-than or equal to + <0> : "∅" U2205 # empty set + + + : "∈" U2208 # element of + : "∉" U2209 # not an element of + + : "∪" U222A # union + : "⋂" U22C2 # n-ary interesection + : "⊂" U2282 # subset of + : "⊆" U2286 # subset of or equal to + : "⊃" U2283 # superset of + : "⊇" U2287 # superset of or equal to + + : "∩" U2229 # intersection + : "∁" U2201 # complement + + : "∃" U2203 # there exists + : "∄" U2204 # there does not exist + : "∀" U2200 # for all + + : "¬" U00AC # not sign + + : "⋁" U2228 # big vee, n-ary logical or + : "⋀" U22C0 # big wedge n-ary LOGICAL AND + + : "∨" U2228 # little vee logical or + : "∧" U2227 # little weddge logical and + : "⊼" U22BC # NAND + : "➜" U27A0 # implies + <=> : "⇒" U21D2 # implies + <=> : "⇔" U21D4 # if and only if + + : "⟳" U27F3 # clockwise gapped circle arrow, 'do' or 'for' operator + : "◨" U25E8 # square with right inked 'rightmost' 'maximum' operator + : "◧" U25E7 # square with left inked 'leftmost' 'minimum' operator + : "☥" U2625 # ankh diff --git a/library/archive/emacs_2024-04-11 b/library/archive/emacs_2024-04-11 new file mode 100644 index 0000000..39e3a8a --- /dev/null +++ b/library/archive/emacs_2024-04-11 @@ -0,0 +1,321 @@ +;;-------------------------------------------------------------------------------- +;; set the title at the top of the frame +;; + (defun frame-title (s) + "sets the frame title" + (interactive "stitle: ") + (setq frame-title-format s) + ) + +;;-------------------------------------------------------------------------------- +;; turn off the annoying bell +;; +;; (setq ring-bell-function (lambda () +;; (call-process-shell-command +;; "xset led 3; xset -led 3" nil 0 nil))) +;; +;; (setq ring-bell-function nil) + + (setq ring-bell-function + (lambda () + (call-process-shell-command "xset led named 'Scroll Lock'") + (call-process-shell-command "xset -led named 'Scroll Lock'"))) + +;;-------------------------------------------------------------------------------- +;; tell emacs not to make new files in the working directory +;; so that backups and git repos don't get polluted +;; + + ;; use a backrevs dir rather than leaving ~file droppings everywhere + ;; + (setq backup-directory-alist `(("." . "~/emacs_backrevs"))) + (setq backup-by-copying t) + + ;; so that lock files do not end up in the repo + ;; + (setq create-lockfiles nil) + +;;-------------------------------------------------------------------------------- +;; Font +;; + +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) + '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + +;;-------------------------------------------------------------------------------- +;; elisp utilities +;; + ;; get buffer filename -- emacs does not have a built in function for this. + ;; + (defun filename-get () + "Gets the name of the file the current buffer is based on." + (buffer-file-name (window-buffer (minibuffer-selected-window)))) + + (defun filename-insert () + "Inserts the name of the file the current buffer is based on." + (interactive) + (insert (filename-get))) + + (global-set-key (kbd "C-c f") 'filename-insert) + + (defun filename () + "Gets the name of the file the current buffer is based on." + (interactive) + (message (filename-get)) + ) + +;;-------------------------------------------------------------------------------- +;; Melpa +;; + (require 'package) + (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) + (add-to-list 'load-path "~/projects/neotree") + (package-initialize) + + ;; M-x package-install + (if (not (package-installed-p 'neotree)) (package-install 'neotree)) + (if (not (package-installed-p 'ace-window)) (package-install 'ace-window)) + +;;-------------------------------------------------------------------------------- +;; emacs shell +;; + + ;; get the pwd in shell mode from the prompt rather than guessing by + ;; watching the commands typed .. yes! now shell variables and source + ;; scripts will work + ;; in bashrc: export PS1='\n$(/usr/local/bin/Z)\u@\h§\w§\n> ' + ;; + (add-hook 'shell-mode-hook + (lambda () + (shell-dirtrack-mode -1) + (dirtrack-mode 1))) + + (add-hook 'dirtrack-directory-change-hook + (lambda () + (message default-directory))) + +;; (setq dirtrack-list '("§\\(.*\\)§\n[>#] " 1)) + (setq dirtrack-list '("§\\([^§]*\\)§" 1)) + +;;-------------------------------------------------------------------------------- +;; Ace Window Manager +;; + +; (use-package ace-window +; :init +; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) +; (setq aw-background nil)) + + ;(global-set-key (kbd "M-o") 'switch-window) + ;(require 'ace-window) +; (global-set-key (kbd "M-o") 'ace-window) +; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) +; (setq aw-background nil) + +;;-------------------------------------------------------------------------------- +;; neotree +;; + ; (require 'neotree) + ; (global-set-key [f8] 'neotree-toggle) + ; (setq neo-window-fixed-size nil) + ; (setq neo-smart-open t) + ; (setq neo-window-width 45) + +;;-------------------------------------------------------------------------------- +;; Tramp +;; +;;;https://www.gnu.org/software/emacs/manual/html_node/tramp/Frequently-Asked-Questions.html +;; + + + ;; trap wants to write to /tmp, but when logged in as root it causes failures and pop up new frames with warnings + ;; + (add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil)) + + + (setq tramp-completion-reread-directory-timeout nil) + + (defun shell-make (dir buffer-name) + (let* ( + (default-directory dir) + (buffer (get-buffer-create buffer-name)) + ) + (set-buffer buffer) + (shell buffer) + )) + + (defun shell~ () (interactive) (shell-make "~" "shell~")) + (defun shell-root () (interactive) (shell-make "/sudo::/root" "shell-root")) + (defun shell-rt () (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com:~" "shell-rt")) + ;(defun shell-rt-root() (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:" "shell-rt-root")) + (defun shell-rt-root() (interactive) (shell-make "/ssh:root@reasoningtechnology.com:~" "shell-rt-root")) + + (defun shell-LFS () (interactive) (shell-make "/ssh:lfs@192.168.122.115:~" "shell-LFS")) + (defun shell-LFS-root () (interactive) (shell-make "/ssh:root@192.168.122.115:~" "shell-LFS-root")) + + (defun shell-Shihju () (interactive) (shell-make "/sudo:Shihju@localhost:/home/Shihju" "shell-Shihju")) + (defun shell-Wendell () (interactive) (shell-make "/ssh:Morpheus@Wendell:~" "shell-Wendell")) + (defun shell-Wendell-root () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Wendell:" "shell-Wendell-root")) + (defun shell-Wendell-Shihju () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Shihju@Wendell:" "shell-Wendell-Shihju")) + + + (defun dired-rt () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com:") + ) + + (defun dired-rt-root () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:") + ) + +;;-------------------------------------------------------------------------------- +;; gdb +;; use gud-gdb instead of gdb and we won't need this. +;; fix 'feature' of broken gdb where it takes control of an +;; emacs window, and locks the user out from switching from it +;; + (defun unlock-window () + "Turns off window dedication." + (interactive) + (set-window-dedicated-p (get-buffer-window (current-buffer)) nil) + ) + +;;-------------------------------------------------------------------------------- +;; shell scripting +;; + (setq sh-basic-offset 2) + +;;-------------------------------------------------------------------------------- +;; json +;; + (setq json-encoding-pretty-print t) + (setq json-encoding-lisp-style-closings t) + ;(setq json-encoding-lisp-style-closings nil) + (defun wrap-comma () + "wrap end of line comma to first of next line" + (interactive) + (while (re-search-forward "\\(.*\\), *\n\\( *\\)" nil t) (replace-match "\\1\n\\2,")) + ) + +;;-------------------------------------------------------------------------------- +;; rust +;; +;; (require 'package) +;; (add-to-list 'package-archives +;; '("melpa-stable" . "https://stable.melpa.org/packages/")) +;; (package-initialize) +;; (package-refresh-contents) +;; +;;; (setq rust-indent-offset 2) +;;; (require 'rust-mode) + +;;-------------------------------------------------------------------------------- +;; python +;; + (add-hook 'python-mode-hook '(lambda () (setq python-indent 2))) + +;;-------------------------------------------------------------------------------- +;; Lisp +;; + (setq lisp-indent-offset 2) + (setq inferior-lisp-program "sbcl") + + (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table) + (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table) + (modify-syntax-entry ?{ "(}" lisp-mode-syntax-table) + (modify-syntax-entry ?} "){" lisp-mode-syntax-table) + +;;-------------------------------------------------------------------------------- +;; Web page development +;; + ;(setq browse-url-browser-function 'browse-url-firefox) + (setq browse-url-browser-function 'browse-url-chrome) + ;(setq browse-url-browser-function 'browse-url-chromium) + + (setq js-indent-level 2) + (setq css-indent-offset 2) + (add-to-list 'auto-mode-alist '("\\.php\\'" . html-mode)) + +;;-------------------------------------------------------------------------------- +;; C +;; + (add-hook 'c-mode-hook (lambda () (modify-syntax-entry ?· "_"))) + ; in customer variables '(c-offsets-alist (quote ((label . 2)))) + (add-to-list 'auto-mode-alist '("\\.isq\\'" . c-mode)) + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(ansi-color-names-vector + ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) + '(c-basic-offset 2) + '(c-offsets-alist '((label . 2))) + '(column-number-mode t) + '(custom-enabled-themes '(wheatgrass deeper-blue)) + '(direx:closed-icon "╞") + '(direx:leaf-icon "┝") + '(direx:open-icon "╘") + '(ediff-diff-options "-w") + '(ediff-split-window-function 'split-window-horizontally) + '(ediff-window-setup-function 'ediff-setup-windows-plain) + '(geiser-racket-binary "racket") +; '(package-selected-packages '(ace-window neotree)) + '(send-mail-function 'smtpmail-send-it) + '(tool-bar-mode nil)) + + +;;-------------------------------------------------------------------------------- +;; emacs behavior + + (setq inhibit-startup-screen t) + + ;; stop the 'tab' character polution + ;; + (setq-default indent-tabs-mode nil) + + ;; turn off the poison C-z key. Use C-x C-z or the command suspend-emacs + ;; + (global-set-key (kbd "C-z") nil) + + ;; truncate rather than wrapping lines (use horizontal scroll to see to the right) + ;; + (set-default 'truncate-lines t) + (setq truncate-partial-width-windows nil) + (setq-default fill-column 80) + (setq fill-column 80) + + ;; recover some window real estate - note also F11 to rid of the top window splash bar + ;; + ;;(set-face-attribute 'mode-line nil :height 75) + + ;; c-x mode-line to toggle the mode-line on and off + (defun mode-line () "toggles the modeline on and off" + (interactive) + (setq mode-line-format + (if (equal mode-line-format nil) + (default-value 'mode-line-format)) ) + (redraw-display)) + + ;(setq-default mode-line-format nil) + (tool-bar-mode -1) + (menu-bar-mode -1) + + (put 'narrow-to-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'set-goal-column 'disabled nil) + (put 'erase-buffer 'disabled nil) + +(put 'upcase-region 'disabled nil) +;; vertical split for ediff + +;; '(package-selected-packages +;; '(ace-window switch-window dired-git ztree dirtree-prosjekt dired-sidebar dirtree direx neotree treemacs markdown-mode rust-mode)) + diff --git a/library/archive/emacs_cp b/library/archive/emacs_cp new file mode 100644 index 0000000..4ed366b --- /dev/null +++ b/library/archive/emacs_cp @@ -0,0 +1,186 @@ +;;-------------------------------------------------------------------------------- +;; set the title at the top of the frame +;; + (defun frame-title (s) + "sets the frame title" + (interactive "stitle: ") + (setq frame-title-format s) + ) + +;;-------------------------------------------------------------------------------- +;; turn off the annoying bell +;; + (setq visible-bell t) + +;;-------------------------------------------------------------------------------- +;; tell emacs not to make new files in the working directory +;; + ;; use a backrevs dir rather than leaving ~file droppings everywhere + ;; + (setq backup-directory-alist `(("." . "~/emacs_backrevs"))) + (setq backup-by-copying t) + + ;; so that lock files do not end up in the repo + ;; + (setq create-lockfiles nil) + +;;-------------------------------------------------------------------------------- +;; Font +;; + (custom-set-faces + '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) + '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + +;;-------------------------------------------------------------------------------- +;; elisp utilities +;; + (defun filename-get () + "Gets the name of the file the current buffer is based on." + (buffer-file-name (window-buffer (minibuffer-selected-window))) + ) + + (defun filename-insert () + "Inserts the name of the file the current buffer is based on." + (interactive) + (insert (filename-get)) + ) + + (global-set-key (kbd "C-c f") 'filename-insert) + + (defun filename () + "Gets the name of the file the current buffer is based on." + (interactive) + (message (filename-get)) + ) + +;;-------------------------------------------------------------------------------- +;; Melpa +;; + (require 'package) + (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) + (add-to-list 'load-path "~/projects/neotree") + (package-initialize) + + ;; M-x package-install + (if (not (package-installed-p 'neotree)) (package-install 'neotree)) + (if (not (package-installed-p 'ace-window)) (package-install 'ace-window)) + +;;-------------------------------------------------------------------------------- +;; emacs shell +;; + + ;; get the pwd in shell mode from the prompt rather than guessing by + ;; watching the commands typed .. yes! now shell variables and source + ;; scripts will work + ;; in bashrc: export PS1='\n$(/usr/local/bin/Z)\u@\h§\w§\n> ' + ;; + (add-hook 'shell-mode-hook + (lambda () + (shell-dirtrack-mode -1) + (dirtrack-mode 1))) + + (add-hook 'dirtrack-directory-change-hook + (lambda () + (message default-directory))) + +;; (setq dirtrack-list '("§\\(.*\\)§\n[>#] " 1)) + (setq dirtrack-list '("§\\([^§]*\\)§" 1)) + +;;-------------------------------------------------------------------------------- +;; gdb +;; use gud-gdb instead of gdb and we won't need this. +;; fix 'feature' of broken gdb where it takes control of an +;; emacs window, and locks the user out from switching from it +;; + (defun unlock-window () + "Turns off window dedication." + (interactive) + (set-window-dedicated-p (get-buffer-window (current-buffer)) nil) + ) + +;;-------------------------------------------------------------------------------- +;; shell scripting +;; + (setq sh-basic-offset 2) + +;;-------------------------------------------------------------------------------- +;; json +;; + (setq json-encoding-pretty-print t) + (setq json-encoding-lisp-style-closings t) + + (defun wrap-comma () + "wrap end of line comma to first of next line" + (interactive) + (while (re-search-forward "\\(.*\\), *\n\\( *\\)" nil t) (replace-match "\\1\n\\2,")) + ) + +;;-------------------------------------------------------------------------------- +;; python +;; + (add-hook 'python-mode-hook '(lambda () (setq python-indent 2))) + +;;-------------------------------------------------------------------------------- +;; Lisp +;; + (setq lisp-indent-offset 2) + (setq inferior-lisp-program "sbcl") + + (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table) + (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table) + (modify-syntax-entry ?{ "(}" lisp-mode-syntax-table) + (modify-syntax-entry ?} "){" lisp-mode-syntax-table) + +;;-------------------------------------------------------------------------------- +;; Web page development +;; + (setq browse-url-browser-function 'browse-url-chrome) + ;(setq browse-url-browser-function 'browse-url-firefox) + ;(setq browse-url-browser-function 'browse-url-chromium) + + (setq js-indent-level 2) + (setq css-indent-offset 2) + (add-to-list 'auto-mode-alist '("\\.php\\'" . html-mode)) + +;;-------------------------------------------------------------------------------- +;; C +;; + (add-hook 'c-mode-hook (lambda () (modify-syntax-entry ?· "_"))) + (add-to-list 'auto-mode-alist '("\\.isq\\'" . c-mode)) + ; in customer variables '(c-offsets-alist (quote ((label . 2)))) + +;;-------------------------------------------------------------------------------- +;; neotree +;; + (require 'neotree) + (global-set-key [f8] 'neotree-toggle) + (setq neo-window-fixed-size nil) + (setq neo-smart-open t) + (setq neo-window-width 45) + +;;-------------------------------------------------------------------------------- +;; Ace Window Manager +;; + (require 'ace-window) + (global-set-key (kbd "M-p") 'ace-window) + +;;-------------------------------------------------------------------------------- +;; emacs behavior +;; + (setq inhibit-startup-screen t) + (setq-default indent-tabs-mode nil) + (global-set-key (kbd "C-z") nil) + (set-default 'truncate-lines t) + (setq truncate-partial-width-windows nil) + (setq-default fill-column 80) + (setq fill-column 80) + (tool-bar-mode -1) + (menu-bar-mode -1) + (put 'narrow-to-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'set-goal-column 'disabled nil) + (put 'erase-buffer 'disabled nil) + (put 'upcase-region 'disabled nil) + (setq byte-compile-warnings '(cl-functions)) + + diff --git a/library/archive/emacs_orig b/library/archive/emacs_orig new file mode 100644 index 0000000..822c9e0 --- /dev/null +++ b/library/archive/emacs_orig @@ -0,0 +1,322 @@ +;;-------------------------------------------------------------------------------- +;; set the title at the top of the frame +;; + (defun frame-title (s) + "sets the frame title" + (interactive "stitle: ") + (setq frame-title-format s) + ) + +;;-------------------------------------------------------------------------------- +;; turn off the annoying bell +;; +;; (setq ring-bell-function (lambda () +;; (call-process-shell-command +;; "xset led 3; xset -led 3" nil 0 nil))) +;; +;; (setq ring-bell-function nil) + + (setq ring-bell-function + (lambda () + (call-process-shell-command "xset led named 'Scroll Lock'") + (call-process-shell-command "xset -led named 'Scroll Lock'"))) + +;;-------------------------------------------------------------------------------- +;; tell emacs not to make new files in the working directory +;; so that backups and git repos don't get polluted +;; + + ;; use a backrevs dir rather than leaving ~file droppings everywhere + ;; + (setq backup-directory-alist `(("." . "~/emacs_backrevs"))) + (setq backup-by-copying t) + + ;; so that lock files do not end up in the repo + ;; + (setq create-lockfiles nil) + +;;-------------------------------------------------------------------------------- +;; Font +;; + +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) + '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + +;;-------------------------------------------------------------------------------- +;; elisp utilities +;; + ;; get buffer filename -- emacs does not have a built in function for this. + ;; + (defun filename-get () + "Gets the name of the file the current buffer is based on." + (buffer-file-name (window-buffer (minibuffer-selected-window)))) + + (defun filename-insert () + "Inserts the name of the file the current buffer is based on." + (interactive) + (insert (filename-get))) + + (global-set-key (kbd "C-c f") 'filename-insert) + + (defun filename () + "Gets the name of the file the current buffer is based on." + (interactive) + (message (filename-get)) + ) + +;;-------------------------------------------------------------------------------- +;; Melpa +;; + (require 'package) + (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) + (add-to-list 'load-path "~/projects/neotree") + (package-initialize) + + ;; M-x package-install + (if (not (package-installed-p 'neotree)) (package-install 'neotree)) + (if (not (package-installed-p 'ace-window)) (package-install 'ace-window)) + +;;-------------------------------------------------------------------------------- +;; emacs shell +;; + + ;; get the pwd in shell mode from the prompt rather than guessing by + ;; watching the commands typed .. yes! now shell variables and source + ;; scripts will work + ;; in bashrc: export PS1='\n$(/usr/local/bin/Z)\u@\h§\w§\n> ' + ;; + (add-hook 'shell-mode-hook + (lambda () + (shell-dirtrack-mode -1) + (dirtrack-mode 1))) + + (add-hook 'dirtrack-directory-change-hook + (lambda () + (message default-directory))) + +;; (setq dirtrack-list '("§\\(.*\\)§\n[>#] " 1)) + (setq dirtrack-list '("§\\([^§]*\\)§" 1)) + +;;-------------------------------------------------------------------------------- +;; Ace Window Manager +;; + +; (use-package ace-window +; :init +; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) +; (setq aw-background nil)) + + ;(global-set-key (kbd "M-o") 'switch-window) + ;(require 'ace-window) +; (global-set-key (kbd "M-o") 'ace-window) +; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) +; (setq aw-background nil) + +;;-------------------------------------------------------------------------------- +;; neotree +;; + ; (require 'neotree) + ; (global-set-key [f8] 'neotree-toggle) + ; (setq neo-window-fixed-size nil) + ; (setq neo-smart-open t) + ; (setq neo-window-width 45) + +;;-------------------------------------------------------------------------------- +;; Tramp +;; +;;;https://www.gnu.org/software/emacs/manual/html_node/tramp/Frequently-Asked-Questions.html +;; + + + ;; trap wants to write to /tmp, but when logged in as root it causes failures and pop up new frames with warnings + ;; + (add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil)) + + + (setq tramp-completion-reread-directory-timeout nil) + + (defun shell-make (dir buffer-name) + (let* ( + (default-directory dir) + (buffer (get-buffer-create buffer-name)) + ) + (set-buffer buffer) + (shell buffer) + )) + + (defun shell~ () (interactive) (shell-make "~" "shell~")) + (defun shell-root () (interactive) (shell-make "/sudo::/root" "shell-root")) + (defun shell-rt () (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com:~" "shell-rt")) + ;(defun shell-rt-root() (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:" "shell-rt-root")) + (defun shell-rt-root() (interactive) (shell-make "/ssh:root@reasoningtechnology.com:~" "shell-rt-root")) + + (defun shell-LFS () (interactive) (shell-make "/ssh:lfs@192.168.122.115:~" "shell-LFS")) + (defun shell-LFS-root () (interactive) (shell-make "/ssh:root@192.168.122.115:~" "shell-LFS-root")) + + (defun shell-Shihju () (interactive) (shell-make "/sudo:Shihju@localhost:/home/Shihju" "shell-Shihju")) + (defun shell-Wendell () (interactive) (shell-make "/ssh:Morpheus@Wendell:~" "shell-Wendell")) + (defun shell-Wendell-root () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Wendell:" "shell-Wendell-root")) + (defun shell-Wendell-Shihju () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Shihju@Wendell:" "shell-Wendell-Shihju")) + + + (defun dired-rt () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com:") + ) + + (defun dired-rt-root () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:") + ) + +;;-------------------------------------------------------------------------------- +;; gdb +;; use gud-gdb instead of gdb and we won't need this. +;; fix 'feature' of broken gdb where it takes control of an +;; emacs window, and locks the user out from switching from it +;; + (defun unlock-window () + "Turns off window dedication." + (interactive) + (set-window-dedicated-p (get-buffer-window (current-buffer)) nil) + ) + +;;-------------------------------------------------------------------------------- +;; shell scripting +;; + (setq sh-basic-offset 2) + +;;-------------------------------------------------------------------------------- +;; json +;; + (setq json-encoding-pretty-print t) + (setq json-encoding-lisp-style-closings t) + ;(setq json-encoding-lisp-style-closings nil) + (defun wrap-comma () + "wrap end of line comma to first of next line" + (interactive) + (while (re-search-forward "\\(.*\\), *\n\\( *\\)" nil t) (replace-match "\\1\n\\2,")) + ) + +;;-------------------------------------------------------------------------------- +;; rust +;; +;; (require 'package) +;; (add-to-list 'package-archives +;; '("melpa-stable" . "https://stable.melpa.org/packages/")) +;; (package-initialize) +;; (package-refresh-contents) +;; +;;; (setq rust-indent-offset 2) +;;; (require 'rust-mode) + +;;-------------------------------------------------------------------------------- +;; python +;; + (add-hook 'python-mode-hook '(lambda () (setq python-indent 2))) + +;;-------------------------------------------------------------------------------- +;; Lisp +;; + (setq lisp-indent-offset 2) + (setq inferior-lisp-program "sbcl") + + (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table) + (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table) + (modify-syntax-entry ?{ "(}" lisp-mode-syntax-table) + (modify-syntax-entry ?} "){" lisp-mode-syntax-table) + +;;-------------------------------------------------------------------------------- +;; Web page development +;; + ;(setq browse-url-browser-function 'browse-url-firefox) + (setq browse-url-browser-function 'browse-url-chrome) + ;(setq browse-url-browser-function 'browse-url-chromium) + + (setq js-indent-level 2) + (setq css-indent-offset 2) + (add-to-list 'auto-mode-alist '("\\.php\\'" . html-mode)) + +;;-------------------------------------------------------------------------------- +;; C +;; + (add-hook 'c-mode-hook (lambda () (modify-syntax-entry ?· "_"))) + ; in customer variables '(c-offsets-alist (quote ((label . 2)))) + (add-to-list 'auto-mode-alist '("\\.isq\\'" . c-mode)) + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(ansi-color-names-vector + ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) + '(c-basic-offset 2) + '(c-offsets-alist '((label . 2))) + '(column-number-mode t) + '(custom-enabled-themes '(wheatgrass deeper-blue)) + '(direx:closed-icon "╞") + '(direx:leaf-icon "┝") + '(direx:open-icon "╘") + '(ediff-diff-options "-w") + '(ediff-split-window-function 'split-window-horizontally) + '(ediff-window-setup-function 'ediff-setup-windows-plain) + '(geiser-racket-binary "racket") +; '(package-selected-packages '(ace-window neotree)) + '(send-mail-function 'smtpmail-send-it) + '(tool-bar-mode nil)) + + +;;-------------------------------------------------------------------------------- +;; emacs behavior + + (setq inhibit-startup-screen t) + + ;; stop the 'tab' character polution + ;; + (setq-default indent-tabs-mode nil) + + ;; turn off the poison C-z key. Use C-x C-z or the command suspend-emacs + ;; + (global-set-key (kbd "C-z") nil) + + ;; truncate rather than wrapping lines (use horizontal scroll to see to the right) + ;; + (set-default 'truncate-lines t) + (setq truncate-partial-width-windows nil) + (setq-default fill-column 80) + (setq fill-column 80) + + ;; recover some window real estate - note also F11 to rid of the top window splash bar + ;; + ;;(set-face-attribute 'mode-line nil :height 75) + + ;; c-x mode-line to toggle the mode-line on and off + (defun mode-line () "toggles the modeline on and off" + (interactive) + (setq mode-line-format + (if (equal mode-line-format nil) + (default-value 'mode-line-format)) ) + (redraw-display)) + + ;(setq-default mode-line-format nil) + (tool-bar-mode -1) + (menu-bar-mode -1) + + (put 'narrow-to-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'set-goal-column 'disabled nil) + (put 'erase-buffer 'disabled nil) + +(put 'upcase-region 'disabled nil) +;; vertical split for ediff + +;; '(package-selected-packages +;; '(ace-window switch-window dired-git ztree dirtree-prosjekt dired-sidebar dirtree direx neotree treemacs markdown-mode rust-mode)) + + diff --git a/library/archive/emacs_with_indent_stuff b/library/archive/emacs_with_indent_stuff new file mode 100644 index 0000000..54eb19d --- /dev/null +++ b/library/archive/emacs_with_indent_stuff @@ -0,0 +1,421 @@ + +;;-------------------------------------------------------------------------------- +;; Melpa +;; + (require 'package) + (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) + (not (gnutls-available-p)))) + (proto (if no-ssl "http" "https"))) + (when no-ssl (warn "\ + Your version of Emacs does not support SSL connections, + which is unsafe because it allows man-in-the-middle attacks. + There are two things you can do about this warning: + 1. Install an Emacs version that does support SSL and be safe. + 2. Remove this warning from your init file so you won't see it again.")) + (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) + ;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities` + ;; and `package-pinned-packages`. Most users will not need or want to do this. + ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) + ) + (package-initialize) + + ;(global-set-key (kbd "M-o") 'switch-window) + (global-set-key (kbd "M-o") 'ace-window) + (setq aw-background nil) + ;(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) + +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(default ((t (:family "Noto Sans Mono CJK JP" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) + '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + + ;; (use-package ace-window + ;; :init + ;; (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) + ;; (setq aw-background nil)) + +;;-------------------------------------------------------------------------------- +;; set the title at the top of the frame +;; + (defun frame-title (s) + "sets the frame title" + (interactive "stitle: ") + (setq frame-title-format s) + ) + +;;-------------------------------------------------------------------------------- +;; neotree +;; + ; now installed via Melpa + ;(add-to-list 'load-path "~/projects/neotree") + (require 'neotree) + (global-set-key [f8] 'neotree-toggle) + (setq neo-window-fixed-size nil) + (setq neo-smart-open t) + (setq neo-window-width 45) + +;;-------------------------------------------------------------------------------- +;; get buffer filename -- emacs does not have a built in functin for this. +;; + (defun filename-get () + "Gets the name of the file the current buffer is based on." + (buffer-file-name (window-buffer (minibuffer-selected-window)))) + + (defun filename-insert () + "Inserts the name of the file the current buffer is based on." + (interactive) + (insert (filename-get))) + + (global-set-key (kbd "C-c f") 'filename-insert) + + (defun filename () + "Gets the name of the file the current buffer is based on." + (interactive) + (message (filename-get)) + ) + +;;-------------------------------------------------------------------------------- +;; Tramp +;; +;;;https://www.gnu.org/software/emacs/manual/html_node/tramp/Frequently-Asked-Questions.html +;; + (setq tramp-completion-reread-directory-timeout nil) + + (defun shell-make (dir buffer-name) + (let* ( + (default-directory dir) + (buffer (get-buffer-create buffer-name)) + ) + (set-buffer buffer) + (shell buffer) + )) + + (defun shell~ () (interactive) (shell-make "~" "shell~")) + (defun shell-root () (interactive) (shell-make "/sudo::/root" "shell-root")) + (defun shell-rt () (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com:~" "shell-rt")) + ;(defun shell-rt-root() (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:" "shell-rt-root")) + (defun shell-rt-root() (interactive) (shell-make "/ssh:root@reasoningtechnology.com:~" "shell-rt-root")) + + (defun shell-LFS () (interactive) (shell-make "/ssh:lfs@192.168.122.115:~" "shell-LFS")) + (defun shell-LFS-root () (interactive) (shell-make "/ssh:root@192.168.122.115:~" "shell-LFS-root")) + + (defun shell-Shihju () (interactive) (shell-make "/sudo:Shihju@localhost:/home/Shihju" "shell-Shihju")) + (defun shell-Wendell () (interactive) (shell-make "/ssh:Morpheus@Wendell:~" "shell-Wendell")) + (defun shell-Wendell-root () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Wendell:" "shell-Wendell-root")) + (defun shell-Wendell-Shihju () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Shihju@Wendell:" "shell-Wendell-Shihju")) + + + (defun dired-rt () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com:") + ) + + (defun dired-rt-root () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:") + ) + +;;-------------------------------------------------------------------------------- +;; gdb +;; use gud-gdb instead of gdb and we won't need this. +;; fix 'feature' of broken gdb where it takes control of an +;; emacs window, and locks the user out from switching from it +;; + (defun unlock-window () + "Turns off window dedication." + (interactive) + (set-window-dedicated-p (get-buffer-window (current-buffer)) nil) + ) + + +;;-------------------------------------------------------------------------------- +;; json +;; + (setq json-encoding-pretty-print t) + (setq json-encoding-lisp-style-closings t) + ;(setq json-encoding-lisp-style-closings nil) + (defun wrap-comma () + "wrap end of line comma to first of next line" + (interactive) + (while (re-search-forward "\\(.*\\), *\n\\( *\\)" nil t) (replace-match "\\1\n\\2,")) + ) + +;;-------------------------------------------------------------------------------- +;; rust +;; +;; (require 'package) +;; (add-to-list 'package-archives +;; '("melpa-stable" . "https://stable.melpa.org/packages/")) +;; (package-initialize) +;; (package-refresh-contents) +;; +;;; (setq rust-indent-offset 2) +;;; (require 'rust-mode) + +;;-------------------------------------------------------------------------------- +;; python +;; + (add-hook 'python-mode-hook '(lambda () (setq python-indent 2))) + +;;-------------------------------------------------------------------------------- +;; Lisp +;; + (setq lisp-indent-offset 2) + (setq inferior-lisp-program "sbcl") + + (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table) + (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table) + (modify-syntax-entry ?{ "(}" lisp-mode-syntax-table) + (modify-syntax-entry ?} "){" lisp-mode-syntax-table) + +;;-------------------------------------------------------------------------------- +;; Javascript +;; + (setq js-indent-level 2) + (setq css-indent-offset 2) + +;;-------------------------------------------------------------------------------- +;; C +;; + (add-hook 'c-mode-hook (lambda () (modify-syntax-entry ?· "_"))) + ; in customer variables '(c-offsets-alist (quote ((label . 2)))) + +;;-------------------------------------------------------------------------------- +;; shell scripting +;; + (setq sh-basic-offset 2) + +;;-------------------------------------------------------------------------------- +;; extended character set for programming examples in the TTCA book +;; +;; preferable to have keys for the characters, but the keyboard is already overloaded .. +;; (define-key key-translation-map (kbd " p") (kbd "¬")) +;; (set-input-method “latin-9-prefix) + + (global-set-key [f1] 'help-command) + (global-set-key "\C-h" 'nil) + (define-key key-translation-map (kbd "M-S") (kbd "§")) + + (global-set-key (kbd "C-x g phi SPC") [?φ]) ; phi for phase + (global-set-key (kbd "C-x g Phi SPC") [?Φ]) + + (global-set-key (kbd "C-x g d SPC") [?δ]) + (global-set-key (kbd "C-x g D SPC") [?Δ]) ; this is 'delta' is not 'increment'! + (global-set-key (kbd "C-x g delta SPC") [?δ]) + (global-set-key (kbd "C-x g Delta SPC") [?Δ]) ; this is 'delta' is not 'increment'! + + (global-set-key (kbd "C-x g g SPC") [?γ]) + (global-set-key (kbd "C-x g G SPC") [?Γ]) + (global-set-key (kbd "C-x g gamma SPC") [?γ]) + (global-set-key (kbd "C-x g Gamma SPC") [?Γ]) + + (global-set-key (kbd "C-x g l SPC") [?λ]) + (global-set-key (kbd "C-x g L SPC") [?Λ]) + (global-set-key (kbd "C-x g lambda SPC") [?λ]) + (global-set-key (kbd "C-x g Lambda SPC") [?Λ]) + + (global-set-key (kbd "C-x g p SPC") [?π]) + (global-set-key (kbd "C-x g P SPC") [?Π]) + (global-set-key (kbd "C-x g pi SPC") [?π]) + (global-set-key (kbd "C-x g Pi SPC") [?Π]) + + (global-set-key (kbd "C-x g > = SPC") [?≥]) + (global-set-key (kbd "C-x g < = SPC") [?≤]) + (global-set-key (kbd "C-x g ! = SPC") [?≠]) + (global-set-key (kbd "C-x g neq SPC") [?≠]) + + (global-set-key (kbd "C-x g nil SPC") [?∅]) + + (global-set-key (kbd "C-x g not SPC") [?¬]) + + (global-set-key (kbd "C-x g and SPC") [?∧]) + (global-set-key (kbd "C-x g or SPC") [?∨]) + + (global-set-key (kbd "C-x g exists SPC") [?∃]) + (global-set-key (kbd "C-x g all SPC") [?∀]) + + (global-set-key (kbd "C-x g do SPC") [?⟳]) ; do + (global-set-key (kbd "C-x g rb SPC") [?◨]) + (global-set-key (kbd "C-x g lb SPC") [?◧]) + + (global-set-key (kbd "C-x g cont SPC") [?➜]) ; continue + (global-set-key (kbd "C-x g thread SPC") [?☥]) ; thread + + (global-set-key (kbd "C-x g in SPC") [?∈]) ; set membership + + (global-set-key (kbd "C-x g times SPC") [?×]) ; set membership + + (global-set-key (kbd "C-x g cdot SPC") [?·]) ; scoping sepearator for gcc C + + +;;-------------------------------------------------------------------------------- +;; turn off the annoying bell +;; +;; (setq ring-bell-function (lambda () +;; (call-process-shell-command +;; "xset led 3; xset -led 3" nil 0 nil))) +;; +;; (setq ring-bell-function nil) + + (setq ring-bell-function + (lambda () + (call-process-shell-command "xset led named 'Scroll Lock'") + (call-process-shell-command "xset -led named 'Scroll Lock'"))) + + +;;-------------------------------------------------------------------------------- +;; dirtrack +;; +;; get the pwd in shell mode from the prompt rather than guessing by +;; watching the commands typed .. yes! now shell variables and source +;; scripts will work +;; in bashrc: export PS1='\n$(/usr/local/bin/Z)\u@\h§\w§\n> ' +;; + (add-hook 'shell-mode-hook + (lambda () + (shell-dirtrack-mode -1) + (dirtrack-mode 1))) + + (add-hook 'dirtrack-directory-change-hook + (lambda () + (message default-directory))) + +;; (setq dirtrack-list '("§\\(.*\\)§\n[>#] " 1)) + (setq dirtrack-list '("§\\([^§]*\\)§" 1)) + +;;-------------------------------------------------------------------------------- +;; emacs behavior + + ;; use a backrevs dir rather than leaving ~file droppings everywhere + ;; + (setq backup-directory-alist `(("." . "~/emacs_backrevs"))) + (setq backup-by-copying t) + + ;; stop the 'tab' character polution + ;; + (setq-default indent-tabs-mode nil) + + ;; turn off the poison C-z key. Use C-x C-z or the command suspend-emacs + ;; + (global-set-key (kbd "C-z") nil) + + ;; truncate rather than wrapping lines (use horizontal scroll to see to the right) + ;; + (set-default 'truncate-lines t) + (setq truncate-partial-width-windows nil) + (setq-default fill-column 120) + (setq fill-column 120) + + ;; recover some window real estate - note also F11 to rid of the top window splash bar + ;; + ;;(set-face-attribute 'mode-line nil :height 75) + + ;; c-x mode-line to toggle the mode-line on and off + (defun mode-line () "toggles the modeline on and off" + (interactive) + (setq mode-line-format + (if (equal mode-line-format nil) + (default-value 'mode-line-format)) ) + (redraw-display)) + + ;(setq-default mode-line-format nil) + (tool-bar-mode -1) + (menu-bar-mode -1) + + (put 'upcase-region 'disabled nil) + (put 'narrow-to-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'set-goal-column 'disabled nil) + (put 'erase-buffer 'disabled nil) + +;(setq browse-url-browser-function 'browse-url-firefox) +(setq browse-url-browser-function 'browse-url-chrome) +;(setq browse-url-browser-function 'browse-url-chromium) + + + +;; vertical split for ediff +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(ansi-color-names-vector + ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) + '(c-offsets-alist '((label . 2))) + '(column-number-mode t) + '(custom-enabled-themes '(wheatgrass)) + '(direx:closed-icon "╞") + '(direx:leaf-icon "┝") + '(direx:open-icon "╘") + '(ediff-diff-options "-w") + '(ediff-split-window-function 'split-window-horizontally) + '(ediff-window-setup-function 'ediff-setup-windows-plain) + '(geiser-racket-binary "racket") + '(package-selected-packages + '(ace-window switch-window dired-git ztree dirtree-prosjekt dired-sidebar dirtree direx neotree treemacs markdown-mode rust-mode)) + '(send-mail-function 'smtpmail-send-it) + '(smtpmail-smtp-server "smtp.sendgrid.net") + '(tool-bar-mode nil)) + +;;-------------------------------------------------------------------------------- +;; direx +;; +;; (add-to-list 'load-path "~/.emacs.d/lisp/direx") +;; (require 'direx) +;; (global-set-key (kbd "C-x C-j") 'direx:jump-to-directory) +;; (push '(direx:direx-mode :position left :width 75 :dedicated t) +;; popwin:special-display-config) +(global-set-key (kbd "C-x C-j") 'direx:jump-to-directory-other-window) + + ;; (define-key map (kbd "R") 'direx:do-rename-file) + ;; (define-key map (kbd "C") 'direx:do-copy-files) + ;; (define-key map (kbd "D") 'direx:do-delete-files) + ;; (define-key map (kbd "+") 'direx:create-directory) + ;; (define-key map (kbd "M") 'direx:do-chmod-file) + ;; (define-key map (kbd "L") 'direx:do-load-file) + ;; (define-key map (kbd "B") 'direx:do-byte-compile-file) + ;; (define-key map (kbd "G") 'direx:do-chgrp) + ;; (define-key map (kbd "O") 'direx:do-chown) + ;; (define-key map (kbd "T") 'direx:do-touch) + + +;;---------- + +;(add-to-list 'tramp-connection-properties +; (list (regexp-quote "/ssh:thomas_lynch@reasoningtechnology.com:") +; "remote-shell" "/usr/bin/bash")) +; +;(customize-set-variable 'tramp-encoding-shell "/usr/bin/bash") + +(connection-local-set-profile-variables + 'remote-bash + '((explicit-shell-file-name . "/bin/bash") + (explicit-bash-args . ("-i")))) + +;(add-to-list 'tramp-connection-properties +; (list (regexp-quote "/ssh:thomas_lynch@reasoningtechnology.com:") +; "remote-shell" "/usr/bin/bash")) +; +;(customize-set-variable 'tramp-encoding-shell "/usr/bin/bash") + +;; (connection-local-set-profile-variables +;; 'remote-bash +;; '((explicit-shell-file-name . "/bin/bash") +;; (explicit-bash-args . ("-i")))) + +;; (connection-local-set-profiles +;; '(:application tramp :protocol "ssh" :machine "localhost") +;; 'remote-bash) + +;; (connection-local-set-profiles +;; '(:application tramp :protocol "ssh" :machine "reasoningtechnology.com") +;; 'remote-bash) + +;;(add-to-list 'tramp-connection-properties +;; (list nil "remote-shell" "/bin/bash")) + +(setq inhibit-startup-screen t) diff --git a/library/bash_profile b/library/bash_profile new file mode 100644 index 0000000..b279bef --- /dev/null +++ b/library/bash_profile @@ -0,0 +1,7 @@ +#!/bin/bash +export PATH="/home/Thomas/subu_data/incommon/executable:$PATH" +systemctl --user import-environment PATH +if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" +fi + diff --git a/library/bashrc b/library/bashrc new file mode 100644 index 0000000..35eefde --- /dev/null +++ b/library/bashrc @@ -0,0 +1,51 @@ +# .bashrc + +# because in x11 bash_profile is not getting sourced, so I've +# temporarily copied it here + +incommon=/home/Thomas/subu_data/incommon/executable +if [[ ":$PATH:" != *":$incommon:"* ]]; then + export PATH="$incommon:$PATH" +fi +systemctl --user import-environment PATH + + +# Localizations and editor preferences +export EDITOR=emacs +export PS_FORMAT='user:15,group:15,pid,command' + +# Shell behaviors +shopt -s histappend +shopt -s checkwinsize +HISTSIZE=400 +HISTFILESIZE=2000 + +# Prompt and visual environment +export PPS1='\n$(Z) [$PROMPT_DECOR:$ROLE] \u@\h\n§$(pwd)§\n> ' +export PPS2='>> ' +export PS1="$PPS1" +export PS2="$PPS2" + +# Aliases +alias emacs='emacs --title="${USER} ${PROMPT_DECOR}:$ROLE ${MODE}"' +alias pstree='pstree -lp' +alias printenv='printenv | awk '\''{gsub(/\n/, "\\n")}1'\'' | sort' +alias ls='ls -a -h --time-style=long-iso' +alias zzz="kill -STOP \$\$" +alias ps="ps -eo user:20,group:20,pid,command" + +# Visual tweaks — only if graphical session is available +if [[ -n "$DISPLAY" ]] && command -v gsettings >/dev/null 2>&1; then + export NO_AT_BRIDGE=1 + gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' 2>/dev/null + export GTK_THEME=Adwaita:dark +fi + +# Developer-specific env +if [[ "$user" == "Thomas-developer" ]]; then + export REPO_DIR=$(home) +fi + +# export JAVA_HOME=/usr/lib/jvm/default-java +# export ANDROID_HOME=$HOME/android-sdk + diff --git a/library/bashrc_root b/library/bashrc_root new file mode 100644 index 0000000..7f35e9a --- /dev/null +++ b/library/bashrc_root @@ -0,0 +1,27 @@ +# .bashrc + +# because in x11 bash_profile is not getting sourced, so I've +# temporarily copied it here + +# Localizations and editor preferences +export EDITOR=emacs +export PS_FORMAT='user:20,group:20,pid,command' + +# Shell behaviors +shopt -s histappend +shopt -s checkwinsize +HISTSIZE=400 +HISTFILESIZE=2000 + +# Prompt and visual environment +export PPS1='\n$(/usr/bin/date -u +"%Y-%m-%d %H:%M:%SZ") [root] \u@\h\n§$(pwd)§\n# ' +export PPS2='>> ' +export PS1="$PPS1" +export PS2="$PPS2" + +# Aliases +alias pstree='pstree -lp' +alias ls='ls -a -h --time-style=long-iso' +alias zzz="kill -STOP \$\$" + + diff --git a/library/el/key-matrix.el b/library/el/key-matrix.el new file mode 100644 index 0000000..622687a --- /dev/null +++ b/library/el/key-matrix.el @@ -0,0 +1,434 @@ +;; I abandoned this approach due to the many vagaries of assigning keys in +;; Emacs. The mappings are not orthogonal, and carry a heavy burden to legacy +;; terminal compatibility. I will instead attempt to define a custom keyboard +;; layout with chords and macros, and re-assign the keys from that layer. +;; + +;; the sake of sanity... +;; +(global-set-key (kbd "C-z") nil) ;; turn off the poison C-z key. Use C-x C-z or the command suspend-emacs +(global-set-key (kbd "C-v") nil) ;; tempting to put paste (yank) for a common typo, but at least lets not jump down the page +;; would be nice to clear C-c but minor modes redefine it + +;;-------------------------------------------------------------------------------- +(when t ; key-matrix minor mode + + (defadvice add-to-ordered-list (around key-matrix-add-to-ordered-list-advice activate) + "Ensure that `key-matrix-mode` always has precedence." + (if (eq (ad-get-arg 0) 'minor-mode-map-alist) + (let ( + (key-matrix-mode-pair (assoc 'key-matrix-mode minor-mode-map-alist)) + ) + (when key-matrix-mode-pair + (setq minor-mode-map-alist (delq key-matrix-mode-pair minor-mode-map-alist)) + (setq minor-mode-map-alist (cons key-matrix-mode-pair minor-mode-map-alist)))) + ad-do-it)) + + (defun key-matrix-make-minor-mode (mode-name) + "Make a custom minor mode with MODE-NAME." + (let* ( + (mode-symbol (intern (concat mode-name "-mode"))) + (lighter (concat " " mode-name)) + (keymap (make-sparse-keymap)) + ) + (eval `(define-minor-mode ,mode-symbol + ,(concat "A minor mode for " mode-name " key bindings.") + :init-value t + :lighter ,lighter + :keymap ',keymap)) + (eval `(,mode-symbol 1)) + mode-symbol)) +) + +;;-------------------------------------------------------------------------------- +(when t ; key-matrix support functions + + (defun key-matrix-dimensions (matrix) + "Return the dimensions of MATRIX as a list of two positive integers [rows, columns]." + (let ((rows (length matrix)) + (cols (if matrix (length (car matrix)) 0))) + (list rows cols))) + + (defun key-matrix-access (matrix row col) + "Return the value at the given coordinates (ROW, COL) from the provided MATRIX." + (if (and (>= row 0) (< row (length matrix)) + (>= col 0) (< col (length (nth row matrix)))) + (nth col (nth row matrix)) + (error "Coordinates out of range"))) + + (defun key-matrix-make-wrapper-matrix (wrapper-function button-matrix filter-list) + "Return a matrix of lambdas that call 'wrapper-function' with BUTTON-MATRIX and coordinates, filtered by FILTER-LIST." + (let* ((dimensions (key-matrix-dimensions button-matrix)) + (rows (car dimensions)) + (cols (cadr dimensions)) + (wrapper-matrix (make-vector rows nil))) + (message "key-matrix-make-wrapper-matrix dimensions: %d %d" rows cols) + (dotimes (i rows) + (aset wrapper-matrix i (make-vector cols nil)) + (dotimes (j cols) + (let ((button-function (key-matrix-access button-matrix i j))) + (when (or (not filter-list) (member button-function filter-list)) + (aset (aref wrapper-matrix i) j + `(lambda () + (interactive) + (message "Calling wrapper-function %s with button-function %s" + ',wrapper-function ',button-function) + (,wrapper-function ',button-function))))))) + wrapper-matrix)) + + ;; (defun key-matrix-make-wrapper-matrix (wrapper-function button-matrix filter-list) + ;; "Return a matrix of lambdas that call 'wrapper-function' with BUTTON-MATRIX and coordinates, filtered by FILTER-LIST." + ;; (let* ((dimensions (key-matrix-dimensions button-matrix)) + ;; (rows (car dimensions)) + ;; (cols (cadr dimensions)) + ;; (wrapper-matrix (make-vector rows nil))) + ;; (dotimes (i rows) + ;; (aset wrapper-matrix i (make-vector cols nil)) + ;; (dotimes (j cols) + ;; (let ((button-function (key-matrix-access button-matrix i j))) + ;; (when (or (not filter-list) (member button-function filter-list)) + ;; (aset (aref wrapper-matrix i) j + ;; `(lambda () + ;; (interactive) + ;; (,wrapper-function ,button-function))))))) + ;; wrapper-matrix)) + + (defun key-matrix-get-minor-mode-keymap (mode-symbol) + "Get the keymap of the minor mode specified by MODE-SYMBOL." + (cdr (assoc mode-symbol minor-mode-map-alist))) + + (defun key-matrix-bind (keymap button-matrix function-matrix &optional modifiers) + "Bind keys based on BUTTON-MATRIX and FUNCTION-MATRIX with optional MODIFIERS, string such as \"C-\" for Control, \"M-\" for Meta, etc. +KEYMAP specifies the keymap to use for these bindings." + (let ((rows (length button-matrix)) + (cols (if button-matrix (length (car button-matrix)) 0))) + (dotimes (i rows) + (dotimes (j cols) + (let ((button (nth j (nth i button-matrix))) + (function (nth j (nth i function-matrix)))) + (when function + (let ((key-binding + (if (and (string= button "m") (string= modifiers "C-")) + (kbd "") + (kbd (concat (or modifiers "") (if (stringp button) button (symbol-name button))))))) + (when t ; Change to nil to disable debugging + (message "Binding key %s to function %s in keymap %s" + (key-description key-binding) + function + keymap)) + (define-key keymap key-binding function)))))))) + + +) + +;;-------------------------------------------------------------------------------- +(when t ; places emacs functions into categories + (defun key-matrix-get-function-categories-alist () + "Return an associative list of function category lists." + (list + (cons 'navigation-function + '( forward-char backward-char forward-word backward-word + beginning-of-line end-of-line next-line previous-line + beginning-of-buffer end-of-buffer forward-sentence backward-sentence + forward-paragraph backward-paragraph forward-page backward-page + forward-list backward-list beginning-of-defun end-of-defun )) + (cons 'search-function + '( isearch-backward isearch-backward-regexp isearch-forward + isearch-forward-regexp re-search-backward re-search-forward + search-backward search-forward word-search-backward + word-search-forward query-replace replace-string )) + (cons 'edit-function + '( backward-kill-word capitalize-word comment-region + delete-backward-char delete-char downcase-region downcase-word + fill-paragraph indent-region join-line kill-line kill-region + kill-whole-line kill-word transpose-chars transpose-lines + transpose-words uncomment-region undo undo-tree-redo upcase-region + upcase-word yank )) + (cons 'buffer-function + '( switch-to-buffer kill-buffer save-buffer revert-buffer list-buffers + next-buffer previous-buffer rename-buffer clone-indirect-buffer )) + (cons 'file-function + '( find-file write-file save-some-buffers delete-file copy-file + rename-file set-visited-file-name )) + (cons 'window-function + '( split-window-right split-window-below delete-window + delete-other-windows other-window previous-window select-window + enlarge-window shrink-window enlarge-window-horizontally + shrink-window-horizontally save-window-excursion + window-configuration-to-register jump-to-register balance-windows + balance-windows-area windmove-right windmove-left windmove-up + windmove-down toggle-frame-fullscreen maximize-window minimize-window + )) + (cons 'frame-functions + '( make-frame-command delete-frame other-frame toggle-frame-fullscreen + frame-configuration-to-register jump-to-register + )) + )) + + (when nil + (let ((categories (key-matrix-get-function-categories-alist))) + (dolist (category categories) + (set (car category) (cdr category)))) + + (message "Navigation Functions: %S" navigation-function) + (message "Search Functions: %S" search-function) + (message "Edit Functions: %S" edit-function) + (message "Buffer Functions: %S" buffer-function) + (message "File Functions: %S" file-function) + (message "Window Functions: %S" window-function) + (message "Frame Functions: %S" frame-functions) + ) + ) + +;;-------------------------------------------------------------------------------- +(when t ; these functions can also be bound to keys + + (defun deactivate-mark-command () + "Deactivate the mark." + (interactive) + (deactivate-mark)) + + (defun toggle-picture-mode () + "Toggle between picture mode and the current mode." + (interactive) + (if (derived-mode-p 'picture-mode) + (picture-mode-exit) + (picture-mode))) + + (defun switch-to-previous-buffer () + "Switch to the previous buffer." + (interactive) + (switch-to-buffer (other-buffer (current-buffer) 1))) + + (defun switch-to-next-buffer () + "Switch to the next buffer." + (interactive) + (bury-buffer) + (switch-to-buffer (other-buffer (current-buffer) 1))) + + (defun start-scope () + "Move to the start of the current scope or paragraph." + (interactive) + (if (derived-mode-p 'prog-mode) + (progn + (condition-case nil + (backward-up-list) + (error (beginning-of-defun)))) + (scroll-up-command))) + + (defun end-scope () + "Move to the start of the current scope or paragraph." + (interactive) + (if (derived-mode-p 'prog-mode) + (progn + (condition-case nil + (backward-down-list) + (error (beginning-of-defun)))) + (scroll-up-command))) + + (defun delete-region-using-navigation (navigation-function) + "Set the mark, call the NAVIGATION-FUNCTION, then delete the resulting region." + (interactive) + (if navigation-function + (progn + (save-excursion + (let ((region (region-active-p))) + (unless region + (set-mark-command nil)) + (call-interactively navigation-function) + (kill-region (mark) (point)) + (when region + (activate-mark))))) + (message "No function defined at the specified coordinates."))) +) + +;;-------------------------------------------------------------------------------- +(when t ; button matrices + (defun key-matrix-get-button-matrices-alist () + "Return an associative list of button matrices." + (list + (cons 'button-matrix-keypad + '( + ("kp-add" "kp-subtract" "") ; from numlock: xmodmap -e "keycode 77 = F13" + ("kp-home" "kp-up" "kp-prior") + ("kp-left" "kp-begin" "kp-right") + ("kp-end" "kp-down" "kp-next") + ("kp-insert" "kp-delete" "kp-enter") + )) + (cons 'button-matrix-qwerty-right + '( + ("7" "8" "9" "0") + ("u" "i" "o" "p") + ("j" "k" "l" ";") + ("m" "," "." "/") + )) + (cons 'button-matrix-workman-right + '( + ("7" "8" "9" "0") + ("y" "u" "o" "i") + ("n" "e" "a" ";") + ("k" "," "." "/") + )))) + + (when nil + (let ((button-matrices (key-matrix-get-button-matrices-alist))) + (dolist (matrix button-matrices) + (set (car matrix) (cdr matrix)))) + + (message "Keypad Button Matrix: %S" button-matrix-keypad) + (message "QWERTY Right Button Matrix: %S" button-matrix-qwerty-right) + (message "Workman Right Button Matrix: %S" button-matrix-workman-right) + ) +) + +;;-------------------------------------------------------------------------------- +(when t ; function matrices + + (defun key-matrix-get-function-matrices-alist () + "Return an associative list of function matrices." + (let* ((categories (key-matrix-get-function-categories-alist)) + (navigation-function (cdr (assoc 'navigation-function categories))) + (function-matrix-navigation + '( + (keyboard-quit set-mark-command exchange-point-and-mark nil) + (backward-word forward-word start-scope end-scope) + (backward-char forward-char previous-line next-line) + (beginning-of-line end-of-line beginning-of-buffer end-of-buffer) + ))) + (list + (cons 'function-matrix-keypad-default + '( + ('+ '- num-lock) + (beginning-of-buffer previous-line scroll-down) + (backward-char recenter forward-char) + (end-of-buffer next-line scroll-up) + (nil delete-char newline) + )) + (cons 'function-matrix-navigation function-matrix-navigation) + (cons 'function-matrix-navigation-deletion + (key-matrix-make-wrapper-matrix 'delete-region-using-navigation function-matrix-navigation navigation-function)) + (cons 'function-matrix-edit + '( + (comment-region uncomment-region upcase-region downcase-region) + (indent-region fill-paragraph nil nil) + (copy-region cut-region paste-region delete-region) + (undo redo nil nil) + )) + (cons 'function-matrix-search + '( + (nil nil nil nil) + (query-replace replace-string replace-regexp nil) + (isearch-forward isearch-forward-regexp search-forward re-search-forward) + (isearch-backward isearch-backward-regexp search-backward re-search-backward) + )) + (cons 'function-matrix-buffer-file + '( + (nil nil nil nil) + (save-buffer rename-buffer kill-buffer revert-buffer) + (next-buffer previous-buffer switch-to-buffer list-buffers) + (find-file write-file nil nil) + )) + (cons 'function-matrix-window + '( + (toggle-frame-fullscreen other-frame make-frame-command delete-frame) + (nil nil nil nil) + (ace-window aw-delete-window delete-other-windows balance-windows) + (split-window-right split-window-below nil nil) + ))))) + + (when nil + (let ( + (function-matrices (key-matrix-get-function-matrices-alist)) + ) + (dolist (matrix function-matrices) + (set (car matrix) (cdr matrix)))) + + (message "Keypad Default Function Matrix: %S" function-matrix-keypad-default) + (message "Navigation Function Matrix: %S" function-matrix-navigation) + (message "Navigation Deletion Function Matrix: %S" function-matrix-navigation-deletion) + (message "Edit Function Matrix: %S" function-matrix-edit) + (message "Search Function Matrix: %S" function-matrix-search) + (message "Buffer File Function Matrix: %S" function-matrix-buffer-file) + (message "Window Function Matrix: %S" function-matrix-window) + ) +) + +;;-------------------------------------------------------------------------------- +(when t ; does the key binding + + (defun key-matrix-main (mode-name) + "Bind keys based on matrices and ensure they are set in a custom minor mode." + + ;; Translate C-m to F13 using key codes + (define-key input-decode-map (kbd "C-m") (kbd "")) + + (let ( + (button-matrices (key-matrix-get-button-matrices-alist)) + (function-matrices (key-matrix-get-function-matrices-alist)) + (mode-symbol (key-matrix-make-minor-mode mode-name)) + ) + (let ( + (keymap (key-matrix-get-minor-mode-keymap mode-symbol)) + (button-matrix-qwerty-right (cdr (assoc 'button-matrix-qwerty-right button-matrices))) + (navigation (cdr (assoc 'function-matrix-navigation function-matrices))) + (deletion (cdr (assoc 'function-matrix-deletion function-matrices))) + (edit (cdr (assoc 'function-matrix-edit function-matrices))) + (search (cdr (assoc 'function-matrix-search function-matrices))) + (file (cdr (assoc 'function-matrix-file function-matrices))) + (window (cdr (assoc 'function-matrix-window function-matrices))) + ) + ;;(message "QWERTY Right Button Matrix: %S" button-matrix-qwerty-right) + ;;(message "Keymap for %s: %s" mode-name keymap) + ;; Bind keys from the matrix + (key-matrix-bind keymap button-matrix-qwerty-right navigation "C-") + (key-matrix-bind keymap button-matrix-qwerty-right deletion "S-A-") + (key-matrix-bind keymap button-matrix-qwerty-right edit "A-") + (key-matrix-bind keymap button-matrix-qwerty-right search "S-C-") + (key-matrix-bind keymap button-matrix-qwerty-right file "S-C-A-") + (key-matrix-bind keymap button-matrix-qwerty-right window "C-A-") + ))) + + (defun key-matrix-disable-mode (mode-name) + "Disable the specified custom minor mode." + (let ((mode-symbol (intern (concat mode-name "-mode")))) + ;; Deactivate the minor mode + (when (boundp mode-symbol) (funcall mode-symbol 0)) + ;; Reset keyboard translation + (define-key input-decode-map (kbd "C-m") (kbd "RET")) + (message "Matrix key mode %s disabled." mode-name))) + + ) + + ;; Call key-matrix-main + ;; (key-matrix-main "RT-keys") + + ;; Example call to disable the custom key mode + ; (key-matrix-disable-mode "RT-keys") + +;; 1. navigation +;; 2. deletion +;; 3. edit +;; 4. search +;; 5. file +;; 6. window + + +;; Shift Control Alt Window (super) +;; supper is currently the compose key, so avoiding it. +;; SCAW +;; 0000 x +;; 1000 x +;; 0100 navigation +;; 1100 search +;; 0010 edit +;; 1010 deletion +;; 0110 window +;; 1110 file +;; 0001 +;; 1001 +;; 0101 +;; 1101 +;; 0011 +;; 1011 +;; 0111 +;; 1111 diff --git a/library/el/key.el b/library/el/key.el new file mode 100644 index 0000000..3e9f584 --- /dev/null +++ b/library/el/key.el @@ -0,0 +1,87 @@ +;; the sake of sanity... +;; +(global-set-key (kbd "C-z") nil) ;; turn off the poison C-z key. Use C-x C-z or the command suspend-emacs +(global-set-key (kbd "C-v") nil) ;; tempting to put paste (yank) for a common typo, but at least lets not jump down the page +;; would be nice to clear C-c but minor modes redefine it + + +;;-------------------------------------------------------------------------------- +;; extended character set for programming examples in the TTCA book +;; +;; preferable to use an Xcompose file definition when available +;; +(when t + + (global-set-key [f1] 'help-command) + (global-set-key "\C-h" 'nil) + (define-key key-translation-map (kbd "M-S") (kbd "§")) + + (global-set-key (kbd "C-x g copyright SPC") [?©]) + + (global-set-key (kbd "C-x g phi SPC") [?φ]) ; phi for phase + (global-set-key (kbd "C-x g Phi SPC") [?Φ]) + + (global-set-key (kbd "C-x g d SPC") [?δ]) + (global-set-key (kbd "C-x g D SPC") [?Δ]) ; this is 'delta' is not 'increment'! + (global-set-key (kbd "C-x g delta SPC") [?δ]) + (global-set-key (kbd "C-x g Delta SPC") [?Δ]) ; this is 'delta' is not 'increment'! + + (global-set-key (kbd "C-x g g SPC") [?γ]) + (global-set-key (kbd "C-x g G SPC") [?Γ]) + (global-set-key (kbd "C-x g gamma SPC") [?γ]) + (global-set-key (kbd "C-x g Gamma SPC") [?Γ]) + + (global-set-key (kbd "C-x g l SPC") [?λ]) + (global-set-key (kbd "C-x g L SPC") [?Λ]) + (global-set-key (kbd "C-x g lambda SPC") [?λ]) + (global-set-key (kbd "C-x g Lambda SPC") [?Λ]) + + (global-set-key (kbd "C-x g m SPC") [?μ]) + (global-set-key (kbd "C-x g M SPC") [?Μ]) + (global-set-key (kbd "C-x g mu SPC") [?μ]) + (global-set-key (kbd "C-x g Mu SPC") [?Μ]) + + (global-set-key (kbd "C-x g p SPC") [?π]) + (global-set-key (kbd "C-x g P SPC") [?Π]) + (global-set-key (kbd "C-x g pi SPC") [?π]) + (global-set-key (kbd "C-x g Pi SPC") [?Π]) + + (global-set-key (kbd "C-x g x SPC") [?ξ]) + (global-set-key (kbd "C-x g X SPC") [?Ξ]) + (global-set-key (kbd "C-x g xi SPC") [?ξ]) + (global-set-key (kbd "C-x g Xi SPC") [?Ξ]) + + (global-set-key (kbd "C-x g > = SPC") [?≥]) + (global-set-key (kbd "C-x g < = SPC") [?≤]) + (global-set-key (kbd "C-x g ! = SPC") [?≠]) + (global-set-key (kbd "C-x g neq SPC") [?≠]) + + (global-set-key (kbd "C-x g nil SPC") [?∅]) + + (global-set-key (kbd "C-x g not SPC") [?¬]) + + (global-set-key (kbd "C-x g and SPC") [?∧]) + (global-set-key (kbd "C-x g or SPC") [?∨]) + + (global-set-key (kbd "C-x g exists SPC") [?∃]) + (global-set-key (kbd "C-x g all SPC") [?∀]) + + (global-set-key (kbd "C-x g do SPC") [?⟳]) ; do + + ;; instead of using these for leftmost, rightmost instead using C, and Ɔ. + (global-set-key (kbd "C-x g rb SPC") [?◨]) + (global-set-key (kbd "C-x g lb SPC") [?◧]) + + (global-set-key (kbd "C-x g cont SPC") [?➜]) ; continue + (global-set-key (kbd "C-x g thread SPC") [?☥]) ; thread + + (global-set-key (kbd "C-x g in SPC") [?∈]) ; set membership + + (global-set-key (kbd "C-x g times SPC") [?×]) ; set membership + + (global-set-key (kbd "C-x g cdot SPC") [?·]) ; scoping sepearator for gcc C + (global-set-key (kbd "C-x g pencil SPC") [?🖉]) ; scoping sepearator for gcc C + (global-set-key (kbd "C-x g CO SPC") [?Ɔ]) ; scoping sepearator for gcc C + + +) diff --git a/library/el/key_key-chord.el b/library/el/key_key-chord.el new file mode 100644 index 0000000..236f6d4 --- /dev/null +++ b/library/el/key_key-chord.el @@ -0,0 +1,63 @@ +;;================================================================================ +;; ;;---------------------------------------- +;; ;; key-chord +;; ;; Example of defining key chords +;; ;; Install and configure Key Chord Mode +;; (use-package key-chord +;; :ensure t +;; :config +;; (key-chord-mode 1) +;; (setq key-chord-two-keys-delay 0.1) + +;; (defun chord-from-bin (str bin) +;; "Return characters in STR that correspond to ones in BIN." +;; ;;ex: (chord-from-bin "abcdef" "101001") -> "acf" +;; (let ((result "")) +;; (dotimes (i (min (length str) (length bin))) +;; (when (= (aref bin i) ?1) +;; (setq result (concat result (string (aref str i)))))) +;; result)) + +;; (defun make-chord-define (str) +;; (lambda (bin f) +;; (let ( +;; (chord (filter-by-binary str bin)) +;; ) +;; (key-chord-define-global chord f) +;; ))) + +;; ;; str must be 4 chars +;; (defun chord-buffer (str) +;; (setq define-chord (make-chord-define str)) +;; ;; 0000 - +;; ;; 1000 - +;; ;; 0100 - +;; ;; 1100 2 +;; (funcall define-chord "1100" 'save-buffer) +;; ;; 0010 - +;; ;; 1010 2 +;; (funcall define-chord "1010" 'kill-buffer) +;; ;; 0110 2 +;; (funcall define-chord "0110" 'rename-buffer) +;; ;; 1110 3 +;; (funcall define-chord "1110" 'buffer-menu) +;; ;; 0001 - +;; ;; 1001 2 +;; (funcall define-chord "1001" 'ace-window) +;; ;; 0101 2 +;; (funcall define-chord "0101" 'list-buffers) +;; ;; 1101 3 +;; (funcall define-chord "1101" 'diff-buffer-with-file) +;; ;; 0011 2 +;; ;; 1011 3 +;; (funcall define-chord "1011" 'revert-buffer) +;; ;; 0111 3 +;; ;; 1111 3 +;; (funcall define-chord "1111" 'keyboard-quit) +;; ) + +;; (chord-buffer "qwer") + +;; ) + + diff --git a/library/el/lisp.el b/library/el/lisp.el new file mode 100644 index 0000000..bb2dc76 --- /dev/null +++ b/library/el/lisp.el @@ -0,0 +1,66 @@ +;;-------------------------------------------------------------------------------- +;; get the name of the file being 'visited' by the buffer +;; +(when t + (setq lisp-indent-offset 2) + (setq inferior-lisp-program "sbcl") + + (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table) + (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table) + (modify-syntax-entry ?{ "(}" lisp-mode-syntax-table) + (modify-syntax-entry ?} "){" lisp-mode-syntax-table) + + ;; get buffer filename -- emacs does not have a builtin function for this. + (when t + (defun filename-get () + "Gets the name of the file the current buffer is based on." + (buffer-file-name (window-buffer (minibuffer-selected-window))) + ) + + (defun filename-insert () + "Inserts the name of the file the current buffer is based on." + (interactive) + (insert (filename-get)) + ) + + (global-set-key (kbd "C-c f") 'filename-insert) + + (defun filename () + "Gets the name of the file the current buffer is based on." + (interactive) + (message (filename-get)) + ) + + ) + ) + +;;-------------------------------------------------------------------------------- +;; unfill a paragraph +;; + +(defun unfill-paragraph () + "Transform a filled paragraph into a single line of text." + (interactive) + (let ((fill-column (point-max))) + (fill-paragraph nil))) + + +;;-------------------------------------------------------------------------------- +;; misc +;; + + (defun mode-line () "toggles the modeline on and off" + (interactive) + (setq mode-line-format + (if (equal mode-line-format nil) + (default-value 'mode-line-format)) ) + (redraw-display)) + + ;; use set set-frame-name + ;; + ;; (defun frame-title (s) + ;; "sets the frame title" + ;; (interactive "stitle: ") + ;; (setq frame-title-format s) + ;; ) + diff --git a/library/el/main.el b/library/el/main.el new file mode 100644 index 0000000..c00f8d0 --- /dev/null +++ b/library/el/main.el @@ -0,0 +1,148 @@ +;; ;; The rest of your appearance settings... +;; ) + +;; (when t +;; (setq ansi-color-names-vector +;; ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) +;; (setq custom-enabled-themes '(wheatgrass deeper-blue)) + +;; (custom-set-faces +;; '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) +;; '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + + +;;-------------------------------------------------------------------------------- +;; appearance +(when t + (setq ansi-color-names-vector + ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) + + (custom-set-faces + '(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight normal :height 98 :width normal)))) + '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))) + + (load-theme 'wheatgrass t) + + (setq inhibit-startup-screen t) + + (setq ring-bell-function 'ignore) + (setq visible-bell nil) + + (setq column-number-mode t) + (tool-bar-mode -1) + (menu-bar-mode -1) + (scroll-bar-mode -1) + + ) + +;;-------------------------------------------------------------------------------- +;; basic settings +(when t + (setq-default indent-tabs-mode nil) ;; stop the 'tab' character pollution + (put 'narrow-to-region 'disabled nil) + (put 'downcase-region 'disabled nil) + (put 'set-goal-column 'disabled nil) + (put 'erase-buffer 'disabled nil) + (put 'upcase-region 'disabled nil) + (set-language-environment "UTF-8") + (add-hook 'text-mode-hook 'flyspell-mode) + (add-hook 'prog-mode-hook 'flyspell-prog-mode) + (setq ispell-dictionary "en_US") + (setq fill-column 80) + ) + +;;-------------------------------------------------------------------------------- +;; prevent repo pollution +;; (when t +;; ;; so that lock files do not end up in the repo +;; (setq create-lockfiles nil) + +;; ;; use a backrevs dir rather than leaving ~file droppings everywhere +;; (setq backup-directory-alist `(("." . "~/emacs_backrevs"))) +;; (setq backup-by-copying t) +;; ) + +;;-------------------------------------------------------------------------------- +;; prevent repo pollution (localize all backups/autosaves, incl. TRAMP) +(when t + (setq create-lockfiles nil) ;; avoid .# lock files anywhere (esp. remote) + + (let* ((backrevs (expand-file-name "~/emacs_backrevs/")) + (autosave (expand-file-name "~/emacs_backrevs/auto-save/")) + (tramp-as (expand-file-name "~/emacs_backrevs/tramp-auto-save/"))) + (dolist (d (list backrevs autosave tramp-as)) + (unless (file-directory-p d) (make-directory d t))) + + ;; Backups (~ files) go to backrevs, for both local and TRAMP + (setq backup-by-copying t + version-control t + delete-old-versions t + kept-new-versions 10 + kept-old-versions 2 + backup-directory-alist `(("." . ,backrevs)) + tramp-backup-directory-alist `(("." . ,backrevs))) + + ;; Autosaves (#…#) go to autosave dirs (TRAMP separate) + (setq auto-save-default t + auto-save-include-big-deletions t + auto-save-file-name-transforms `((".*" ,autosave t)) + tramp-auto-save-directory tramp-as))) + + (setq backup-by-copying-when-linked t) + + +;;-------------------------------------------------------------------------------- +;; tell emacs to write customizations stuff back into the users .emacs file +;; without this it will try to write them here, and fail +(when t + (setq custom-file nil) ; using '.emacs' causes a 'ciruclar reference error' .. why? dunno. + ) + +;;-------------------------------------------------------------------------------- +;; dired +(when t + (defun dired-open-shell () + "Open a shell in the directory associated with the current buffer." + (interactive) + (let* ( + (dir-dired (dired-current-directory)) + (buffer-shell-name (concat "shell-" (replace-regexp-in-string "/" "-" dir-dired) "*")) + ) + (if dir-dired + (progn + (kill-buffer (current-buffer)) + (switch-to-buffer buffer-shell-name) + (shell (current-buffer)) + (cd dir-dired) + )))) + + (eval-after-load "dired" + '(define-key dired-mode-map "1" 'dired-open-shell) + ) + ) + +;;-------------------------------------------------------------------------------- +;; emacs shell +(when t + ;; get the pwd in shell mode from the prompt rather than guessing by + ;; watching the commands typed .. yes! now shell variables and source + ;; scripts will work + ;; in bashrc: export PS1='\n$(/usr/local/bin/Z)\u@\h§\w§\n> ' + ;; + + ;; (setq dirtrack-list '("§\\(.*\\)§\n[>#] " 1)) + (setq dirtrack-list '("§\\([^§]*\\)§" 1)) + + (add-hook 'shell-mode-hook + (lambda () + (shell-dirtrack-mode -1) + (dirtrack-mode 1) + (comint-send-input) ;; send an input at the shell start so it will boot the dir track + )) + + (add-hook 'dirtrack-directory-change-hook + (lambda () + (message default-directory))) + + ) + diff --git a/library/el/package.el b/library/el/package.el new file mode 100644 index 0000000..a79f3b1 --- /dev/null +++ b/library/el/package.el @@ -0,0 +1,86 @@ +;; Package setup +(when t + (setq byte-compile-warnings '(cl-functions)) + + ;; Ensure package archives are set up + (require 'package) + (setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("gnu" . "https://elpa.gnu.org/packages/"))) + (package-initialize) + + (defun update-packages () + "Interactively update all packages from package-archives." + (interactive) + (when (y-or-n-p "Do you want to refresh package contents and update missing packages?") + (message "Refreshing package contents...") + (package-refresh-contents) +; (ensure-package-installed '(neotree groovy-mode ace-window adaptive-wrap)) + (ensure-package-installed 'neotree) + (ensure-package-installed 'groovy-mode) + (ensure-package-installed 'ace-window) + (ensure-package-installed 'adaptive-wrap) + (message "Package updates complete!"))) + + ;; Notify on startup + (add-hook 'emacs-startup-hook + (lambda () + (message "To update packages, run M-x update-packages."))) + + (defun maybe-refresh-packages () + "Prompt user to refresh package contents if desired." + (when (y-or-n-p "Refresh package contents? ") + (package-refresh-contents))) + + (defun ensure-package-installed (pkg) + "Ensure the given PKG is installed. Prompt to refresh packages if necessary." + (unless (package-installed-p pkg) + (maybe-refresh-packages) + (unless (package-installed-p pkg) + (package-install pkg)))) + + + ;; Configure NeoTree + (with-eval-after-load 'neotree + (setq neo-window-fixed-size nil) + (setq neo-smart-open t) + (setq neo-window-width 45)) + + (global-set-key [f8] 'neotree-toggle) + + ;; Custom NeoTree sorting + (defadvice neo-buffer--get-nodes + (after neo-buffer--get-nodes-new-sorter activate) + (setq ad-return-value + (let ((nodes ad-return-value) + (comparator (lambda (s1 s2) (string< (downcase (reverse-file-extension s1)) + (downcase (reverse-file-extension s2)))))) + (apply 'cons (mapcar (lambda (x) (sort (apply x (list nodes)) + comparator)) + '(car cdr)))))) + + (defun reverse-file-extension (filename) filename) + ;; Original categorizes by filename extension + ;; (defun reverse-file-extension (filename) + ;; (mapconcat 'identity (reverse (split-string filename "\\.")) ".")) + + ;; Ace Window Manager configuration + (when (package-installed-p 'ace-window) + (require 'ace-window) + (global-set-key (kbd "C-x o") 'ace-window)) + + ;; adaptive-wrap line mode + (if + (package-installed-p 'adaptive-wrap) + (progn + (require 'adaptive-wrap) + (setq-default visual-line-mode-desired-column 80) + (global-visual-line-mode 1) + (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode) + ) + (progn + (set-default 'truncate-lines t) ;; truncate rather than wrapping lines (use horizontal scroll to see to the right) + (setq truncate-partial-width-windows nil) + (setq-default fill-column 80) + (setq fill-column 80) + )) +) diff --git a/library/el/programming.el b/library/el/programming.el new file mode 100644 index 0000000..4e2b3d8 --- /dev/null +++ b/library/el/programming.el @@ -0,0 +1,94 @@ +;;-------------------------------------------------------------------------------- +;; gdb +;; use gud-gdb instead of gdb and we won't need this. +;; fix 'feature' of broken gdb where it takes control of an +;; emacs window, and locks the user out from switching from it +(when t + (defun unlock-window () + "Turns off window dedication." + (interactive) + (set-window-dedicated-p (get-buffer-window (current-buffer)) nil) + ) + ) + +;;-------------------------------------------------------------------------------- +;; shell +;; +(when t + (setq sh-basic-offset 2) + ) + +;;-------------------------------------------------------------------------------- +;; json +(when t + (setq json-encoding-pretty-print t) + (setq json-encoding-lisp-style-closings t) + ;(setq json-encoding-lisp-style-closings nil) + (defun wrap-comma () + "wrap end of line comma to first of next line" + (interactive) + (while (re-search-forward "\\(.*\\), *\n\\( *\\)" nil t) (replace-match "\\1\n\\2,")) + ) + ) + +;;-------------------------------------------------------------------------------- +;; rust +;; +;; (require 'package) +;; (add-to-list 'package-archives +;; '("melpa-stable" . "https://stable.melpa.org/packages/")) +;; (package-initialize) +;; (package-refresh-contents) +;; +;;; (setq rust-indent-offset 2) +;;; (require 'rust-mode) + +;;-------------------------------------------------------------------------------- +;; python +(when t + (add-hook 'python-mode-hook '(lambda () (setq python-indent 2))) + ) + +;;-------------------------------------------------------------------------------- +;; Web page development +(when t + ;(setq browse-url-browser-function 'browse-url-firefox) + ;(setq browse-url-browser-function 'browse-url-chrome) + ;(setq browse-url-browser-function 'browse-url-chromium) + +(setq browse-url-browser-function 'browse-url-generic + browse-url-generic-program "firefox") + + (setq js-indent-level 2) + (setq css-indent-offset 2) + (add-to-list 'auto-mode-alist '("\\.php\\'" . html-mode)) + ) + +;;-------------------------------------------------------------------------------- +;; C +;; +(when t + (setq c-basic-offset 2) + (setq c-offsets-alist '((label . 2))) + (add-hook 'c-mode-hook (lambda () (modify-syntax-entry ?· "_"))) + ; in customer variables '(c-offsets-alist (quote ((label . 2)))) + (add-to-list 'auto-mode-alist '("\\.isq\\'" . c-mode)) + ) + + +;;-------------------------------------------------------------------------------- +;; lisp +;; + (setq-default lisp-indent-offset 2) ; Set indentation for Lisp modes + +;;-------------------------------------------------------------------------------- +;; groovy +;; + + ;; Configure NeoTree + (with-eval-after-load 'groovy-mode + (setq groovy-indent-offset 2) + ) + + ;; Enable Groovy mode for files with `#!/usr/bin/env groovy` shebang + (add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode)) diff --git a/library/el/tramp.el b/library/el/tramp.el new file mode 100644 index 0000000..3d81aea --- /dev/null +++ b/library/el/tramp.el @@ -0,0 +1,116 @@ +;;-------------------------------------------------------------------------------- +;; Tramp +;; +;;;https://www.gnu.org/software/emacs/manual/html_node/tramp/Frequently-Asked-Questions.html +;; + + +;; remote shells with Tramp always come up in sh, not bash. +;; This tries to convince tramp to use bash. +(when t + + ;; this does nothing in fact + (with-eval-after-load 'tramp + ;; Use bash for remote commands, and treat them as login (-l) so profile/rc files run. + (setq tramp-remote-shell "/bin/bash") + (setq tramp-remote-shell-args '("-lc"))) ;; login + run command + + ;; this should force all shells to be bash + (defun shell-make (dir buffer-name) + (let* ((default-directory dir) + (buffer (get-buffer-create buffer-name))) + (with-current-buffer buffer + ;; Force bash for this shell buffer (remote or local) + (setq-local explicit-shell-file-name "/bin/bash") + (setq-local shell-file-name "/bin/bash") + ;; Login shell; interactive because comint allocates a pty + (setq-local explicit-bash-args '("-l")) + ;; Avoid echoed input in TRAMP shells + (setq-local comint-process-echoes t)) + (shell buffer))) + + ;; maybe this would do it + (with-eval-after-load 'tramp + (connection-local-set-profile-variables + 'rt/remote-bash + '((explicit-shell-file-name . "/bin/bash") + (shell-file-name . "/bin/bash") + (explicit-bash-args . ("-l")) + (comint-process-echoes . t))) + + ;; Apply to all SSH TRAMP connections + (connection-local-set-profiles '(:application tramp :protocol "ssh") 'rt/remote-bash)) + +) + +(when t + + ;; trap wants to write to /tmp, but when logged in as root it causes failures and pop up new frames with warnings + ;; + ;; --> this is causing it to leave emacs droppings all over: + ;; (add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil)) + + (setq tramp-completion-reread-directory-timeout nil) + + (defun shell-make (dir buffer-name) + (let* ( + (default-directory dir) + (buffer (get-buffer-create buffer-name)) + ) + (set-buffer buffer) + (shell buffer) + )) + + (defun shell~ () (interactive) (shell-make "~" "shell~")) + (defun shell-root () (interactive) (shell-make "/sudo::/root" "shell-root")) + + (defun shell-rt-Thomas () (interactive) (shell-make "/ssh:rt-Thomas:~" "shell-rt")) + (defun shell-rt-root () (interactive) (shell-make "/ssh:rt-root:~" "shell-rt-root")) + + (defun shell-x6-Thomas () (interactive) (shell-make "/ssh:x6-Thomas:~" "shell-x6-Thomas")) + (defun shell-x6-root () (interactive) (shell-make "/ssh:x6-root:~" "shell-x6-root")) + + +;; (defun shell-rt () (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com:~" "shell-rt")) +;; (defun shell-rt-root() (interactive) (shell-make "/ssh:root@reasoningtechnology.com:~" "shell-rt-root")) + + ;;(defun shell-rt-root() (interactive) (shell-make "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:" "shell-rt-root")) + ;;(defun shell-rt-root() (interactive) (shell-make "/ssh:reasoningtechnology-root:~" "shell-rt-root")) + ;;(defun shell-rt-root() (interactive) (shell-make "/ssh:root@35.194.71.194:~" "shell-rt-root")) + + + (defun shell-LFS () (interactive) (shell-make "/ssh:lfs@192.168.122.115:~" "shell-LFS")) + (defun shell-LFS-root () (interactive) (shell-make "/ssh:root@192.168.122.115:~" "shell-LFS-root")) + + (defun shell-Shihju () (interactive) (shell-make "/sudo:Shihju@localhost:/home/Shihju" "shell-Shihju")) + (defun shell-Wendell () (interactive) (shell-make "/ssh:Morpheus@Wendell:~" "shell-Wendell")) + (defun shell-Wendell-root () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Wendell:" "shell-Wendell-root")) + (defun shell-Wendell-Shihju () (interactive) (shell-make "/ssh:Morpheus@Wendell|sudo:Shihju@Wendell:" "shell-Wendell-Shihju")) + + (defun shell-Pi + () + (interactive) + (shell-make "/ssh:piuser@Pi:~" "shell-Pi") + ) + + (defun shell-Pi-root + () + (interactive) + (shell-make + "/ssh:piuser@Pi|sudo:root@Pi:" + "shell-Pi-root" + )) + + + + (defun dired-rt () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com:") + ) + + (defun dired-rt-root () + (interactive) + (dired "/ssh:thomas_lynch@reasoningtechnology.com|sudo:reasoningtechnology.com:") + ) + +) diff --git a/library/emacs b/library/emacs new file mode 100644 index 0000000..40ef484 --- /dev/null +++ b/library/emacs @@ -0,0 +1,14 @@ + +(when t + (message ".emacs/emacs") + (let ( + (el-dir (concat "el/" (file-name-directory load-file-name))) + ) + (load (concat el-dir "el/lisp.el")) + (load (concat el-dir "el/main.el")) + (load (concat el-dir "el/key.el")) + (load (concat el-dir "el/package.el")) + (load (concat el-dir "el/tramp.el")) + (load (concat el-dir "el/programming.el")) + ) +) diff --git a/library/emacs_local b/library/emacs_local new file mode 100644 index 0000000..2576441 --- /dev/null +++ b/library/emacs_local @@ -0,0 +1,6 @@ + +;; Load the common configuration file +(load "/home/Thomas-mastu/incommon/library/emacs") + +;; User-specific configurations go below this line + diff --git a/library/sound_headphone b/library/sound_headphone new file mode 100644 index 0000000..9740c8e --- /dev/null +++ b/library/sound_headphone @@ -0,0 +1,113 @@ + +If we use the terminology state and nation + +both ... + +taiwan contested + +the chinese have referred to officially as ancient sacred territory +the taiwanse + +one government two system .. so in an uncontested manner we can refer +to Taiwan as that second system. + +due to this desparaty any community wiki article on Taiwan will of course present unique challenges.. + +today's political situation is not unique, similar situation in Qing era + + +systemctl --user restart pipewire pipewire-pulse wireplumber + +pactl set-default-source alsa_input.usb-Logi_USB_Headset_Logi_USB_Headset-00.mono-fallback + + + + +pactl list sinks short +pactl list sources short + +pactl set-default-sink +pactl set-default-source + +---- +for aldervine or whatever it is called, to work (these will already be installed) +dnf install xdg-desktop-portal xdg-desktop-portal-gtk + +as user: +systemctl --user restart xdg-desktop-portal + + + + +# set defaults to the current device +# pactl move-sink-input +# pactl move-source-output + + +Yes, you can use pactl or alsamixer to set the microphone and speaker devices on Fedora. Here's how: + +Using pactl (PulseAudio): +List available sinks (speakers): + +bash +Copy code +pactl list sinks short +Identify the sink (speaker) you'd like to use. Note its name or index. + +Set the default sink (speaker): + +bash +Copy code +pactl set-default-sink +List available sources (microphones): + +bash +Copy code +pactl list sources short +Identify the source (microphone) you'd like to use. Note its name or index. + +Set the default source (microphone): + +bash +Copy code +pactl set-default-source +Move currently active streams to the new default sink/source: For sink: + +bash +Copy code +pactl move-sink-input +For source: + +bash +Copy code +pactl move-source-output +You can find input/output indices using: + +bash +Copy code +pactl list sink-inputs +pactl list source-outputs +Using alsamixer (for ALSA directly): +Open alsamixer: +bash +Copy code +alsamixer +Press F6 to select the sound card. +Use arrow keys to navigate and adjust volumes or toggle input/output devices. +Automating Device Selection: +To make this persistent across reboots: + +Create or edit a PulseAudio configuration file: +bash +Copy code +nano ~/.config/pulse/default.pa +Add lines to set your preferred devices: +text +Copy code +set-default-sink +set-default-source +Restart PulseAudio: +bash +Copy code +systemctl --user restart pulseaudio +

: "ℙ" U2119 # double-struck capital P + : "ℚ" U211A # double-struck capital Q + : "ℝ" U211D # double-struck capital R + : "𝕊" U1D54A # double-struck capital S + : "𝕋" U1D54B # double-struck capital T + : "𝕌" U1D54C # double-struck capital U + : "𝕍" U1D54D # double-struck capital V + : "𝕎" U1D54E # double-struck capital W + : "𝕏" U1D54F # double-struck capital X + : "𝕐" U1D550 # double-struck capital Y + : "ℤ" U2124 # double-struck capital Z + + : "𝕒" U1D552 # double-struck lowercase a + : "𝕓" U1D553 # double-struck lowercase b + : "𝕔" U1D554 # double-struck lowercase c + : "𝕕" U1D555 # double-struck lowercase d + : "𝕖" U1D556 # double-struck lowercase e + : "𝕗" U1D557 # double-struck lowercase f + : "𝕘" U1D558 # double-struck lowercase g + : "𝕙" U1D559 # double-struck lowercase h + : "𝕚" U1D55A # double-struck lowercase i + : "𝕛" U1D55B # double-struck lowercase j + : "𝕜" U1D55C # double-struck lowercase k + : "𝕝" U1D55D # double-struck lowercase l + : "𝕞" U1D55E # double-struck lowercase m + : "𝕟" U1D55F # double-struck lowercase n + : "𝕠" U1D560 # double-struck lowercase o +