From b0c87544fe0c8b103354904370445757e05b9bab Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 12 Jun 2024 23:17:41 -0700 Subject: Restructuring - Break functions out to their own files - Move user settings to its own file - Move dashboard to its own file - Remove old splash - Don't hardcode executables --- elchemy-personal.el | 181 ++++------------------------------------------------ 1 file changed, 12 insertions(+), 169 deletions(-) (limited to 'elchemy-personal.el') diff --git a/elchemy-personal.el b/elchemy-personal.el index ac99314..dbb3423 100644 --- a/elchemy-personal.el +++ b/elchemy-personal.el @@ -1,21 +1,15 @@ -;; Ignore bell -(setq ring-bell-function 'ignore) +(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.8)) +(let ((png (cdr (assoc 'dvipng org-preview-latex-process-alist)))) + (plist-put png :latex-compiler '("latex -interaction nonstopmode -output-directory %o %F")) + (plist-put png :image-converter '("dvipng -D %D -T tight -o %O %F")) + (plist-put png :transparent-image-converter '("dvipng -D %D -T tight -bg Transparent -o %O %F"))) -(setq python-shell-interpreter "~/.micromamba/envs/emacs-py/bin/ipython" - python-shell-interpreter-args "--pylab") +(when (executable-find "guile") + (add-to-list 'load-path (concat elchemy/elchemy-root "extras/")) + (require 'guile-interaction)) -(defun elchemy/add-to-pypath (&optional path) - "# Add to python path" - (interactive) - (let* ((fullpath (if path - path - (ido-read-directory-name "Path: ")))) - (setenv "PYTHONPATH" - (let ((current (getenv "PYTHONPATH")) - (new fullpath)) - (if current - (concat new ":" current) - new))))) +(put 'narrow-to-region 'disabled nil) +(put 'downcase-region 'disabled nil) (add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode)) @@ -24,26 +18,6 @@ (define-key eglot-mode-map (kbd "C-c l f") 'eglot-format) (define-key eglot-mode-map (kbd "C-c l d") 'eldoc) -(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.8)) -(let ((png (cdr (assoc 'dvipng org-preview-latex-process-alist)))) - (plist-put png :latex-compiler '("latex -interaction nonstopmode -output-directory %o %F")) - (plist-put png :image-converter '("dvipng -D %D -T tight -o %O %F")) - (plist-put png :transparent-image-converter '("dvipng -D %D -T tight -bg Transparent -o %O %F"))) - -(org-babel-do-load-languages - 'org-babel-load-languages - '((python . t) - (gnuplot . t) - (R . t))) -(setq org-babel-python-command python-shell-interpreter) -(setq org-babel-R-command "/usr/local/bin/R --slave --no-save") -(setq org-babel-gnuplot-command "/usr/local/bin/gnuplot") -(setq org-confirm-babel-evaluate nil) - -(defun elchemy/personal/ignore-angle-brackets () - "Ignore angle brackets in org mode" - (modify-syntax-entry ?< ".") - (modify-syntax-entry ?> ".")) (add-hook 'org-mode-hook 'elchemy/personal/ignore-angle-brackets) (add-to-list 'load-path "~/.emacs.d/extras/") @@ -60,145 +34,14 @@ (get-buffer-process (current-buffer)) nil "_")))) -(setq sentence-end-double-space nil) - -(defun elchemy/read-alist-file (file-path) - "Read a file where each line is an alist of the form (name . location), returning a list of these pairs." - (interactive "fEnter file path: ") - (let (result) - (with-temp-buffer - (insert-file-contents file-path) - (goto-char (point-min)) - (while (not (eobp)) - (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) - (when (not (string-blank-p line)) - (let ((pair (car (read-from-string line)))) - (push pair result)))) - (forward-line 1))) - (reverse result))) - -(defun elchemy/find-file (FILENAME) - "Find File to new split" - (let ((buffer (find-file-noselect FILENAME))) - (when (one-window-p) - (split-window-right)) - (other-window 1) - (switch-to-buffer buffer))) -(defun elchemy/term (TERM) - "Terminal to new split" - (when (one-window-p) - (split-window-right)) - (other-window 1) - (term TERM)) - -(setq elchemy/dashboard/heading-columns 3 - elchemy/dashboard/heading-buttons '( - ("Open Local TODO" . (lambda (x) (elchemy/find-file "~/org/todo.org"))) - ("Open Remote TODO" . (lambda (x) (elchemy/find-file "/ssh:onid:todo.org"))) - ("Open Local Notes" . (lambda (x) (elchemy/find-file "~/org/notes.org"))) - ("Open Remote Notes" . (lambda (x) (elchemy/find-file "/ssh:onid:knowledge.org"))) - ("Open Terminal" . (lambda (x) (elchemy/term "/bin/zsh"))) - ("Open Scratch" . (lambda (x) - (when (one-window-p) - (split-window-right)) - (other-window 1) - (scratch-buffer))) - ("Testing" . (lambda (x) (elchemy/find-file "/ssh:onid:test.el"))) - ) - elchemy/dashboard/heading-max-length (apply #'max (mapcar #'(lambda (x) (length (car x))) elchemy/dashboard/heading-buttons)) - elchemy/dashboard/heading-padding 4) - -(defun elchemy/create-dashboard () - "Create the user dashboard" - (interactive) - (let ((buffer (get-buffer-create "*Dashboard*"))) - (switch-to-buffer buffer) - (unless buffer-read-only - (when (file-exists-p "~/.elchemy/assets/splash.png") - (insert-image (create-image "~/.elchemy/assets/splash.png" nil nil :scale 0.25)) - (insert "\n")) - (let ((start (point))) - (insert "Elchemy Dashboard") - (add-text-properties start (point) - '(face (:height 4.0)))) - (insert "\n\n") - (dotimes (i (length elchemy/dashboard/heading-buttons)) - (let* ((button (nth i elchemy/dashboard/heading-buttons)) - (title (car button)) - (callback (cdr button))) - (insert (buttonize title callback)) - (if (eq (% (+ i 1) elchemy/dashboard/heading-columns) 0) - (insert "\n") - (insert (format (concat "%-" (format "%d" (+ (- elchemy/dashboard/heading-max-length (length title)) elchemy/dashboard/heading-padding)) "s") " "))))) - (unless (eq (% (length elchemy/dashboard/heading-buttons) elchemy/dashboard/heading-columns) 0) - (insert "\n")) - (insert "\n") - (insert - (buttonize "Open Personal Configuration" (lambda (x) (elchemy/find-file "~/.elchemy/elchemy-personal.el")))) - (insert "\n\n") - (when (file-exists-p "~/.elchemy/projects") - (let ((start (point))) - (insert "Projects") - (add-text-properties start (point) - '(face (:height 1.5)))) - (insert "\n") - (mapcar #'(lambda (x) (let ((name (car x)) - (path (cdr x))) - (insert (buttonize name (lambda (y) (elchemy/find-file y)) path) "\n"))) - (elchemy/read-alist-file "~/.elchemy/projects")) - (insert "\n")) - (let ((start (point))) - (insert "Command Reference") - (add-text-properties start (point) - '(face (:height 1.5)))) - (insert "\n") - (insert "C-/ ~ Undo\n") - (insert "C-x n n ~ Narrow\n") - (insert "C-x n w ~ Widen\n") - (insert "M-% ~ Query Replace\n") - (insert "C-M-s ~ Regex Search\n") - (insert "F3 ~ Record Macro\n") - (insert "F4 ~ Play Macro\n") - (insert "M-0 F4 ~ Play Macro until failure\n") - (insert "M-l ~ Lowercase following word\n") - (insert "M-u ~ Uppercase following word\n") - (insert "M-c ~ Capitalize following word\n") - (insert "M-g w ~ Jump to word\n") - (insert "M-g l ~ Jump to line\n") - (insert "C-x C-l ~ Lowercase Region\n") - (insert "C-x C-u ~ Uppercase Region\n") - (insert "C-M-n ~ Move forward one balanced expression\n") - (insert "C-M-p ~ Move forward one balanced expression\n") - (setq header-line-format nil) - (button-mode +1) - (read-only-mode +1)))) -(elchemy/create-dashboard) - -(add-to-list 'org-agenda-files "/ssh:onid:todo.org") -(add-to-list 'org-capture-templates '("o" "OSU Todo" entry (file+headline "/ssh:onid:todo.org" "Imported") - "* TODO %?\n %i\n %a\n")) -(add-to-list 'org-capture-templates '("k" "Knowledge Entry" entry (file+headline "/ssh:onid:knowledge.org" "Imported") - "* %?\n %i\n %a\n")) +(when (require 'elchemy-dashboard nil t) + (elchemy/create-dashboard)) (add-hook 'minibuffer-setup-hook (lambda () (make-local-variable 'face-remapping-alist) (add-to-list 'face-remapping-alist '(default (:background "gray90"))))) -(setq-default header-line-format '( - (:propertize "♥︎" face (:foreground "red")) - " " - (:propertize "ELCHEMY" face (:weight bold)) - " " - (:propertize "♦︎" face (:foreground "red")) - " " - (:propertize "%b" face (:slant italic)) - " ♣︎ " - (:eval mode-name) - " ♠︎")) - -(load "extras/guile-interaction.el") -(require 'guile-interaction) (provide 'elchemy-personal) -- cgit v1.2.1