(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."))))