diff --git a/config-min.org b/config-min.org index e298b48..fd1695d 100644 --- a/config-min.org +++ b/config-min.org @@ -508,8 +508,7 @@ '(display-buffer-in-side-window (side . left) (dedicated . t) - (inhibit-same-window . t) - (window-parameters (no-other-window . t)))) + (inhibit-same-window . t))) (global-set-key (kbd "C-x g") 'magit-status) (global-set-key (kbd "C-x M-g") 'magit-dispatch) (require 'magit-overrides) diff --git a/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el b/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el index f930ff1..afa7147 100644 --- a/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el +++ b/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el @@ -79,12 +79,14 @@ :compiler compiler :file file :action compiler-action - :output output) - (pcase action - ('debug (format "-mllvm -debug-only=%s" (ll/read-pass-name "Which pass? "))) - ('before-after (let ((pass (ll/read-pass-name "Which pass? "))) - (format "-mllvm -print-before=%s -mllvm -print-after=%s" pass pass))) - ('changed "-mllvm -print-before-all")) + :output output + :flags + (list + (pcase action + ('debug (format "-mllvm -debug-only=%s" (ll/read-pass-name "Which pass? "))) + ('before-after (let ((pass (ll/read-pass-name "Which pass? "))) + (format "-mllvm -print-before=%s -mllvm -print-after=%s" pass pass))) + ('changed "-mllvm -print-before-all")))) " ") " ")))) diff --git a/lisp/llvm-lib/llvm-shared.el b/lisp/llvm-lib/llvm-shared.el index dd1ba03..29975a3 100644 --- a/lisp/llvm-lib/llvm-shared.el +++ b/lisp/llvm-lib/llvm-shared.el @@ -247,8 +247,8 @@ (apply (lls/conf-get 'dis-command-fun) args)) ;; ========================= LLVM Build Dirs ========================= -(cl-defun lls/default-comp-fun (&key compiler file action output rest) - (string-join +(cl-defun lls/default-comp-fun (&key compiler file action output flags) + (--> (list compiler (lls/get-clang-options) (string-join rest " ") @@ -259,11 +259,13 @@ ('preprocess "-E") ('llvm-ir "-S -emit-llvm") ('executable "")) + flags "-o -" (or (and output (format "| tee %s" output)) "")) - " ")) + (flatten-list it) + (string-join it " "))) (defun ll/read-pass () (completing-read "Which pass? " diff --git a/lisp/llvm-lib/load-llvm-mode.el b/lisp/llvm-lib/load-llvm-mode.el index 23d519a..d2926f8 100644 --- a/lisp/llvm-lib/load-llvm-mode.el +++ b/lisp/llvm-lib/load-llvm-mode.el @@ -45,7 +45,7 @@ `(,(regexp-opt '("nnan" "ninf" "nsz" "arcp" "contract" "afn" "reassoc" "fast") 'symbols) . 'shadow))) (add-to-list 'llvm-font-lock-keywords - `(,(rx line-start (optional "# ") "***" (+ nonl) "***" (optional ":") "\n") . 'llvm-separator-face)) + `(,(rx line-start (optional (any "#;") " ") "***" (+ nonl) "***" (optional ":") "\n") . 'llvm-separator-face)) (--> "\\b[-]?[0-9]+\\b" @@ -53,7 +53,15 @@ (cl-position it llvm-font-lock-keywords) (nth it llvm-font-lock-keywords) (setf it - `(,(rx word-boundary (optional "-") ))))) + `(,(rx word-boundary (optional "-") )))) + + (pop c-mode-common-hook) + (add-hook 'c-mode-common-hook + (function + (lambda nil + (if (and buffer-file-name (string-match "llvm" buffer-file-name)) + (progn + (c-set-style "llvm.org"))))))) (provide 'load-llvm-mode) ;;; load-llvm-mode.el ends here diff --git a/lisp/magit-overrides.el b/lisp/magit-overrides.el index 4efb25e..bbb1fd4 100644 --- a/lisp/magit-overrides.el +++ b/lisp/magit-overrides.el @@ -163,9 +163,9 @@ transient-display-buffer-action))) (when (window-live-p transient--window) (with-selected-window transient--window + ;; Save the previous value of the 'no-other-window window parameter. (set-window-parameter nil 'prev--no-other-window (window-parameter nil 'no-other-window)) - (set-window-parameter nil 'no-other-window t) (goto-char (point-min)) (when transient-enable-popup-navigation (transient--goto-button focus)) @@ -175,5 +175,42 @@ :override #'my/transient--show) +;; What's so great about the above advice? Why can't the below work?! +;; +;; (defun my/transient--show-post () +;; (let ((transient--shadowed-buffer (current-buffer)) +;; (focus nil)) +;; (setq transient--buffer (get-buffer-create transient--buffer-name)) +;; (with-current-buffer transient--buffer +;; (when transient-enable-popup-navigation +;; (setq focus (or (button-get (point) 'command) +;; (and (not (bobp)) +;; (button-get (1- (point)) 'command)) +;; (transient--heading-at-point))))) +;; (when (window-live-p transient--window) +;; (with-selected-window transient--window +;; (set-window-parameter nil 'prev--no-other-window +;; (window-parameter nil 'no-other-window)) +;; (set-window-parameter nil 'no-other-window t) +;; (goto-char (point-min)) +;; (when transient-enable-popup-navigation +;; (transient--goto-button focus)) +;; (transient--fit-window-to-buffer transient--window))))) + +;; (advice-add #'transient--show +;; :after +;; #'my/transient--show-post) + +(defun my/transient--delete-win-restore-window-param (&rest ignore) + (when (window-live-p transient--window) + (with-selected-window transient--window + ;; Restore the value + (set-window-parameter nil 'no-other-window + (window-parameter nil 'prev--no-other-window))))) + +(advice-add #'transient--delete-window + :before + #'my/transient--delete-win-restore-window-param) + (provide 'magit-overrides) ;;; magit-overrides.el ends here diff --git a/lisp/multi-vterm-tabs.el b/lisp/multi-vterm-tabs.el index 3ac2206..774d095 100644 --- a/lisp/multi-vterm-tabs.el +++ b/lisp/multi-vterm-tabs.el @@ -70,14 +70,24 @@ it)))) (defun mvt/get-all-buffers (tab-name) - (let* ((tab-sym (intern tab-name)) - (mvti (mvt/get-or-create-info tab-sym)) - (max-num (slot-value mvti 'max-number)) - buffs) - (dotimes (i max-num) - (awhen (get-buffer (mvt/format-buffer-name tab-name i)) - (push it buffs))) - (reverse buffs))) + (->> (buffer-list) + (remove-if-not + (lambda (buff) + (with-current-buffer buff + (and (eq major-mode 'vterm-mode) + (string-match-p + (rx "*" (literal tab-name) "-vterm<" (+ digit) ">*") + (buffer-name buff)))))))) + +;; (defun mvt/get-all-buffers (tab-name) +;; (let* ((tab-sym (intern tab-name)) +;; (mvti (mvt/get-or-create-info tab-sym)) +;; (max-num (slot-value mvti 'max-number)) +;; buffs) +;; (dotimes (i max-num) +;; (awhen (get-buffer (mvt/format-buffer-name tab-name i)) +;; (push it buffs))) +;; (reverse buffs))) ;; (mvt/get-all-buffers (alist-get 'name (tab-bar--current-tab))) diff --git a/lisp/org-config/my-org-agenda-files.el b/lisp/org-config/my-org-agenda-files.el index 46d1cac..9ee0951 100644 --- a/lisp/org-config/my-org-agenda-files.el +++ b/lisp/org-config/my-org-agenda-files.el @@ -24,7 +24,7 @@ ;;; Code: (require 'my-plaintext-files) -(require 'org-roam-util) +(require 'org-roam-update-agenda) (defconst my/org-folder (my/plaintext-file "org")) @@ -59,34 +59,15 @@ `(,(my/agenda-file "vrchat_things.org") ,(my/org-file "journal2.gpg"))) -(custom-set-variables - `(org-agenda-files - '(,(my/agenda-file "plan.org") - ,(my/agenda-file "thoughts.org") - ,(my/agenda-file "refile.org") - ,(my/agenda-file "sandbox.org") - ,(my/agenda-file "dev.org") - ,(my/agenda-file "prod.org") - ,(my/agenda-file "habits.org") - ,(my/agenda-file "calendars/production.org")))) - -(defun my/update-org-agenda-files () - (interactive) - (setq org-agenda-files - (append - `(,(my/agenda-file "plan.org") - ,(my/agenda-file "thoughts.org") - ,(my/agenda-file "refile.org") - ,(my/agenda-file "sandbox.org") - ,(my/agenda-file "dev.org") - ,(my/agenda-file "prod.org") - ,(my/agenda-file "habits.org") - ,(my/agenda-file "calendars/production.org")) - (my/get-org-roam-files-by-tags '("Project" "active"))))) - -(advice-add #'org-agenda - :before - #'my/update-org-agenda-files) +(setq orua/agenda-files + `(,(my/agenda-file "plan.org") + ,(my/agenda-file "thoughts.org") + ,(my/agenda-file "refile.org") + ,(my/agenda-file "sandbox.org") + ,(my/agenda-file "dev.org") + ,(my/agenda-file "prod.org") + ,(my/agenda-file "habits.org") + ,(my/agenda-file "calendars/production.org"))) (defconst my/all-agenda-files (cons (my/agenda-file "eternal.org") diff --git a/lisp/org-config/my-org-roam-logger.el b/lisp/org-config/my-org-roam-logger.el index 96d261c..c825fcd 100644 --- a/lisp/org-config/my-org-roam-logger.el +++ b/lisp/org-config/my-org-roam-logger.el @@ -26,7 +26,7 @@ (require 'org-roam) (require 'org-roam-util) -(defvar my/current-logger-cache nil) +(defvar my/current-logger-cache (make-hash-table)) (defvar my/org-roam-logger-filter-fun nil) (defvar my/org-roam-logger-templates @@ -51,36 +51,41 @@ (defun my/org-roam-logger-capture-current (arg) (interactive "P") - (when (or (null my/current-logger-cache) - (equal arg '(16)) - (equal arg '(64))) - (setq my/current-logger-cache - (org-roam-node-read - nil - (when (not (equal arg '(64))) - my/org-roam-logger-filter-fun)))) + (let* ((tab-sym (intern (alist-get 'name (tab-bar--current-tab)))) + (node + (or (and (not (equal arg '(16))) + (not (equal arg '(64))) + (gethash tab-sym my/current-logger-cache)) + (puthash tab-sym + (org-roam-node-read + nil + (when (not (equal arg '(64))) + my/org-roam-logger-filter-fun)) + my/current-logger-cache)))) + ;; On NEW nodes, org-roam-node-read generates an empty struct with + ;; only a few things, one of which being an id. Do a sanity check to + ;; make sure that we re-init the current node with a node that has + ;; the file name. Only do this initialization if we have an ID for + ;; the org-roam. + ;; + ;; ASSUMPTION: org-roam-capture- initializes node with + ;; org-roam-node-id field. + ;; + ;; TODO: Ummm, this doesn't work in the case where the file gets deleted + ;; after a first capture + capture abort. + (when (and (null (org-roam-node-file node)) + (org-roam-node-id node)) + (setq node + (org-roam-node-from-id (org-roam-node-id node)))) - ;; On NEW nodes, org-roam-node-read generates an empty struct with - ;; only a few things, one of which being an id. Do a sanity check to - ;; make sure that we re-init the current node with a node that has - ;; the file name. Only do this initialization if we have an ID for - ;; the org-roam. - ;; - ;; ASSUMPTION: org-roam-capture- initializes node with - ;; org-roam-node-id field. - (when (and (null (org-roam-node-file my/current-logger-cache)) - (org-roam-node-id my/current-logger-cache)) - (setq my/current-logger-cache - (org-roam-node-from-id (org-roam-node-id my/current-logger-cache)))) - - (if (equal arg '(4)) - (-> my/current-logger-cache - (org-roam-node-file) - (find-file-noselect) - (pop-to-buffer-same-window)) - (org-roam-capture- - :node my/current-logger-cache - :templates my/org-roam-logger-templates))) + (if (equal arg '(4)) + (-> node + (org-roam-node-file) + (find-file-noselect) + (pop-to-buffer-same-window)) + (org-roam-capture- + :node node + :templates my/org-roam-logger-templates)))) (provide 'my-org-roam-logger) ;;; my-org-roam-logger.el ends here diff --git a/lisp/org-config/org-roam-update-agenda.el b/lisp/org-config/org-roam-update-agenda.el new file mode 100644 index 0000000..0bed2e5 --- /dev/null +++ b/lisp/org-config/org-roam-update-agenda.el @@ -0,0 +1,70 @@ +;;; org-roam-update-agenda.el --- -*- lexical-binding: t -*- + +;; Copyright (C) 2025 Benson Chu + +;; Author: Benson Chu +;; Created: [2025-07-02 10:25] + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: +(require 'org-roam-util) + +(defvar orua/agenda-files nil) + +(defun my/update-org-agenda-files () + (interactive) + (setq org-agenda-files + (append + orua/agenda-files + (my/get-org-roam-files-by-tags '("Project" "active"))))) + +(advice-add #'org-agenda + :before + #'my/update-org-agenda-files) + +(defun my/view-org-agenda-files () + (interactive) + (find-file + (consult--read + org-agenda-files + :prompt "org-agenda-files: " + :sort nil ;; cands are already sorted + :require-match t + :state (consult--preview-org-agenda-files) + :category 'org-roam-node))) + +(defun consult--preview-org-agenda-files () + "Create preview function for nodes." + (let ((open (consult--temporary-files)) + (preview (consult--buffer-preview)) + (state (window-state-get))) + (lambda (action cand) + (when (eq action 'exit) + (progn + ;; Restore saved window state + ;; To move point to the original position + (window-state-put state) + (funcall open))) + (funcall preview action + (and cand + (eq action 'preview) + (funcall open cand)))))) + +(provide 'org-roam-update-agenda) +;;; org-roam-update-agenda.el ends here diff --git a/lisp/ti-config/work-config.el b/lisp/ti-config/work-config.el index 245cf7f..00de410 100644 --- a/lisp/ti-config/work-config.el +++ b/lisp/ti-config/work-config.el @@ -108,14 +108,6 @@ (add-to-list 'auto-mode-alist '("\\.gel" . c-mode)) -(pop c-mode-common-hook) -(add-hook 'c-mode-common-hook - (function - (lambda nil - (if (and buffer-file-name (string-match "llvm" buffer-file-name)) - (progn - (c-set-style "llvm.org")))))) - (define-key *root-map* (kbd "u") (lambda () (interactive) diff --git a/lisp/ti-config/work-org-stuff.el b/lisp/ti-config/work-org-stuff.el index 562775f..6a02580 100644 --- a/lisp/ti-config/work-org-stuff.el +++ b/lisp/ti-config/work-org-stuff.el @@ -252,20 +252,19 @@ (setq org-outline-path-complete-in-steps nil) (setq org-refile-use-outline-path t) -(setq org-agenda-files +(require 'org-roam-update-agenda) + +(setq orua/agenda-files (list "~/org/refile.org" "~/org/all.org")) -(defun my/update-org-agenda-files () - (interactive) - (setq org-agenda-files - (cons "~/org/refile.org" - (cons "~/org/all.org" - (my/get-org-roam-files-by-tags '("Project" "active")))))) - (setq org-refile-targets `((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9))) +(global-set-key (kbd "C-c n a") #'my/view-org-agenda-files) + +(setq org-agenda-sticky t) + (require 'org-protocol) ;; (defun wait-mark-blocking-tasks (change-plist) @@ -518,10 +517,12 @@ (defun my/org-roam-find-active-projects () (interactive) - ;; Select a project file to open, creating it if necessary - (org-roam-node-find nil nil - (my/org-roam-filter-by-tag '("Project" "active")) - nil :templates my/project-templates)) + (cl-letf (((symbol-function 'org-roam-node-read) + (symbol-function 'consult-org-roam-node-read))) + ;; Select a project file to open, creating it if necessary + (org-roam-node-find nil nil + (my/org-roam-filter-by-tag '("Project" "active")) + nil :templates my/project-templates))) (defun org-agenda-insert-breaks-between (str1 str2) (let ((r (rx line-start