emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] org-delete-indentation
@ 2015-05-16 15:34 Rasmus
  2015-05-16 19:05 ` Rasmus
  2015-05-17  8:33 ` Nicolas Goaziou
  0 siblings, 2 replies; 6+ messages in thread
From: Rasmus @ 2015-05-16 15:34 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

Hi,

Due to recent controversy about Org being lacking Microsoftesque detail I
finally implemented org-delete-indentation, which is a function I have
been missing forever.

It only behaves differently from delete-indentation at headlines where it
add stuff to the headline text.  It is at least what I would expect.

Examples:

  * foo :tag:
  bar|
=> (org-delete-indentation)
  * foo bar :tag:

  * foo | :tag:
   bar
=> (org-delete-indentation t)
   * foo bar :tag:

—Rasmus

-- 
With monopolies the cake is a lie!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-org.el-New-function-org-delete-indentation.patch --]
[-- Type: text/x-diff, Size: 4203 bytes --]

From ef242f5d599d4888cdf57e1f6a65db8406626499 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sat, 16 May 2015 17:19:03 +0200
Subject: [PATCH 2/2] org.el: New function org-delete-indentation

* org.el (org-delete-indentation): New function.
  (org-mode-map): Bind org-delete-indentation to M-^.
* test-org.el (test-org-delete-indentation): Test org-delete-indentation.
* ORG-NEWS: Add entry on org-delete-indentation.
---
 etc/ORG-NEWS             |  3 +++
 lisp/org.el              | 25 +++++++++++++++++++++++++
 testing/lisp/test-org.el | 28 ++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a3e1ae2..91e30f8 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -377,6 +377,9 @@ for details.
 Calling ~org-edit-footnote-reference~ (C-c ') on a footnote reference
 allows to edit its definition, as long as it is not anonymous, in
 a dedicated buffer.  It works even if buffer is currently narrowed.
+*** New function ~org-delete-indentation~ bound to ~M-^~
+Work as ~delete-indentation~ unless at heading, in which case text is
+added to headline text.
 ** Miscellaneous
 *** Strip all meta data from ITEM special property
 ITEM special property does not contain TODO, priority or tags anymore.
diff --git a/lisp/org.el b/lisp/org.el
index 93183f9..f30c25c 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19832,6 +19832,7 @@ boundaries."
 (org-defkey org-mode-map [remap comment-dwim] 'org-comment-dwim)
 (org-defkey org-mode-map [remap forward-paragraph] 'org-forward-paragraph)
 (org-defkey org-mode-map [remap backward-paragraph] 'org-backward-paragraph)
+(org-defkey org-mode-map "\M-^"     'org-delete-indentation)
 (org-defkey org-mode-map "\C-m"     'org-return)
 (org-defkey org-mode-map "\C-j"     'org-return-indent)
 (org-defkey org-mode-map "\C-c?"    'org-table-field-info)
@@ -21159,6 +21160,30 @@ This command does many different things, depending on context:
     (let ((org-note-abort t))
       (funcall org-finish-function))))
 
+(defun org-delete-indentation (&optional ARG)
+  "Join this line to previous and fix up whitespace at join.
+
+If previous row is a headline add to headline text."
+  (interactive "*P")
+  (if (save-excursion (if ARG
+			  (beginning-of-line)
+			(forward-line -1))
+		      (looking-at org-complex-heading-regexp))
+      ;; At headline.
+      (let ((string (concat " " (prog2 (and ARG (forward-line 1))
+				    (org-trim (delete-and-extract-region (line-beginning-position)
+									 (line-end-position)))))))
+	(when (eq (preceding-char) ?\n) (delete-region (point) (1- (point))))
+	(goto-char (or (match-beginning 5)
+		       (match-end 0)))
+	(skip-chars-backward " \t")
+	(when (and (match-beginning 5)
+		   (< (+ (point) (length string))
+		      (match-beginning 5)))
+	  (delete-region (point) (+ (point) (length string))))
+	(save-excursion (insert string)))
+    (delete-indentation ARG)))
+
 (defun org-open-line (n)
   "Insert a new row in tables, call `open-line' elsewhere.
 If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index ecfece5..a241f26 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -833,6 +833,34 @@
 \f
 ;;; Editing
 
+(ert-deftest test-org-delete-indentation ()
+  "Test M-^ (`org-delete-indentation') specification."
+  ;; Regular test.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo \n bar<point>"
+		  (org-delete-indentation)
+		  (buffer-string))))
+  ;; With optional argument.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo<point> \n bar"
+		  (org-delete-indentation t)
+		  (buffer-string))))
+  ;; At headline text should be appended to the headline text.
+  (should
+   (equal "* foo bar :tag:"
+	  (org-test-with-temp-text
+	      "* foo :tag:\n bar<point>"
+	    (org-delete-indentation)
+	    (buffer-string))))
+  (should
+   (equal "* foo bar :tag:"
+	  (org-test-with-temp-text
+	      "* foo <point>:tag:\n bar"
+	    (org-delete-indentation t)
+	    (buffer-string)))))
+
 (ert-deftest test-org/return ()
   "Test RET (`org-return') specifications."
   ;; Regular test.
-- 
2.4.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] org-delete-indentation
  2015-05-16 15:34 [patch] org-delete-indentation Rasmus
@ 2015-05-16 19:05 ` Rasmus
  2015-05-17  8:33 ` Nicolas Goaziou
  1 sibling, 0 replies; 6+ messages in thread
From: Rasmus @ 2015-05-16 19:05 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

Rasmus <rasmus@gmx.us> writes:

> Due to recent controversy about Org being lacking Microsoftesque detail I
> finally implemented org-delete-indentation, which is a function I have
> been missing forever.

Updated patch attached.  It now uses (org-fix-tags-on-the-fly).  A
consequence of this is that (i) it works with entities; (ii) it is very
strict about org-tag-column.  But I guess so is C-c C-c on headlines, so
maybe it is not an issue.

Rasmus

-- 
Summon the Mothership!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-org.el-New-function-org-delete-indentation.patch --]
[-- Type: text/x-diff, Size: 4070 bytes --]

From 31ac966a7913de5a6cd3fb81e2ad4abfa3413d61 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sat, 16 May 2015 17:19:03 +0200
Subject: [PATCH 2/2] org.el: New function org-delete-indentation

* org.el (org-delete-indentation): New function.
  (org-mode-map): Bind org-delete-indentation to M-^.
* test-org.el (test-org-delete-indentation): Test org-delete-indentation.
* ORG-NEWS: Add entry on org-delete-indentation.
---
 etc/ORG-NEWS             |  3 +++
 lisp/org.el              | 22 ++++++++++++++++++++++
 testing/lisp/test-org.el | 28 ++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a3e1ae2..91e30f8 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -377,6 +377,9 @@ for details.
 Calling ~org-edit-footnote-reference~ (C-c ') on a footnote reference
 allows to edit its definition, as long as it is not anonymous, in
 a dedicated buffer.  It works even if buffer is currently narrowed.
+*** New function ~org-delete-indentation~ bound to ~M-^~
+Work as ~delete-indentation~ unless at heading, in which case text is
+added to headline text.
 ** Miscellaneous
 *** Strip all meta data from ITEM special property
 ITEM special property does not contain TODO, priority or tags anymore.
diff --git a/lisp/org.el b/lisp/org.el
index 8527c2d..59a2653 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19832,6 +19832,7 @@ boundaries."
 (org-defkey org-mode-map [remap comment-dwim] 'org-comment-dwim)
 (org-defkey org-mode-map [remap forward-paragraph] 'org-forward-paragraph)
 (org-defkey org-mode-map [remap backward-paragraph] 'org-backward-paragraph)
+(org-defkey org-mode-map "\M-^"     'org-delete-indentation)
 (org-defkey org-mode-map "\C-m"     'org-return)
 (org-defkey org-mode-map "\C-j"     'org-return-indent)
 (org-defkey org-mode-map "\C-c?"    'org-table-field-info)
@@ -20976,6 +20977,27 @@ This command does many different things, depending on context:
     (let ((org-note-abort t))
       (funcall org-finish-function))))
 
+(defun org-delete-indentation (&optional ARG)
+  "Join this line to previous and fix up whitespace at join.
+
+If previous row is a headline add to headline text."
+  (interactive "*P")
+  (if (save-excursion (if ARG
+			  (beginning-of-line)
+			(forward-line -1))
+		      (looking-at org-complex-heading-regexp))
+      ;; At headline.
+      (let ((string (concat " " (prog2 (and ARG (forward-line 1))
+				    (org-trim (delete-and-extract-region (line-beginning-position)
+									 (line-end-position)))))))
+	(when (eq (preceding-char) ?\n) (delete-region (point) (1- (point))))
+	(goto-char (or (match-beginning 5)
+		       (match-end 0)))
+	(skip-chars-backward " \t")
+	(save-excursion (insert string))
+	(org-fix-tags-on-the-fly))
+    (delete-indentation ARG)))
+
 (defun org-open-line (n)
   "Insert a new row in tables, call `open-line' elsewhere.
 If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index ecfece5..a241f26 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -833,6 +833,34 @@
 \f
 ;;; Editing
 
+(ert-deftest test-org-delete-indentation ()
+  "Test M-^ (`org-delete-indentation') specification."
+  ;; Regular test.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo \n bar<point>"
+		  (org-delete-indentation)
+		  (buffer-string))))
+  ;; With optional argument.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo<point> \n bar"
+		  (org-delete-indentation t)
+		  (buffer-string))))
+  ;; At headline text should be appended to the headline text.
+  (should
+   (equal "* foo bar :tag:"
+	  (org-test-with-temp-text
+	      "* foo :tag:\n bar<point>"
+	    (org-delete-indentation)
+	    (buffer-string))))
+  (should
+   (equal "* foo bar :tag:"
+	  (org-test-with-temp-text
+	      "* foo <point>:tag:\n bar"
+	    (org-delete-indentation t)
+	    (buffer-string)))))
+
 (ert-deftest test-org/return ()
   "Test RET (`org-return') specifications."
   ;; Regular test.
-- 
2.4.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] org-delete-indentation
  2015-05-16 15:34 [patch] org-delete-indentation Rasmus
  2015-05-16 19:05 ` Rasmus
@ 2015-05-17  8:33 ` Nicolas Goaziou
  2015-05-17  8:35   ` Nicolas Goaziou
  2015-05-17 13:21   ` Rasmus
  1 sibling, 2 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-05-17  8:33 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> Due to recent controversy about Org being lacking Microsoftesque detail I
> finally implemented org-delete-indentation, which is a function I have
> been missing forever.

Thank you.

> +(defun org-delete-indentation (&optional ARG)
> +  "Join this line to previous and fix up whitespace at join.
> +
> +If previous row is a headline add to headline text."

You need to describe what ARG does.

> +  (interactive "*P")
> +  (if (save-excursion (if ARG
> +			  (beginning-of-line)
> +			(forward-line -1))
> +		      (looking-at org-complex-heading-regexp))
> +      ;; At headline.
> +      (let ((string (concat " " (prog2 (and ARG (forward-line 1))
> +				    (org-trim (delete-and-extract-region (line-beginning-position)
> +									 (line-end-position)))))))
> +	(when (eq (preceding-char) ?\n) (delete-region (point) (1- (point))))

  (unless (bobp) (delete-region ....))

Also, shouldn't the final (delete-indentation ARG) be in the "else" part
of the `if'?

> +(ert-deftest test-org-delete-indentation ()
> +  "Test M-^ (`org-delete-indentation') specification."

I suggest to omit binding in the description. That's one thing less we
have to keep up-to-date if it ever changes.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] org-delete-indentation
  2015-05-17  8:33 ` Nicolas Goaziou
@ 2015-05-17  8:35   ` Nicolas Goaziou
  2015-05-17 13:21   ` Rasmus
  1 sibling, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-05-17  8:35 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

>> +      (let ((string (concat " " (prog2 (and ARG (forward-line 1))
>> +				    (org-trim (delete-and-extract-region (line-beginning-position)
>> +									 (line-end-position)))))))

Also,

  (concat " " 
          (progn (when ARG (forward-line))
                 (org-trim ...)))
                   

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] org-delete-indentation
  2015-05-17  8:33 ` Nicolas Goaziou
  2015-05-17  8:35   ` Nicolas Goaziou
@ 2015-05-17 13:21   ` Rasmus
  2015-05-20 22:48     ` Rasmus
  1 sibling, 1 reply; 6+ messages in thread
From: Rasmus @ 2015-05-17 13:21 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1544 bytes --]

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Also, shouldn't the final (delete-indentation ARG) be in the "else" part
> of the `if'?

It was, at least on my disk.  I did not check the patch.

>> +(ert-deftest test-org-delete-indentation ()
>> +  "Test M-^ (`org-delete-indentation') specification."
>
> I suggest to omit binding in the description. That's one thing less we
> have to keep up-to-date if it ever changes.

OK.

The attached patch is updated and seems pretty good.  It also handles tags
and entities according to org-auto-align-tags.

The second patch (0003) adds support for tables in the sense that

| a | c |
| b | d |

can be made into

| a b | c |
|     | d |

using M-^.

While this is pretty nice since it's hidden away in a uncommon key, one
thing that bothers me about it is that there's no natural key to go back
to the first situation.

While RET could be made to move content between, it may be too annoying.
Personally. I never use RET in tables for movement commands so it would
not bother me.  I wrote a preliminary patch for this, but there's many
open questions on supposed behavior IMO.

I can work more on M-^ and tables if desirable (primarily it should be
moved to org-table, I guess).  I can also work more on RET in tables, if
desirable.  Another "quirk" that I noticed is that RET works differently
when next row is a hline (insert new row) and a row (move to next row).
This is completely illogical to me.

—Rasmus

-- 
. . . The proofs are technical in nature and provides no real understanding

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-org.el-New-function-org-delete-indentation.patch --]
[-- Type: text/x-diff, Size: 4458 bytes --]

From 6f2a4d4f02680fae95c2e799db2ae455a06aa115 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sat, 16 May 2015 17:19:03 +0200
Subject: [PATCH 2/3] org.el: New function org-delete-indentation

* org.el (org-delete-indentation): New function.
  (org-mode-map): Bind org-delete-indentation to M-^.
* test-org.el (test-org-delete-indentation): Test org-delete-indentation.
* ORG-NEWS: Add entry on org-delete-indentation.
---
 etc/ORG-NEWS             |  3 +++
 lisp/org.el              | 31 +++++++++++++++++++++++++++++++
 testing/lisp/test-org.el | 30 ++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a3e1ae2..91e30f8 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -377,6 +377,9 @@ for details.
 Calling ~org-edit-footnote-reference~ (C-c ') on a footnote reference
 allows to edit its definition, as long as it is not anonymous, in
 a dedicated buffer.  It works even if buffer is currently narrowed.
+*** New function ~org-delete-indentation~ bound to ~M-^~
+Work as ~delete-indentation~ unless at heading, in which case text is
+added to headline text.
 ** Miscellaneous
 *** Strip all meta data from ITEM special property
 ITEM special property does not contain TODO, priority or tags anymore.
diff --git a/lisp/org.el b/lisp/org.el
index a46cb86..6db69c1 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19832,6 +19832,7 @@ boundaries."
 (org-defkey org-mode-map [remap comment-dwim] 'org-comment-dwim)
 (org-defkey org-mode-map [remap forward-paragraph] 'org-forward-paragraph)
 (org-defkey org-mode-map [remap backward-paragraph] 'org-backward-paragraph)
+(org-defkey org-mode-map "\M-^"     'org-delete-indentation)
 (org-defkey org-mode-map "\C-m"     'org-return)
 (org-defkey org-mode-map "\C-j"     'org-return-indent)
 (org-defkey org-mode-map "\C-c?"    'org-table-field-info)
@@ -20976,6 +20977,36 @@ This command does many different things, depending on context:
     (let ((org-note-abort t))
       (funcall org-finish-function))))
 
+(defun org-delete-indentation (&optional ARG)
+  "Join this line to previous and fix up whitespace at join.
+
+If previous line is a headline add to headline text.  Otherwise
+the function calls `delete-indentation'.
+
+With argument, join this line to following line."
+  (interactive "*P")
+  (if (save-excursion
+	(if ARG (beginning-of-line)
+	  (forward-line -1))
+	(looking-at org-complex-heading-regexp))
+      ;; At headline.
+      (let ((tags-column (when (match-beginning 5)
+			   (save-excursion (goto-char (match-beginning 5))
+					   (current-column))))
+	    (string (concat " " (progn (when ARG (forward-line 1))
+				       (org-trim (delete-and-extract-region
+						  (line-beginning-position)
+						  (line-end-position)))))))
+	(unless (bobp) (delete-region (point) (1- (point))))
+	(goto-char (or (match-beginning 5)
+		       (match-end 0)))
+	(skip-chars-backward " \t")
+	(save-excursion (insert string))
+	;; Adjust alignment of tags.
+	(when tags-column
+	  (org-align-tags-here (if org-auto-align-tags org-tags-column tags-column))))
+    (delete-indentation ARG)))
+
 (defun org-open-line (n)
   "Insert a new row in tables, call `open-line' elsewhere.
 If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 2f21c8e..04e0843 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -833,6 +833,36 @@
 \f
 ;;; Editing
 
+(ert-deftest test-org/delete-indentation ()
+  "Test `org-delete-indentation' specifications."
+  ;; Regular test.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo \n bar<point>"
+		  (org-delete-indentation)
+		  (buffer-string))))
+  ;; With optional argument.
+  (should (equal "foo bar"
+		(org-test-with-temp-text
+		    "foo<point> \n bar"
+		  (org-delete-indentation t)
+		  (buffer-string))))
+  ;; At headline text should be appended to the headline text.
+  (should
+   (equal"* foo bar :tag:"
+	 (let (org-auto-align-tags)
+	   (org-test-with-temp-text
+	       "* foo :tag:\n bar<point>"
+	     (org-delete-indentation)
+	     (buffer-string)))))
+  (should
+   (equal "* foo bar :tag:"
+	  (let (org-auto-align-tags)
+	    (org-test-with-temp-text
+		"* foo <point>:tag:\n bar"
+	      (org-delete-indentation t)
+	      (buffer-string))))))
+
 (ert-deftest test-org/return ()
   "Test `org-return' specifications."
   ;; Regular test.
-- 
2.4.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0003-org-delete-indentation-Add-support-for-tables.patch --]
[-- Type: text/x-diff, Size: 3274 bytes --]

From 25cca4de0a20667b339abaf7cae067540e47a33d Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sun, 17 May 2015 14:46:25 +0200
Subject: [PATCH 3/3] org-delete-indentation: Add support for tables

* org.el (org-delete-indentation): Add support for tables.
---
 lisp/org.el | 66 +++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 45 insertions(+), 21 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 6db69c1..0c3e61c 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20985,27 +20985,51 @@ the function calls `delete-indentation'.
 
 With argument, join this line to following line."
   (interactive "*P")
-  (if (save-excursion
-	(if ARG (beginning-of-line)
-	  (forward-line -1))
-	(looking-at org-complex-heading-regexp))
-      ;; At headline.
-      (let ((tags-column (when (match-beginning 5)
-			   (save-excursion (goto-char (match-beginning 5))
-					   (current-column))))
-	    (string (concat " " (progn (when ARG (forward-line 1))
-				       (org-trim (delete-and-extract-region
-						  (line-beginning-position)
-						  (line-end-position)))))))
-	(unless (bobp) (delete-region (point) (1- (point))))
-	(goto-char (or (match-beginning 5)
-		       (match-end 0)))
-	(skip-chars-backward " \t")
-	(save-excursion (insert string))
-	;; Adjust alignment of tags.
-	(when tags-column
-	  (org-align-tags-here (if org-auto-align-tags org-tags-column tags-column))))
-    (delete-indentation ARG)))
+  (cond ((save-excursion (if ARG (beginning-of-line)
+			   (forward-line -1))
+			 (looking-at org-complex-heading-regexp))
+	 ;; At a headline.
+	 (let ((tags-column (when (match-beginning 5)
+			      (save-excursion (goto-char (match-beginning 5))
+					      (current-column))))
+	       (string (concat " " (progn (when ARG (forward-line 1))
+					  (org-trim (delete-and-extract-region
+						     (line-beginning-position)
+						     (line-end-position)))))))
+	   (unless (bobp) (delete-region (point) (1- (point))))
+	   (goto-char (or (match-beginning 5)
+			  (match-end 0)))
+	   (skip-chars-backward " \t")
+	   (save-excursion (insert string))
+	   ;; Adjust alignment of tags.
+	   (when tags-column
+	     (org-align-tags-here (if org-auto-align-tags
+				      org-tags-column
+				    tags-column)))))
+	;; TODO: Should be moved to separate function in org-table.
+	((let ((current-line (org-table-current-line)))
+	   (and (org-at-table-p)
+		(or (or ARG (not (eq current-line 1)))
+		    (and ARG (eq current-line
+				 (save-excursion
+				   (org-table-end)
+				   (org-table-current-line)))))))
+	 (when ARG (org-table-next-row))
+	 (let ((column (org-table-current-column))
+	       (starting-line (org-table-current-line))
+	       (string (delete-and-extract-region
+			(point) (1- (search-forward "|")))))
+	   (org-table-goto-line (1- starting-line))
+	   (org-table-goto-column column)
+	   (search-forward "|")
+	   (backward-char)
+	   (skip-chars-backward " \t")
+	   (let ((column (current-column)))
+	     (insert " " (org-trim string))
+	     (org-table-align)
+	     (move-to-column column)
+	     (when (eq (preceding-char) ?|) (forward-char)))))
+	(t (delete-indentation ARG))))
 
 (defun org-open-line (n)
   "Insert a new row in tables, call `open-line' elsewhere.
-- 
2.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] org-delete-indentation
  2015-05-17 13:21   ` Rasmus
@ 2015-05-20 22:48     ` Rasmus
  0 siblings, 0 replies; 6+ messages in thread
From: Rasmus @ 2015-05-20 22:48 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> Also, shouldn't the final (delete-indentation ARG) be in the "else" part
>> of the `if'?
>
> It was, at least on my disk.  I did not check the patch.
>
>>> +(ert-deftest test-org-delete-indentation ()
>>> +  "Test M-^ (`org-delete-indentation') specification."
>>
>> I suggest to omit binding in the description. That's one thing less we
>> have to keep up-to-date if it ever changes.
>
> OK.
>
> The attached patch is updated and seems pretty good.  It also handles tags
> and entities according to org-auto-align-tags.

Pushed.  

> The second patch (0003) adds support for tables in the sense that

Not pushed.  I'm still uncertain if this makes sense unless a some key
enables breaking table cells.

Rasmus

-- 
9000!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-20 22:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-16 15:34 [patch] org-delete-indentation Rasmus
2015-05-16 19:05 ` Rasmus
2015-05-17  8:33 ` Nicolas Goaziou
2015-05-17  8:35   ` Nicolas Goaziou
2015-05-17 13:21   ` Rasmus
2015-05-20 22:48     ` Rasmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).