emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture regression?
@ 2018-09-20  8:13 Thomas Holst
  2018-09-20 12:53 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Holst @ 2018-09-20  8:13 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

a view weeks ago a wrote a post about problems I have with one of my
captue templates. (see:
http://lists.gnu.org/archive/html/emacs-orgmode/2018-08/msg00161.html)

Today I dug a little deeper.

In March 2017 I sent two patches to enable the capture property
:table-line-pos to be either a string, a variable or a function.

#+begin_example
commit 599ccd1cc83cc8a1b0af82ac93e23760637b37b5
Author: Thomas Holst <Thomas_Holst@gmx.de>
Date:   Mon Mar 17 09:01:40 2014 +0100

    docu change for table-line-pos new feature
    
commit 176125c32ff2a8adc6e1d3091a57e46e482da638
Author: Thomas Holst <Thomas_Holst@gmx.de>
Date:   Sat Mar 15 16:22:44 2014 +0100

    org-capture.el: Allow `:table-line-pos' to be a function name, a string or a variable
#+end_example

Since a few weeks this is not working anymore. I have a capture template
unsing this feature (which I use rarely but still).

So here is I patch I came up with to re-enable theese features:

#+begin_src diff
  * doc/org-manual.org (Template elements): document new/old features of
  `:table-line-pos'

  * lisp/org-captue.el (org-capture-place-table-line): eval the content
    of `:table-line-pos'
  ---
   doc/org-manual.org  | 6 ++++--
   lisp/org-capture.el | 3 ++-
   2 files changed, 6 insertions(+), 3 deletions(-)

  diff --git a/doc/org-manual.org b/doc/org-manual.org
  index ae7c07c88..4a2a64fc4 100644
  --- a/doc/org-manual.org
  +++ b/doc/org-manual.org
  @@ -7361,9 +7361,11 @@ Now lets look at the elements of a template definition.  Each entry in
        - ~:table-line-pos~ ::
   
             Specification of the location in the table where the new line
  -          should be inserted.  It should be a string like =II-3= meaning
  +          should be inserted.  It could be a string like =II-3= meaning
             that the new line should become the third line before the
  -          second horizontal separator line.
  +          second horizontal separator line. Or it could be a function
  +          returning a string or a variable containing a string as
  +          explained above.
   
        - ~:kill-buffer~ ::
   
  diff --git a/lisp/org-capture.el b/lisp/org-capture.el
  index cbc72d43b..7f3e9e623 100644
  --- a/lisp/org-capture.el
  +++ b/lisp/org-capture.el
  @@ -1212,7 +1212,8 @@ may have been stored before."
   	   ((pred (string-match-p org-table-border-regexp))
   	    "| %?Bad template |")
   	   (text (concat text "\n"))))
  -	(table-line-pos (org-capture-get :table-line-pos))
  +	(table-line-pos
  +	 (eval (org-capture-get :table-line-pos)))
   	beg end)
       (cond
        ((org-capture-get :exact-position)
  -- 
  2.19.0
#+end_src

This works for me. I can use my capture template again. In the meantime I signed FSF papers
so TINYCHANGE is not required anymore.

Thank you for looking into this.

--
Bis neulich ...
  Thomas

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

* Re: org-capture regression?
  2018-09-20  8:13 org-capture regression? Thomas Holst
@ 2018-09-20 12:53 ` Nicolas Goaziou
  2018-09-20 14:01   ` Thomas Holst
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2018-09-20 12:53 UTC (permalink / raw)
  To: Thomas Holst; +Cc: emacs-orgmode

Hello,

Thomas Holst <Thomas_Holst@gmx.de> writes:

> a view weeks ago a wrote a post about problems I have with one of my
> captue templates. (see:
> http://lists.gnu.org/archive/html/emacs-orgmode/2018-08/msg00161.html)

I thought I had answered it.

> Since a few weeks this is not working anymore. I have a capture template
> unsing this feature (which I use rarely but still).
>
> So here is I patch I came up with to re-enable theese features:

Thank you. However, I have two issues with it.

The first one is that I don't like `eval'. See, for example, this
excerpt from the Elisp manual:

    On rare occasions, you may need to write code that evaluates a form
    that is computed at run time, such as after reading a form from text
    being edited or getting one from a property list. On these
    occasions, use the ‘eval’ function. Often ‘eval’ is not needed and
    something else should be used instead. For example, to get the value
    of a variable, while ‘eval’ works, ‘symbol-value’ is preferable; or
    rather than store expressions in a property list that then need to
    go through ‘eval’, it is better to store functions instead that are
    then passed to ‘funcall’.

So, I'd rather use `symbol-value' and `funcall' and forbid arbitrary
Sexps.

Also, this introduces a discrepancy between :table-line-pos and other
parameters, which do not allow variables nor functions. This is another
issue.

IOW, it may need be to be implemented at a lower level, with proper
tooling.

WDYT?

> This works for me. I can use my capture template again. In the
>meantime I signed FSF papers so TINYCHANGE is not required anymore.

Great!

Regards,

-- 
Nicolas Goaziou

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

* Re: org-capture regression?
  2018-09-20 12:53 ` Nicolas Goaziou
@ 2018-09-20 14:01   ` Thomas Holst
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Holst @ 2018-09-20 14:01 UTC (permalink / raw)
  To: emacs-orgmode

Hello,
· Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Thomas Holst <Thomas_Holst@gmx.de> writes:
>> [...snip...]
>> So here is I patch I came up with to re-enable theese features:
>
> Thank you. However, I have two issues with it.
>
> The first one is that I don't like `eval'. See, for example, this
> excerpt from the Elisp manual:
>
>     On rare occasions, you may need to write code that evaluates a form
>     that is computed at run time, such as after reading a form from text
>     being edited or getting one from a property list. On these
>     occasions, use the ‘eval’ function. Often ‘eval’ is not needed and
>     something else should be used instead. For example, to get the value
>     of a variable, while ‘eval’ works, ‘symbol-value’ is preferable; or
>     rather than store expressions in a property list that then need to
>     go through ‘eval’, it is better to store functions instead that are
>     then passed to ‘funcall’.
>
> So, I'd rather use `symbol-value' and `funcall' and forbid arbitrary
> Sexps.
>
> Also, this introduces a discrepancy between :table-line-pos and other
> parameters, which do not allow variables nor functions. This is another
> issue.
>
> IOW, it may need be to be implemented at a lower level, with proper
> tooling.
>
> WDYT?

For me this sounds resonalble. Basically I am an elisp novice. I
will try to implement the feature like explaind above in
`org-capture-get'. So it can be used for other parameters.

When I have questions or a few lines of code I will come back here.

Right now I can live with my solution for my personal needs. Since my
time for working on this is limited it might take some time. It seems
that nobody else is missing this feature. So I will take the oportunity
and find my way through elisp.

--
Bis neulich ...
  Thomas

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

end of thread, other threads:[~2018-09-20 14:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-20  8:13 org-capture regression? Thomas Holst
2018-09-20 12:53 ` Nicolas Goaziou
2018-09-20 14:01   ` Thomas Holst

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).