From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: How to hide a table column from exporting Date: Mon, 07 May 2018 20:45:52 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000199e22056ba3c28c" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFn1M-0005BQ-JL for emacs-orgmode@gnu.org; Mon, 07 May 2018 16:46:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fFn1L-0007ZA-1y for emacs-orgmode@gnu.org; Mon, 07 May 2018 16:46:08 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:46617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fFn1K-0007Yy-Kk for emacs-orgmode@gnu.org; Mon, 07 May 2018 16:46:06 -0400 Received: by mail-lf0-x22d.google.com with SMTP id x7-v6so7611307lff.13 for ; Mon, 07 May 2018 13:46:05 -0700 (PDT) In-Reply-To: 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" To: Michael Brand Cc: emacs-org list --000000000000199e22056ba3c28c Content-Type: text/plain; charset="UTF-8" A quick update on the solution I posted there. Within the org-export-before-processing-hook, it seems like a "(goto-char (point-min))" was always implied before? That's not the case any more. So that goto-char now has to be added explicitly. This works now (as of Org mode version 9.1.13 (release_9.1.13-726-gc71e93..)): /Wondering if this change is expected through some series of changes in 9.x ../ ===== (defun mbrand/org-export-delete-commented-cols (back-end) "Delete columns $2 to $> marked as `<#>' on a row with `/' in $1. If you want a non-empty column $1 to be deleted make it $2 by inserting an empty column before and adding `/' in $1." (goto-char (point-min)) ;Only this added to the previous solution (while (re-search-forward "^[ \t]*| +/ +|\\(.*|\\)? +\\(<#>\\) *|" nil :noerror) (goto-char (match-beginning 2)) (org-table-delete-column) (beginning-of-line))) ===== On Tue, May 3, 2016 at 12:57 PM Kaushal Modi wrote: > Thanks Michael! > > That solution works great! I followed the discussion that followed in that > thread and have adopted the following solution in my config for now. > > # http://thread.gmane.org/gmane.emacs.orgmode/106497/focus=106683 > > | / | <#> | | | > | | 1n | 2y | 3y | > # Exports to ASCII as > # 2y 3y > > | / | | <#> | | > | | 1y | 2n | 3y | > # Exports to ASCII as > # 1y 3y > > | / | | <#> | > | 1y | 2y | 3n | > # Exports to ASCII as > # 1y 2y > > | / | <#> | <#> | | <#> | <#> | <#> | > | | 1n | 2n | 3y | 4n | 5n | 6n | > # Exports to ASCII as > # 3y > > | / | | | | | | | > | / | <#> | <#> | <#> | | <#> | <#> | > | | 1n | 2n | 3n | 4y | 5n | 6n | > # Exports to ASCII as > # 4y > > # Same result with a less useful notation: > | / | | | | | | | > | / | <#> | <#> | | | <#> | <#> | > | / | | <#> | <#> | | | | > | | 1n | 2n | 3n | 4y | 5n | 6n | > # Exports to ASCII as > # 4y > > # Deletion must not get trapped with this: > | / | | | | | | | > | / | | | | | | | > | | <#> | <#> | <#> | | | | > | | 1y | 2y | 3y | 4y | 5y | 6y | > # Exports to ASCII as > # <#> <#> <#> > # 1y 2y 3y 4y 5y 6y > > > * COMMENT > #+BEGIN_SRC emacs-lisp > (defun mbrand/org-export-delete-commented-cols (back-end) > "Delete columns $2 to $> marked as `<#>' on a row with `/' in $1. > If you want a non-empty column $1 to be deleted make it $2 by > inserting an empty column before and adding `/' in $1." > (while (re-search-forward "^[ \t]*| +/ +|\\(.*|\\)? +\\(<#>\\) *|" nil t) > (goto-char (match-beginning 2)) > (org-table-delete-column) > (beginning-of-line))) > (add-hook 'org-export-before-processing-hook > #'mbrand/org-export-delete-commented-cols) > ;; (remove-hook 'org-export-before-processing-hook > #'mbrand/org-export-delete-commented-cols) > #+END_SRC > > > On Tue, Apr 26, 2016 at 12:29 PM Michael Brand > wrote: > >> Hi Kaushal >> >> On Fri, Apr 22, 2016 at 8:40 PM, Kaushal Modi >> wrote: >> >> > I was trying to prevent an org table column from exporting to html. So I >> > started looking for a solution and found this: >> > http://stackoverflow.com/q/6641379/1219634 >> >> Please see my answer for one solution in the thread "tables, comment >> in one line, export to html" that started on 2016-04-19, e. g. at >> http://thread.gmane.org/gmane.emacs.orgmode/106497/focus=106683 >> >> Michael >> > -- > > -- > Kaushal Modi > -- Kaushal Modi --000000000000199e22056ba3c28c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
A quick update on the solution I posted the= re.

Within the org-export-before-processing-hook, it seems lik= e a "(goto-char (point-min))" was always implied before? That'= ;s not the case any more.

So that goto-char now has to be adde= d explicitly. This works now (as of Org mode version 9.1.13 (release_9.1.13= -726-gc71e93..)):

/Wondering if this change is expected throug= h some series of changes in 9.x ../

=3D=3D=3D=3D=3D
(de= fun mbrand/org-export-delete-commented-cols (back-end)
=C2=A0 "Dele= te columns $2 to $> marked as `<#>' on a row with `/' in $= 1.
If you want a non-empty column $1 to be deleted make it $2 by
inse= rting an empty column before and adding `/' in $1."
=C2=A0 (got= o-char (point-min)) ;Only this added to the previous solution
=C2=A0 (wh= ile (re-search-forward
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 "^[ \t]*| +/ +|\\(.*|\\)? +\\(<#>\\) *|" nil :noerro= r)
=C2=A0=C2=A0=C2=A0 (goto-char (match-beginning 2))
=C2=A0=C2=A0=C2= =A0 (org-table-delete-column)
=C2=A0=C2=A0=C2=A0 (beginning-of-line)))=3D=3D=3D=3D=3D

On Tue, May 3, 2016 at 12:57 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
Thanks Michael!

= That solution works great! I followed the discussion that followed in that = thread and have adopted the following solution in my config for now.
<= div>

| / | &l= t;#> | =C2=A0 =C2=A0| <r> |
| =C2=A0 | 1n =C2=A0| 2y | = =C2=A03y |
# Exports to ASCII as
# 2y =C2=A03y

| / | <r> | <#> | =C2=A0 =C2=A0|
| = =C2=A0 | =C2=A01y | 2n =C2=A0| 3y |
# Exports to ASCII as
# 1y =C2=A03y

| / =C2=A0| <r> | <#>= |
| 1y | =C2=A02y | 3n =C2=A0|
# Exports to ASCII as
# 1y =C2=A02y

| / | <#> | <#>= | <r> | <#> | <#> | <#> |
| =C2=A0 | 1n = =C2=A0| 2n =C2=A0| =C2=A03y | 4n =C2=A0| 5n =C2=A0| 6n =C2=A0|
# = Exports to ASCII as
# 3y

| / | <r>= | <l> | <r> | <l> | <r> | <l> |
| = / | <#> | <#> | <#> | =C2=A0 =C2=A0 | <#> | <#&g= t; |
| =C2=A0 | =C2=A01n | 2n =C2=A0| =C2=A03n | 4y =C2=A0| =C2= =A05n | 6n =C2=A0|
# Exports to ASCII as
# 4y

# Same result with a less useful notation:
| / | = <r> | <l> | <r> | <l> | <r> | <l> |
| / | <#> | <#> | =C2=A0 =C2=A0 | =C2=A0 =C2=A0 | <#&= gt; | <#> |
| / | =C2=A0 =C2=A0 | <#> | <#> | = =C2=A0 =C2=A0 | =C2=A0 =C2=A0 | =C2=A0 =C2=A0 |
| =C2=A0 | =C2=A0= 1n | 2n =C2=A0| =C2=A03n | 4y =C2=A0| =C2=A05n | 6n =C2=A0|
# Exp= orts to ASCII as
# 4y

# Deletion must no= t get trapped with this:
| / | <r> | <l> | <r> = | <l> | <r> | <l> |
| / | =C2=A0 =C2=A0 | =C2= =A0 =C2=A0 | =C2=A0 =C2=A0 | =C2=A0 =C2=A0 | =C2=A0 =C2=A0 | =C2=A0 =C2=A0 = |
| =C2=A0 | <#> | <#> | <#> | =C2=A0 =C2=A0 | = =C2=A0 =C2=A0 | =C2=A0 =C2=A0 |
| =C2=A0 | =C2=A01y | 2y =C2=A0| = =C2=A03y | 4y =C2=A0| =C2=A05y | 6y =C2=A0|
# Exports to ASCII as=
# <#> =C2=A0<#> =C2=A0<#>
# =C2=A01y= =C2=A02y =C2=A0 =C2=A03y =C2=A04y =C2=A05y =C2=A06y


* COMMENT
#+BEGIN_SRC emacs-lisp
(def= un mbrand/org-export-delete-commented-cols (back-end)
=C2=A0 &quo= t;Delete columns $2 to $> marked as `<#>' on a row with `/'= ; in $1.
If you want a non-empty column $1 to be deleted make it = $2 by
inserting an empty column before and adding `/' in $1.&= quot;
=C2=A0 (while (re-search-forward "^[ \t]*| +/ +|\\(.*|= \\)? +\\(<#>\\) *|" nil t)
=C2=A0 =C2=A0 (goto-char (m= atch-beginning 2))
=C2=A0 =C2=A0 (org-table-delete-column)
<= div>=C2=A0 =C2=A0 (beginning-of-line)))
(add-hook 'org-export= -before-processing-hook #'mbrand/org-export-delete-commented-cols)
;; (remove-hook 'org-export-before-processing-hook #'mbrand/o= rg-export-delete-commented-cols)
#+END_SRC


On Tue, Apr 26, 2= 016 at 12:29 PM Michael Brand <michael.ch.brand@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">Hi Kaushal

On Fri, Apr 22, 2016 at 8:40 PM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
> I was trying to prevent an org table column from exporting to html. So= I
> started looking for a solution and found this:
> http://stackoverflow.com/q/6641379/1219634

Please see my answer for one solution in the thread "tables, comment in one line, export to html" that started on 2016-04-19, e. g. at
http://thread.gmane.org/gmane.emacs= .orgmode/106497/focus=3D106683

Michael
--

--
Kaushal Modi

--

K= aushal Modi

--000000000000199e22056ba3c28c--