about summary refs log tree commit diff stats
path: root/lisp/acdw-org.el
diff options
context:
space:
mode:
authorCase Duckworth2021-04-14 17:06:59 -0500
committerCase Duckworth2021-04-14 17:06:59 -0500
commite5795d6bf49cae67fb52fb65395d04b95296934f (patch)
tree5f42a97e3f7123a09c5fe9f40d98787264db484f /lisp/acdw-org.el
parentMerge branch 'main' of https://tildegit.org/acdw/emacs (diff)
downloademacs-e5795d6bf49cae67fb52fb65395d04b95296934f.tar.gz
emacs-e5795d6bf49cae67fb52fb65395d04b95296934f.zip
Make `org-return-dwim' auto-fill-mode-aware
Added a block at the top of the function to call `auto-fill-function' if it's
enabled, and I changed the calls to `newline' to `insert "\n"`, due to
... something.  It was having issues figuring out that the new lines were list
items I think.

I also removed the message part in the middle of the function that I forgot to
remove before.
Diffstat (limited to 'lisp/acdw-org.el')
-rw-r--r--lisp/acdw-org.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 06803d3..c4431ab 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el
@@ -38,6 +38,12 @@ lists, insert a new item or end the list, with checkbox if
38appropriate. In tables, insert a new row or end the table." 38appropriate. In tables, insert a new row or end the table."
39 ;; Inspired by John Kitchin: http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/ 39 ;; Inspired by John Kitchin: http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/
40 (interactive "P") 40 (interactive "P")
41 ;; Auto-fill if enabled
42 (when auto-fill-function
43 (if (listp auto-fill-function)
44 (dolist (func auto-fill-function)
45 (funcall func))
46 (funcall auto-fill-function)))
41 (if default 47 (if default
42 (org-return) 48 (org-return)
43 (cond 49 (cond
@@ -87,10 +93,6 @@ appropriate. In tables, insert a new row or end the table."
87 (org-element-property :contents-end context))) 93 (org-element-property :contents-end context)))
88 (item-child-p 94 (item-child-p
89 (unpackaged/org-element-descendant-of 'item context))) 95 (unpackaged/org-element-descendant-of 'item context)))
90 (message "(or %S (and %S %S) %S)"
91 first-item-p
92 itemp (not emptyp)
93 item-child-p)
94 ;; The original function from unpackaged just tested the (or ...) test 96 ;; The original function from unpackaged just tested the (or ...) test
95 ;; in this cond, in an if. However, that doesn't auto-end nested 97 ;; in this cond, in an if. However, that doesn't auto-end nested
96 ;; lists. So I made this form a cond and added the (and...) test in 98 ;; lists. So I made this form a cond and added the (and...) test in
@@ -99,13 +101,13 @@ appropriate. In tables, insert a new row or end the table."
99 ;; for now, it works well enough. 101 ;; for now, it works well enough.
100 (cond ((and itemp emptyp) 102 (cond ((and itemp emptyp)
101 (delete-region (line-beginning-position) (line-end-position)) 103 (delete-region (line-beginning-position) (line-end-position))
102 (newline 2)) 104 (insert "\n\n"))
103 ((or first-item-p 105 ((or first-item-p
104 (and itemp (not emptyp)) 106 (and itemp (not emptyp))
105 item-child-p) 107 item-child-p)
106 (org-insert-item)) 108 (org-insert-item))
107 (t (delete-region (line-beginning-position) (line-end-position)) 109 (t (delete-region (line-beginning-position) (line-end-position))
108 (newline))))) 110 (insert "\n")))))
109 111
110 ((when (fboundp 'org-inlinetask-in-task-p) 112 ((when (fboundp 'org-inlinetask-in-task-p)
111 (org-inlinetask-in-task-p)) 113 (org-inlinetask-in-task-p))