From d54f4e23eb0f566c8641b4de29b98333797c7daf Mon Sep 17 00:00:00 2001 From: KemoNine Date: Fri, 7 Apr 2023 17:10:23 -0400 Subject: [PATCH] clean up org agendas, tune auto-start layout for org-mode profile ; add auto-uuid generator for org-mode files ; add method for opening a dired side panel --- common/_global.el | 22 ++++++++++++++++++++++ org/config-org-desktop.el | 33 +++++++-------------------------- org/config-org-mobile.el | 2 ++ org/init.el | 17 +++++++++++++++++ 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/common/_global.el b/common/_global.el index e8136e5..865bf7e 100644 --- a/common/_global.el +++ b/common/_global.el @@ -17,6 +17,26 @@ (setq kmn/is-termux (string-suffix-p "Android" (string-trim (shell-command-to-string "uname -a")))) +(defun kmn/dired-default-directory-on-left () + (defvar parameters + '(window-parameters . ((no-other-window . t) + (no-delete-other-windows . t)))) + + (setq fit-window-to-buffer-horizontally t) + (setq window-resize-pixelwise t) + + "Display `default-directory' in side window on left, hiding details." + (interactive) + (let ((buffer (dired-noselect default-directory))) + (with-current-buffer buffer (dired-hide-details-mode t)) + (display-buffer-in-side-window + buffer `((side . left) (slot . -1) + (window-width . fit-window-to-buffer) + (preserve-size . (t . nil)) , parameters) + ) + ) +) + ; ensure elisp plugins are compiled (require 'dash) (require 'f) @@ -68,6 +88,8 @@ ;; (setq dired-x-hands-off-my-keys nil) ) (require 'dired-single) +(setq dired-single-use-magic-buffer t) +(setq dired-single-magic-buffer-name "dired - main") ; open dirs in same dired window + open files in main window ; facilitates static file browser sidebar diff --git a/org/config-org-desktop.el b/org/config-org-desktop.el index f4ed8da..a348bc4 100644 --- a/org/config-org-desktop.el +++ b/org/config-org-desktop.el @@ -10,36 +10,17 @@ ; - common org files open in the bottom window (add-hook 'after-init-hook (lambda () (interactive) + (find-file "~/org/health/health_houdini.org") + (find-file "~/org/orgzly/_habits.org") + (find-file "~/org/orgzly/_todo.org") + (find-file "~/org/_index.org") (org-agenda nil "r") - (set-window-dedicated-p (selected-window) "t") (delete-other-windows) (split-window-below 15) (next-multiframe-window) - (find-file "~/org/orgzly/_habits.org") - (find-file "~/org/orgzly/_todo.org") + (find-file "~/org/health/health_mike.org") + (split-window-below 15) + (next-multiframe-window) (find-file "~/org/orgzly/_slipbox.org") - (find-file "~/org/_index.org") ) ) - -; Make sure emacs and org don't keep opening new windows (Desktop) -(setq pop-up-windows nil) -(setq inhibit-same-window nil) -(setq inhibit-switch-frame nil) -(setq split-height-threshold 200) -(setq split-width-threshold 200) -(defun my-display-buffer-function (buf not-this-window) - (if (and (not pop-up-frames) - (one-window-p) - (or not-this-window - (not (eq (window-buffer (selected-window)) buf))) - (> (frame-width) 162)) - (split-window-horizontally)) - ;; Note: Some modules sets `pop-up-windows' to t before calling - ;; `display-buffer' -- Why, oh, why! - (let ((display-buffer-function nil) - (pop-up-windows nil)) - (display-buffer buf nil))) - -(setq display-buffer-function 'my-display-buffer-function) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/org/config-org-mobile.el b/org/config-org-mobile.el index ce81f34..c44244d 100644 --- a/org/config-org-mobile.el +++ b/org/config-org-mobile.el @@ -2,6 +2,8 @@ ;; /data/data/com.termux/files/home/storage/shared/.emacs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Open main files used as 'gateway' to everything else (Mobile) +(find-file "~/org/health/health_houdini.org") +(find-file "~/org/health/health_mike.org") (find-file "~/storage/shared/org/orgzly/_habits.org") (find-file "~/storage/shared/org/orgzly/_todo.org") (find-file "~/storage/shared/org/orgzly/_slipbox.org" diff --git a/org/init.el b/org/init.el index 14549e7..575b086 100644 --- a/org/init.el +++ b/org/init.el @@ -109,6 +109,23 @@ (setq org-log-into-drawer t) (setq org-log-done t) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; automatic ids for everything +; From https://web.archive.org/web/20220512120917/https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode +; This hunk of lisp automatically adds IDs to every header in an org file when you hit save. it usese org-id which can generated IDs of various types including timestamps. I’m using the default UUIDs +(defun stackoverflow/org-add-ids-to-headlines-in-file () + "cargo cult from stackoverflow to add ids" + (interactive) + (save-excursion + (goto-char (point-max)) + (while (outline-previous-heading) + (org-id-get-create))) + ) + (add-hook 'org-mode-hook + (lambda () + (add-hook 'before-save-hook 'stackoverflow/org-add-ids-to-headlines-in-file nil 'local))) +(add-hook 'org-capture-prepare-finalize-hook 'org-id-get-create) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ox-hugo for blog (with-eval-after-load 'ox (require 'ox-hugo))