Re: bug#44824: 27.1; Org export as pdf and open file does not open it

2021-01-27 Thread Maxim Nikulin

On 27/01/2021 10:36, Lars Ingebrigtsen wrote:



Executing the command "xdg-open /path/to/file.pdf" in a terminal
(Konsole) works.


The problem may be related to SIGHUP sent to children due to pty created 
by emacs and closed as soon as the handler exits:


https://orgmode.org/list/ru4d75$11sc$1...@ciao.gmane.io/

As a workaround you could try to set another handler for PDF files in 
mailcap, e.g. okular directly without xdg-open wrapper. Handler should 
not try to launch actual application in background with immediate exit.


Currently start-process elisp function is used internally in 
org-open-file. Low level (make-process :connection-type 'pipe ...) 
should allow to avoid pty+SIGHUP problem. Maybe there are some 
consequences of such change that I am not aware of.





embedded calc and org tables

2021-01-27 Thread Eric S Fraga
Hello all,

I use embedded calc a lot for teaching related documents (slides,
courseworks, etc.).  Incredibly powerful computer algebra system
built-in to Emacs.  What's not to like. ;-)

However, I also use org tables a lot (as spreadsheet calculators).

Is there an easy (or any) way to access embedded calc variables in an
org table?  This may actually be an elisp & calc question that I can
post to emacs.help but I thought I'd ask here first as it would be a
nice feature for org.

For completeness, an expression like

   x <= sqrt(5) =>

will be processed by embedded calc to evaluate the expression, save the
value in x, and display the result after the =>.  I would like to access
the value of x in an org table.

Thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-199-gbc511b



bug#44824: 27.1; Org export as pdf and open file does not open it

2021-01-27 Thread Glenn Morris


Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
https://bugzilla.gnome.org/show_bug.cgi?id=652262
https://gitlab.gnome.org/GNOME/glib/-/issues/1208
and others going back over a decade.
I think Emacs should have a PROBLEMS entry about this.





what happened to org-insert-structure-template

2021-01-27 Thread JRSS
Hi,

This has been missing for a while for me and I recently checked the manual. It 
seems like org-insert-structure-template doesn't exist. I tried Emacs -q, same 
thing. I also loaded org-tempo, thought it has something to do with it, but 
nothing.

How do I activate is so that C-c C-, works?

Re: what happened to org-insert-structure-template

2021-01-27 Thread tomas
On Wed, Jan 27, 2021 at 09:29:14PM +, JRSS wrote:
> Hi,
> 
> This has been missing for a while for me and I recently checked the manual. 
> It seems like org-insert-structure-template doesn't exist. I tried Emacs -q, 
> same thing. I also loaded org-tempo, thought it has something to do with it, 
> but nothing.

Hm. Works for me (Org 9.4.4).

> How do I activate is so that C-c C-, works?

Strange. C-h f org-insert-structure-template turns up empty?

Cheers
 - t


signature.asc
Description: Digital signature


Re: what happened to org-insert-structure-template

2021-01-27 Thread Diego Zamboni
Also works for me, Org version 9.5.

Could it be that just the keybinding got un/redefined somehow? Have you
tried running M-x org-insert-structure-template?

--Diego

On Wed, Jan 27, 2021 at 10:45 PM  wrote:

> On Wed, Jan 27, 2021 at 09:29:14PM +, JRSS wrote:
> > Hi,
> >
> > This has been missing for a while for me and I recently checked the
> manual. It seems like org-insert-structure-template doesn't exist. I tried
> Emacs -q, same thing. I also loaded org-tempo, thought it has something to
> do with it, but nothing.
>
> Hm. Works for me (Org 9.4.4).
>
> > How do I activate is so that C-c C-, works?
>
> Strange. C-h f org-insert-structure-template turns up empty?
>
> Cheers
>  - t
>


Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread doltes
Get =#+RESULTS= without re-evaluating source code block?

Let's suppose I have a code block which requires a long time to finish

#+NAME: big-computation
#+begin_src bash
sleep 5 # Some computation which requires a long time to complete.
echo a
#+end_src

#+RESULTS: big-computation
#+begin_example
a
#+end_example

I want to use the results of that code block in other code blocks so I
use a =noweb= reference (see below.)

#+begin_src bash :noweb yes
printf "%s\n" <>
#+end_src

#+RESULTS:
#+begin_example
a

#+end_example

However, doing this (i.e. using a =noweb= reference) would make the
command to be evaluated whenever getting its results. I don't want
this, I want the =:noweb= reference to actually use the already
computed results.

So, my question is: Is it possible to use the actual =#+RESULTS= code
block instead of always evaluating it when referencing the results
through a =:noweb= reference?

-- 
Greetings,
doltes.



Re: Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread tomas
On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
> Get =#+RESULTS= without re-evaluating source code block?
> 
> Let's suppose I have a code block which requires a long time to finish
> 
> #+NAME: big-computation
> #+begin_src bash
> sleep 5 # Some computation which requires a long time to complete.
> echo a
> #+end_src
> 
> #+RESULTS: big-computation
> #+begin_example
> a
> #+end_example
> 
> I want to use the results of that code block in other code blocks so I
> use a =noweb= reference (see below.)
> 
> #+begin_src bash :noweb yes
> printf "%s\n" <>
> #+end_src
> 
> #+RESULTS:
> #+begin_example
> a
> 
> #+end_example
> 
> However, doing this (i.e. using a =noweb= reference) would make the
> command to be evaluated whenever getting its results. I don't want
> this, I want the =:noweb= reference to actually use the already
> computed results.
> 
> So, my question is: Is it possible to use the actual =#+RESULTS= code
> block instead of always evaluating it when referencing the results
> through a =:noweb= reference?

Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
in the Interwebs here [1] is for you.

In short, add a header argument :cache yes to your code block.

Cheers

[1] https://orgmode.org/org.html#Evaluating-Code-Blocks

 - t


signature.asc
Description: Digital signature


Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-01-27 Thread Kevin Foley
Kyle Meyer  writes:

Thanks for the review Kyle.

> nit: No ":" after "lisp/org-agenda.el".

Fixed.

> Drop either "about" or "for"?

Fixed.

> In addition to the NEWS entry that Ihor mentioned, it looks like an
> update to the manual is missing.

NEWS entry added.  With regard to the manual, the custom bulk function
option is only mentioned as a footnote.  I'm happy to add a more in
depth explanation, however I'm not sure where it should go, any
recommendations?

> s/it's/its/

Fixed.

> Should this :type be updated?

Updated.  I went with list with and optional second element for the
argument collection function (I also updated my patch to handle a nil
second argument).

I think it makes sense to encourage use of the list even when not using
an argument collection function but let me know if you think a choice
between function and list would be better.

> Please update this version, or rather drop :version and add
>   :package-version '(Org . "9.5")

Updated.


Thanks,
Kevin

>From 1d09a90abcb4136a3cf7562870f7eda831f163d3 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Thu, 21 Jan 2021 08:48:52 -0500
Subject: [PATCH] org-agenda.el: Support argument collection for custom bulk
 functions

* lisp/org-agenda.el (org-agenda-bulk-custom-functions): Add
documentation about argument collection for custom bulk functions.
(org-agenda-bulk-action): Support function to collect arguments for
custom bulk functions.
* etc/ORG-NEWS (Option ~org-agenda-bulk-custom-functions~ now supports
collecting bulk arguments): Add entry to NEWS.
---
 etc/ORG-NEWS   |  7 ++-
 lisp/org-agenda.el | 29 +
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5e5f1954d..4958d2b2e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -81,8 +81,13 @@ block. ~org-babel-latex-preamble~, ~org-babel-latex-begin-env~ and
 the user to specify the preamble and code that preceedes and proceeds
 the contents of the source block.
 
+*** Option ~org-agenda-bulk-custom-functions~ now supports collecting bulk arguments
+
+When specifying a custom agenda bulk option, you can now also specify a function which collects the arguments to be used with each call to the custom function.
+
+
 ** New features
-*** =ob-python= improvements to =:return= header argument 
+*** =ob-python= improvements to =:return= header argument
 
 The =:return= header argument in =ob-python= now works for session
 blocks as well as non-session blocks.  Also, it now works with the
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..c5c1b54ba 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2080,9 +2080,25 @@ (defcustom org-agenda-bulk-custom-functions nil
 
 With selected entries in an agenda buffer, `B R' will call
 the custom function `set-category' on the selected entries.
-Note that functions in this alist don't need to be quoted."
-  :type '(alist :key-type character :value-type (group function))
-  :version "24.1"
+Note that functions in this alist don't need to be quoted.
+
+If the custom function accepts arguments which you'd like to
+collect once from the user to be used for each call, you can pass
+a list with the bulk function, and the function which collects
+its arguments and returns them as a list.  For example:
+
+  \\='((?R (set-category get-category))
+(?C bulk-cut))
+
+Now, `B R' will call the custom `get-category' which would prompt
+the user once for a category.  That category is then passed as an
+argument to `set-category' for each entry it's called against.
+"
+  :type '(alist :key-type character
+:value-type (list (function :tag "Bulk Custom Function")
+  (choice (const :tag "No Bulk Custom Argument Function" nil)
+  (function :tag "Bulk Custom Argument Function"
+  :package-version '(Org . "9.5")
   :group 'org-agenda)
 
 (defmacro org-agenda-with-point-at-orig-entry (string &rest body)
@@ -10487,7 +10503,12 @@ (defun org-agenda-bulk-action (&optional arg)
 
 	(action
 	 (pcase (assoc action org-agenda-bulk-custom-functions)
-	   (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
+	   (`(,_ ,f)
+(when (listp f)
+  (let ((args (when (nth 1 f) (funcall (nth 1 f
+(func (nth 0 f)))
+(setq f (apply #'apply-partially func args
+(setq cmd f) (setq redo-at-end t))
 	   (_ (user-error "Invalid bulk action: %c" action)
 
   ;; Sort the markers, to make sure that parents are handled
-- 
2.28.0



Re: Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread John Kitchin
I tried this but it did not work for me.


On Wed, Jan 27, 2021 at 5:38 PM  wrote:

> On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
> > Get =#+RESULTS= without re-evaluating source code block?
> >
> > Let's suppose I have a code block which requires a long time to finish
> >
> > #+NAME: big-computation
> > #+begin_src bash
> > sleep 5 # Some computation which requires a long time to complete.
> > echo a
> > #+end_src
> >
> > #+RESULTS: big-computation
> > #+begin_example
> > a
> > #+end_example
> >
> > I want to use the results of that code block in other code blocks so I
> > use a =noweb= reference (see below.)
> >
> > #+begin_src bash :noweb yes
> > printf "%s\n" <>
> > #+end_src
> >
> > #+RESULTS:
> > #+begin_example
> > a
> >
> > #+end_example
> >
> > However, doing this (i.e. using a =noweb= reference) would make the
> > command to be evaluated whenever getting its results. I don't want
> > this, I want the =:noweb= reference to actually use the already
> > computed results.
> >
> > So, my question is: Is it possible to use the actual =#+RESULTS= code
> > block instead of always evaluating it when referencing the results
> > through a =:noweb= reference?
>
> Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
> in the Interwebs here [1] is for you.
>
> In short, add a header argument :cache yes to your code block.
>
> Cheers
>
> [1] https://orgmode.org/org.html#Evaluating-Code-Blocks
>
>  - t
>
-- 
John

---
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


Re: Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread doltes


Yes, it worked like a charm!

Thanks!

to...@tuxteam.de writes:

> On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
>> Get =#+RESULTS= without re-evaluating source code block?
>> 
>> Let's suppose I have a code block which requires a long time to finish
>> 
>> #+NAME: big-computation
>> #+begin_src bash
>> sleep 5 # Some computation which requires a long time to complete.
>> echo a
>> #+end_src
>> 
>> #+RESULTS: big-computation
>> #+begin_example
>> a
>> #+end_example
>> 
>> I want to use the results of that code block in other code blocks so I
>> use a =noweb= reference (see below.)
>> 
>> #+begin_src bash :noweb yes
>> printf "%s\n" <>
>> #+end_src
>> 
>> #+RESULTS:
>> #+begin_example
>> a
>> 
>> #+end_example
>> 
>> However, doing this (i.e. using a =noweb= reference) would make the
>> command to be evaluated whenever getting its results. I don't want
>> this, I want the =:noweb= reference to actually use the already
>> computed results.
>> 
>> So, my question is: Is it possible to use the actual =#+RESULTS= code
>> block instead of always evaluating it when referencing the results
>> through a =:noweb= reference?
>
> Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
> in the Interwebs here [1] is for you.
>
> In short, add a header argument :cache yes to your code block.
>
> Cheers
>
> [1] https://orgmode.org/org.html#Evaluating-Code-Blocks
>
>  - t


-- 
Greetings,
doltes.



bug#44824: 27.1; Org export as pdf and open file does not open it

2021-01-27 Thread Lars Ingebrigtsen
"gbio...@gmail.com"  writes:

> The same as using C-c C-e l o
> "The default PDF program (okular) appears to open (i see the icon, but not
> the window) and closes without showing anything."

If I do

$ xdg-open ./doc/lispintro/cons-2.pdf

after `M-x shell', "Document Viewer" is opened as normal.

You don't get any output from xdg-open or anything in the shell buffer?

Glenn Morris  writes:

> Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
> https://bugzilla.gnome.org/show_bug.cgi?id=652262
> https://gitlab.gnome.org/GNOME/glib/-/issues/1208
> and others going back over a decade.
> I think Emacs should have a PROBLEMS entry about this.

Yeah, calling xdg-open (and expecting it not to exit) is a known
problem, but here it seems that xdg-open doesn't even work from *shell*,
which is very odd.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





Re: Get =#+RESULTS= without re-evaluating source code block?

2021-01-27 Thread Greg Minshall
John,

> I tried this but it did not work for me.

to be clear, caching means that the *first* time you execute, your
reference will have to wait for the long-running computation to
complete, but not during subsequent executions (unless the source block
that performs the execution changes, in which case the reference will
again have to wait).

also, caching means that, after the first execution (ditto caveat) the
source block *will no longer run*.  so, if there were any (other) side
effects of running that source block, they will not happen.  (you could
possibly split the side effect-producing code out of that block.)

i'm not sure if this explains what did not work for you.

cheers, Greg

> 
> 
> On Wed, Jan 27, 2021 at 5:38 PM  wrote:
> 
> > On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
> > > Get =#+RESULTS= without re-evaluating source code block?
> > >
> > > Let's suppose I have a code block which requires a long time to finish
> > >
> > > #+NAME: big-computation
> > > #+begin_src bash
> > > sleep 5 # Some computation which requires a long time to complete.
> > > echo a
> > > #+end_src
> > >
> > > #+RESULTS: big-computation
> > > #+begin_example
> > > a
> > > #+end_example
> > >
> > > I want to use the results of that code block in other code blocks so I
> > > use a =noweb= reference (see below.)
> > >
> > > #+begin_src bash :noweb yes
> > > printf "%s\n" <>
> > > #+end_src
> > >
> > > #+RESULTS:
> > > #+begin_example
> > > a
> > >
> > > #+end_example
> > >
> > > However, doing this (i.e. using a =noweb= reference) would make the
> > > command to be evaluated whenever getting its results. I don't want
> > > this, I want the =:noweb= reference to actually use the already
> > > computed results.
> > >
> > > So, my question is: Is it possible to use the actual =#+RESULTS= code
> > > block instead of always evaluating it when referencing the results
> > > through a =:noweb= reference?
> >
> > Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
> > in the Interwebs here [1] is for you.
> >
> > In short, add a header argument :cache yes to your code block.
> >
> > Cheers
> >
> > [1] https://orgmode.org/org.html#Evaluating-Code-Blocks
> >
> >  - t
> >
> -- 
> John
> 
> ---
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu