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-functions.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'elchemy-functions.el') diff --git a/elchemy-functions.el b/elchemy-functions.el index 465034b..a5919d7 100644 --- a/elchemy-functions.el +++ b/elchemy-functions.el @@ -1,10 +1,59 @@ (defun elchemy/replace-in-buffer () + "Replace strings in buffer" (interactive) (save-excursion (if (equal mark-active nil) (mark-word)) (setq elchemy/rib/current-word (buffer-substring-no-properties (mark) (point))) - (setq elchemy/rib/old-string (read-string "OLD string:\n" elchemy/rib/current-word)) - (setq elchemy/rib/new-string (read-string "NEW string:\n" elchemy/rib/old-string)) + (setq elchemy/rib/old-string (read-string "OLD string: " elchemy/rib/current-word)) + (setq elchemy/rib/new-string (read-string "NEW string: " elchemy/rib/old-string)) (query-replace elchemy/rib/old-string elchemy/rib/new-string nil (point-min) (point-max)))) +(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))))) + +(defun elchemy/personal/ignore-angle-brackets () + "Ignore angle brackets in org mode" + (modify-syntax-entry ?< ".") + (modify-syntax-entry ?> ".")) + +(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)) + (provide 'elchemy-functions) -- cgit v1.2.1