Simplify and add emacs config

This commit is contained in:
2025-09-26 17:51:52 -04:00
parent 4f38297378
commit 93aecdd5cb
13 changed files with 2334 additions and 0 deletions

View File

@ -0,0 +1,69 @@
(defun fullpath-relative-to-current-file (file-relative-path)
"Returns the full path of FILE-RELATIVE-PATH, relative to file location where this function is called."
(concat (file-name-directory (or load-file-name buffer-file-name)) file-relative-path))
(defun bury-compile-buffer-if-successful (buffer string)
"Bury a compilation buffer if succeeded without warnings "
(if (and
(string-match "compilation" (buffer-name buffer))
(string-match "finished" string)
(not
(with-current-buffer buffer
(search-forward "warning" nil t))))
(run-with-timer 1 nil
(lambda (buf)
(bury-buffer buf)
(switch-to-prev-buffer (get-buffer-window buf) 'kill))
buffer)))
(defun iwb ()
"indent whole buffer"
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
(defun big-font () (interactive)
(set-face-attribute 'default (selected-frame) :family "inconsolata" :height 300) )
(defun normal-font () (interactive)
(set-face-attribute 'default (selected-frame) :family "lime" :height 75))
(define-derived-mode chat-mode text-mode "chat"
"Major mode for screen chatting with people"
(interactive)
(buffer-face-set :family "inconsolata" :height 300)
(set 'fill-column 70))
(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
;; projectile mode tree thing?
(defun neotree-project-dir ()
"Open NeoTree using the git root."
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-toggle)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-find file-name)))
(message "Could not find git project root."))))