summary refs log tree commit diff stats
path: root/lisp/+org.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+org.el')
-rw-r--r--lisp/+org.el53
1 files changed, 49 insertions, 4 deletions
diff --git a/lisp/+org.el b/lisp/+org.el index 6b93a7a..0d6e300 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -2,6 +2,7 @@
2 2
3;;; Code: 3;;; Code:
4 4
5(require 'el-patch)
5(require 'org) 6(require 'org)
6(require 'org-element) 7(require 'org-element)
7(require 'ox) 8(require 'ox)
@@ -96,7 +97,7 @@ appropriate. In tables, insert a new row or end the table."
96 ;; for now, it works well enough. 97 ;; for now, it works well enough.
97 (cond ((and itemp emptyp) 98 (cond ((and itemp emptyp)
98 (delete-region (line-beginning-position) (line-end-position)) 99 (delete-region (line-beginning-position) (line-end-position))
99 (insert "\n\n")) 100 (insert "\n"))
100 ((or first-item-p 101 ((or first-item-p
101 (and itemp (not emptyp)) 102 (and itemp (not emptyp))
102 item-child-p) 103 item-child-p)
@@ -252,11 +253,11 @@ instead of the true count."
252 ((use-region-p) 253 ((use-region-p)
253 (message "%d words in region" 254 (message "%d words in region"
254 (+org-count-words-stupidly (region-beginning) 255 (+org-count-words-stupidly (region-beginning)
255 (region-end)))) 256 (region-end))))
256 (t 257 (t
257 (message "%d words in buffer" 258 (message "%d words in buffer"
258 (+org-count-words-stupidly (point-min) 259 (+org-count-words-stupidly (point-min)
259 (point-max)))))) 260 (point-max))))))
260 261
261;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/ 262;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/
262 263
@@ -561,7 +562,7 @@ and POST-PROCESS are passed to `org-export-to-file'."
561 (let ((org-tmp-file "/tmp/org.html")) 562 (let ((org-tmp-file "/tmp/org.html"))
562 (org-export-to-file 'html org-tmp-file 563 (org-export-to-file 'html org-tmp-file
563 async subtreep visible-only body-only ext-plist post-process) 564 async subtreep visible-only body-only ext-plist post-process)
564 (start-process "xclicp" "*xclip*" 565 (start-process "xclip" "*xclip*"
565 "xclip" "-verbose" 566 "xclip" "-verbose"
566 "-i" org-tmp-file 567 "-i" org-tmp-file
567 "-t" "text/html" 568 "-t" "text/html"
@@ -684,5 +685,49 @@ This should only fire when switching to a buffer from `org-agenda'."
684 (advice-remove 'org-agenda #'+org-agenda-inhibit-hooks) 685 (advice-remove 'org-agenda #'+org-agenda-inhibit-hooks)
685 (advice-remove 'org-agenda-switch-to #'+org-agenda-switch-run-hooks)))) 686 (advice-remove 'org-agenda-switch-to #'+org-agenda-switch-run-hooks))))
686 687
688
689;;; "Fix" `org-align-tags'
690
691(el-patch-defun org-align-tags (&optional all)
692 "Align tags in current entry.
693When optional argument ALL is non-nil, align all tags in the
694visible part of the buffer."
695 (let ((get-indent-column
696 (lambda ()
697 (let ((offset (el-patch-swap
698 (if (bound-and-true-p org-indent-mode)
699 (* (1- org-indent-indentation-per-level)
700 (1- (org-current-level)))
701 0)
702 0)))
703 (+ org-tags-column
704 (if (> org-tags-column 0) (- offset) offset))))))
705 (if (and (not all) (org-at-heading-p))
706 (org--align-tags-here (funcall get-indent-column))
707 (save-excursion
708 (if all
709 (progn
710 (goto-char (point-min))
711 (while (re-search-forward org-tag-line-re nil t)
712 (org--align-tags-here (funcall get-indent-column))))
713 (org-back-to-heading t)
714 (org--align-tags-here (funcall get-indent-column)))))))
715
716;;; Meta-return
717
718(defun +org-meta-return (&optional arg)
719 "Insert a new line, or wrap a region in a table.
720See `org-meta-return', but `+org-return-dwim' does most of the
721stuff I would want out of that function already.
722
723When called with a prefix ARG, will still unconditionally call
724`org-insert-heading'."
725 (interactive "P")
726 (org-fold-check-before-invisible-edit 'insert)
727 (or (run-hook-with-args-until-success 'org-metareturn-hook) ; Allow customizations
728 (call-interactively (cond (arg #'org-insert-heading)
729 ((org-at-table-p) #'org-table-wrap-region)
730 (t #'org-return)))))
731
687(provide '+org) 732(provide '+org)
688;;; +org.el ends here 733;;; +org.el ends here