unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
@ 2020-10-22  7:27 Boruch Baum
  2021-05-13 10:56 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Boruch Baum @ 2020-10-22  7:27 UTC (permalink / raw)
  To: 44133

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

Currently, functions org-table-insert-column and
org-table-delete-column only perform the operation a single time. The
attached patch adds a feature to allow insertion and deletion of
multiple columns by specifying a numeric prefix argument.

A nice follow-up would be for someone else to add operations on a range,
but I'm not offering that here.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: org-table-mult-ops.patch --]
[-- Type: text/x-diff, Size: 4789 bytes --]

diff --git a/org-table.el b/org-table.el
index dcf7430..23bb480 100644
--- a/org-table.el
+++ b/org-table.el
@@ -1386,27 +1386,29 @@ However, when FORCE is non-nil, create new columns if necessary."
       (if (looking-at " ") (forward-char 1)))))

 ;;;###autoload
-(defun org-table-insert-column ()
-  "Insert a new column into the table."
-  (interactive)
+(defun org-table-insert-column (&optional arg)
+  "Insert a new column into the table.
+With optional prefix ARG, perform the operation that many times."
+  (interactive "p")
   (unless (org-at-table-p) (user-error "Not at a table"))
-  (org-table-find-dataline)
-  (let* ((col (max 1 (org-table-current-column)))
-	 (beg (org-table-begin))
-	 (end (copy-marker (org-table-end))))
-    (org-table-save-field
-     (goto-char beg)
-     (while (< (point) end)
-       (unless (org-at-table-hline-p)
-	 (org-table-goto-column col t)
-	 (insert "|   "))
-       (forward-line)))
-    (set-marker end nil)
-    (org-table-align)
-    (when (or (not org-table-fix-formulas-confirm)
-	      (funcall org-table-fix-formulas-confirm "Fix formulas? "))
-      (org-table-fix-formulas "$" nil (1- col) 1)
-      (org-table-fix-formulas "$LR" nil (1- col) 1))))
+  (dotimes (n (max arg 0))
+    (org-table-find-dataline)
+    (let* ((col (max 1 (org-table-current-column)))
+  	 (beg (org-table-begin))
+  	 (end (copy-marker (org-table-end))))
+      (org-table-save-field
+       (goto-char beg)
+       (while (< (point) end)
+         (unless (org-at-table-hline-p)
+  	 (org-table-goto-column col t)
+  	 (insert "|   "))
+         (forward-line)))
+      (set-marker end nil)
+      (org-table-align)
+      (when (or (not org-table-fix-formulas-confirm)
+  	      (funcall org-table-fix-formulas-confirm "Fix formulas? "))
+        (org-table-fix-formulas "$" nil (1- col) 1)
+        (org-table-fix-formulas "$LR" nil (1- col) 1)))))

 (defun org-table-find-dataline ()
   "Find a data line in the current table, which is needed for column commands."
@@ -1451,33 +1453,44 @@ non-nil, the one above is used."
 	       (if above min max))))))

 ;;;###autoload
-(defun org-table-delete-column ()
-  "Delete a column from the table."
-  (interactive)
+(defun org-table-delete-column (&optional arg)
+  "Delete a column from the table.
+With optional prefix ARG, perform the operation that many times."
+  (interactive "p")
   (unless (org-at-table-p) (user-error "Not at a table"))
-  (org-table-find-dataline)
-  (org-table-check-inside-data-field)
-  (let ((col (org-table-current-column))
-	(beg (org-table-begin))
-	(end (copy-marker (org-table-end))))
-    (org-table-save-field
-     (goto-char beg)
-     (while (< (point) end)
-       (if (org-at-table-hline-p)
-	   nil
-	 (org-table-goto-column col t)
-	 (and (looking-at "|[^|\n]+|")
-	      (replace-match "|")))
-       (forward-line)))
-    (set-marker end nil)
-    (org-table-goto-column (max 1 (1- col)))
-    (org-table-align)
-    (when (or (not org-table-fix-formulas-confirm)
-	      (funcall org-table-fix-formulas-confirm "Fix formulas? "))
-      (org-table-fix-formulas
-       "$" (list (cons (number-to-string col) "INVALID")) col -1 col)
-      (org-table-fix-formulas
-       "$LR" (list (cons (number-to-string col) "INVALID")) col -1 col))))
+    (org-table-find-dataline)
+    (org-table-check-inside-data-field)
+    (dotimes (n (min (max arg 0)
+                     (let ((p  (point))
+                           (c1 (org-table-current-column))
+                           c2)
+                       (end-of-line)
+                       (setq c2 (org-table-current-column))
+                       (goto-char p)
+                       (- c2 c1))))
+      (let ((col (org-table-current-column))
+    	(beg (org-table-begin))
+    	(end (copy-marker (org-table-end))))
+        (org-table-save-field
+         (goto-char beg)
+         (while (< (point) end)
+           (if (org-at-table-hline-p)
+    	   nil
+    	 (org-table-goto-column col t)
+    	 (and (looking-at "|[^|\n]+|")
+    	      (replace-match "|")))
+           (forward-line)))
+        (set-marker end nil)
+        (org-table-goto-column (max 1 (1- col)))
+        (org-table-align)
+        (when (or (not org-table-fix-formulas-confirm)
+    	      (funcall org-table-fix-formulas-confirm "Fix formulas? "))
+          (org-table-fix-formulas
+           "$" (list (cons (number-to-string col) "INVALID")) col -1 col)
+          (org-table-fix-formulas
+           "$LR" (list (cons (number-to-string col) "INVALID")) col -1 col)))
+      (org-table-next-field))
+    (org-table-previous-field))

 ;;;###autoload
 (defun org-table-move-column-right ()

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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2020-10-22  7:27 bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED] Boruch Baum
@ 2021-05-13 10:56 ` Lars Ingebrigtsen
  2021-05-14  5:16   ` Bastien
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-13 10:56 UTC (permalink / raw)
  To: Boruch Baum; +Cc: Bastien, 44133

Boruch Baum <boruch_baum@gmx.com> writes:

> Currently, functions org-table-insert-column and
> org-table-delete-column only perform the operation a single time. The
> attached patch adds a feature to allow insertion and deletion of
> multiple columns by specifying a numeric prefix argument.

This seems like a useful addition to me.  I've added Bastien to the CCs;
perhaps he'll have some comments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2021-05-13 10:56 ` Lars Ingebrigtsen
@ 2021-05-14  5:16   ` Bastien
  2021-07-21 12:09     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2021-05-14  5:16 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 44133, Boruch Baum

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Boruch Baum <boruch_baum@gmx.com> writes:
>
>> Currently, functions org-table-insert-column and
>> org-table-delete-column only perform the operation a single time. The
>> attached patch adds a feature to allow insertion and deletion of
>> multiple columns by specifying a numeric prefix argument.
>
> This seems like a useful addition to me.  I've added Bastien to the CCs;
> perhaps he'll have some comments.

Indeed, thanks for the heads up.

Boruch, can you resend this patch with git send-email to
emacs-orgmode@gnu.org together with a changelog entry?

See https://orgmode.org/worg/org-contribute.html#commit-messages for
directions on writing the patch.

-- 
 Bastien





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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2021-05-14  5:16   ` Bastien
@ 2021-07-21 12:09     ` Lars Ingebrigtsen
  2021-10-11 12:53       ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-21 12:09 UTC (permalink / raw)
  To: Bastien; +Cc: 44133, Boruch Baum

Bastien <bzg@gnu.org> writes:

> Boruch, can you resend this patch with git send-email to
> emacs-orgmode@gnu.org together with a changelog entry?
>
> See https://orgmode.org/worg/org-contribute.html#commit-messages for
> directions on writing the patch.

Has there been any progress here on this patch?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2021-07-21 12:09     ` Lars Ingebrigtsen
@ 2021-10-11 12:53       ` Stefan Kangas
  2021-10-13  7:57         ` Bastien Guerry
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2021-10-11 12:53 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Bastien, 44133, Boruch Baum

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Bastien <bzg@gnu.org> writes:
>
>> Boruch, can you resend this patch with git send-email to
>> emacs-orgmode@gnu.org together with a changelog entry?
>>
>> See https://orgmode.org/worg/org-contribute.html#commit-messages for
>> directions on writing the patch.
>
> Has there been any progress here on this patch?

Just a friendly ping.





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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2021-10-11 12:53       ` Stefan Kangas
@ 2021-10-13  7:57         ` Bastien Guerry
  2021-11-12  8:00           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien Guerry @ 2021-10-13  7:57 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Lars Ingebrigtsen, 44133, Boruch Baum

Stefan Kangas <stefan@marxist.se> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Bastien <bzg@gnu.org> writes:
>>
>>> Boruch, can you resend this patch with git send-email to
>>> emacs-orgmode@gnu.org together with a changelog entry?
>>>
>>> See https://orgmode.org/worg/org-contribute.html#commit-messages for
>>> directions on writing the patch.
>>
>> Has there been any progress here on this patch?
>
> Just a friendly ping.

Thanks -- Boruch, now is a good time for such patches against the main
branch of Org, as we are working on 9.6.

See https://orgmode.org/worg/org-contribute.html for directions on how
to contribute.

Best,

-- 
 Bastien





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

* bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED]
  2021-10-13  7:57         ` Bastien Guerry
@ 2021-11-12  8:00           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-12  8:00 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: Stefan Kangas, 44133, Boruch Baum

Bastien Guerry <bzg@gnu.org> writes:

> Thanks -- Boruch, now is a good time for such patches against the main
> branch of Org, as we are working on 9.6.
>
> See https://orgmode.org/worg/org-contribute.html for directions on how
> to contribute.

This was four weeks ago -- has there been any progress here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-11-12  8:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22  7:27 bug#44133: org-table insert/delete multiple columns [PATCH INCLUDED] Boruch Baum
2021-05-13 10:56 ` Lars Ingebrigtsen
2021-05-14  5:16   ` Bastien
2021-07-21 12:09     ` Lars Ingebrigtsen
2021-10-11 12:53       ` Stefan Kangas
2021-10-13  7:57         ` Bastien Guerry
2021-11-12  8:00           ` Lars Ingebrigtsen

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

	https://git.savannah.gnu.org/cgit/emacs.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).