Re: [BUG] org-create-file-search-functions and description [9.5.5 (release_9.5.5 @ /usr/share/emacs/29.0.50/lisp/org/)]

2022-09-26 Thread Magnus Therning


Ihor Radchenko  writes:


Magnus Therning  writes:

The documenation on org-create-file-search-functions contains 
this

piece of text

  A function in this hook may also use setq to set the variable
  description to provide a suggestion for the descriptive text 
  to
  be used for this link when it gets inserted into an Org 
  buffer

  with org-insert-link.

This doesn't seem to be true though. I really would love for 
there
to be a way to influence the link description, but no matter 
what

the documentation should be corrected.

For some more info look at
https://www.reddit.com/r/orgmode/comments/xmvtsy/orgcreatefilesearchfunctions_and_description/


Thanks for reporting!
Confirmed.

This is a regression after we switched to lexical binding, and 
after we

removed the apparently uninitialized `description' variable from
let-binding in `org-store-link'.

a85b4cc5c64b1eb6b97f5d7843dd54eb0632ef91
Author: Stefan Monnier 
AuthorDate: Thu Mar 11 13:07:37 2021 -0500
Commit: Kyle Meyer 
CommitDate: Sun Mar 14 17:54:17 2021 -0400

Backport commit 7d0dc3183 from Emacs

...
* lisp/ol.el (org-store-link):
Remove always-nil variable `description`.

In order to make things work now with lexical binding, we need 
to create
a top-level defvar in ol.el, which is not nice since 
`description'

variable name is a bad name to define.

Interestingly, this issue has not been noticed for a long time 
and not

many users are probably making use of it.

Thus, we may as well take this opportunity and allow
`org-create-file-search-functions' to return a cons cell
("search term" . "description"). This will not require 
unintuitive

global variables.

WDYT?


I think returning a cons cell would be a very nice solution.

/M

--
Magnus Therning   OpenPGP: 0x927912051716CE39
email: mag...@therning.org
@magthe@mastodon.technology   http://magnus.therning.org/

Never argue with stupid people, they will drag you down to their 
level

and then beat you with experience.
― Mark Twain


signature.asc
Description: PGP signature


[BUG] org-create-file-search-functions and description [9.5.5 (release_9.5.5 @ /usr/share/emacs/29.0.50/lisp/org/)]

2022-09-25 Thread Magnus Therning
Remember to cover the basics, that is, what you expected to happen 
and
what in fact did happen.  You don't know how to make a good 
report?  See


https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


The documenation on org-create-file-search-functions contains this 
piece of text


 A function in this hook may also use setq to set the variable 
 description to provide a suggestion for the descriptive text to 
 be used for this link when it gets inserted into an Org buffer 
 with org-insert-link.


This doesn't seem to be true though. I really would love for there 
to be a way to influence the link description, but no matter what 
the documentation should be corrected.


For some more info look at 
https://www.reddit.com/r/orgmode/comments/xmvtsy/orgcreatefilesearchfunctions_and_description/


Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.34, cairo version 1.17.6)

of 2022-09-21
Package: Org mode version 9.5.5 (release_9.5.5 @ 
/usr/share/emacs/29.0.50/lisp/org/)


/M

--
Magnus Therning   OpenPGP: 0x927912051716CE39
email: mag...@therning.org
@magthe@mastodon.technology   http://magnus.therning.org/

You can't depend on your judgement when your imagination is out of 
focus.

— Mark Twain


signature.asc
Description: PGP signature


Re: Using a code block as input to another code block

2020-11-23 Thread Magnus Therning

Berry, Charles  writes:

> Inline.
>
>> On Nov 21, 2020, at 2:30 PM, Magnus Therning  wrote:
>>
>> I know I can use an example block (literal example) as input to a code
>> block, but I haven't found a way to fontify examples. Since my input is
>> code (JSON, and various programming languages) I would really like to
>> have that, as well as the language's mode when editing by using
>> ~org-edit-source-code~.
>>
>> A code block gives me fontification, but I haven't found a way to pass a
>> code block as is to another code block.
>>
>> For instance, something like this:
>>
>> #+name: code-input
>> #+begin_src C
>> #include 
>> #+end_src
>>
>> #+begin_src bash :var input=input :results verbatim
>> cat <> ${input}
>> EOF
>> #+end_src
>
>
> Sounds like you want the :noweb header and code chunks, viz.
>
> #+begin_src bash :noweb yes :results verbatim
> cat < <>
> EOF
> #+end_src
>
> HTH,
>
> Chuck
>
> [deleted]

Ah, I didn't think of that. It does have some limitations though as
:noweb isn't as flexible as shell expansion. For instance, I'm not able
to do

#+name: my-json
#+begin_src json
{
  ...
}
#+end_src

#+begin_src bash :noweb yes :results verbatim
cat <> | jq '@text')
}
EOF
#+end_src

Though it isn't too difficult to work around in this case:

#+begin_src bash :noweb yes :results verbatim
cat <>
EOF0
{
  "foo": $(cat /dev/stdin)
}
EOF1
#+end_src

It's absolutely a workable solution. Thanks!

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org
twitter: magthe  http://magnus.therning.org/

Sometimes I wonder whether the world is being run by smart people who
are putting us on or by imbeciles who really mean it.
 — Mark Twain
Clearly, it's the imbeciles. And they really mean it.
 — DBT


signature.asc
Description: PGP signature


Using a code block as input to another code block

2020-11-21 Thread Magnus Therning
I know I can use an example block (literal example) as input to a code
block, but I haven't found a way to fontify examples. Since my input is
code (JSON, and various programming languages) I would really like to
have that, as well as the language's mode when editing by using
~org-edit-source-code~.

A code block gives me fontification, but I haven't found a way to pass a
code block as is to another code block.

For instance, something like this:

#+name: code-input
#+begin_src C
#include 
#+end_src

#+begin_src bash :var input=input :results verbatim
cat 

Setting language on result of code block

2020-08-02 Thread Magnus Therning
Is there some way to specify the language on the result of a code block.
For instance, if the block

#+begin_src bash
aws --endpoint-url=http://localhost:4566 sns create-topic --name the-topic
#+end_src

gives the result

#+RESULTS:
#+begin_example
{
"TopicArn": "arn:aws:sns:eu-central-1::the-topic"
}
#+end_example

Is there some way I can specify that the result is JSON? That is get the
result

#+RESULTS:
#+begin_example json
{
"TopicArn": "arn:aws:sns:eu-central-1::the-topic"
}
#+end_example

/M

--
Magnus Therning  OpenPGP: 0x927912051716CE39
email: mag...@therning.org
twitter: magthe  http://magnus.therning.org/

Every act of creation is first an act of destruction.
 — Pablo Picasso


signature.asc
Description: PGP signature