changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: init alik installer example, more emacs-lisp

changeset 422: 3e0a434b0c56
parent 421: 05e9cbc641dd
child 423: d2966214778d
author: Richard Westhaver <ellis@rwest.io>
date: Thu, 06 Jun 2024 23:15:11 -0400
files: emacs/default.el emacs/lib/publish.el emacs/lib/skt.el rust/ui/alik/Cargo.toml rust/ui/alik/examples/installer.rs
description: init alik installer example, more emacs-lisp
     1.1--- a/emacs/default.el	Thu Jun 06 17:53:22 2024 -0400
     1.2+++ b/emacs/default.el	Thu Jun 06 23:15:11 2024 -0400
     1.3@@ -54,11 +54,9 @@
     1.4 (defvar user-custom-file (expand-file-name (format "%s.el" user-login-name) user-emacs-directory))
     1.5 (defvar user-home-directory (expand-file-name "~"))
     1.6 (defvar user-lab-directory (expand-file-name "lab" user-home-directory))
     1.7-(defvar user-stash-directory (expand-file-name "stash" user-home-directory))
     1.8-(defvar user-store-directory (expand-file-name "store" user-home-directory))
     1.9-(defvar user-shed-directory (expand-file-name "shed" user-home-directory))
    1.10+(defvar user-stash-directory (expand-file-name ".stash" user-home-directory))
    1.11+(defvar user-store-directory (expand-file-name ".store" user-home-directory))
    1.12 (defvar user-mail-directory (expand-file-name "mail" user-home-directory))
    1.13-(defvar user-media-directory (expand-file-name "media" user-home-directory))
    1.14 
    1.15 (defvar default-theme 'leuven-dark)
    1.16 (defvar company-source-directory (join-paths user-lab-directory "comp"))
    1.17@@ -711,6 +709,35 @@
    1.18 
    1.19 ;; archive
    1.20 (setq org-archive-location "archive.org::")
    1.21+(defun extract-org-directory-titles-as-list (&optional dir)
    1.22+  (interactive "D")
    1.23+  (print
    1.24+   (delete nil
    1.25+           (let ((case-fold-search t))
    1.26+             (mapcar (lambda (f)
    1.27+                       (when (string-match "org$" f)
    1.28+                         (with-temp-buffer
    1.29+                           (insert-file-contents-literally
    1.30+                            (concat (file-name-as-directory dir) f))
    1.31+                           (while (and (not (looking-at-p "#\\+TITLE:"))
    1.32+                                       (not (eobp)))
    1.33+                             (forward-line))
    1.34+                           (when (not (eobp))
    1.35+                             (cons f (substring (thing-at-point 'line) 9 -1))))))
    1.36+                     (directory-files dir))))))
    1.37+
    1.38+(defun insert-directory-org-file-titles (&optional dir)
    1.39+  (interactive "D")
    1.40+  (let ((files-titles (extract-org-directory-titles-as-list dir)))
    1.41+    (dolist (ft files-titles)
    1.42+      (insert (concat "[[file:" (car ft)"][" (cdr ft) "]]\n")))))
    1.43+
    1.44+(defun insert-directory-org-files (&optional dir)
    1.45+  (interactive "D")
    1.46+  (let ((files (directory-files dir)))
    1.47+    (dolist (f files)
    1.48+      (insert (concat "[[file:" f "][" (file-name-base f) "]]\n")))))
    1.49+
    1.50 (defun org-todo-at-date (date)
    1.51   "create a todo entry for a given date."
    1.52   (interactive (list (org-time-string-to-time (org-read-date))))
     2.1--- a/emacs/lib/publish.el	Thu Jun 06 17:53:22 2024 -0400
     2.2+++ b/emacs/lib/publish.el	Thu Jun 06 23:15:11 2024 -0400
     2.3@@ -13,8 +13,8 @@
     2.4 (defvar url "https://compiler.company")
     2.5 (defvar vc-url "https://vc.compiler.company")
     2.6 (defvar packy-url "https://packy.compiler.company")
     2.7-(defvar html-nav (format "<div class=\"nav\"> (<a href = \"%s\">~</a> (<a href = \"%s/blog\">blog</a> <a href = \"%s/docs\">docs</a>) (<a href = \"%s\">vc</a> <a href = \"%s\">packy</a>))</div>"
     2.8-                         url url url vc-url packy-url))
     2.9+(defvar html-nav (format "<div class=\"nav\"> (<a href = \"%s\">~</a> (<a href = \"%s/blog\">blog</a> <a href = \"%s/docs\">docs</a> <a href = \"%s/plan\">plan</a> <a href = \"%s/notes\">notes</a>) (<a href = \"%s\">vc</a> <a href = \"%s\">packy</a>))</div>"
    2.10+                         url url url url url vc-url packy-url))
    2.11 
    2.12 (defvar html-foot "<footer><p>updated %C</p></footer>")
    2.13 
    2.14@@ -38,7 +38,7 @@
    2.15       org-id-link-to-org-use-id t)
    2.16 
    2.17 (setq org-publish-project-alist
    2.18-      `(("compiler.company" :components ("index" "blog" "docs"))
    2.19+      `(("compiler.company" :components ("index" "blog" "docs" "notes" "plan"))
    2.20         ("index"
    2.21          :base-directory ,project-dir
    2.22          :base-extension "org"
    2.23@@ -60,6 +60,26 @@
    2.24 	 :htmlized-source t
    2.25 	 :html-preamble ,html-nav
    2.26 	 :html-postamble ,html-foot)
    2.27+        ("plan"
    2.28+         :base-directory ,(expand-file-name "plan" project-dir)
    2.29+         :base-extension "org"
    2.30+         :footnote-section-p t
    2.31+         :html-doctype "<!doctype html>"
    2.32+         :publishing-directory ,(expand-file-name "plan" publish-dir)
    2.33+         :publishing-function org-html-publish-to-html
    2.34+         :htmlized-source t
    2.35+         :html-preamble ,html-nav
    2.36+         :html-postamble ,html-foot)
    2.37+        ("notes"
    2.38+         :base-directory ,(expand-file-name "notes" project-dir)
    2.39+         :base-extension "org"
    2.40+         :footnote-section-p t
    2.41+         :html-doctype "<!doctype html>"
    2.42+         :publishing-directory ,(expand-file-name "notes" publish-dir)
    2.43+         :publishing-function org-html-publish-to-html
    2.44+         :htmlized-source t
    2.45+         :html-preamble ,html-nav
    2.46+         :html-postamble ,html-foot)
    2.47         ("docs"
    2.48          :base-directory ,(expand-file-name "docs" project-dir)
    2.49          :base-extension "org"
     3.1--- a/emacs/lib/skt.el	Thu Jun 06 17:53:22 2024 -0400
     3.2+++ b/emacs/lib/skt.el	Thu Jun 06 23:15:11 2024 -0400
     3.3@@ -23,7 +23,7 @@
     3.4 ;; 
     3.5 
     3.6 ;;; Code:
     3.7-(require 'skel)
     3.8+(require 'sk)
     3.9 
    3.10 ;; ref: https://raw.githubusercontent.com/xFA25E/skempo/master/skempo.el
    3.11 
     4.1--- a/rust/ui/alik/Cargo.toml	Thu Jun 06 17:53:22 2024 -0400
     4.2+++ b/rust/ui/alik/Cargo.toml	Thu Jun 06 23:15:11 2024 -0400
     4.3@@ -7,16 +7,21 @@
     4.4 name = "alik_ui"
     4.5 path = "src/main.rs"
     4.6 [dependencies]
     4.7-egui = "0.27.2"
     4.8+egui = { version = "0.27.2", features = [
     4.9+  "rayon",
    4.10+  "log",
    4.11+] }
    4.12 eframe = { version = "0.27.0", default-features = false, features = [
    4.13-    "accesskit",
    4.14-    "default_fonts", # Embed the default egui fonts.
    4.15-    "glow",          # Use the glow rendering backend. Alternative: "wgpu".
    4.16-    "persistence",   # Enable restoring app state when restarting the app.
    4.17+  # "accesskit",
    4.18+  "default_fonts", # Embed the default egui fonts.
    4.19+  "glow",          # Use the glow rendering backend. Alternative: "wgpu".
    4.20+  "persistence",   # Enable restoring app state when restarting the app.
    4.21 ] }
    4.22 log = "0.4"
    4.23 # You only need serde if you want app persistence:
    4.24 serde = { version = "1", features = ["derive"] }
    4.25+rfd = "0.14.1"
    4.26+futures = "0.3.30"
    4.27 
    4.28 # native:
    4.29 # [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
     5.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2+++ b/rust/ui/alik/examples/installer.rs	Thu Jun 06 23:15:11 2024 -0400
     5.3@@ -0,0 +1,44 @@
     5.4+//! installer.rs --- Alik Installer Example
     5.5+
     5.6+// 
     5.7+
     5.8+//! Code: 
     5.9+use std::future::Future;
    5.10+
    5.11+#[cfg(not(target_arch = "wasm32"))]
    5.12+fn execute<F: Future<Output = ()> + Send + 'static>(f: F) {
    5.13+  // this is stupid... use any executor of your choice instead
    5.14+  std::thread::spawn(move || futures::executor::block_on(f));
    5.15+}
    5.16+#[cfg(target_arch = "wasm32")]
    5.17+fn execute<F: Future<Output = ()> + 'static>(f: F) {
    5.18+  wasm_bindgen_futures::spawn_local(f);
    5.19+}
    5.20+
    5.21+fn main() -> Result<(), Box<dyn std::error::Error>> {
    5.22+  // sync
    5.23+  let res = rfd::MessageDialog::new()
    5.24+    .set_title("Msg!")
    5.25+    .set_description("Description!")
    5.26+    .set_buttons(rfd::MessageButtons::OkCancel)
    5.27+    .show();
    5.28+  println!("{}", res);  
    5.29+  // async
    5.30+  let task = rfd::AsyncFileDialog::new().pick_file();
    5.31+
    5.32+  // Await somewhere else
    5.33+  execute(async {
    5.34+    let file = task.await;
    5.35+
    5.36+    if let Some(file) = file {
    5.37+      // If you are on native platform you can just get the path
    5.38+      #[cfg(not(target_arch = "wasm32"))]
    5.39+      println!("{:?}", file.path());
    5.40+      // on wasm just file.read().await;
    5.41+    }
    5.42+  });
    5.43+  eframe::run_native("alik_installer_example",
    5.44+                     eframe::NativeOptions::default(),
    5.45+                     Box::new(|cc| Box::new(alik_ui::AlikApp::new(cc)))).unwrap();
    5.46+  Ok(())
    5.47+}