Hello, Rasmus <ras...@gmx.us> writes:
> The attached patch re-enables breaks in region four of > org-complex-heading-regexp, i.e. from the cookie up to tags. A quick test > suggests it works nicely. Thank you. > WDYT? Some comments follow. > Subject: [PATCH 2/2] org.el: RET works in headline text > > * org.el (org-return): RET works in headline text. "RET breaks headline text" may be more accurate. > + (let* ((context (if org-return-follows-link (org-element-context) > + (org-element-at-point))) > + (type (org-element-type context))) > + (cond > + ;; At a headline > + ((and (eq type 'headline) (not (bolp))) You are removing an optimization here. Checking if point is on a headline/inlinetask doesn't require to use `org-element-at-point'/`org-element-context'. It is faster to simply check for `org-outline-regexp' (or derived) at bol. This optimization is less important than it used to be, now that properties drawers are at a fixed location. Nevertheless, it might be worth keeping it in mind. > + (org-show-entry) > + (let ((string "")) > + (unless (and (save-excursion > + (beginning-of-line) > + (looking-at org-complex-heading-regexp)) > + (or (and (match-beginning 3) > + (< (point) > + (save-excursion > + (goto-char (match-beginning 4)) > + (skip-chars-backward " \t") > + (point)))) > + (and (match-beginning 5) > + (>= (point) (match-beginning 5))))) > + ;; Point is on headline keywords, tags or cookies. Do not break > + ;; them: add a newline after the headline instead. > + (setq string (delete-and-extract-region > + (point) (or (match-beginning 5) > + (line-end-position)))) The `setq' is not necessary here. Bind it within `let' instead. > + (when (match-beginning 5) > + (insert (make-string (length string) ?\ )))) ?\ -> ?\s If you add this feature, please augment `test-org/return' from "test-org.el" accordingly. Regards, -- Nicolas Goaziou