Re: Bug: crash exporing to html [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]

2021-03-21 Thread Greg Minshall
Kyle Meyer  wrote:

> At the very least, the failure message should be informative in this
> situation (a call referencing an unknown name).  I've pushed a commit
> (5450d6420) to improve the error reporting.

thanks!



Re: source blocks DAG evaluation

2021-03-21 Thread Thomas S. Dye

Aloha c4to,

I would be tempted to use noweb expansion here.

#+name: libB
#+begin_src scheme :results none :noweb yes
<>
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

#+begin_src scheme :session example :results output :noweb yes
<>
(display greetings)
#+end_src

Does this do what you want?

All the best,
Tom

c4t0 writes:


Hi,

Is it possible to have a dependency hierarchy of source blocks?

i.e.: in C, if you use libA from a compilation unit and that 
library needs libB, you don't need to include it in main.c


-> main.c
#include "libB.h"
-> libB.c
#include "libA.h"

you don't need to:
-> main.c
#include "libB.h"
#include "libA.h"

because library headers are closed under inclusion.

I haven't succeeded in doing the same in org-mode. Even after 
populating org-babel-library-of-babel.


Using #+call just doesn't work. Using :var is better, evaluates 
all, but there appears to lack session support, it doesn't check 
for cycles and it feels a little hacky


With #+call I need to do it like this:

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+name: libB
#+begin_src scheme :results none
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

here is my "main" I need to C-c C-c in each #+call line and 
write the :session that the code block uses in each one, and do 
it in the correct order. If I C-c C-c in libB first it won't 
eval because 'hi' is not defined.


#+call: libB[:session example]
#+call: libA[:session example]
#+begin_src scheme :session example :results output
(display greetings)
#+end_src

source blocks can be #+call(ed) but aren't closed under #+call 
(a source block can be called but then the callee won't)


instead I would like to :

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+call: libA
#+name: libB
#+begin_src scheme :results none
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

#+call: libB
#+begin_src scheme :session example :results output
(display greetings)
#+end_src

- there shouldn't be needed to C-c C-c in the #+call line, 
evaluating the source block alone should suffice.

- there shouldn't be a need to write the :session
  - it should use the session of the user evaled block, unless 
  specified otherwise


In the other hand, using :var with a dummy variable:

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+name: libB
#+begin_src scheme :results none :var _=libA
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

#+HEADER: :var _=libB
#+begin_src scheme :session example :results output
(display greetings)
#+end_src

It evals libA then libB and finally the (display greetings) 
code.
But it fails, because the :session example is ignored. Even if I 
add a :session example to every source block (which would be 
really bad, sessión must be decided by the consumer) it doesn't 
work. I think that is because :var expects a value, so it just 
opens a new session to evaluate code every time.


Besides if there are any dependency cycles, it just fails with: 
Lisp nesting exceeds ‘max-lisp-eval-depth’


So if I'm right and there is not an implemented way to do this, 
how can we do it? Adding session support for :var? constructing 
a DAG of #+calls and then evaluating in order? maybe using a new 
header?


COD.



--
Thomas S. Dye
https://tsdye.online/tsdye



Re: trivial software engineering'ish question: switching org's

2021-03-21 Thread Gustav Wikström
Straight.el is worth looking into for this. Has served me well for similar use 
cases.

BR
Gustav

Get Outlook for iOS

From: Emacs-orgmode  on behalf of 
Tim Cross 
Sent: Sunday, March 21, 2021 10:35:00 PM
To: emacs-orgmode@gnu.org 
Subject: Re: trivial software engineering'ish question: switching org's


Greg Minshall  writes:

> hi.  i occasionally want to switch from the org package to a git
> version, then back again.  and, i want to avoid the dread "mixed
> installation".
>
> i'm wondering is there a way people do this other than simply
> installing/deleting the package version?
>

As I understand it, the critical part is when Emacs compiles the org
files to get the *.elc versions. Provided you do not have any org
functionality loaded during that compilation process, everything should
be OK. The 'mixed' versions problem arises because you go to compile a
different version and Emacs includes definitions already loaded from
another version, generating *.elc files with mixed versions.

Once org is compiled, the critical part is having the org version you
want show up first in the load-path, so the problem becomes one of just
managing the load-path entries appropriately. You could just ensure the
version you want is higher in the load-path or you could go the
'paranoid' route and have code which removes the version you don't want
from the load-path.

In the past, what I've done is have the git version of org in a specific
directory which I build with a separate process from the command line
using the make recipes in the repository - essentially just configuring
and running make. I then have some code in my init.el file which sets
that version at the start of my load-path when I want to run it and
which I comment out when I just want to run the version installed by
package.el. I also use the use-package macro to load my org
configuration and have two different blocks for that - one loading the
git repo version and one loading the org-plus-contrib  version I
normally use. I just comment out the one I don't want to use. I probably
could write some elisp to automate this, but to be honest, I switch
between org versions so rarely, commenting/uncommenting parts of my
init.el file is easy enough.

I don't do any of that at the moment as I've not needed to run from the
git repo since I switched to spacemacs and the spacemacs setup already
has the necessary workflow to ensure new versions of org are compiled in
a clean environment. Have not yet thought about how I will need to add
git based org when using spacemacs. Suspect All I'll need to do is
adjust the load-path as part of the init to reference the git sources
before any org functionality is loaded.

--
Tim Cross



source blocks DAG evaluation

2021-03-21 Thread c4t0


Hi,

Is it possible to have a dependency hierarchy of source blocks?

i.e.: in C, if you use libA from a compilation unit and that library needs 
libB, you don't need to include it in main.c

-> main.c
#include "libB.h"
-> libB.c
#include "libA.h"

you don't need to:
-> main.c
#include "libB.h"
#include "libA.h"

because library headers are closed under inclusion.

I haven't succeeded in doing the same in org-mode. Even after populating 
org-babel-library-of-babel.

Using #+call just doesn't work. Using :var is better, evaluates all, but there 
appears to lack session support, it doesn't check for cycles and it feels a 
little hacky

With #+call I need to do it like this:

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+name: libB
#+begin_src scheme :results none
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

here is my "main" I need to C-c C-c in each #+call line and write the :session 
that the code block uses in each one, and do it in the correct order. If I C-c 
C-c in libB first it won't eval because 'hi' is not defined.

#+call: libB[:session example]
#+call: libA[:session example]
#+begin_src scheme :session example :results output
(display greetings)
#+end_src

source blocks can be #+call(ed) but aren't closed under #+call (a source block 
can be called but then the callee won't) 

instead I would like to :

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+call: libA
#+name: libB
#+begin_src scheme :results none
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

#+call: libB
#+begin_src scheme :session example :results output
(display greetings)
#+end_src

- there shouldn't be needed to C-c C-c in the #+call line, evaluating the 
source block alone should suffice.
- there shouldn't be a need to write the :session
  - it should use the session of the user evaled block, unless specified 
otherwise

In the other hand, using :var with a dummy variable:

#+name: libA
#+begin_src scheme :results none
(define hi "hello")
#+end_src

#+name: libB
#+begin_src scheme :results none :var _=libA
(define greetings (string-append hi ", " "to all the people!"))
#+end_src

#+HEADER: :var _=libB
#+begin_src scheme :session example :results output 
(display greetings)
#+end_src

It evals libA then libB and finally the (display greetings) code.
But it fails, because the :session example is ignored. Even if I add a :session 
example to every source block (which would be really bad, sessión must be 
decided by the consumer) it doesn't work. I think that is because :var expects 
a value, so it just opens a new session to evaluate code every time.

Besides if there are any dependency cycles, it just fails with: Lisp nesting 
exceeds ‘max-lisp-eval-depth’

So if I'm right and there is not an implemented way to do this, how can we do 
it? Adding session support for :var? constructing a DAG of #+calls and then 
evaluating in order? maybe using a new header?

COD.



Re: trivial software engineering'ish question: switching org's

2021-03-21 Thread Anthony Cowley



> On Mar 21, 2021, at 1:46 PM, Greg Minshall  wrote:
> 
> hi.  i occasionally want to switch from the org package to a git
> version, then back again.  and, i want to avoid the dread "mixed
> installation".
> 
> i'm wondering is there a way people do this other than simply
> installing/deleting the package version?
> 
> cheers, Greg
> 

The nix package manager is outstanding for these uses. You can have two 
versions of emacs — each with a different version of org — side by side, or 
switch between them without needing to re-byte compile anything.

Anthony




Re: trivial software engineering'ish question: switching org's

2021-03-21 Thread Tim Cross


Greg Minshall  writes:

> hi.  i occasionally want to switch from the org package to a git
> version, then back again.  and, i want to avoid the dread "mixed
> installation".
>
> i'm wondering is there a way people do this other than simply
> installing/deleting the package version?
>

As I understand it, the critical part is when Emacs compiles the org
files to get the *.elc versions. Provided you do not have any org
functionality loaded during that compilation process, everything should
be OK. The 'mixed' versions problem arises because you go to compile a
different version and Emacs includes definitions already loaded from
another version, generating *.elc files with mixed versions. 

Once org is compiled, the critical part is having the org version you
want show up first in the load-path, so the problem becomes one of just
managing the load-path entries appropriately. You could just ensure the
version you want is higher in the load-path or you could go the
'paranoid' route and have code which removes the version you don't want
from the load-path.

In the past, what I've done is have the git version of org in a specific
directory which I build with a separate process from the command line
using the make recipes in the repository - essentially just configuring
and running make. I then have some code in my init.el file which sets
that version at the start of my load-path when I want to run it and
which I comment out when I just want to run the version installed by
package.el. I also use the use-package macro to load my org
configuration and have two different blocks for that - one loading the
git repo version and one loading the org-plus-contrib  version I
normally use. I just comment out the one I don't want to use. I probably
could write some elisp to automate this, but to be honest, I switch
between org versions so rarely, commenting/uncommenting parts of my
init.el file is easy enough.

I don't do any of that at the moment as I've not needed to run from the
git repo since I switched to spacemacs and the spacemacs setup already
has the necessary workflow to ensure new versions of org are compiled in
a clean environment. Have not yet thought about how I will need to add
git based org when using spacemacs. Suspect All I'll need to do is
adjust the load-path as part of the init to reference the git sources
before any org functionality is loaded.

-- 
Tim Cross



Re: [PATCH] org-src.el Do not ask to revert unmodified buffers

2021-03-21 Thread Kyle Meyer
Thanks for the patch.

pillule writes:

> Hi, it is asked to the user if we want to revert changes when 
> re-entering in a org-source buffer.
> Even if the buffer have no modifications.

Hmm, that description seems to be focusing on the prompt's parenthetical
note.  When org-src-ask-before-returning-to-edit-buffer is non-nil and
there's an existing source buffer, the caller is asked whether to return
to it or regenerate/overwrite it.  The message warns that the second
option (i.e. answering "no, don't return to existing buffer") will
discard changes.

It looks like this patch assumes that, when the buffer is unmodified,
the answer to the above question necessarily becomes "yes, return to the
existing buffer", but it's not clear to me why that should be.  With an
unmodified buffer, I suppose there's less of a difference between the
two answers, but at least with the default org-src-window-setup value,
there's still a user-visible difference in terms of window organization.



Re: [PATCH] Prefer HTTPS to HTTP for links to gnu.org

2021-03-21 Thread Kyle Meyer
Stefan Kangas writes:

> Thanks.  Here's a followup patch that converts most remaining http-links
> to https.  All of them have been manually tested to avoid breakage.

Great, thank you.  Pushed (2e1c98415).



Re: [PATCH] Prefer HTTPS to HTTP for links to gnu.org

2021-03-21 Thread Stefan Kangas
Kyle Meyer  writes:

> Pushed (8cc992f7b).

Thanks.  Here's a followup patch that converts most remaining http-links
to https.  All of them have been manually tested to avoid breakage.
From 0f5a6cd7dcd540daf529a23da6a59a31f2723e87 Mon Sep 17 00:00:00 2001
From: Stefan Kangas 
Date: Sun, 21 Mar 2021 19:55:14 +0100
Subject: [PATCH] Prefer HTTPS to HTTP in most links

---
 COPYING  |   2 +-
 README_ELPA  |   2 +-
 contrib/lisp/ob-eukleides.el |   2 +-
 contrib/lisp/ob-smiles.el|   2 +-
 contrib/lisp/ob-spice.el |   4 +-
 contrib/lisp/ob-stata.el |   4 +-
 contrib/lisp/ol-wl.el|   2 +-
 contrib/lisp/org-contacts.el |   2 +-
 contrib/lisp/org-eldoc.el|   2 +-
 contrib/lisp/org-learn.el|   4 +-
 contrib/lisp/org-license.el  | 164 +++
 contrib/lisp/ox-bibtex.el|   4 +-
 contrib/lisp/ox-rss.el   |   4 +-
 contrib/lisp/ox-s5.el|   2 +-
 contrib/lisp/ox-taskjuggler.el   |   2 +-
 contrib/scripts/org-docco.org|   2 +-
 contrib/scripts/org2hpda |   2 +-
 contrib/scripts/staticmathjax/README.org |   2 +-
 doc/fdl.org  |   2 +-
 doc/org-manual.org   |  20 +--
 doc/texinfo.tex  |   6 +-
 etc/ORG-NEWS |   4 +-
 lisp/ob-clojure.el   |   2 +-
 lisp/ob-dot.el   |   2 +-
 lisp/ob-gnuplot.el   |   2 +-
 lisp/ob-haskell.el   |   6 +-
 lisp/ob-io.el|   2 +-
 lisp/ob-lilypond.el  |   4 +-
 lisp/ob-lisp.el  |   2 +-
 lisp/ob-mscgen.el|   2 +-
 lisp/ob-ocaml.el |   2 +-
 lisp/ob-picolisp.el  |   4 +-
 lisp/ob-processing.el|   2 +-
 lisp/ob-ruby.el  |   2 +-
 lisp/ob-sass.el  |   2 +-
 lisp/ol-bibtex.el|   2 +-
 lisp/org-protocol.el |   2 +-
 lisp/org-table.el|   2 +-
 lisp/ox-html.el  |   2 +-
 lisp/ox-latex.el |   2 +-
 lisp/ox.el   |   2 +-
 41 files changed, 143 insertions(+), 143 deletions(-)

diff --git a/COPYING b/COPYING
index 2a000655e..e60008693 100644
--- a/COPYING
+++ b/COPYING
@@ -1,7 +1,7 @@
 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
 
- Copyright (C) 2007 Free Software Foundation, Inc. 
+ Copyright (C) 2007 Free Software Foundation, Inc. 
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
diff --git a/README_ELPA b/README_ELPA
index 7640a4498..73447bcd9 100644
--- a/README_ELPA
+++ b/README_ELPA
@@ -10,7 +10,7 @@ This distribution contains an ELPA packaged version of Org.
 "ELPA" stands for the "Emacs Lisp Package Archive".
 
 The GNU ELPA is at:
-  http://elpa.gnu.org
+  https://elpa.gnu.org
 
 It contains the org-*.tar package, containing only the org files
 that are also part of GNU Emacs.
diff --git a/contrib/lisp/ob-eukleides.el b/contrib/lisp/ob-eukleides.el
index b1cc91b64..be3f1fd1c 100644
--- a/contrib/lisp/ob-eukleides.el
+++ b/contrib/lisp/ob-eukleides.el
@@ -26,7 +26,7 @@
 ;; Org-Babel support for evaluating eukleides script.
 ;;
 ;; Inspired by Ian Yang's org-export-blocks-format-eukleides
-;; http://www.emacswiki.org/emacs/org-export-blocks-format-eukleides.el
+;; https://www.emacswiki.org/emacs/org-export-blocks-format-eukleides.el
 
 ;;; Requirements:
 
diff --git a/contrib/lisp/ob-smiles.el b/contrib/lisp/ob-smiles.el
index 5a0fbf61a..9b1ac6840 100644
--- a/contrib/lisp/ob-smiles.el
+++ b/contrib/lisp/ob-smiles.el
@@ -8,7 +8,7 @@
 ;;; Commentary:
 
 ;;; I copy code from:
-;;; http://kitchingroup.cheme.cmu.edu/blog/2016/03/26/A-molecule-link-for-org-mode
+;;; https://kitchingroup.cheme.cmu.edu/blog/2016/03/26/A-molecule-link-for-org-mode
 
 ;; Author: John Kitchin [jkitc...@andrew.cmu.edu]
 ;; Maintainer: stardiviner [numbch...@gmail.com]
diff --git a/contrib/lisp/ob-spice.el b/contrib/lisp/ob-spice.el
index 3139d0eba..e8ea87af5 100644
--- a/contrib/lisp/ob-spice.el
+++ b/contrib/lisp/ob-spice.el
@@ -5,7 +5,7 @@
 ;; Maintainer: stardiviner (numbch...@gmail.com)
 ;; Version: 0.4
 ;; Package-Requires: ((spice-mode "0.0.1") (org "8"))
-;; Homepage: http://tiagoweber.github.io
+;; Homepage: https://tiagoweber.github.io
 
 ;; License: GPL v3, or any later version
 ;;
@@ -25,7 +25,7 @@
 ;;; Commentary:
 
 ;; Org-Babel support for evaluating spice script.
-;; Inspired by Ian Yang's org-export-blocks-format-plantuml 

Re: [PATCH] Prefer HTTPS to HTTP for links to gnu.org

2021-03-21 Thread Kyle Meyer
Stefan Kangas writes:

> The attached patch updates all links to gnu.org to use https instead of
> http.

Pushed (8cc992f7b).

> (Such a change was made in Emacs itself already in 2017.)

Yep, I believe those came into Org's tree with ff0dcf52a (Backport
commit bc511a64f from Emacs, 2017-09-13) and d4d7cda57 (Backport commit
5da53a019 from Emacs, 2017-09-13).  I should have taken the time then to
do a tree-wide update of Org files that are not included with Emacs.

Thanks.



Re: Bug: crash exporing to html [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]

2021-03-21 Thread Kyle Meyer
Greg Minshall writes:

> one line in why.org:
> 
> call_find-orgs()
> 
>
> then
> 
> emacs -Q
> 
>
> then
> 
> C-e h h
> 
>
> then
> 
> Debugger entered--Lisp error: (wrong-type-argument consp nil)
>   org-babel-exp-code(nil lob)
>   org-babel-exp-do-export(nil lob)
>   org-babel-exp-process-buffer()

Thanks for the report and reproducer.

At the very least, the failure message should be informative in this
situation (a call referencing an unknown name).  I've pushed a commit
(5450d6420) to improve the error reporting.



trivial software engineering'ish question: switching org's

2021-03-21 Thread Greg Minshall
hi.  i occasionally want to switch from the org package to a git
version, then back again.  and, i want to avoid the dread "mixed
installation".

i'm wondering is there a way people do this other than simply
installing/deleting the package version?

cheers, Greg



Re: Using lexical-binding

2021-03-21 Thread Greg Minshall
Kyle,

> Hmm, given that the lexical-binding change to ob-core was back in Org
> 9.0 (November 2016), it seems like dynamic scoping wasn't really being
> relied on (or, if it was, downstream code has already been adjusted).
> In my view it'd be better to stick with lexical scoping for these
> variables, with callers explicitly passing the subset of needed
> variables to the underlying function(s).

yes, that makes sense.  thanks.

cheers, Greg



Re: Invalid function: org-preserve-local-variables

2021-03-21 Thread Kyle Meyer
Loris Bennett writes:

> Hi,
>
> I'm running
>
>   Org mode version 9.4.4 (9.4.4-25-g3a522a-elpaplus @ 
> /home/loris/.emacs.d/elpa/org-plus-contrib-20210222/)
>
> and today I encountered the following error when refiling
>
>   org-refile: Invalid function: org-preserve-local-variables
>
> Despite the error, the refiling itself did however work.
>
> I am fairly sure that I have refiled without seeing this error message
> since I last updated Org, thus I am somewhat surprised by it.

org-preserve-local-variables is a macro defined in org-macs.el. That
file is loaded by org.el, which is loaded by org-refile.el.  So, I think
everything looks fine there.

My guess---especially if you're running Emacs 26 or lower, which ships
with an Org that didn't yet have org-preserve-local-variables---is that
you have a mixed installation.  list-load-path-shadows might reveal the
problem.

https://orgmode.org/worg/org-faq.html#mixed-install



Re: Using lexical-binding

2021-03-21 Thread Kyle Meyer
Greg Minshall writes:

> Kyle,
>
> thanks.  i see.  i wondered why the talk was all about agendas.
>
> since, in my (brand new, experimenting) use of
> =org-babel-map-src-blocks=, i'm calling a function, and that function is
> trying to de-reference, e.g., =beg-block=, i get an error.

Thanks for the details.

> it is (or does seem to be) the case that if the macro included all the
> valueless =defvars=, a function called from it has access to all those.
> i don't know if this would be a useful modification.

Hmm, given that the lexical-binding change to ob-core was back in Org
9.0 (November 2016), it seems like dynamic scoping wasn't really being
relied on (or, if it was, downstream code has already been adjusted).
In my view it'd be better to stick with lexical scoping for these
variables, with callers explicitly passing the subset of needed
variables to the underlying function(s).



Re: org-capture-template: table lines including newline of sorts

2021-03-21 Thread Maxim Nikulin

On 15/03/2021 03:41, Uwe Brauer wrote:



On 2021-03-13 02:24, Uwe Brauer wrote:



Do you need to add more pipes to keep the table structure on the line
after the newline?



I don't think so.


I am afraid, then you should significantly modify implementation for 
table-line capture type.


Your examples are hardly could be considered as minimal that anyone 
could easily try. I admit that you need namely the template for exams 
that could be quickly filled from email, but still...


 ("w" "Table - works" table-line
  (file+headline "" "Table")
  "| %U | It |\n| | Works |" :prepend t)
 ("b" "Table - broken" table-line
  (file+headline "" "Table")
  "| %U | Broken\nmultiline |" :prepend t)




bug#44824: [PATCH] org.el: Avoid xdg-open silent failure

2021-03-21 Thread Kyle Meyer
Maxim Nikulin writes:

> I hope, I have addressed other your comments in the updated patch.
>
> commit 5eca7764d94dd46b9f9a7792d1b786a3f03b20b6
> Author: Max Nikulin 
> Date:   Wed Feb 17 16:35:58 2021 +
>
> org.el: Avoid xdg-open silent failure

Thanks.  A note for future patches: your patch isn't in a format that's
ready to be consumed by git-am.  git-format-patch can help you here.

Applied to the Org repo (5db61eb0f), adding a TINYCHANGE cookie to the
commit message.  Please consider completing the copyright paperwork for
future patches
(see ).

If I understand correctly, this bug can be closed, but please reopen if
I'm mistaken.





Re: Where has the manual on one html page gone?

2021-03-21 Thread Russell Adams
On Sun, Mar 21, 2021 at 09:54:48AM +0100, Christine Köhn wrote:
> Here's why I prefer the one page manual:
>
> I can search it easily. Sometimes I do not find what I'm looking for
> where I would expect it to be. Also, searching is convenient way to find
> out if something *is not* in the manual.
>
> I'm used to reading and searching in a browser.

Searching and saving are both effective use cases.

> I agree that it's not efficient to download a whole manual but I guess
> that's what caching is for? Anyway, I thought about switching to
> accessing the manual offline but I haven't gotten to it yet.

I disagree. With transparent gzip compression its a few hundred K,
less than all the Javascript libraries that load when you open most
popular websites.

You are also less likely to reopen it repeatedly or reload it.

Perhaps the main link can goto a sectioned manual, but I'd like to see
a link to the one page manual preserved.


--
Russell Adamsrlad...@adamsinfoserv.com

PGP Key ID: 0x1160DCB3   http://www.adamsinfoserv.com/

Fingerprint:1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3



Re: greedy substitution in org-open-file

2021-03-21 Thread Maxim Nikulin

On 13/02/2021 11:38, Kyle Meyer wrote:
  
+(defun org--open-file-format-spec (format specification)

+  (with-temp-buffer
+(insert format)
+(goto-char (point-min))
+(while (search-forward "%" nil t)
+  (cond ((eq (char-after) ?%)
+ (delete-char 1))
+((looking-at "[s0-9]")
+ (replace-match
+  (or (cdr (assoc (match-string 0) specification))
+  (error "Invalid format string"))
+  'fixed-case 'literal)
+ (delete-region (1- (match-beginning 0)) (match-beginning 0)))


Finally I managed to convince myself that delete-region does not change 
position in the buffer, so "%s" or "%1" in specification are not a 
problem. I am aware that this implementation is a simplified version of 
format-spec, but I am still unsure if jumping over a buffer is the best 
choice.


I am in doubts if strings or characters should be used in the spec:
'(("s" . "file.pdf")) vs. '((?s . "file.pdf")), but really it does not 
matter.


I have created some tests for this function, see the attachment. 
Actually I do not like such style of tests since first failure stops 
whole test and it is hard to get general impression to which degree the 
function under the test is broken, but I am not aware of a better way.
Recently I asked Ihor a similar question: 
https://orgmode.org/list/s324b0$74g$1...@ciao.gmane.io


I know that functions called from one point are not in favor in org 
sources, but I do not mind to have additional helper function to add 
tests that all substitutions are properly escaped.



+  (let ((ngroups (- (/ (length link-match-data) 2) 1)))
+(and (> ngroups 0)
+ (progn
+   (set-match-data link-match-data)
+   (mapcar (lambda (n)
+ (cons (number-to-string n)
+   (match-string-no-properties n dlink)))
+   (number-sequence 1 ngroups


Matter of taste: it seems that with (number-sequence 1 ngroups 1)) it is 
possible to avoid (> ngroups 0).


I have spent some time evaluating how to make errors more helpful to 
users. I am unsure if multiline message is acceptable to dump content of 
specification. For a while, a place in the format where error has 
happened (combined with a different approach to parse format string)


(defun org--open-file-format-spec (format specification)
  (apply #'concat
 (nreverse
  (let ((result nil)
(token-end 0))
(while (string-match "%\\(.?\\)" format token-end)
  (let ((token-start (match-beginning 0))
(subst (match-string-no-properties 1 format)))
(push (substring format token-end token-start) result)
(push (if (equal subst "%")
  "%"
(or (cdr (assoc subst specification))
  (error "Unknown substitution: '%s%s'"
   (substring format 0 token-start)
   (substring format token-start nil
  result))
  (setq token-end (match-end 0)))
(push (substring format token-end nil) result)

To my surprise neither ^ nor \\` in string-match regexp works if 
start-pos is not zero.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 78cd29576..b6e42dc99 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -8236,6 +8236,72 @@ two
  (call-interactively #'org-paste-subtree)
  (buffer-string)
 
+(ert-deftest org-test/org--open-file-format-spec ()
+  "Test `org-open-file' helper `org--open-file-format-spec'."
+  (let ((def-spec '(("s" . "file.pdf") ("1" . "10") ("2" . "pattern"
+(should (equal "zathura --page 10 --find pattern file.pdf"
+		   (org--open-file-format-spec
+		"zathura --page %1 --find %2 %s" def-spec)))
+(should (equal "no subst"
+		   (org--open-file-format-spec
+		"no subst" def-spec)))
+(should (equal "simple file.pdf"
+		   (org--open-file-format-spec
+		"simple %s" def-spec)))
+(should (equal "with --page 10 file.pdf"
+		   (org--open-file-format-spec
+		  "with --page %1 %s" def-spec)))
+(should (equal "file.pdf at start"
+		 (org--open-file-format-spec
+		  "%s at start" def-spec)))
+(should (equal "in the file.pdf middle"
+		 (org--open-file-format-spec
+		  "in the %s middle" def-spec)))
+(should (equal "literal %"
+		   (org--open-file-format-spec
+		"literal %%" def-spec)))
+(should (equal "literal %s in the middle"
+		   (org--open-file-format-spec
+		"literal %%s in the middle" def-spec)))
+(should (equal "% literal at start"
+		 (org--open-file-format-spec
+		  "%% literal at start" def-spec)))
+(should (equal "" (org--open-file-format-spec "" def-spec)))
+(should (equal 

Re: [patch suggestion] Mitigating the poor Emacs performance on huge org files: Do not use overlays for PROPERTY and LOGBOOK drawers

2021-03-21 Thread Ihor Radchenko
Hello,

This is another update about the status of the patch.

I am mostly happy with the current state of the code, got rid of most of
the bugs, and did not get any new bug reports in github for a while.

I would like to start the process of applying the patch on master.
As a first step, I would like to submit the core folding library
(org-fold-core) for review.

org-fold-core is pretty much independent from org-mode code base and
does not affect anything if applied as is. It will be used by
org-specific org-fold.el I will finalise and send later.

For now, I would like to hear any suggestions about API and
implementation of org-fold-core.el. I tried to document all the details
in the code.

Looking forward for the feedback.

Best,
Ihor



org-fold-core.el
Description: application/emacs-lisp


Re: Where has the manual on one html page gone?

2021-03-21 Thread Christine Köhn
Here's why I prefer the one page manual:

I can search it easily. Sometimes I do not find what I'm looking for
where I would expect it to be. Also, searching is convenient way to find
out if something *is not* in the manual.

I'm used to reading and searching in a browser.

For me, it's easier to read a whole chapter/section if I just have to
scroll down. Especially if I only do cursory reading, e.g if I read
about spreadsheets after not having used them in a while. If I can just
scroll down, it's also easier to read on my smartphone (I'd like not to
do that but in the pandemic some things cannot be chosen).

I agree that it's not efficient to download a whole manual but I guess
that's what caching is for? Anyway, I thought about switching to
accessing the manual offline but I haven't gotten to it yet.



Re: Syntax Proposal: Multi-line Table Cells/Text Wrapping

2021-03-21 Thread Juan Manuel Macías
Hi Samuel,

Samuel Wales  writes:

> i like that.  such an org edit special type feature could efven in
> principle work for a column or a row all at once.

I like the idea of being able to edit rows or columns as well...

As I mentioned in a previous message, I made this rudimentary proof of
concept (only with cells):
https://lunotipia.juanmanuelmacias.com/edit-cell-sample-2021-03-19_09.29.17.mp4

The idea is that the content of the cell would be 'filled' while it is in
the edit buffer and, back to the cell, it would be a single line again.

Certain marks (in my sample it is a simple macro (nl = latex \newline)
would cause a line break in the edit buffer, to facilitate editing.

Best regards,

Juan Manuel 



Bug: org-protocol-protocol-alist: needs better description, not mentioning key/value [9.4.4 (release_9.4.4 @ /home/admin/Programming/Software/emacs/lisp/org/)]

2021-03-21 Thread Jean Louis



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 variable `org-protocol-protocol-alist' is describing what it has to
contain, but does not describe what `key' has to contain and what
`value' has to contain, as those are entries where user has to enter
something.

Key -- should contain the module name in quotes, this fact is not
described, example on my side is:

Key: "Hyperscope Store Hyperlink"

Value -- should contain the list, but how is that list formatted is not
explained here.

On my side I have tried by providing quoted list, that did not work,
then I figured out myself I would to provide this:

Value: 
(:protocol "store-link" :function hyperscope-org-protocol-store-link)

And I first tried quoting with:

function 'hyperscope-org-protocol-store-link

which did not work, then I tried the above version which did work. It is
a guess work.

The text below should be corrected by developers to tell to users what
belongs to `key' and what exactly belongs to `value', and example of
entering data should be clearly given.


Hide Org Protocol Protocol Alist:
Alist:
INS DEL Key: nil
Value: nil
INS
State : EDITED, shown value does not take effect until you set or save it.
   Register custom handlers for org-protocol. Hide
   
   Each element of this list must be of the form:
   
 (module-name :protocol protocol :function func :kill-client nil)
   
   protocol - protocol to detect in a filename without trailing
  colon and slashes.  See rfc1738 section 2.1 for more
  on this.  If you define a protocol "my-protocol",
  ‘org-protocol-check-filename-for-protocol’ will search
  filenames for "org-protocol:/my-protocol" and
  trigger your action for every match.  ‘org-protocol’
  is defined in ‘org-protocol-the-protocol’.  Double and
  triple slashes are compressed to one by emacsclient.
   
   function - function that handles requests with protocol and takes
  one argument.  If a new-style link (key=val=val2)
  is given, the argument will be a property list with
  the values from the link.  If an old-style link is
  given (val1/val2), the argument will be the filename
  with all protocols stripped.
   
  If the function returns nil, emacsclient and -server
  do nothing.  Any non-nil return value is considered a
  valid filename and thus passed to the server.
   
  ‘org-protocol.el’ provides some support for handling
  old-style filenames, if you follow the conventions
  used for the standard handlers in
  ‘org-protocol-protocol-alist-default’.  See
  ‘org-protocol-parse-parameters’.
   
   kill-client - If t, kill the client immediately, once the sub-protocol is
  detected.  This is necessary for actions that can be interrupted 
by
  ‘C-g’ to avoid dangling emacsclients.  Note that all other command
  line arguments but the this one will be discarded.  Greedy 
handlers
  still receive the whole list of arguments though.
   
   Here is an example:
   
 (setq org-protocol-protocol-alist
 '(("my-protocol"
:protocol "my-protocol"
:function my-protocol-handler-function)
   ("your-protocol"
:protocol "your-protocol"
:function your-protocol-handler-function)))


Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo 
version 1.17.4, Xaw scroll bars)
 of 2021-03-15
Package: Org mode version 9.4.4 (release_9.4.4 @ 
/home/admin/Programming/Software/emacs/lisp/org/)
-- 
Thanks,
Jean Louis
⎔ λ  퍄 팡 팚