diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index 08edcb1f..6b0dc894 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -68,11 +68,13 @@ ;; Disables custom.el (setq custom-file null-device) -;; Emacs dashboard +;; emacs-dashboard setup (require 'all-the-icons) (require 'dashboard) -(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) -(setq doom-fallback-buffer-name "*dashboard*") +(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")) + doom-fallback-buffer-name "*dashboard*") + +;; emacs-dashboard variables (setq dashboard-banner-logo-title "Welcome to Nix Doom Emacs") (setq dashboard-startup-banner 2) (setq dashboard-icon-type 'all-the-icons) ;; use `all-the-icons' package @@ -84,8 +86,6 @@ (setq dashboard-footer-messages '("Here to do customizing, or actual work?" "M-x insert-inspiring-message" "My software never has bugs. It just develops random features." - "Give a man a program and you will frustrate him for a day. -Teach him how to program and you will frustrate him for a lifetime." "Dad, what are clouds made of? Linux servers, mostly." "There is no place like ~" "~ sweet ~" @@ -94,41 +94,42 @@ Teach him how to program and you will frustrate him for a lifetime." "I'd tell you a UDP joke, but you might not get it." "I'll tell you a TCP joke. Do you want to hear it?")) (setq dashboard-navigator-buttons - `(;; line1 - ( (,"Roam" "" "" (lambda (&rest _)) 'org-formula) - (,(all-the-icons-octicon "globe" :height 1.0 :v-adjust 0.0) - "Notes overview" "" (lambda (&rest _) (org-roam-default-overview)) 'org-formula) - (,(all-the-icons-fileicon "org" :height 1.0 :v-adjust 0.0) - "Switch roam db" "" (lambda (&rest _) (org-roam-switch-db)) 'org-formula) - ) - ;; line 2 - ( (,"Git" "" "" (lambda (&rest _)) 'match) - (,(all-the-icons-octicon "mark-github" :height 1.0 :v-adjust 0.0) - "GitHub" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://github.com/librephoenix")) 'match) - (,(all-the-icons-faicon "gitlab" :height 1.0 :v-adjust 0.0) - "GitLab" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://gitlab.com/librephoenix")) 'match) - (,(all-the-icons-faicon "coffee" :height 1.0 :v-adjust 0.0) - "Gitea" "" (lambda (&rest _) (browse-url my-gitea-domain)) 'match) - ) - ;; line 3 - ( (,"Agenda" "" "" (lambda (&rest _)) 'dired-warning) - (,(all-the-icons-octicon "checklist" :height 1.0 :v-adjust 0.0) - "Agenda todos" "" (lambda (&rest _) (org-agenda-list)) 'dired-warning) - (,(all-the-icons-octicon "calendar" :height 1.0 :v-adjust 0.0) - "Agenda calendar" "" (lambda (&rest _) (cfw:open-org-calendar)) 'dired-warning) - ) - ;; line 4 - ( (,"Config" "" "" (lambda (&rest _)) 'dired-mark) - (,(all-the-icons-faicon "cogs" :height 1.0 :v-adjust 0.0) - "System config" "" (lambda (&rest _) (projectile-switch-project-by-name "~/.dotfiles" t)) 'dired-mark) - (,(all-the-icons-material "help" :height 1.0 :v-adjust -0.2) - "Doom documentation" "" (lambda (&rest _) (doom/help)) 'dired-mark) - ) - )) -(setq dashboard-footer-icon (all-the-icons-faicon "list-alt" - :height 1.0 - :v-adjust -0.15 - :face 'font-lock-keyword-face)) + `(;; line1 + ( (,"Roam" "" "" (lambda (&rest _)) 'org-formula) + (,(all-the-icons-octicon "globe" :height 1.0 :v-adjust 0.0) + "Notes overview" "" (lambda (&rest _) (org-roam-default-overview)) 'org-formula) + (,(all-the-icons-fileicon "org" :height 1.0 :v-adjust 0.0) + "Switch roam db" "" (lambda (&rest _) (org-roam-switch-db)) 'org-formula) + ) + ;; line 2 + ( (,"Git" "" "" (lambda (&rest _)) 'match) + (,(all-the-icons-octicon "mark-github" :height 1.0 :v-adjust 0.0) + "GitHub" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://github.com/librephoenix")) 'match) + (,(all-the-icons-faicon "gitlab" :height 1.0 :v-adjust 0.0) + "GitLab" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://gitlab.com/librephoenix")) 'match) + (,(all-the-icons-faicon "coffee" :height 1.0 :v-adjust 0.0) + "Gitea" "" (lambda (&rest _) (browse-url my-gitea-domain)) 'match) + ) + ;; line 3 + ( (,"Agenda" "" "" (lambda (&rest _)) 'dired-warning) + (,(all-the-icons-octicon "checklist" :height 1.0 :v-adjust 0.0) + "Agenda todos" "" (lambda (&rest _) (org-agenda-list)) 'dired-warning) + (,(all-the-icons-octicon "calendar" :height 1.0 :v-adjust 0.0) + "Agenda calendar" "" (lambda (&rest _) (cfw:open-org-calendar)) 'dired-warning) + ) + ;; line 4 + ( (,"Config" "" "" (lambda (&rest _)) 'dired-mark) + (,(all-the-icons-faicon "cogs" :height 1.0 :v-adjust 0.0) + "System config" "" (lambda (&rest _) (projectile-switch-project-by-name "~/.dotfiles" t)) 'dired-mark) + (,(all-the-icons-material "help" :height 1.0 :v-adjust -0.2) + "Doom documentation" "" (lambda (&rest _) (doom/help)) 'dired-mark) + ))) + +(setq dashboard-footer-icon + (all-the-icons-faicon "list-alt" + :height 1.0 + :v-adjust -0.15 + :face 'font-lock-keyword-face)) (dashboard-setup-startup-hook) ;; Smooth scrolling @@ -205,8 +206,8 @@ Teach him how to program and you will frustrate him for a lifetime." ;; Add frame borders and window dividers (modify-all-frames-parameters - '((right-divider-width . 10) - (internal-border-width . 10))) + '((right-divider-width . 5) + (internal-border-width . 5))) (dolist (face '(window-divider window-divider-first-pixel window-divider-last-pixel)) @@ -215,19 +216,19 @@ Teach him how to program and you will frustrate him for a lifetime." (set-face-background 'fringe (face-attribute 'default :background)) (setq - ;; Edit settings - org-auto-align-tags nil - org-tags-column 0 - org-catch-invisible-edits 'show-and-error - org-special-ctrl-a/e t - org-insert-heading-respect-content t + ;; Edit settings + org-auto-align-tags nil + org-tags-column 0 + org-catch-invisible-edits 'show-and-error + org-special-ctrl-a/e t + org-insert-heading-respect-content t - ;; Org styling, hide markup etc. - org-hide-emphasis-markers t - org-pretty-entities t - org-ellipsis "…") + ;; Org styling, hide markup etc. + org-hide-emphasis-markers t + org-pretty-entities t + org-ellipsis "…") -(setq-default line-spacing 0.1) +(setq-default line-spacing 0.15) ; Automatic table of contents is nice (if (require 'toc-org nil t) @@ -254,25 +255,6 @@ Teach him how to program and you will frustrate him for a lifetime." ;; Better for org source blocks (setq electric-indent-mode nil) (setq org-src-window-setup 'current-window) -(delete - '("^\\*Org Src" - (+popup-buffer) - (actions) - (side . bottom) - (size . 0.42) - (window-width . 40) - (window-height . 0.42) - (slot) - (vslot) - (window-parameters - (ttl) - (quit) - (select . t) - (modeline . t) - (autosave . t) - (transient . t) - (no-other-window . t))) - display-buffer-alist) ;; Horizontal scrolling tables (add-load-path! "~/.emacs.d/phscroll") @@ -286,7 +268,12 @@ Teach him how to program and you will frustrate him for a lifetime." ;; Drag-and-drop to `dired` (add-hook 'dired-mode-hook 'org-download-enable) -(setq org-download-screenshot-method "flameshot gui -p %s") +;; system-wm-type, wayland or x11? only should be considered if system-nix-profile is "personal" or "work" +(if (string= system-wm-type "wayland") + (setq org-download-screenshot-method "grim -g \"$(slurp)\" %s") + (setq org-download-screenshot-method "flameshot gui -p %s") +) + (after! org-download (setq org-download-method 'directory)) @@ -294,37 +281,24 @@ Teach him how to program and you will frustrate him for a lifetime." (setq-default org-download-image-dir "img/" org-download-heading-lvl nil)) -(defun my-org-screenshot () - "Take a screenshot into a time stamped unique-named file in the -same directory as the org-buffer and insert a link to this file." - (interactive) - (setq filename - (concat - (make-temp-name - (concat (buffer-file-name) - "_" - (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")) - (shell-command (concat "emacs-wayshot " filename)) - (insert (concat "[[" filename "]]")) - (org-display-inline-images)) +(add-to-list 'display-buffer-alist '("^*Async Shell Command*" . (display-buffer-no-window))) -(defun my-org-paste() - "Take an image from the clipboard into a time stamped unique-named file in the -same directory as the org-buffer and insert a link to this file." +(defun org-download-clipboard-basename () (interactive) - (setq filename - (concat - (make-temp-name - (concat (file-name-directory (buffer-file-name)) - "img/" - (file-name-nondirectory (buffer-file-name)) - "_" - (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")) - (shell-command (concat "wl-paste > " filename)) - (insert (concat "[[" filename "]]")) - (org-display-inline-images)) + (setq org-download-path-last-dir org-download-image-dir) + (setq org-download-image-dir (completing-read "directory: " (-filter #'f-directory-p (directory-files-recursively "." "" t)) nil t)) + (org-download-clipboard (completing-read "basename: " '() nil nil)) + (setq org-download-image-dir org-download-path-last-dir) +) -(defun my-org-new-file-from-template() +(map! :leader + :desc "Insert a screenshot" + "i s" 'org-download-screenshot + :desc "Insert image from clipboard" + "i p" 'org-download-clipboard + "i P" 'org-download-clipboard-basename) + +(defun org-new-file-from-template() "Copy a template from ~/Templates into a time stamped unique-named file in the same directory as the org-buffer and insert a link to this file." (interactive) @@ -342,76 +316,57 @@ same directory as the org-buffer and insert a link to this file." (insert (concat "[[./files/" (file-name-nondirectory filename) "][" prettyname "]]")) (org-display-inline-images)) -(when (require 'openwith nil 'noerror) - (setq openwith-associations - (list - (list (openwith-make-extension-regexp - '("mpg" "mpeg" "mp3" "mp4" - "avi" "wmv" "wav" "mov" "flv" - "ogm" "ogg" "mkv")) - "mpv" - '(file)) - (list (openwith-make-extension-regexp - '("doc" "xls" "ppt" "odt" "ods" "odg" "odp")) - "libreoffice" - '(file)) - '("\\.lyx" "lyx" (file)) - '("\\.chm" "kchmviewer" (file)) - (list (openwith-make-extension-regexp - '("pdf" "ps" "ps.gz" "dvi")) - "atril" - '(file)) - (list (openwith-make-extension-regexp - '("kdenlive")) - "kdenlive" - '(file)) - (list (openwith-make-extension-regexp - '("kra")) - "krita" - '(file)) - (list (openwith-make-extension-regexp - '("blend" "blend1")) - "blender" - '(file)) - (list (openwith-make-extension-regexp - '("helio")) - "helio" - '(file)) - (list (openwith-make-extension-regexp - '("svg")) - "inkscape" - '(file)) - (list (openwith-make-extension-regexp - '("flp")) - "~/.local/bin/flstudio" - '(file)) - )) - (openwith-mode 1)) - -(add-to-list 'display-buffer-alist '("^*Async Shell Command*" . (display-buffer-no-window))) - -(map! :leader - :desc "Insert a screenshot" -;; "i s" 'my-org-screenshot) - "i s" 'org-download-screenshot) - -(defun org-download-clipboard-basename () - (interactive) - (setq org-download-path-last-dir org-download-image-dir) - (setq org-download-image-dir (completing-read "directory: " (-filter #'f-directory-p (directory-files-recursively "." "" t)) nil t)) - (org-download-clipboard (completing-read "basename: " '() nil nil)) - (setq org-download-image-dir org-download-path-last-dir) -) - -(map! :leader - :desc "Insert image from clipboard" - "i p" 'org-download-clipboard - "i P" 'org-download-clipboard-basename) - (map! :leader :desc "Create a new file from a template and insert a link at point" "i t" 'my-org-new-file-from-template) +(if (not (string= system-nix-profile "wsl")) + (when (require 'openwith nil 'noerror) + (setq openwith-associations + (list + (list (openwith-make-extension-regexp + '("mpg" "mpeg" "mp3" "mp4" + "avi" "wmv" "wav" "mov" "flv" + "ogm" "ogg" "mkv")) + "mpv" + '(file)) + (list (openwith-make-extension-regexp + '("doc" "xls" "ppt" "odt" "ods" "odg" "odp")) + "libreoffice" + '(file)) + '("\\.lyx" "lyx" (file)) + '("\\.chm" "kchmviewer" (file)) + (list (openwith-make-extension-regexp + '("pdf" "ps" "ps.gz" "dvi")) + "atril" + '(file)) + (list (openwith-make-extension-regexp + '("kdenlive")) + "kdenlive" + '(file)) + (list (openwith-make-extension-regexp + '("kra")) + "krita" + '(file)) + (list (openwith-make-extension-regexp + '("blend" "blend1")) + "blender" + '(file)) + (list (openwith-make-extension-regexp + '("helio")) + "helio" + '(file)) + (list (openwith-make-extension-regexp + '("svg")) + "inkscape" + '(file)) + (list (openwith-make-extension-regexp + '("flp")) + "~/.local/bin/flstudio" + '(file)) + )) + (openwith-mode 1))) + (defun org-copy-link-to-clipboard-at-point () "Copy current link at point into clipboard (useful for images and links)" ;; Remember to press C-g to kill this foreground process if it hangs! @@ -425,7 +380,7 @@ same directory as the org-buffer and insert a link to this file." (if (eq major-mode #'image-mode) (image-mode-copy-file-name-as-kill) ) - (shell-command (concat "~/.emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh " (gui-get-selection 'CLIPBOARD)) nil nil) + (shell-command "~/.emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh " nil nil) ) (map! :leader @@ -520,6 +475,9 @@ same directory as the org-buffer and insert a link to this file." :leader :prefix "n" :desc "Org Transclusion Mode" "t" #'org-transclusion-mode)) +(map! :leader :prefix "n" "l" #'org-transclusion-live-sync-start) + +(add-hook 'org-mode-hook #'org-transclusion-mode) ;;;------ Org roam configuration ------;;; (require 'org-roam) diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index af44a370..9f74209f 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -34,12 +34,12 @@ - [[https://orgmode.org/][Org Mode]] (Hierarchical text-based document format) - [[https://www.orgroam.com/][Org Roam]] (A second brain / personal wiki) - [[https://orgmode.org/][Org Agenda]] (Calendar and todo list) -- [[https://magit.vc/][magit]] (Git Client) +- [[https://magit.vc/][Magit]] (Git Client) I have found Emacs to be incredibly efficient, and transferring my workflow to fit inside of Emacs has allowed me to get much more work done. I primarily use Emacs for writing, note-taking, task/project management and organizing information. * Configuration for Doom Emacs -Doom Emacs is configured via 3 main files, written in Elisp, a dialect of the Lisp programming langauge designed for Emacs. These 3 main files are: +Doom Emacs is configured via 3 main files, written in Elisp, a dialect of the Lisp programming language designed for Emacs. These 3 main files are: - [[./config.el][config.el]] - Stores your main configuration and allows to set user variables. - [[./init.el][init.el]] - Allows quick downloads of groups of Emacs packages. These groups of Emacs packages are curated by the Doom Emacs developers. - [[./packages.el][packages.el]] - Allows you to download additional packages from Melpa (Emacs package manager). @@ -52,9 +52,9 @@ You can also load separate files inside of [[./config.el][config.el]] via the =l (load! "~/.doom.d/private.el") #+END_SRC -I use this functionality to load my private config file with non-public information. +This can be used to load private config file with non-public information, or can be used to create modular configuration. -Doom Emacs is traditionally installed by cloning the repository ([[https://github.com/doomemacs/doomemacs][https://github.com/doomemacs/doomemacs]]) and running =./bin/doom install=. I instead install Doom Emacs via Nix Doom Emacs ([[https://github.com/nix-community/nix-doom-emacs][https://github.com/nix-community/nix-doom-emacs]]), which packages Doom Emacs as a Nix derivation. The advantage to this is that I get more reproducibility and the ability to rollback updates (if anything breaks), but the downside is that every time the config is changed/updated, the entire derivation must be rebuilt from scratch (this is often time-consuming). I load this as a Nix derivation in my flake using the [[./doom.nix][doom.nix]] module. +Doom Emacs is traditionally installed by cloning the repository ([[https://github.com/doomemacs/doomemacs][https://github.com/doomemacs/doomemacs]]) and running =./bin/doom install=. I instead install Doom Emacs via Nix Doom Emacs ([[https://github.com/nix-community/nix-doom-emacs][https://github.com/nix-community/nix-doom-emacs]]), which packages Doom Emacs as a Nix derivation. The advantage to this is that I get more reproducibility and the ability to rollback updates (if anything breaks), but the downside is that any time Emacs packages are changed/updated, the entire derivation must be rebuilt from scratch (this is often time-consuming). I load this as a Nix derivation in my flake using the [[./doom.nix][doom.nix]] module. * My config.el ** Preamble + User Configuration @@ -129,11 +129,13 @@ Doom Emacs is traditionally installed by cloning the repository ([[https://githu ;; Disables custom.el (setq custom-file null-device) -;; Emacs dashboard +;; emacs-dashboard setup (require 'all-the-icons) (require 'dashboard) -(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) -(setq doom-fallback-buffer-name "*dashboard*") +(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")) + doom-fallback-buffer-name "*dashboard*") + +;; emacs-dashboard variables (setq dashboard-banner-logo-title "Welcome to Nix Doom Emacs") (setq dashboard-startup-banner 2) (setq dashboard-icon-type 'all-the-icons) ;; use `all-the-icons' package @@ -145,8 +147,6 @@ Doom Emacs is traditionally installed by cloning the repository ([[https://githu (setq dashboard-footer-messages '("Here to do customizing, or actual work?" "M-x insert-inspiring-message" "My software never has bugs. It just develops random features." - "Give a man a program and you will frustrate him for a day. -Teach him how to program and you will frustrate him for a lifetime." "Dad, what are clouds made of? Linux servers, mostly." "There is no place like ~" "~ sweet ~" @@ -155,41 +155,42 @@ Teach him how to program and you will frustrate him for a lifetime." "I'd tell you a UDP joke, but you might not get it." "I'll tell you a TCP joke. Do you want to hear it?")) (setq dashboard-navigator-buttons - `(;; line1 - ( (,"Roam" "" "" (lambda (&rest _)) 'org-formula) - (,(all-the-icons-octicon "globe" :height 1.0 :v-adjust 0.0) - "Notes overview" "" (lambda (&rest _) (org-roam-default-overview)) 'org-formula) - (,(all-the-icons-fileicon "org" :height 1.0 :v-adjust 0.0) - "Switch roam db" "" (lambda (&rest _) (org-roam-switch-db)) 'org-formula) - ) - ;; line 2 - ( (,"Git" "" "" (lambda (&rest _)) 'match) - (,(all-the-icons-octicon "mark-github" :height 1.0 :v-adjust 0.0) - "GitHub" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://github.com/librephoenix")) 'match) - (,(all-the-icons-faicon "gitlab" :height 1.0 :v-adjust 0.0) - "GitLab" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://gitlab.com/librephoenix")) 'match) - (,(all-the-icons-faicon "coffee" :height 1.0 :v-adjust 0.0) - "Gitea" "" (lambda (&rest _) (browse-url my-gitea-domain)) 'match) - ) - ;; line 3 - ( (,"Agenda" "" "" (lambda (&rest _)) 'dired-warning) - (,(all-the-icons-octicon "checklist" :height 1.0 :v-adjust 0.0) - "Agenda todos" "" (lambda (&rest _) (org-agenda-list)) 'dired-warning) - (,(all-the-icons-octicon "calendar" :height 1.0 :v-adjust 0.0) - "Agenda calendar" "" (lambda (&rest _) (cfw:open-org-calendar)) 'dired-warning) - ) - ;; line 4 - ( (,"Config" "" "" (lambda (&rest _)) 'dired-mark) - (,(all-the-icons-faicon "cogs" :height 1.0 :v-adjust 0.0) - "System config" "" (lambda (&rest _) (projectile-switch-project-by-name "~/.dotfiles" t)) 'dired-mark) - (,(all-the-icons-material "help" :height 1.0 :v-adjust -0.2) - "Doom documentation" "" (lambda (&rest _) (doom/help)) 'dired-mark) - ) - )) -(setq dashboard-footer-icon (all-the-icons-faicon "list-alt" - :height 1.0 - :v-adjust -0.15 - :face 'font-lock-keyword-face)) + `(;; line1 + ( (,"Roam" "" "" (lambda (&rest _)) 'org-formula) + (,(all-the-icons-octicon "globe" :height 1.0 :v-adjust 0.0) + "Notes overview" "" (lambda (&rest _) (org-roam-default-overview)) 'org-formula) + (,(all-the-icons-fileicon "org" :height 1.0 :v-adjust 0.0) + "Switch roam db" "" (lambda (&rest _) (org-roam-switch-db)) 'org-formula) + ) + ;; line 2 + ( (,"Git" "" "" (lambda (&rest _)) 'match) + (,(all-the-icons-octicon "mark-github" :height 1.0 :v-adjust 0.0) + "GitHub" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://github.com/librephoenix")) 'match) + (,(all-the-icons-faicon "gitlab" :height 1.0 :v-adjust 0.0) + "GitLab" "" (lambda (&rest _) (browse-url "ext+container:name=Tech&url=https://gitlab.com/librephoenix")) 'match) + (,(all-the-icons-faicon "coffee" :height 1.0 :v-adjust 0.0) + "Gitea" "" (lambda (&rest _) (browse-url my-gitea-domain)) 'match) + ) + ;; line 3 + ( (,"Agenda" "" "" (lambda (&rest _)) 'dired-warning) + (,(all-the-icons-octicon "checklist" :height 1.0 :v-adjust 0.0) + "Agenda todos" "" (lambda (&rest _) (org-agenda-list)) 'dired-warning) + (,(all-the-icons-octicon "calendar" :height 1.0 :v-adjust 0.0) + "Agenda calendar" "" (lambda (&rest _) (cfw:open-org-calendar)) 'dired-warning) + ) + ;; line 4 + ( (,"Config" "" "" (lambda (&rest _)) 'dired-mark) + (,(all-the-icons-faicon "cogs" :height 1.0 :v-adjust 0.0) + "System config" "" (lambda (&rest _) (projectile-switch-project-by-name "~/.dotfiles" t)) 'dired-mark) + (,(all-the-icons-material "help" :height 1.0 :v-adjust -0.2) + "Doom documentation" "" (lambda (&rest _) (doom/help)) 'dired-mark) + ))) + +(setq dashboard-footer-icon + (all-the-icons-faicon "list-alt" + :height 1.0 + :v-adjust -0.15 + :face 'font-lock-keyword-face)) (dashboard-setup-startup-hook) ;; Smooth scrolling @@ -273,8 +274,8 @@ Teach him how to program and you will frustrate him for a lifetime." ;; Add frame borders and window dividers (modify-all-frames-parameters - '((right-divider-width . 10) - (internal-border-width . 10))) + '((right-divider-width . 5) + (internal-border-width . 5))) (dolist (face '(window-divider window-divider-first-pixel window-divider-last-pixel)) @@ -283,19 +284,19 @@ Teach him how to program and you will frustrate him for a lifetime." (set-face-background 'fringe (face-attribute 'default :background)) (setq - ;; Edit settings - org-auto-align-tags nil - org-tags-column 0 - org-catch-invisible-edits 'show-and-error - org-special-ctrl-a/e t - org-insert-heading-respect-content t + ;; Edit settings + org-auto-align-tags nil + org-tags-column 0 + org-catch-invisible-edits 'show-and-error + org-special-ctrl-a/e t + org-insert-heading-respect-content t - ;; Org styling, hide markup etc. - org-hide-emphasis-markers t - org-pretty-entities t - org-ellipsis "…") + ;; Org styling, hide markup etc. + org-hide-emphasis-markers t + org-pretty-entities t + org-ellipsis "…") -(setq-default line-spacing 0.1) +(setq-default line-spacing 0.15) ; Automatic table of contents is nice (if (require 'toc-org nil t) @@ -322,25 +323,6 @@ Teach him how to program and you will frustrate him for a lifetime." ;; Better for org source blocks (setq electric-indent-mode nil) (setq org-src-window-setup 'current-window) -(delete - '("^\\*Org Src" - (+popup-buffer) - (actions) - (side . bottom) - (size . 0.42) - (window-width . 40) - (window-height . 0.42) - (slot) - (vslot) - (window-parameters - (ttl) - (quit) - (select . t) - (modeline . t) - (autosave . t) - (transient . t) - (no-other-window . t))) - display-buffer-alist) ;; Horizontal scrolling tables (add-load-path! "~/.emacs.d/phscroll") @@ -350,14 +332,20 @@ Teach him how to program and you will frustrate him for a lifetime." (setq phscroll-calculate-in-pixels t) #+END_SRC -*** Org Download, Image Capture, and Opening Files in External Programs + +*** Org Download and Image Capture #+BEGIN_SRC emacs-lisp :tangle config.el (require 'org-download) ;; Drag-and-drop to `dired` (add-hook 'dired-mode-hook 'org-download-enable) -(setq org-download-screenshot-method "flameshot gui -p %s") +;; system-wm-type, wayland or x11? only should be considered if system-nix-profile is "personal" or "work" +(if (string= system-wm-type "wayland") + (setq org-download-screenshot-method "grim -g \"$(slurp)\" %s") + (setq org-download-screenshot-method "flameshot gui -p %s") +) + (after! org-download (setq org-download-method 'directory)) @@ -365,37 +353,27 @@ Teach him how to program and you will frustrate him for a lifetime." (setq-default org-download-image-dir "img/" org-download-heading-lvl nil)) -(defun my-org-screenshot () - "Take a screenshot into a time stamped unique-named file in the -same directory as the org-buffer and insert a link to this file." - (interactive) - (setq filename - (concat - (make-temp-name - (concat (buffer-file-name) - "_" - (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")) - (shell-command (concat "emacs-wayshot " filename)) - (insert (concat "[[" filename "]]")) - (org-display-inline-images)) +(add-to-list 'display-buffer-alist '("^*Async Shell Command*" . (display-buffer-no-window))) -(defun my-org-paste() - "Take an image from the clipboard into a time stamped unique-named file in the -same directory as the org-buffer and insert a link to this file." +(defun org-download-clipboard-basename () (interactive) - (setq filename - (concat - (make-temp-name - (concat (file-name-directory (buffer-file-name)) - "img/" - (file-name-nondirectory (buffer-file-name)) - "_" - (format-time-string "%Y%m%d_%H%M%S_")) ) ".png")) - (shell-command (concat "wl-paste > " filename)) - (insert (concat "[[" filename "]]")) - (org-display-inline-images)) + (setq org-download-path-last-dir org-download-image-dir) + (setq org-download-image-dir (completing-read "directory: " (-filter #'f-directory-p (directory-files-recursively "." "" t)) nil t)) + (org-download-clipboard (completing-read "basename: " '() nil nil)) + (setq org-download-image-dir org-download-path-last-dir) +) -(defun my-org-new-file-from-template() +(map! :leader + :desc "Insert a screenshot" + "i s" 'org-download-screenshot + :desc "Insert image from clipboard" + "i p" 'org-download-clipboard + "i P" 'org-download-clipboard-basename) + +#+END_SRC +*** External Program File Management +#+BEGIN_SRC emacs-lisp :tangle config.el +(defun org-new-file-from-template() "Copy a template from ~/Templates into a time stamped unique-named file in the same directory as the org-buffer and insert a link to this file." (interactive) @@ -413,76 +391,57 @@ same directory as the org-buffer and insert a link to this file." (insert (concat "[[./files/" (file-name-nondirectory filename) "][" prettyname "]]")) (org-display-inline-images)) -(when (require 'openwith nil 'noerror) - (setq openwith-associations - (list - (list (openwith-make-extension-regexp - '("mpg" "mpeg" "mp3" "mp4" - "avi" "wmv" "wav" "mov" "flv" - "ogm" "ogg" "mkv")) - "mpv" - '(file)) - (list (openwith-make-extension-regexp - '("doc" "xls" "ppt" "odt" "ods" "odg" "odp")) - "libreoffice" - '(file)) - '("\\.lyx" "lyx" (file)) - '("\\.chm" "kchmviewer" (file)) - (list (openwith-make-extension-regexp - '("pdf" "ps" "ps.gz" "dvi")) - "atril" - '(file)) - (list (openwith-make-extension-regexp - '("kdenlive")) - "kdenlive" - '(file)) - (list (openwith-make-extension-regexp - '("kra")) - "krita" - '(file)) - (list (openwith-make-extension-regexp - '("blend" "blend1")) - "blender" - '(file)) - (list (openwith-make-extension-regexp - '("helio")) - "helio" - '(file)) - (list (openwith-make-extension-regexp - '("svg")) - "inkscape" - '(file)) - (list (openwith-make-extension-regexp - '("flp")) - "~/.local/bin/flstudio" - '(file)) - )) - (openwith-mode 1)) - -(add-to-list 'display-buffer-alist '("^*Async Shell Command*" . (display-buffer-no-window))) - -(map! :leader - :desc "Insert a screenshot" -;; "i s" 'my-org-screenshot) - "i s" 'org-download-screenshot) - -(defun org-download-clipboard-basename () - (interactive) - (setq org-download-path-last-dir org-download-image-dir) - (setq org-download-image-dir (completing-read "directory: " (-filter #'f-directory-p (directory-files-recursively "." "" t)) nil t)) - (org-download-clipboard (completing-read "basename: " '() nil nil)) - (setq org-download-image-dir org-download-path-last-dir) -) - -(map! :leader - :desc "Insert image from clipboard" - "i p" 'org-download-clipboard - "i P" 'org-download-clipboard-basename) - (map! :leader :desc "Create a new file from a template and insert a link at point" "i t" 'my-org-new-file-from-template) +(if (not (string= system-nix-profile "wsl")) + (when (require 'openwith nil 'noerror) + (setq openwith-associations + (list + (list (openwith-make-extension-regexp + '("mpg" "mpeg" "mp3" "mp4" + "avi" "wmv" "wav" "mov" "flv" + "ogm" "ogg" "mkv")) + "mpv" + '(file)) + (list (openwith-make-extension-regexp + '("doc" "xls" "ppt" "odt" "ods" "odg" "odp")) + "libreoffice" + '(file)) + '("\\.lyx" "lyx" (file)) + '("\\.chm" "kchmviewer" (file)) + (list (openwith-make-extension-regexp + '("pdf" "ps" "ps.gz" "dvi")) + "atril" + '(file)) + (list (openwith-make-extension-regexp + '("kdenlive")) + "kdenlive" + '(file)) + (list (openwith-make-extension-regexp + '("kra")) + "krita" + '(file)) + (list (openwith-make-extension-regexp + '("blend" "blend1")) + "blender" + '(file)) + (list (openwith-make-extension-regexp + '("helio")) + "helio" + '(file)) + (list (openwith-make-extension-regexp + '("svg")) + "inkscape" + '(file)) + (list (openwith-make-extension-regexp + '("flp")) + "~/.local/bin/flstudio" + '(file)) + )) + (openwith-mode 1))) + #+END_SRC *** Copy Links/Files into Clipboard #+BEGIN_SRC emacs-lisp :tangle config.el @@ -499,7 +458,7 @@ same directory as the org-buffer and insert a link to this file." (if (eq major-mode #'image-mode) (image-mode-copy-file-name-as-kill) ) - (shell-command (concat "~/.emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh " (gui-get-selection 'CLIPBOARD)) nil nil) + (shell-command "~/.emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh " nil nil) ) (map! :leader @@ -511,11 +470,22 @@ same directory as the org-buffer and insert a link to this file." Shamelessly stolen from [[https://unix.stackexchange.com/questions/30093/copy-image-from-command-line-to-clipboard][here]] and modified for my use. #+BEGIN_SRC shell :tangle ./scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh :tangle-mode (identity #o755) #!/bin/sh -if [[ -f "$1" ]]; then - TYPE=$(file -b --mime-type "$1") - xclip -selection clipboard -t "$TYPE" -i "$1" +if [ $(echo $XDG_SESSION_TYPE) == "wayland" ]; then + FILENAME="$(wl-paste)" + FILTEREDFILENAME=$(echo "$FILENAME" | sed "s+file:+./+") + echo "$FILTEREDFILENAME" + if [[ -f "$FILTEREDFILENAME" ]]; then + wl-copy < "$FILTEREDFILENAME" + fi +elif [ $(echo $XDG_SESSION_TYPE) == "x11" ]; then + FILENAME="$(xclip -o)" + FILTEREDFILENAME=$(echo "$FILENAME" | sed "s+file:+./+") + if [[ -f "$FILTEREDFILENAME" ]]; then + TYPE=$(file -b --mime-type "$FILTEREDFILENAME") + xclip -selection clipboard -t "$TYPE" -i "$FILTEREDFILENAME" + exit + fi else - echo $1 | xclip -selection clipboard -t text/plain &> /dev/null exit fi exit @@ -620,6 +590,9 @@ exit :leader :prefix "n" :desc "Org Transclusion Mode" "t" #'org-transclusion-mode)) +(map! :leader :prefix "n" "l" #'org-transclusion-live-sync-start) + +(add-hook 'org-mode-hook #'org-transclusion-mode) #+END_SRC ** Org Roam Configuration diff --git a/user/app/doom-emacs/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh b/user/app/doom-emacs/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh index d67c8028..59c147ba 100755 --- a/user/app/doom-emacs/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh +++ b/user/app/doom-emacs/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh @@ -1,9 +1,20 @@ #!/bin/sh -if [[ -f "$1" ]]; then - TYPE=$(file -b --mime-type "$1") - xclip -selection clipboard -t "$TYPE" -i "$1" +if [ $(echo $XDG_SESSION_TYPE) == "wayland" ]; then + FILENAME="$(wl-paste)" + FILTEREDFILENAME=$(echo "$FILENAME" | sed "s+file:+./+") + echo "$FILTEREDFILENAME" + if [[ -f "$FILTEREDFILENAME" ]]; then + wl-copy < "$FILTEREDFILENAME" + fi +elif [ $(echo $XDG_SESSION_TYPE) == "x11" ]; then + FILENAME="$(xclip -o)" + FILTEREDFILENAME=$(echo "$FILENAME" | sed "s+file:+./+") + if [[ -f "$FILTEREDFILENAME" ]]; then + TYPE=$(file -b --mime-type "$FILTEREDFILENAME") + xclip -selection clipboard -t "$TYPE" -i "$FILTEREDFILENAME" + exit + fi else - echo $1 | xclip -selection clipboard -t text/plain &> /dev/null exit fi exit