diff options
author | dx <aryadevchavali1@gmail.com> | 2020-07-15 15:31:56 +0100 |
---|---|---|
committer | dx <aryadevchavali1@gmail.com> | 2020-07-15 15:31:56 +0100 |
commit | f8ca6b9e1b038c58b7756d08a55076a625c25f2e (patch) | |
tree | 3c4e25df18b4e0402562d86046744cbebb864874 /Emacs/.config/emacs/+org.el | |
parent | e27bda1bde45cf44c5aed3447d8fb6ee09a4387a (diff) | |
download | dotfiles-f8ca6b9e1b038c58b7756d08a55076a625c25f2e.tar.gz dotfiles-f8ca6b9e1b038c58b7756d08a55076a625c25f2e.tar.bz2 dotfiles-f8ca6b9e1b038c58b7756d08a55076a625c25f2e.zip |
+major refactors to vanilla Emacs config
Developed quite a bit of the config.
I've added a literate org config, loaded through the init.el file.
Furthermore, I've added some basic general maps and have gained a much
better understanding of Emacs than before. This refactor is one of the
main reasons I decided to so heavily refactor my doom config.
Diffstat (limited to 'Emacs/.config/emacs/+org.el')
-rw-r--r-- | Emacs/.config/emacs/+org.el | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Emacs/.config/emacs/+org.el b/Emacs/.config/emacs/+org.el new file mode 100644 index 0000000..aa5e755 --- /dev/null +++ b/Emacs/.config/emacs/+org.el @@ -0,0 +1,78 @@ +(defun dx:org-insert-item (direction) + "Shamelessly copied from Doom Emacs, better insert item" + (let* ((context + (save-excursion + (when (bolp) + (back-to-indentation) + (forward-char)) + (org-element-lineage + (org-element-context) + '(table table-row headline inlinetask item plain-list) + t))) + (type (org-element-type context))) + (cond ((memq type '(item plain-list)) + (let ((marker (org-element-property :bullet context)) + (pad (save-excursion + (org-beginning-of-item) + (back-to-indentation) + (- (point) (line-beginning-position))))) + (save-match-data + (pcase direction + (`below + (org-end-of-item) + (backward-char) + (end-of-line) + (if (and marker (string-match "\\([0-9]+\\)\\([).] *\\)" marker)) + (let ((l (line-number-at-pos))) + (org-insert-item) + (when (= l (line-number-at-pos)) + (org-next-item) + (org-end-of-line))) + (insert "\n" (make-string pad 32) (or marker "")))) + (`above + (org-beginning-of-item) + (if (and marker (string-match-p "[0-9]+[).]" marker)) + (org-insert-item) + (insert (make-string pad 32) (or marker "")) + (save-excursion (insert "\n"))))))) + (when (org-element-property :checkbox context) + (insert "[ ] "))) + + ((memq type '(table table-row)) + (pcase direction + ('below (save-excursion (org-table-insert-row t)) + (org-table-next-row)) + ('above (save-excursion (org-shiftmetadown)) + (+org/table-previous-row)))) + + ((let ((level (or (org-current-level) 1))) + (pcase direction + (`below + (let (org-insert-heading-respect-content) + (goto-char (line-end-position)) + (org-end-of-subtree) + (insert "\n" (make-string level ?*) " "))) + (`above + (org-back-to-heading) + (insert (make-string level ?*) " ") + (save-excursion (insert "\n")))) + (when-let* ((todo-keyword (org-element-property :todo-keyword context)) + (todo-type (org-element-property :todo-type context))) + (org-todo (cond ((eq todo-type 'done) + (car (+org-get-todo-keywords-for todo-keyword))) + (todo-keyword) + ('todo))))))) + + (when (org-invisible-p) + (org-show-hidden-entry)) + (when (and (bound-and-true-p evil-local-mode) + (not (evil-emacs-state-p))) + (evil-insert 1)))) + +(defun dx:org-insert-item-below () + (interactive) + (dx:org-insert-item 'below)) + +(defun dx:org-insert-item-above () + (interactive) + (dx:org-insert-item 'above)) |