From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: A Microsoftesque detail in org Date: Fri, 15 May 2015 13:27:51 +0200 Message-ID: <87lhgqxeq0.fsf@gmx.us> References: <87382yji8z.fsf@iki.fi> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtDmj-0005Zs-0X for emacs-orgmode@gnu.org; Fri, 15 May 2015 07:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YtDme-0002fP-RA for emacs-orgmode@gnu.org; Fri, 15 May 2015 07:28:08 -0400 Received: from plane.gmane.org ([80.91.229.3]:54534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtDme-0002fJ-F8 for emacs-orgmode@gnu.org; Fri, 15 May 2015 07:28:04 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YtDmd-0003iv-F2 for emacs-orgmode@gnu.org; Fri, 15 May 2015 13:28:03 +0200 Received: from tsn109-201-152-242.dyn.nltelcom.net ([109.201.152.242]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 May 2015 13:28:03 +0200 Received: from rasmus by tsn109-201-152-242.dyn.nltelcom.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 May 2015 13:28:03 +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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Jarmo, Jarmo Hurri writes: > I was just amazed by the following detail in org. In the example below, > if my cursor is anywhere inside the word "Example", and I press Enter, a > new line will be inserted below, and the cursor will jump to the next > line. The location of the cursor inside the heading line is ignored, and > the heading line will not be broken. > > # -------------------------------------------------------------------- > * Example > Some text. > # -------------------------------------------------------------------- > > This immediately reminded me of Microsoft products, where the software > tries to be too intelligent, thus making it harder for the user. In this > case, I needed to figure out that Ctrl-o is needed to break the line. > > I would suggest that the original interpretation of Enter would not be > messed with. Messing with Alt-Enter and such is fine, but Enter, please > no. I disagree. Consider the more complete example: * TODO [#A] foo bar :tag: With your behavior you can (i) break the TODO tag; (ii) break the cookie; (iii) break the tag. At least (i) and (ii) are quite destructive. I, for one, would hate to have to readjust my tags every time I break a headline. Call me spoiled by MS if you like and if you think it's relevant. Yet, not being able to break between foo and bar is quite annoying. 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. WDYT? —Rasmus -- However beautiful the theory, you should occasionally look at the evidence --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-org.el-RET-works-in-headline-text.patch >From 8a2477cb70770526939a6c665026802d46db21ea Mon Sep 17 00:00:00 2001 From: Rasmus Date: Fri, 15 May 2015 13:08:11 +0200 Subject: [PATCH 2/2] org.el: RET works in headline text * org.el (org-return): RET works in headline text. --- lisp/org.el | 93 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 4b44a94..8adec05 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -21185,45 +21185,60 @@ will not happen if point is in a table or on a \"dead\" object (e.g., within a comment). In these case, you need to use `org-open-at-point' directly." (interactive) - (if (and (save-excursion - (beginning-of-line) - (looking-at org-todo-line-regexp)) - (match-beginning 3) - (>= (point) (match-beginning 3))) - ;; Point is on headline tags. Do not break them: add a newline - ;; after the headline instead. - (progn (org-show-entry) - (end-of-line) - (if indent (newline-and-indent) (newline))) - (let* ((context (if org-return-follows-link (org-element-context) - (org-element-at-point))) - (type (org-element-type context))) - (cond - ;; In a table, call `org-table-next-row'. - ((or (and (eq type 'table) - (>= (point) (org-element-property :contents-begin context)) - (< (point) (org-element-property :contents-end context))) - (org-element-lineage context '(table-row table-cell) t)) - (org-table-justify-field-maybe) - (call-interactively #'org-table-next-row)) - ;; On a link or a timestamp but not on white spaces after it, - ;; call `org-open-line' if `org-return-follows-link' allows it. - ((and org-return-follows-link - (memq type '(link timestamp)) - (< (point) - (save-excursion (goto-char (org-element-property :end context)) - (skip-chars-backward " \t") - (point)))) - (call-interactively #'org-open-at-point)) - ;; In a list, make sure indenting keeps trailing text within. - ((and indent - (not (eolp)) - (org-element-lineage context '(item))) - (let ((trailing-data - (delete-and-extract-region (point) (line-end-position)))) - (newline-and-indent) - (save-excursion (insert trailing-data)))) - (t (if indent (newline-and-indent) (newline))))))) + (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))) + (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)))) + (when (match-beginning 5) + (insert (make-string (length string) ?\ )))) + (end-of-line) + (if indent (newline-and-indent) (newline)) + (save-excursion (insert (org-trim string))))) + ;; In a table, call `org-table-next-row'. + ((or (and (eq type 'table) + (>= (point) (org-element-property :contents-begin context)) + (< (point) (org-element-property :contents-end context))) + (org-element-lineage context '(table-row table-cell) t)) + (org-table-justify-field-maybe) + (call-interactively #'org-table-next-row)) + ;; On a link or a timestamp but not on white spaces after it, + ;; call `org-open-line' if `org-return-follows-link' allows it. + ((and org-return-follows-link + (memq type '(link timestamp)) + (< (point) + (save-excursion (goto-char (org-element-property :end context)) + (skip-chars-backward " \t") + (point)))) + (call-interactively #'org-open-at-point)) + ;; In a list, make sure indenting keeps trailing text within. + ((and indent + (not (eolp)) + (org-element-lineage context '(item))) + (let ((trailing-data + (delete-and-extract-region (point) (line-end-position)))) + (newline-and-indent) + (save-excursion (insert trailing-data)))) + (t (if indent (newline-and-indent) (newline)))))) (defun org-return-indent () "Goto next table row or insert a newline and indent. -- 2.4.0 --=-=-=--