From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: A Microsoftesque detail in org Date: Sat, 16 May 2015 10:05:35 +0200 Message-ID: <87k2w99cc0.fsf@nicolasgoaziou.fr> References: <87382yji8z.fsf@iki.fi> <87lhgqxeq0.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtX4y-0004UC-MF for emacs-orgmode@gnu.org; Sat, 16 May 2015 04:04:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YtX4x-00026F-LB for emacs-orgmode@gnu.org; Sat, 16 May 2015 04:04:16 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:47987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtX4x-000243-Eu for emacs-orgmode@gnu.org; Sat, 16 May 2015 04:04:15 -0400 In-Reply-To: <87lhgqxeq0.fsf@gmx.us> (rasmus@gmx.us's message of "Fri, 15 May 2015 13:27:51 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus 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