emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Proposal to replace the prefix repetition with whitespace during expansion of noweb references
@ 2014-03-28 23:46 Pontus Michael
  2014-03-29 15:30 ` Charles Berry
  2014-03-31  8:17 ` Sebastien Vauban
  0 siblings, 2 replies; 10+ messages in thread
From: Pontus Michael @ 2014-03-28 23:46 UTC (permalink / raw)
  To: emacs-orgmode

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

I would like to propose a change to the behavior of noweb expansion in
relation to prefix handling. Current behavior intends to insert the text
preceding noweb reference before every successive line of referenced
code.

For instance the expansion of following source block:

#+begin_src emacs-lisp :noweb yes
(concat <<foo>>)
#+end_src

In presence of this source block:

#+begin_src emacs-lisp :noweb-ref foo
"foo"
"bar"
#+end_src

Will result in code from next source block:

#+begin_src emacs-lisp
(concat "foo"
(concat "bar")
#+end_src

I recommend to introduce a change that will replace the inserted prefix
with whitespace of equal length. If it was the case then provided
example would produce the following code after expansion:

#+begin_src emacs-lisp
(concat "foo"
        "bar")
#+end_src

Here are the arguments in support of my proposal:

1) The proposed behavior is identical to one produced by original noweb.

2) Documentation provides a reasoning for current behavior as an example
   of reference expansion after the introduction of single-line comment
   with intention to comment all the lines caught in expansion. This
   reasoning follows simplistic assumption of semantics of arbitrary
   language and takes advantage of the single line comment notation used
   for non-intended purpose (i.e. multiline comment should have been
   used instead).

3) Continuing the line of examples given in emacs lisp, which lacks the
   notation for multiline comments I fail to see a situation where
   docstrings would not only serve the intended purpose, but in many
   cases contribute to quality and readability of the code.

4) Current behavior lacks the mechanism for handling multiple noweb
   references present on the same line. If prefix would be extracted
   from the unexpanded code and expansion would include raw noweb
   references notation. Clearly this is unexpected behavior.

If my proposal will find support in the community I can put my own
effort in bringing this change into existence.

[-- Attachment #2: Type: text/html, Size: 2308 bytes --]

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-03-28 23:46 Pontus Michael
@ 2014-03-29 15:30 ` Charles Berry
  2014-03-31  8:17 ` Sebastien Vauban
  1 sibling, 0 replies; 10+ messages in thread
From: Charles Berry @ 2014-03-29 15:30 UTC (permalink / raw)
  To: emacs-orgmode

Pontus Michael <m.pontus <at> gmail.com> writes:

> 
> I would like to propose a change to the behavior of noweb expansion in 
> relation to prefix handling. 
[snip]


> I recommend to introduce a change that will replace the inserted prefix
> with whitespace of equal length.

[snip]


The behavior you desire can be obtained by using the 

     <<code-block-name(optional arguments)>>

idiom for noweb. For example, with a suitably crafted block called 
'my-noweb', this reference

    <<my-noweb( "(concat", "foo", ")" )>>

would expand just as you want. You can use the functions
org-babel-goto-named-src-block  and org-babel-get-src-block-info to achieve
this.

Multiple noweb references might be handled as well by delimiting the second
argument, e.g. "foo,bar".

---

Revising the behavior of the existing code base might break code
that folks have written that depend on the current behavior.

HTH,

Chuck

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
@ 2014-03-30 21:13 Pontus Michael
  2014-04-11  9:36 ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Pontus Michael @ 2014-03-30 21:13 UTC (permalink / raw)
  To: ccberry, emacs-orgmode

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

Hello, Charles.

Thank you for your reply.

I appreciate your suggestion, however the example which I used is not a
limiting factor which I seek help in overcoming. Instead I'm trying to
address a potential design flaw.

You make a valid point that change of this nature will inevitably break
existing code that has been taking advantage of this functionality. From
my point of view this is an argument in favor of having this issue
addressed as soon as possible.

[-- Attachment #2: Type: text/html, Size: 532 bytes --]

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-03-28 23:46 Pontus Michael
  2014-03-29 15:30 ` Charles Berry
@ 2014-03-31  8:17 ` Sebastien Vauban
  2014-08-16 12:55   ` Pierre-Henry FRÖHRING
  1 sibling, 1 reply; 10+ messages in thread
From: Sebastien Vauban @ 2014-03-31  8:17 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Pontus Michael wrote:
> I recommend to introduce a change that will replace the inserted prefix
> with whitespace of equal length. If it was the case then provided
> example would produce the following code after expansion:
>
> #+begin_src emacs-lisp
> (concat "foo"
>         "bar")
> #+end_src
>
> Here are the arguments in support of my proposal:
>
> 1) The proposed behavior is identical to one produced by original noweb.
>
> 2) Documentation provides a reasoning for current behavior as an example
>    of reference expansion after the introduction of single-line comment
>    with intention to comment all the lines caught in expansion. This
>    reasoning follows simplistic assumption of semantics of arbitrary
>    language and takes advantage of the single line comment notation used
>    for non-intended purpose (i.e. multiline comment should have been
>    used instead).
>
> 3) Continuing the line of examples given in emacs lisp, which lacks the
>    notation for multiline comments I fail to see a situation where
>    docstrings would not only serve the intended purpose, but in many
>    cases contribute to quality and readability of the code.
>
> 4) Current behavior lacks the mechanism for handling multiple noweb
>    references present on the same line. If prefix would be extracted
>    from the unexpanded code and expansion would include raw noweb
>    references notation. Clearly this is unexpected behavior.
>
> If my proposal will find support in the community I can put my own
> effort in bringing this change into existence.

I am more or less the one who asked for the current behavior because
I wanted to be able to easily comment blocks in SQL or ELisp or ...

--8<---------------cut here---------------start------------->8---
SELECT *
FROM table
WHERE <<cond1>> AND
      -- <<cond2>> AND
      <<cond3>>
--8<---------------cut here---------------end--------------->8---

However, as you say, in the SQL case, I could have used multiline
comments.

This is a pity it does not exist in ELisp.

However, your arguments 1 and 4 are important to me. Hence, I'd see no
objection to move in the direction you propose (insert whitespaces, so
that indentation is correctly done).

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-03-30 21:13 Proposal to replace the prefix repetition with whitespace during expansion of noweb references Pontus Michael
@ 2014-04-11  9:36 ` Bastien
  0 siblings, 0 replies; 10+ messages in thread
From: Bastien @ 2014-04-11  9:36 UTC (permalink / raw)
  To: Pontus Michael; +Cc: emacs-orgmode, ccberry

Hi Michael,

Pontus Michael <m.pontus@gmail.com> writes:

> You make a valid point that change of this nature will inevitably
> break existing code that has been taking advantage of this
> functionality.  From my point of view this is an argument in favor
> of having this issue addressed as soon as possible.

I'll wait for Eric to join the discussion, as I'm not familiar enough
with these use cases.

As for breaking changes, we keep them for major versions of Org.
The next one is 8.3, which is maybe not that far away.

PS: your reply broke the thread -- if you can, please keep replies
within the same thread.

-- 
 Bastien

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-03-31  8:17 ` Sebastien Vauban
@ 2014-08-16 12:55   ` Pierre-Henry FRÖHRING
  2014-08-18 11:55     ` Sebastien Vauban
  0 siblings, 1 reply; 10+ messages in thread
From: Pierre-Henry FRÖHRING @ 2014-08-16 12:55 UTC (permalink / raw)
  To: emacs-orgmode

I would like to back this proposition with our use case :

        #+BEGIN_SRC js
          REACTIVE_STATE = TYPE_BUILDER(
              <<REACTIVE_STATE.constructor>>
              , "reactive_state"
              , <<REACTIVE_STATE.functions>>
          )
        #+END_SRC

Where `<<REACTIVE_STATE.constructor>>` is expanded as expected,
and `, <<REACTIVE_STATE.functions>>` is not, leading to `,  ` prefixing all
lines.

Best regards.
Pierre

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-08-16 12:55   ` Pierre-Henry FRÖHRING
@ 2014-08-18 11:55     ` Sebastien Vauban
  2014-08-23  8:35       ` Aaron Ecay
  0 siblings, 1 reply; 10+ messages in thread
From: Sebastien Vauban @ 2014-08-18 11:55 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Pierre-Henry FRÖHRING wrote:
> I would like to back this proposition with our use case :
>
>         #+BEGIN_SRC js
>           REACTIVE_STATE = TYPE_BUILDER(
>               <<REACTIVE_STATE.constructor>>
>               , "reactive_state"
>               , <<REACTIVE_STATE.functions>>
>           )
>         #+END_SRC
>
> Where `<<REACTIVE_STATE.constructor>>` is expanded as expected,
> and `, <<REACTIVE_STATE.functions>>` is not, leading to `,  ` prefixing all
> lines.

See https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg01606.html
for some context about that.

As I wrote, yes, I think it makes sense to do such a change.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-08-18 11:55     ` Sebastien Vauban
@ 2014-08-23  8:35       ` Aaron Ecay
  2014-10-12 12:43         ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Aaron Ecay @ 2014-08-23  8:35 UTC (permalink / raw)
  To: Sebastien Vauban, emacs-orgmode

Hello,

2014ko abuztuak 18an, Sebastien Vauban-ek idatzi zuen:
> 
> Pierre-Henry FRÖHRING wrote:
>> I would like to back this proposition with our use case :
>> 
>> #+BEGIN_SRC js
>> REACTIVE_STATE = TYPE_BUILDER(
>> <<REACTIVE_STATE.constructor>>
>> , "reactive_state"
>> , <<REACTIVE_STATE.functions>>
>> )
>> #+END_SRC
>> 
>> Where `<<REACTIVE_STATE.constructor>>` is expanded as expected,
>> and `, <<REACTIVE_STATE.functions>>` is not, leading to `,  ` prefixing all
>> lines.
> 
> See https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg01606.html
> for some context about that.
> 
> As I wrote, yes, I think it makes sense to do such a change.

FWIW, I also think the present behavior is too magical, and am in favor
of the proposed change.

-- 
Aaron Ecay

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-08-23  8:35       ` Aaron Ecay
@ 2014-10-12 12:43         ` Bastien
  2014-10-12 15:42           ` Aaron Ecay
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2014-10-12 12:43 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: Sebastien Vauban, emacs-orgmode

Hi Aaron,

Aaron Ecay <aaronecay@gmail.com> writes:

> FWIW, I also think the present behavior is too magical, and am in favor
> of the proposed change.

Feel free to push this change.  Thanks!

-- 
 Bastien

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

* Re: Proposal to replace the prefix repetition with whitespace during expansion of noweb references
  2014-10-12 12:43         ` Bastien
@ 2014-10-12 15:42           ` Aaron Ecay
  0 siblings, 0 replies; 10+ messages in thread
From: Aaron Ecay @ 2014-10-12 15:42 UTC (permalink / raw)
  To: Bastien; +Cc: Sebastien Vauban, emacs-orgmode

Hi Bastien,

2014ko urriak 12an, Bastien-ek idatzi zuen:
> 
> Hi Aaron,
> 
> Aaron Ecay <aaronecay@gmail.com> writes:
> 
>> FWIW, I also think the present behavior is too magical, and am in favor
>> of the proposed change.
> 
> Feel free to push this change.  Thanks!

AFAIK this was just an idea and a patch never materialized, but I will
put it on my todo list.  I’ll send an update to this thread when it’s
done.  (But anyone else who feels a more pressing need should feel free
to go ahead and do it, of course.)

-- 
Aaron Ecay

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

end of thread, other threads:[~2014-10-12 15:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-30 21:13 Proposal to replace the prefix repetition with whitespace during expansion of noweb references Pontus Michael
2014-04-11  9:36 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2014-03-28 23:46 Pontus Michael
2014-03-29 15:30 ` Charles Berry
2014-03-31  8:17 ` Sebastien Vauban
2014-08-16 12:55   ` Pierre-Henry FRÖHRING
2014-08-18 11:55     ` Sebastien Vauban
2014-08-23  8:35       ` Aaron Ecay
2014-10-12 12:43         ` Bastien
2014-10-12 15:42           ` Aaron Ecay

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