This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; because, why not? | |
| (setq lexical-binding t) | |
| (defmacro cycle-forms (&rest forms) | |
| (let ((sym (make-symbol "sym")) | |
| (n 0) | |
| (l (length forms))) | |
| (set sym 0) | |
| `(case (prog1 ,sym |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defvar all-make-modes | |
| '(makefile-makepp-mode makefile-bsdmake-mode makefile-imake-mode makefile-automake-mode makefile-mode makefile-gmake-mode) | |
| "A list of the makefile major modes") | |
| (defun my-cleanup-buffer-before-save () | |
| (delete-trailing-whitespace (point-min) (point-max)) | |
| (when (and (derived-mode-p 'prog-mode) | |
| (not (member major-mode all-make-modes))) | |
| (indent-region (point-min) (point-max)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; automatically swith rubies when changing buffer to a ruby buffer outside the current project. | |
| ;; requires rvm.el and projectile | |
| (defvar jorbi/-last-active-ruby-project nil) | |
| (defun jorbi/maybe-activate-new-ruby () | |
| (when (and (equal major-mode 'ruby-mode) | |
| (not (equal jorbi/-last-active-ruby-project | |
| (setq jorbi/-last-active-ruby-project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun jorbi-magit/-line-region-of-section-at-point () | |
| "If point is in a hunk return a list of info about the hunk. | |
| The info is like (expanded-file-name starting-line number-of-lines-show)" | |
| (let* ((section (magit-current-section)) | |
| (context-type (magit-section-context-type section))) | |
| (when (and (member 'hunk context-type)) | |
| (let* ((info | |
| (mapcar 'string-to-number | |
| (split-string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun jorbi-magit/-line-region-of-section-at-point () | |
| "If point is in a hunk return a list of info about the hunk. | |
| The info is like (expanded-file-name starting-line number-of-lines-show)" | |
| (let* ((section (magit-current-section)) | |
| (context-type (magit-section-context-type section))) | |
| (when (and (member 'hunk context-type)) | |
| (let* ((info | |
| (mapcar 'string-to-number | |
| (split-string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun battery-level () | |
| (string-to-number (shell-command-to-string "echo \"$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\\d+)%.*/\\1/')\""))) | |
| (defvar battery-status-function 'battery-level) | |
| (defun battery-indicator-string () | |
| (let* ((bat (funcall battery-status-function)) | |
| (index (cl-position-if (lambda (e) (> bat e)) '(87 75 62 50 37 25 12 7 -1))) | |
| (symbol (nth index '("█" "▇" "▆" "▅" "▄" "▃" "▂" "▁" "!"))) | |
| (color (nth index (mapcar (lambda (c) (apply 'color-rgb-to-hex c)) (color-gradient '(.3 1 .2) '(1 .2 .1) 9))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defmacro fmt (str) | |
| "Elisp string interpolation. | |
| Example: | |
| (fmt \"My name is #{user-full-name}, I am running Emacs #{(if (display-graphic-p) \\\"with a GUI\\\" \\\"in a terminal\\\".)}\"" | |
| (let ((exprs nil)) | |
| (with-temp-buffer | |
| (insert str) | |
| (goto-char 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defmacro background-function (&rest args) | |
| "Generates a function that runs in the background. | |
| In order to work in Emacs single threaded environment. | |
| The function must be broken in to steps. | |
| See source for keywords." | |
| (declare (indent defun) (doc-string 3)) | |
| (let* ((name (car args)) | |
| (margs (cadr args)) | |
| (docstring (when (stringp (caddr args)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun guess-all-hooks () | |
| "Return a list of all variables that are probably hook lists." | |
| (let ((syms '())) | |
| (mapatoms (lambda (sym) | |
| (if (ignore-errors (symbol-value sym)) | |
| (let ((name (symbol-name sym))) | |
| (when (string-match "-\\(hook[s]?\\|functions\\)$" name) | |
| (push sym syms)))))) | |
| syms)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun toggle-80-editting-columns () | |
| "Set the right window margin so the edittable space is only 80 columns." | |
| (interactive) | |
| (let ((margins (window-margins))) | |
| (if (or (car margins) (cdr margins)) | |
| (set-window-margins nil 0 0) | |
| (set-window-margins nil 0 (max (- (window-width) 80) 0))))) | |
| (defun toggle-80-editting-columns-balanced () | |
| "Set both window margins so the edittable space is only 80 columns." |