all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] org-table.el: Fix usage of user-error
@ 2021-05-23  8:54 Utkarsh Singh
  2021-05-23  9:13 ` Utkarsh Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Utkarsh Singh @ 2021-05-23  8:54 UTC (permalink / raw)
  To: emacs-orgmode

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: patch --]
[-- Type: text/x-patch, Size: 4320 bytes --]

From 96b1a0b6095ecefed0f7103ea1e08e325452d3a6 Mon Sep 17 00:00:00 2001
From: Utkarsh Singh <utkarsh190601@gmail.com>
Date: Sun, 23 May 2021 13:48:33 +0530
Subject: [PATCH] org-table.el: Fix usage of user-error

* lisp/org-table.el (org-table-convert-region): Don't use `if' because
  Elisp has no concept of continuable errors.
---
 lisp/org-table.el | 88 +++++++++++++++++++++++------------------------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index cc69542f9..3e5563573 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -861,52 +861,52 @@ nil      When nil, the command tries to be smart and figure out the
   (let* ((beg (min beg0 end0))
 	 (end (max beg0 end0))
 	 re)
-    (if (> (count-lines beg end) org-table-convert-region-max-lines)
-	(user-error "Region is longer than `org-table-convert-region-max-lines' (%s) lines; not converting"
-		    org-table-convert-region-max-lines)
-      (when (equal separator '(64))
-	(setq separator (read-regexp "Regexp for field separator")))
-      (goto-char beg)
-      (beginning-of-line 1)
-      (setq beg (point-marker))
-      (goto-char end)
-      (if (bolp) (backward-char 1) (end-of-line 1))
-      (setq end (point-marker))
-      ;; Get the right field separator
-      (unless separator
-	(goto-char beg)
-	(setq separator
-	      (cond
-	       ((not (re-search-forward "^[^\n\t]+$" end t)) '(16))
-	       ((not (re-search-forward "^[^\n,]+$" end t)) '(4))
-	       (t 1))))
+    (when (> (count-lines beg end) org-table-convert-region-max-lines)
+      (user-error "Region is longer than `org-table-convert-region-max-lines' (%s) lines; not converting"
+		  org-table-convert-region-max-lines))
+    (when (equal separator '(64))
+      (setq separator (read-regexp "Regexp for field separator")))
+    (goto-char beg)
+    (beginning-of-line 1)
+    (setq beg (point-marker))
+    (goto-char end)
+    (if (bolp) (backward-char 1) (end-of-line 1))
+    (setq end (point-marker))
+    ;; Get the right field separator
+    (unless separator
       (goto-char beg)
-      (if (equal separator '(4))
-	  (while (< (point) end)
-	    ;; parse the csv stuff
+      (setq separator
 	    (cond
-	     ((looking-at "^") (insert "| "))
-	     ((looking-at "[ \t]*$") (replace-match " |") (beginning-of-line 2))
-	     ((looking-at "[ \t]*\"\\([^\"\n]*\\)\"")
-	      (replace-match "\\1")
-	      (if (looking-at "\"") (insert "\"")))
-	     ((looking-at "[^,\n]+") (goto-char (match-end 0)))
-	     ((looking-at "[ \t]*,") (replace-match " | "))
-	     (t (beginning-of-line 2))))
-	(setq re (cond
-		  ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
-		  ((equal separator '(16)) "^\\|\t")
-		  ((integerp separator)
-		   (if (< separator 1)
-		       (user-error "Number of spaces in separator must be >= 1")
-		     (format "^ *\\| *\t *\\| \\{%d,\\}" separator)))
-		  ((stringp separator)
-		   (format "^ *\\|%s" separator))
-		  (t (error "This should not happen"))))
-	(while (re-search-forward re end t)
-	  (replace-match "| " t t)))
-      (goto-char beg)
-      (org-table-align))))
+	     ((not (re-search-forward "^[^\n\t]+$" end t)) '(16))
+	     ((not (re-search-forward "^[^\n,]+$" end t)) '(4))
+	     (t 1))))
+    (goto-char beg)
+    (if (equal separator '(4))
+	(while (< (point) end)
+	  ;; parse the csv stuff
+	  (cond
+	   ((looking-at "^") (insert "| "))
+	   ((looking-at "[ \t]*$") (replace-match " |") (beginning-of-line 2))
+	   ((looking-at "[ \t]*\"\\([^\"\n]*\\)\"")
+	    (replace-match "\\1")
+	    (if (looking-at "\"") (insert "\"")))
+	   ((looking-at "[^,\n]+") (goto-char (match-end 0)))
+	   ((looking-at "[ \t]*,") (replace-match " | "))
+	   (t (beginning-of-line 2))))
+      (setq re (cond
+		((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
+		((equal separator '(16)) "^\\|\t")
+		((integerp separator)
+		 (if (< separator 1)
+		     (user-error "Number of spaces in separator must be >= 1")
+		   (format "^ *\\| *\t *\\| \\{%d,\\}" separator)))
+		((stringp separator)
+		 (format "^ *\\|%s" separator))
+		(t (error "This should not happen"))))
+      (while (re-search-forward re end t)
+	(replace-match "| " t t)))
+    (goto-char beg)
+    (org-table-align)))
 
 ;;;###autoload
 (defun org-table-import (file separator)
-- 
2.31.1


[-- Attachment #2: Type: text/plain, Size: 42 bytes --]

-- 
Utkarsh Singh
http://utkarshsingh.xyz

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

* Re: [PATCH] org-table.el: Fix usage of user-error
  2021-05-23  8:54 [PATCH] org-table.el: Fix usage of user-error Utkarsh Singh
@ 2021-05-23  9:13 ` Utkarsh Singh
  2021-05-31 14:40 ` Utkarsh Singh
  2021-09-25 14:24 ` Bastien
  2 siblings, 0 replies; 5+ messages in thread
From: Utkarsh Singh @ 2021-05-23  9:13 UTC (permalink / raw)
  To: emacs-orgmode

On 2021-05-23, 14:24 +0530, Utkarsh Singh <utkarsh190601@gmail.com> wrote:

Hi,

This patch tries to fix usage of `user-error' in
`org-table-convert-region' which is currently _not_ taking benefit of
non-local exit of `user-error' function and using `if' to carry out it's
operations.

Please note that this is just an aesthetic improvement.

Thank you,
Utkarsh Singh

-- 
Utkarsh Singh
http://utkarshsingh.xyz


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

* Re: [PATCH] org-table.el: Fix usage of user-error
  2021-05-23  8:54 [PATCH] org-table.el: Fix usage of user-error Utkarsh Singh
  2021-05-23  9:13 ` Utkarsh Singh
@ 2021-05-31 14:40 ` Utkarsh Singh
  2021-06-03 10:05   ` Bastien
  2021-09-25 14:24 ` Bastien
  2 siblings, 1 reply; 5+ messages in thread
From: Utkarsh Singh @ 2021-05-31 14:40 UTC (permalink / raw)
  To: emacs-orgmode


Ping!

-- 
Utkarsh Singh
http://utkarshsingh.xyz


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

* Re: [PATCH] org-table.el: Fix usage of user-error
  2021-05-31 14:40 ` Utkarsh Singh
@ 2021-06-03 10:05   ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2021-06-03 10:05 UTC (permalink / raw)
  To: Utkarsh Singh; +Cc: emacs-orgmode

Hi Utkarsh,

Utkarsh Singh <utkarsh190601@gmail.com> writes:

> Ping!

Please read https://orgmode.org/worg/org-mailing-list.html#i-didnt-receive-an-answer

From what I understand, the change is not really a bugfix.

I hope someone can review and approve it.  If not, I will look at it
when I have some time

Thanks,

-- 
 Bastien


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

* Re: [PATCH] org-table.el: Fix usage of user-error
  2021-05-23  8:54 [PATCH] org-table.el: Fix usage of user-error Utkarsh Singh
  2021-05-23  9:13 ` Utkarsh Singh
  2021-05-31 14:40 ` Utkarsh Singh
@ 2021-09-25 14:24 ` Bastien
  2 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2021-09-25 14:24 UTC (permalink / raw)
  To: Utkarsh Singh; +Cc: emacs-orgmode

Applied in main, thanks and sorry for the delay.

-- 
 Bastien


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

end of thread, other threads:[~2021-09-25 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-23  8:54 [PATCH] org-table.el: Fix usage of user-error Utkarsh Singh
2021-05-23  9:13 ` Utkarsh Singh
2021-05-31 14:40 ` Utkarsh Singh
2021-06-03 10:05   ` Bastien
2021-09-25 14:24 ` Bastien

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.