From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CGqsNmIYqmCdCgAAgWs5BA (envelope-from ) for ; Sun, 23 May 2021 10:54:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UF1cMmIYqmCQVgAAB5/wlQ (envelope-from ) for ; Sun, 23 May 2021 08:54:58 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D8D49BE0F for ; Sun, 23 May 2021 10:54:57 +0200 (CEST) Received: from localhost ([::1]:44524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lkjsu-0004ye-5d for larch@yhetil.org; Sun, 23 May 2021 04:54:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkjsL-0004yK-Hk for emacs-orgmode@gnu.org; Sun, 23 May 2021 04:54:21 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:44598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lkjsJ-0007qV-Rt for emacs-orgmode@gnu.org; Sun, 23 May 2021 04:54:21 -0400 Received: by mail-pj1-x1035.google.com with SMTP id h20-20020a17090aa894b029015db8f3969eso8830616pjq.3 for ; Sun, 23 May 2021 01:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=8/HsYpdiST3GXnwK4FfMg9TH3eLrGGJY6xzmErUTURU=; b=jQGagALkmPY6QcMXxdEdWYKIuv6+rs+XKO1Gesrs9t6Z9IgEOTIcDfFM5T3zYgLyY5 9Y7Xk13+haL59szV5FbSUgZX/tyJdEexDaiePSX2zoe4zQ8zhht5f3JQLf9faOas9cWP wUKrxuf4inQZlON4SXzSJKn551f6q5fOeSAi4abLn0pNBLN//K2i7dKR4SQ3isr3MlQ0 JnYNGFocHlQBnyZyYH8JSdYkwcOoJKSRkBdMMjlB7RajrtRqrrlcsiclYyxBn7PWFCHY In653loRCUT6fH92ZKzjW9I1oZSOPhGeBj/rqD3rOhPjWqaA0ariKYa/eUxAy4B5zawO giRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=8/HsYpdiST3GXnwK4FfMg9TH3eLrGGJY6xzmErUTURU=; b=KCgy9S/WqDdHvLxJdPAZm2Ckjywbh61Lmo6TneGgtw9pwtMO2IIvCE2Zm7E8nKIlrd B674DjBiqmZpOwUrLaFBaeSerDYwkkvK1G5+QLlw2jl+zGnHUkV1ZauS4M3jHgGxQDsm BmI3f/GiIoi3PkRMxofIwo9sQSzaJfJyhutwEGMginPqobULtcEnK/D788gFPaxRSAgm 1FOjajlBLqoY4MSU3QVHnrclt+l1y9Gn5y3shGYo8MKfvW5hZzTs8/1LZ1NpvRnlWuvt /Ml9eF1Fcqkp8HhgtG2XthRutc7bFmoKJUF3HX/brx/jhzivaFDTZbXgfAt4iUlmdHUI fLzA== X-Gm-Message-State: AOAM530hPM6JzGupYW2SyKAbsszJEwkbS95vTzqCs7vs6AG8mD/ulsOU MvfNT17uP2WbS6eKq755DhYoWfrI7Go= X-Google-Smtp-Source: ABdhPJzQpWmFZeVCIRga5x9+Wk+kHLUxN4F8Wz9vjMeP/ybpfzYzScyfoqT8aDT4pybWMyt1uAsfFQ== X-Received: by 2002:a17:902:b282:b029:f7:8167:7b9d with SMTP id u2-20020a170902b282b02900f781677b9dmr10083626plr.18.1621760054415; Sun, 23 May 2021 01:54:14 -0700 (PDT) Received: from localhost ([103.77.0.17]) by smtp.gmail.com with ESMTPSA id ge5sm8551418pjb.45.2021.05.23.01.54.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 01:54:13 -0700 (PDT) From: Utkarsh Singh To: emacs-orgmode@gnu.org Subject: [PATCH] org-table.el: Fix usage of user-error Date: Sun, 23 May 2021 14:24:25 +0530 Message-ID: <87v979vni6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=utkarsh190601@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_OTHER_BAD_TLD=1.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621760098; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8/HsYpdiST3GXnwK4FfMg9TH3eLrGGJY6xzmErUTURU=; b=L4afxuN+mEslxClzX9EXwZNA1UQC0oRCUPeqwaesqtKhXvb2gPGghT+lWSVQo5wO/LHy9D O4RI/Ez3BZsx0JFsaSKcWMxMX8j0plHGO/3MfIaGjqMKoqRpOrzl4oIiSx/b1UcSOofe9X Qsq7VsG98NCEWl5NIqtHRtmSpgt0svlVcB4hkJ6x23OOHYRPgSkE0p0nvc+d8LK/B2RfmE YsaQs9mgGSkvbrCb/zCHRZU86+Z+PEeSvLMkC6ATY93Z7FQcbelSvykK6hqANqJC1p9AUB 2ktvad9kcBRd9qg8HHXt7SI749UNUJ1SpN4Wl2+00Vyv2yar8Ca6Ca0S2n3eyA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621760098; a=rsa-sha256; cv=none; b=E0Wbz04eB1oIyBhdgnb0Gr2CyKstCTLzGDOJlW/CxO6w7CiLnnEV+Y++hFjH/eLQfTPlrj LzdCJua+B/CH0EJYo54m78LsyTKw5D8SJ9e9SCewOh1cFE7uCD9kLlLJTU9Tx8AjKwKAJ7 vgPPi1O0fJzQMrmuE7BNzvenpnCP8mu4TFFCXwu02xy1oa6jKFeFuVoJTFaGy0uMrgieKJ AgLEO6gYuFwHSxSkbI4JsmLxVRLeyNwS/3G3zdEAfROr7uEC+CH4QT4swIoaM4knEEOFTS 5oBRYY/bopHt+dm+gvslpo6fsnVlHgURqteYDd923o3/BkjVxL7PXPVfoccY1Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jQGagALk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jQGagALk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: D8D49BE0F X-Spam-Score: -3.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: pxD5cCbNYO8L --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-table.el-Fix-usage-of-user-error.patch Content-Description: patch >From 96b1a0b6095ecefed0f7103ea1e08e325452d3a6 Mon Sep 17 00:00:00 2001 From: Utkarsh Singh 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 --=-=-= Content-Type: text/plain -- Utkarsh Singh http://utkarshsingh.xyz --=-=-=--