Re: org-crypt ?

2022-06-11 Thread David Masterson
Ihor Radchenko  writes:

> David Masterson  writes:
>
>>> For that use case, I would use asymmetric rather than symmetric
>>> encryuption.
>>
>> Hmm.  Point taken.  I have to work on understanding asymmetric
>> encryption with org-crypt more.
>
> You just need to set org-crypt-key to your key name.
>

As well as setup GnuPG properly...  ;-)

-- 
David Masterson



Re: org-crypt ?

2022-06-11 Thread Tim Cross


David Masterson  writes:

> Tim Cross  writes:
>
>> David Masterson  writes:
>>
>>> Tim Cross  writes:
>>>
 Warning: I have not used org-crypt for many years. These days, I just
 use a .org.gpg extensions and symmetrically encrypt the whole file.
 However, I think I can probably answer some of your questions -
>>>
>>> Hmm, two questions that this brings up:
>>>
>>> 1. Do you access your files on (say) iPhone?
>>> 2. Do you store your files in Git (say Github)?
>>>
>>
>> Well, yes and yes, but I don't tend to need to access encrypted files on
>> iphone. I do have encrypted files in github. For example, I have a
>> private repository of files I share across computers (Linux and macOS).
>> Some of these files are gpg encrypted.
>
> Exactly the system I'm looking for! (or almost)
>
> I am already using (Emacs, Org, MaGit) on Linux, (BeOrg, Working Copy)
> on the iPhone, and a Github private repository.  This is complicated to
> the new user (like me w/ 42yrs [off and on] of Emacs usage), but Git has
> saved me a number of times on resyncing if I change things on both
> sides.  But I would like to use more encryption with this.  When it's
> secure, I'd like to roll it out on my family's iPhones as well.
>

I suspect the challenge will be in getting gnuPG support on the iphone.
I've never tried that and don't know if there is a gnuPG version for
iphone. That would be the first thing I'd try to verify. If you can
encrypt/decrypt on the iphone, it should be possible to handle the rest. 

The one problem you can run into with gpg files and git is that git can
see those as binary files. The general 'rule of thumb' is that you don't
put binary files into git. The thinking is that binary files are
typically generated from some text file and it is the original source
text which you would put into git. There are also some minor technical
issues, mainly with large binary files, which make git somewhat
inefficient. 

The big issue however is that by default, most git forges, like github,
have a limit on the siace of binary files they will allow in git. That
size is reasonably large, but there is a limit which I think you have to
pay to have increased. I've not run into that limit with encrypted
files, but have with PDFs and other formats I wanted to include in my
git repo. 



>
> Hmm.  Point taken.  I have to work on understanding asymmetric
> encryption with org-crypt more.
>

The main downside with asymmetric encryption is that if you want
different keys you have to create lots of different keys and manage them
securely. With symmetric encryption, you just have to remember
passwords/passphrases. The big advantage with asymmetric is that
encryption and decryption are separated. Someone can have your public
key and can encrypt data which only you (or whomever has the private
key) can decrypt.

Based on your desire to roll something out to your family, I would
actually recommend a different route. There are some very good open
source password managers out there. Many of them, for a very small fee
(i.e. $12pa), will also provide a few Gb of encrypted file storage as
well. 

What I find good with some of these is that provided you select the
right one, you have full control over the encryption (so the server the
provider uses has your data encrypted and only you have the key) and
they usually have mobile device support. The big benefit is that the
mobile clients will take care of the encryption/decryption bits. 

Personally, I've been using ipassword for years, but if I was setting
things up now from scratch, I would be chekcing out bitwarden and
keypass (as well as some others) as possible alternatives. These
password managers have grown to be  alot more than just password
managers. They typically have some support for encrypted files as well
as 'secure notes'. The basic architecture of many (especailly the open
source ones) is basically the same as your outlined use case - benefit
is they have taken care of all the nitty gritty stuff and most of them
are based on the same technology (i.e. gnupg under the hood). The other
benefit is you also often get support for 2FA/OTP, hardware keys like
yubikey etc. Such solutions are also often easier for family members who
may not be as technical oriented to learn/use.  

I also used lastpass at one of the businesses I worked for. While it was
a pretty good product when it was first released, I would no longer
recommend them. The quality and reliability seems ot have dropped off
significantly once they were sold to LogMeIn.

I did use borg, though not so much since I retired. It worked OK, but I
really just used it to manage tasks and keep notes using my tablet or
iphone (I usually used my ipad for meetings). However, since retirement
and no longer needing to interact with 'enterprise' environments, my
macbook and ipad are pretty much dust collectors! Everything these days
is just on my Linux system. 




Re: org-crypt ?

2022-06-11 Thread Ihor Radchenko
David Masterson  writes:

>> For that use case, I would use asymmetric rather than symmetric
>> encryuption.
>
> Hmm.  Point taken.  I have to work on understanding asymmetric
> encryption with org-crypt more.

You just need to set org-crypt-key to your key name.

Best,
Ihor



Re: org-crypt ?

2022-06-11 Thread David Masterson
Tim Cross  writes:

> David Masterson  writes:
>
>> Tim Cross  writes:
>>
>>> Warning: I have not used org-crypt for many years. These days, I just
>>> use a .org.gpg extensions and symmetrically encrypt the whole file.
>>> However, I think I can probably answer some of your questions -
>>
>> Hmm, two questions that this brings up:
>>
>> 1. Do you access your files on (say) iPhone?
>> 2. Do you store your files in Git (say Github)?
>>
>
> Well, yes and yes, but I don't tend to need to access encrypted files on
> iphone. I do have encrypted files in github. For example, I have a
> private repository of files I share across computers (Linux and macOS).
> Some of these files are gpg encrypted.

Exactly the system I'm looking for! (or almost)

I am already using (Emacs, Org, MaGit) on Linux, (BeOrg, Working Copy)
on the iPhone, and a Github private repository.  This is complicated to
the new user (like me w/ 42yrs [off and on] of Emacs usage), but Git has
saved me a number of times on resyncing if I change things on both
sides.  But I would like to use more encryption with this.  When it's
secure, I'd like to roll it out on my family's iPhones as well.

> Determining which parts are encrypted isn't hard. However, how do you
> know which key to associate with each bit? The only solution I can see
> is to attempt every known symetric key to each chunk until one works and
> if none of the known ones work, ask for another one. This could be how
> it works, but that seems extremely inefficient and difficult to manage
> to me. 
>
> The other problem is how to prompt for the key. Lets say you have 10
> encrypted items in an org file, each encrypted with a different
> symmetric key. Org has to ask the user for the key for each one. What
> goes into the prompt to give the user an idea which of the 10 different
> keys to enter? I guess it could say "Entger key for chunk 1:" and "Enter
> key for chunk2":, but I'm not sure that is good. The system could use
> the section heading, but I didn't see anything to indicate it would do
> that when scanning the code, but perhaps I missed it. 
>
>
>>
>> Hmm, you're suggesting you don't use org-(en/de)crypt.  The manual
>> doesn't spell out very well how to do that.  Where do you put your key
>> for symmetric encryption?
>>
>
> With symmetric encryhption, there is no 'key' to put anywhere. The key
> is the password/passphrase. You only have a 'key' with asymmetric
> encryption, where you have two files, the private and public key. These
> are managed by gnupg in the .gnupg directory (typically).

Problem with my terminology, I guess.

> One thing which you may find helpful is to look at the 3 separate layers
> involved with org-crypt as they all have their own manual and each layer
> provides some of the information you are after i.e.
>
> - Encryption/decryption and key management is largely handled by gnupg.
> The documentation associated with gnupg is pretty good and will likely
> answer many of your questions.

Hmm. Okay.

> - The interface to gnupg from within Emacs is managed by easyPG, which
> basically consists of two libraries - epa, which provides the Emacs
> interface layer for gnupg and epg, which provides a library that can be
> used by Emacs packages to access gnupg. This is primarily what org-crypt
> uses. The easyPG manual is pretty good and contains some good
> information.

Okay.

> - org-crypt, which is a very light-weight wrapper around the epg
> functions. It provides the basic integration between org and easyPG. 

Org-crypt needs more documentation to point to the other two as well as
provide a simple example to help people know if they are on the right
track.

>>> What is your use case where you need multiple symmetric encryption keys
>>> in one file?
>>
>> One broken key doesn't give up the whole file.
>>
>
> That might be a false sense of security. The big weakness with symmetric
> encryption is they key/passphrase. It suffers from the same problem of
> passwords (which are mostly 'human'). If one of your keys is weak enough
> it has been broken, the odds are pretty high that the others will be as
> well. The likelihood with symmetric encrytion is higher because
> everything is based on the key/passphrase you supply. With asymmetric
> encryption, the key is not related to the passphrase. To breach the key,
> someone needs to either get hold of the private key and the passphrase
> (assuming it has a passphrase, which is normal practice for secure
> setup) or they need to crack the very strong key. 
>
> For that use case, I would use asymmetric rather than symmetric
> encryuption.

Hmm.  Point taken.  I have to work on understanding asymmetric
encryption with org-crypt more.

Thanks
-- 
David Masterson



Re: org-crypt ?

2022-06-11 Thread Ihor Radchenko
Tim Cross  writes:

> Ihor's response to this indicates I'm incorrect here. As I stated
> earlier, it has been a long time since I used org-crypt, so I'd trust
> his advice more. However, from a technical perspective, I don't
> understand how gnupg or org-crypto can prompt to get the different keys
> and know which chunk to apply which key to, but that is my limited
> technical expertise more than anything else. With asymmetric encryption,
> you specify the key name, so it knows which key belongs with each
> encrypted chunk. I don't see in the code how this is handled for
> symmetric encryption where no key name is specified. 

If you run M-x org-decrypt-entry, the prompt will be for that entry. It
is up to the user to figure out which key is the key to be used there.

If you run M-x org-decrypt-entries, it simply runs org-decrypt-entry on
each encrypted headline appearing in the buffer. From top to bottom. No
indication will be done about which headline is being processed at any
given point. The user may need to count.

Of course, the last scenario is not very user-friendly, but I doubt that
many users really use different symmetric encryption keys on different
headings in a single file. Nobody bothered enough to implement a more
verbose prompt.

>>> Probably, though I don't know what else you would put in there which
>>> isn't already there. Feel free to supply a PR or patch once you have
>>> worked it out. However, as noted in the commentary section, org-crypt.el
>>> is really a very light-weight wrapper around functions in epg.el, so
>>> likely the first place to start when looking for documentation and
>>> examples is the epa/epg/easyPG manual
>>
>> Not good at writing these days, buy I'll consider.
>
> Please do. Often the best documentation comes from end users rather than
> developers. The developer is often too close to the code, which makes it
> harder for them to appreciate what users don't understand/know. For a
> user, the challenges they encounter are often 'fresher' and puts them in
> a better place to explain things. People on the list will provide
> feedback to help clarify and improve what you write. 

Fully agree. It is too easy to skip "obvious" things in documentation
when you know ins and outs of the code.

Best,
Ihor



Re: org-crypt ?

2022-06-11 Thread Tim Cross


David Masterson  writes:

> Tim Cross  writes:
>
>> David Masterson  writes:
>>
>>> I think I've gotten org-crypt working, but I think some things are not
>>> making sense (it might be just me):
>>>
>>> 1. I've set org-crypt-key to nil (symmetric encryption).
>>> 2. Can I use a different encryption key for each encrypted paragraph?
>>> 3. Does org-encrypt only ask for the key the first time?
>>> 4. Does org-decrypt only ask for the key the first time?
>>> 5. How do they know where to get the password when they don't ask?
>>> 6. Shouldn't org-crypt docs in org manual have examples?
>>> Does this make sense -- I think I'm messing something up.
>>
>> Warning: I have not used org-crypt for many years. These days, I just
>> use a .org.gpg extensions and symmetrically encrypt the whole file.
>> However, I think I can probably answer some of your questions -
>
> Hmm, two questions that this brings up:
>
> 1. Do you access your files on (say) iPhone?
> 2. Do you store your files in Git (say Github)?
>

Well, yes and yes, but I don't tend to need to access encrypted files on
iphone. I do have encrypted files in github. For example, I have a
private repository of files I share across computers (Linux and macOS).
Some of these files are gpg encrypted. 

>>> 2. Can I use a different encryption key for each encrypted paragraph?
>>
>> According to the manual -
>>  
>> No, not with symmetric encryption. I think this can only work with
>> asymmetric encryption.
>
> This needs to be spelled out better.

Ihor's response to this indicates I'm incorrect here. As I stated
earlier, it has been a long time since I used org-crypt, so I'd trust
his advice more. However, from a technical perspective, I don't
understand how gnupg or org-crypto can prompt to get the different keys
and know which chunk to apply which key to, but that is my limited
technical expertise more than anything else. With asymmetric encryption,
you specify the key name, so it knows which key belongs with each
encrypted chunk. I don't see in the code how this is handled for
symmetric encryption where no key name is specified. 

With symmetric encryption, the key is really just the passphrase. GnuPG
asks you for the key (passpharase) and it uses that to encrypt/decrypt
the data. With asymmetric, there is a public and private pair and an
associated 'name'. When encrypting, it knows or asks for the key name
and uses the public key and for decrypting, the private key, which most
often (but not always) has a passphrase used to unlock it. 
>
>> If your using symmetric encryption, you typically just have one key for
>> all the data within the file. From the gnuPG perspective, this is just
>> encrypted text. It does not 'know' about different paragraphs. To have
>> different encryption with each paragraph, you would need to specify
>> different keys and there is no mechanism to do that with symmetric
>> encryption only asymmetric.
>
> org-(en/de)crypt ??

Determining which parts are encrypted isn't hard. However, how do you
know which key to associate with each bit? The only solution I can see
is to attempt every known symetric key to each chunk until one works and
if none of the known ones work, ask for another one. This could be how
it works, but that seems extremely inefficient and difficult to manage
to me. 

The other problem is how to prompt for the key. Lets say you have 10
encrypted items in an org file, each encrypted with a different
symmetric key. Org has to ask the user for the key for each one. What
goes into the prompt to give the user an idea which of the 10 different
keys to enter? I guess it could say "Entger key for chunk 1:" and "Enter
key for chunk2":, but I'm not sure that is good. The system could use
the section heading, but I didn't see anything to indicate it would do
that when scanning the code, but perhaps I missed it. 


>
> Hmm, you're suggesting you don't use org-(en/de)crypt.  The manual
> doesn't spell out very well how to do that.  Where do you put your key
> for symmetric encryption?
>

With symmetric encryhption, there is no 'key' to put anywhere. The key
is the password/passphrase. You only have a 'key' with asymmetric
encryption, where you have two files, the private and public key. These
are managed by gnupg in the .gnupg directory (typically). 

One thing which you may find helpful is to look at the 3 separate layers
involved with org-crypt as they all have their own manual and each layer
provides some of the information you are after i.e.

- Encryption/decryption and key management is largely handled by gnupg.
The documentation associated with gnupg is pretty good and will likely
answer many of your questions. 

- The interface to gnupg from within Emacs is managed by easyPG, which
basically consists of two libraries - epa, whihc provides the Emacs
interface layer for gnupg and epg, which provides a library that can be
used by Emacs packages to access gnupg. This is primarily what org-crypt
uses. The easyPG manual is pretty 

Re: [PATCH] Re: New source block results option for attaching file to node

2022-06-11 Thread Ryan Scott
Ah sorry about that. I'm on a windows laptop and didn't have make, so was
testing interactively and they were passing.
I cleaned that up and remove the f-* usage and verified under Ubuntu (on
WSL) that the new tests are passing. I was getting some failures with
unrelated tests, but also get those in master as well.

Unless I'm missing something it looks like test-ob-core/dir-mkdirp covers
most other :dir usage.

I've remove the ID creation altogether and throw an error if org-attach-dir
is nil at that point. The error directs the user to add :ID: or :DIR: and
we don't need to do any guessing on their behalf. Implicit ID creation
should likely live elsewhere anyway.


On Sat, Jun 11, 2022 at 5:49 AM Ihor Radchenko  wrote:

> Ryan Scott  writes:
>
> > Had no experience with the :DIR: property or writing unit tests for Org,
> > but I think I've got both covered now.
> > The ID creation prompting now only happens if there is no result from
> > org-attach-dir, which should address the :DIR: case.
>
> Thanks!
>
> > Let me know if there's anything about those tests that I should modify.
>
> Yeah. They do not pass, currently...
> You can try yourself by running make test from Org git directory.
>
> >> > +  ((or '(:dir . attach) '(:dir . "'attach"))
> >> > +   (unless (org-id-get)
> >> > + (if (or noninteractive (y-or-n-p (format "Create ID for
> >> entry \"%s\"?"
> >> > +
> (org-get-heading
> >> t t t t
> >> > + (org-id-get-create)
> >> > +   (error "Can't attach to entry \"%s\". Entry has no ID"
> >> > +  (org-get-heading t t t t
>
> Unconditional ID creation for noninteractive is a bad idea. It is safer
> to throw an error.
>
> This code also generates warnings:
>
>
> In end of data:
> ob-core.el:2788:21: Warning: the function ‘org-id-get-create’ is not known
> to
> be defined.
> ob-core.el:2787:58: Warning: the function ‘org-get-heading’ is not known
> to be
> defined.
> ob-core.el:2785:23: Warning: the function ‘org-id-get’ is not known to be
> defined.
> ob-core.el:2792:38: Warning: the function ‘org-attach-dir’ is not known to
> be
> defined.
>
> Note that not all the ideas use org-id. Hence, `org-id-get-create' may
> not be available during runtime. Adding (require 'org-id) is not a good
> idea either (there will be other side-effects). So, if org-id is not
> loaded, it will be better to just throw an error.
>
> > +(ert-deftest test-ob-core/dir-attach ()
> > +  "Test :dir header using special 'attach value"
> > +  (should
> > +   (org-test-with-temp-text-in-file
> > +"* Symbol
> > +#+begin_src elisp :dir 'attach :results file
> > +(f-write-text \"attachment testing\" 'utf-8 \"test.txt\")
>
> f-write-text requires f.el, which is external packages. You cannot use
> it.
>
> Also, while you are here, you can as well add tests for other possible
> :dir settings.
>
> Best,
> Ihor
>


org-src-block-results-attach-dir.patch
Description: Binary data


Re: org-crypt ?

2022-06-11 Thread Ignacio Casso
Hello,

I'll take this chance to bring this up again, since it's also an issue
concerning org-crypt and it may be relevant if you decide to update
org-crypt's documentation:
https://lists.gnu.org/archive/html/emacs-orgmode/2021-12/msg00675.html.

Regards,

Ignacio

David Masterson  writes:

> Ihor Radchenko  writes:
>
>> David Masterson  writes:
>>
>>> I think I've gotten org-crypt working, but I think some things are not
>>> making sense (it might be just me):
>>>
>>> 1. I've set org-crypt-key to nil (symmetric encryption).
>>> 2. Can I use a different encryption key for each encrypted paragraph?
>>
>> Yes. For each individual encrypted headline contents. Just enter
>> different passwords when queried to encrypt.
>>
>>> 3. Does org-encrypt only ask for the key the first time?
>>
>> No. Strictly speaking it may depend on you GnuPG config. Not by default.
>>
>>> 4. Does org-decrypt only ask for the key the first time?
>>
>> Depends on your GnuPG config. AFAIK, GnuPG will not cache keys by default.
>>
>>> 5. How do they know where to get the password when they don't ask?
>>
>> From gpg-agent.
>>
>>> 6. Shouldn't org-crypt docs in org manual have examples?
>>
>> We can mention org-encrypt-entry/entries and org-decrypt-entry/entries.
>> Would it help?
>
> Yes.  Also, any basic config of gpg to work with.  Also, a simple test
> example to show what should happen to help users determine if their
> heading the right way.
>
> Thanks




Re: org-crypt ?

2022-06-11 Thread David Masterson
Tim Cross  writes:

> David Masterson  writes:
>
>> I think I've gotten org-crypt working, but I think some things are not
>> making sense (it might be just me):
>>
>> 1. I've set org-crypt-key to nil (symmetric encryption).
>> 2. Can I use a different encryption key for each encrypted paragraph?
>> 3. Does org-encrypt only ask for the key the first time?
>> 4. Does org-decrypt only ask for the key the first time?
>> 5. How do they know where to get the password when they don't ask?
>> 6. Shouldn't org-crypt docs in org manual have examples?
>> Does this make sense -- I think I'm messing something up.
>
> Warning: I have not used org-crypt for many years. These days, I just
> use a .org.gpg extensions and symmetrically encrypt the whole file.
> However, I think I can probably answer some of your questions -

Hmm, two questions that this brings up:

1. Do you access your files on (say) iPhone?
2. Do you store your files in Git (say Github)?

>> 2. Can I use a different encryption key for each encrypted paragraph?
>
> According to the manual -
>  
> No, not with symmetric encryption. I think this can only work with
> asymmetric encryption.

This needs to be spelled out better.

> If your using symmetric encryption, you typically just have one key for
> all the data within the file. From the gnuPG perspective, this is just
> encrypted text. It does not 'know' about different paragraphs. To have
> different encryption with each paragraph, you would need to specify
> different keys and there is no mechanism to do that with symmetric
> encryption only asymmetric.

org-(en/de)crypt ??

Hmm, you're suggesting you don't use org-(en/de)crypt.  The manual
doesn't spell out very well how to do that.  Where do you put your key
for symmetric encryption?

> What is your use case where you need multiple symmetric encryption keys
> in one file?

One broken key doesn't give up the whole file.

>> 6. Shouldn't org-crypt docs in org manual have examples?
>
> Probably, though I don't know what else you would put in there which
> isn't already there. Feel free to supply a PR or patch once you have
> worked it out. However, as noted in the commentary section, org-crypt.el
> is really a very light-weight wrapper around functions in epg.el, so
> likely the first place to start when looking for documentation and
> examples is the epa/epg/easyPG manual

Not good at writing these days, buy I'll consider.

-- 
David Masterson



Re: org-crypt ?

2022-06-11 Thread David Masterson
Ihor Radchenko  writes:

> David Masterson  writes:
>
>> I think I've gotten org-crypt working, but I think some things are not
>> making sense (it might be just me):
>>
>> 1. I've set org-crypt-key to nil (symmetric encryption).
>> 2. Can I use a different encryption key for each encrypted paragraph?
>
> Yes. For each individual encrypted headline contents. Just enter
> different passwords when queried to encrypt.
>
>> 3. Does org-encrypt only ask for the key the first time?
>
> No. Strictly speaking it may depend on you GnuPG config. Not by default.
>
>> 4. Does org-decrypt only ask for the key the first time?
>
> Depends on your GnuPG config. AFAIK, GnuPG will not cache keys by default.
>
>> 5. How do they know where to get the password when they don't ask?
>
> From gpg-agent.
>
>> 6. Shouldn't org-crypt docs in org manual have examples?
>
> We can mention org-encrypt-entry/entries and org-decrypt-entry/entries.
> Would it help?

Yes.  Also, any basic config of gpg to work with.  Also, a simple test
example to show what should happen to help users determine if their
heading the right way.

Thanks

-- 
David Masterson



Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)]

2022-06-11 Thread Ignacio Casso

> LGTM! Unless others have objections, I am inclined to merge the patch
> fully. But please add changlog entries to the commit message.

Done. I attach the patch with the new commit message.

>From 26d157aedfaf1496174682a1f9033d83160a06c2 Mon Sep 17 00:00:00 2001
From: Ignacio Casso 
Date: Sat, 11 Jun 2022 18:59:15 +0200
Subject: [PATCH] use `set-default-toplevel-value' in `defcustom' setters

* lisp/ob-lilypond.el (org-babel-lilypond-commands): use
`set-default-toplevel-value' instead of `set' or `set-default' in
`defcustom' :set argument.
* lisp/ob-shell.el (org-babel-shell-names): Ditto.
* lisp/org-capture.el (org-capture-templates): Ditto.
* lisp/org-clock.el (org-clock-ask-before-exiting): Ditto.
* lisp/org-duration.el (org-duration-units): Ditto.
* lisp/org-faces.el (org-set-tag-faces): Ditto.
* lisp/org-footnote.el (org-footnote-section): Ditto.
* lisp/org-list.el (org-plain-list-ordered-item-terminator): Ditto.
(org-list-allow-alphabetical): Ditto.
* lisp/org.el (org-babel-do-load-languages): Ditto.
(org-set-modules): Ditto.
(org-export-backends): Ditto.
(org-use-fast-todo-selection): Ditto.
(org-enforce-todo-dependencies): Ditto.
(org-enforce-todo-checkbox-dependencies): Ditto.
(org-display-custom-times): Ditto.
(org-set-packages-alist): Ditto.
(org-set-emph-re): Ditto.
* lisp/ox-odt.el (org-odt-schema-dir): Ditto.

This commit fixes a bug that occurred when using an autoload function
inside a let-binding for a custom variable when the feature defining
both the function and the custom variable had not been loaded yet.
---
 lisp/ob-lilypond.el  |  2 +-
 lisp/ob-shell.el |  2 +-
 lisp/org-capture.el  |  2 +-
 lisp/org-clock.el|  2 +-
 lisp/org-duration.el |  2 +-
 lisp/org-faces.el|  2 +-
 lisp/org-footnote.el |  2 +-
 lisp/org-list.el |  4 ++--
 lisp/org.el  | 23 +++
 lisp/ox-odt.el   |  2 +-
 10 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index df128441a..dc33ebc17 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -107,7 +107,7 @@ you can leave the string empty on this case."
   :package-version '(Org . "8.2.7")
   :set
   (lambda (symbol value)
-(set symbol value)
+(set-default-toplevel-value symbol value)
 (setq
  org-babel-lilypond-ly-command   (nth 0 value)
  org-babel-lilypond-pdf-command  (nth 1 value)
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index c25941a44..4454e3b5d 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -68,7 +68,7 @@ outside the Customize interface."
   :group 'org-babel
   :type '(repeat (string :tag "Shell name: "))
   :set (lambda (symbol value)
-	 (set-default symbol value)
+	 (set-default-toplevel-value symbol value)
 	 (org-babel-shell-initialize)))
 
 (defcustom org-babel-shell-results-defaults-to-output t
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 773234967..948eb8bc6 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -376,7 +376,7 @@ When you need to insert a literal percent sign in the template,
 you can escape ambiguous cases with a backward slash, e.g., \\%i."
   :group 'org-capture
   :package-version '(Org . "9.5")
-  :set (lambda (s v) (set s (org-capture-upgrade-templates v)))
+  :set (lambda (s v) (set-default-toplevel-value s (org-capture-upgrade-templates v)))
   :type
   (let ((file-variants '(choice :tag "Filename   "
 (file :tag "Literal")
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e0c40ae23..b94c79baa 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -493,7 +493,7 @@ This variable only has effect if set with \\[customize]."
  (if value
  (add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
(remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
- (set symbol value))
+ (set-default-toplevel-value symbol value))
   :type 'boolean
   :package-version '(Org . "9.5"))
 
diff --git a/lisp/org-duration.el b/lisp/org-duration.el
index b242a6f2c..338ea11a9 100644
--- a/lisp/org-duration.el
+++ b/lisp/org-duration.el
@@ -98,7 +98,7 @@ sure to call the following command:
   :version "26.1"
   :package-version '(Org . "9.1")
   :set (lambda (var val)
- (set-default var val)
+ (set-default-toplevel-value var val)
  ;; Avoid recursive load at startup.
 	 (when (featurep 'org-duration)
(org-duration-set-regexps)))
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index f919a6b47..5fb6c3e07 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -338,7 +338,7 @@ determines if it is a foreground or a background color."
 
 (defvar org-tags-special-faces-re nil)
 (defun org-set-tag-faces (var value)
-  (set var value)
+  (set-default-toplevel-value var value)
   (if (not value)
   (setq org-tags-special-faces-re nil)
 (setq org-tags-special-faces-re
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 0a5f994a4..8e0ac0da2 

Re: Google Docs now supports MarkDown, but not Org syntax

2022-06-11 Thread Jean Louis
* TRS-80  [2022-05-05 03:42]:
> Ken Mankoff  writes:
> 
> > Google Docs now supports MarkDown, not Org syntax :(.
> >
> > https://workspaceupdates.googleblog.com/2022/03/compose-with-markdown-in-google-docs-on.html

Google Docs is anyway proprietary Javascript software, it is not good
to drive users into it.

> There is a Free Software (AGPL3.0) alternative to Google Docs called
> HedgeDoc.  We have used it a little bit (within Armbian project) and I
> think it's pretty neat! [0]

I am just looking into:

HedgeDoc - The best platform to write and share markdown.
https://hedgedoc.org/

It is good for Markdown, but nothing similar to Google Docs, I can't
say it is alternative.

However, it would be good if HedgeDoc starts supporting Org mode, then
it would become very interesting. It is not hard really to support the
basics of Org. Can you do something about it?

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



Re: caption lost

2022-06-11 Thread Antonio Carlos Padoan Junior
Katarzyna Chauvat  writes:

Hi, try to associate "caption" (and perhaps "label") to the #+RESULTS: block
instead of the source code block.


> Hi,
>
> I would like to ask you for some advice.
> I am a beginner in org-mode. I try to
> include in  my text a Figure produced
> by R block code, just like this:
>
> #+caption: My caption
> #+label: fig:MyFigure
> #+begin_src R :exports results :results output graphics :file
> MyFigure.pdf :width 4.8 :height 6.5 :pointsize 7
> plot(1:5,1:5)
>  #+end_src
>
> The figure is produced and integrated in the text but
> I have lost my caption : how should I change my command to get it?
>
> Thank you in advance for your help.
> Best regards
> Katarzyna
>
>

-- 
Antonio Carlos PADOAN JUNIOR
GPG fingerprint:
243F 237F 2DD3 4DCA 4EA3  1341 2481 90F9 B421 A6C9



Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)]

2022-06-11 Thread Ihor Radchenko
Ignacio Casso  writes:

> Then we should decide if we want to use autoload cookies for custom
> variables to make this work also with lexical binding. Otherwise, code
> like the snippet above would produce an error in Emacs 29, and in Emacs
> 27 the let binding would be ignored (although at least the custom setter
> would work). I have no opinion regarding this last point since I don't
> remember what were the disadvantages of using autoload cookies for
> custom variables.

AFAIK, autoloading defcustoms is not discussed in the manual. I have no
idea about possible pitfalls as well.

> I've prepared a patch for the first point, which I attach at the end of
> this email. All changes fall in one of the following cases:
>
> - `set-default' -> `set-default-toplevel-value' (as explained)
>
> - `set' -> `set-default-toplevel-value'
>
>   The same, but in this cases there was another bug: If a buffer set the
>   custom variable locally before the feature was autoloaded, the setter
>   of the variable would not set the standard value as the default for
>   other buffers, and would overwrite the buffer-local value.
>
> - :set 'set-default -> nothing, since it would be already the default
>
> I don't really know what most of the variables whose setter I have
> changed do or whether it makes any sense to use them inside a let
> binding, but I have made the change for all of them nevertheless, since
> it can not harm and could potentially fix a bug. Feel free to restrict
> those changes only to those variables where it makes sense, such as
> `org-capture-templates', if you want to keep the patch small and simple.

LGTM! Unless others have objections, I am inclined to merge the patch
fully. But please add changlog entries to the commit message.

Best,
Ihor



Re: caption lost

2022-06-11 Thread Vikas Rawal
>
>
> #+caption: My caption
> #+label: fig:MyFigure
> #+begin_src R :exports results :results output graphics :file MyFigure.pdf
> :width 4.8 :height 6.5 :pointsize 7
> plot(1:5,1:5)
>  #+end_src
>
>
The figure is produced and integrated in the text but
>

#+CAPTION: line should be added to the output and not to the code block. As
follows.

#+CAPTION: My caption.
[[file:MyFigure.pdf]]

That is, you evaluate the code block, and once the output is created, add
caption to it.

Vikas


Bug: html-postamble string does not allow space [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/27.2/lisp/org/)]

2022-06-11 Thread Pierre Balayé
I am using html export feature for org files and I want to change the value
of html-postamble (see [doc](
https://orgmode.org/manual/HTML-preamble-and-postamble.html)).

Here is the `index.org` file:
```
#+title: Home

Welcome

#+options: html-postamble:"TESTSPACE"
```

When I export with `M-x org-html-export-as-html` everything is all right
and I have the following at the end of the html produced buffer:

```html

TESTSPACE

```

But if I add a space:
```
#+title: Home

Welcome

#+options: html-postamble:"TEST SPACE"
```

it raises this error I cannot solve:
`org-export--parse-option-keyword: End of file during parsing`

Emacs  : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw
scroll bars)
 of 2022-05-10
Package: Org mode version 9.4.4 (release_9.4.4 @
/usr/local/share/emacs/27.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-mode-hook '(#[0 "\301\211 \207" [imenu-create-index-function
org-imenu-get-tree] 2]
#[0 "\300\301\302\303\304$\207"
  [add-hook change-major-mode-hook org-show-all append local] 5]
#[0 "\300\301\302\303\304$\207"
  [add-hook change-major-mode-hook org-babel-show-result-all append local]
  5]
org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-agenda-loop-over-headlines-in-active-region nil
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
 org-cycle-show-empty-lines org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-follow :complete
org-attach-complete-link)
  ("id" :follow org-id-open)
  ("eww" :follow org-eww-open :store org-eww-store-link)
  ("rmail" :follow org-rmail-open :store org-rmail-store-link)
  ("mhe" :follow org-mhe-open :store org-mhe-store-link)
  ("irc" :follow org-irc-visit :store org-irc-store-link :export
org-irc-export)
  ("info" :follow org-info-open :export org-info-export :store
org-info-store-link)
  ("gnus" :follow org-gnus-open :store org-gnus-store-link)
  ("docview" :follow org-docview-open :export org-docview-export
:store org-docview-store-link)
  ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
  ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete
org-bbdb-complete-link :store org-bbdb-store-link)
  ("w3m" :store org-w3m-store-link) ("file+sys") ("file+emacs")
  ("shell" :follow org-link--open-shell)
  ("news" :follow
#[514 "\301\300\302 Q \"\207" ["news" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("mailto" :follow
#[514 "\301\300\302 Q \"\207" ["mailto" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("https" :follow
#[514 "\301\300\302 Q \"\207" ["https" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("http" :follow
#[514 "\301\300\302 Q \"\207" ["http" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("ftp" :follow
#[514 "\301\300\302 Q \"\207" ["ftp" browse-url ":"] 6
 "\n\n(fn URL ARG)"]
)
  ("help" :follow org-link--open-help)
  ("file" :complete org-link-complete-file)
  ("elisp" :follow org-link--open-elisp)
  ("doi" :follow org-link--open-doi))
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-link-elisp-confirm-function 'yes-or-no-p
 org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-html-format-headline-function
'org-html-format-headline-default-function
 )

Cordialement,

Dr. Pierre BALAYÉ


*__*
*Médecin de Santé 

caption lost

2022-06-11 Thread Katarzyna Chauvat
Hi,

I would like to ask you for some advice.
I am a beginner in org-mode. I try to
include in  my text a Figure produced
by R block code, just like this:

#+caption: My caption
#+label: fig:MyFigure
#+begin_src R :exports results :results output graphics :file MyFigure.pdf
:width 4.8 :height 6.5 :pointsize 7
plot(1:5,1:5)
 #+end_src

The figure is produced and integrated in the text but
I have lost my caption : how should I change my command to get it?

Thank you in advance for your help.
Best regards
Katarzyna


Re: [PATCH] Re: New source block results option for attaching file to node

2022-06-11 Thread Ihor Radchenko
Ryan Scott  writes:

>> > + (if (or noninteractive (y-or-n-p (format "Create ID for
>> entry \"%s\"?"

One more thing I forgot.
Please, use `yes-or-no-p'. `y-or-n-p' is not a good idea - it is too
easy to accidently confirm by hitting space.

Best,
Ihor



Re: [PATCH] Re: New source block results option for attaching file to node

2022-06-11 Thread Ihor Radchenko
Ryan Scott  writes:

> Had no experience with the :DIR: property or writing unit tests for Org,
> but I think I've got both covered now.
> The ID creation prompting now only happens if there is no result from
> org-attach-dir, which should address the :DIR: case.

Thanks!

> Let me know if there's anything about those tests that I should modify.

Yeah. They do not pass, currently...
You can try yourself by running make test from Org git directory.

>> > +  ((or '(:dir . attach) '(:dir . "'attach"))
>> > +   (unless (org-id-get)
>> > + (if (or noninteractive (y-or-n-p (format "Create ID for
>> entry \"%s\"?"
>> > +  (org-get-heading
>> t t t t
>> > + (org-id-get-create)
>> > +   (error "Can't attach to entry \"%s\". Entry has no ID"
>> > +  (org-get-heading t t t t

Unconditional ID creation for noninteractive is a bad idea. It is safer
to throw an error.

This code also generates warnings:


In end of data:
ob-core.el:2788:21: Warning: the function ‘org-id-get-create’ is not known to
be defined.
ob-core.el:2787:58: Warning: the function ‘org-get-heading’ is not known to be
defined.
ob-core.el:2785:23: Warning: the function ‘org-id-get’ is not known to be
defined.
ob-core.el:2792:38: Warning: the function ‘org-attach-dir’ is not known to be
defined.

Note that not all the ideas use org-id. Hence, `org-id-get-create' may
not be available during runtime. Adding (require 'org-id) is not a good
idea either (there will be other side-effects). So, if org-id is not
loaded, it will be better to just throw an error.

> +(ert-deftest test-ob-core/dir-attach ()
> +  "Test :dir header using special 'attach value"
> +  (should
> +   (org-test-with-temp-text-in-file
> +"* Symbol
> +#+begin_src elisp :dir 'attach :results file
> +(f-write-text \"attachment testing\" 'utf-8 \"test.txt\")

f-write-text requires f.el, which is external packages. You cannot use
it.

Also, while you are here, you can as well add tests for other possible
:dir settings.

Best,
Ihor



Re: [PATCH v2] Bug: Indenting empty description list item leaves point at beginning of line [9.4.4]

2022-06-11 Thread Ihor Radchenko
Bodertz  writes:

> After some quick testing, your patch seems to work as expected.  Thanks!

Applied onto main via ed6f8dc67.

Best,
Ihor



Re: org-html-htmlize-generate-css not including org htmlize synthetic faces

2022-06-11 Thread Ihor Radchenko
Steve Downey  writes:

> But now it seems it's just generating definitions for faces that org itself
> defines, rather than basically everything, just prefixed with "org-",
> the htmlize-css-name-prefix.
>
> Has anyone else seen this?

Could you provide a reproducer?
See https://orgmode.org/manual/Feedback.html

Best,
Ihor



[PATCH] Re: Help with assigning org-attach-id-dir using directory local variables

2022-06-11 Thread Ihor Radchenko
Alen Alex Ninan  writes:

> 1. Have I made an error in how I define the directory local file?

No.

> 2. If I have not made and error, Is it possible to define the attachment 
> directory in directory local variable and have org mode respect the 
> location when display of inline images are enabled during startup?

The problem you are seeing is because Emacs assigns directory-local and
buffer-local variables _after_ Org mode (or any other major mode) is
loaded.

Org startup staff happens during loading before directory-local
variables are assigned. Hence error.

I've seen multiple issues coming from the above behavior.
Hence, I'd like to propose Org to call `hack-local-variables' early
during startup. The patch is attached.

Best,
Ihor

>From 85af884fcb70cda42acd4cb1610411dcacac82b9 Mon Sep 17 00:00:00 2001
Message-Id: <85af884fcb70cda42acd4cb1610411dcacac82b9.1654948539.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Sat, 11 Jun 2022 19:53:37 +0800
Subject: [PATCH] org-mode: Make local variables effective during Org startup

* lisp/org.el (org-mode): Call `hack-local-variables' early during Org
mode startup.  This way, Org startup options will regard local
variable settings.

Fixes
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa5...@gmail.com/T/#u
---
 lisp/org.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 080962cdb..2b8a6cd10 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4606,6 +4606,10 @@ (define-derived-mode org-mode outline-mode "Org"
 
 \\{org-mode-map}"
   (setq-local org-mode-loading t)
+  ;; Apply file-local and directory-local variables, so that Org
+  ;; startup respects them.  See
+  ;; https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa5...@gmail.com/T/#u
+  (hack-local-variables 'ignore-mode-settings)
   (org-load-modules-maybe)
   (org-install-agenda-files-menu)
   (when (and org-link-descriptive
-- 
2.35.1



Re: Org Column in Thunderbird

2022-06-11 Thread Max Nikulin

On 10/06/2022 21:26, Ihor Radchenko wrote:

You dropped Org ML from the CC. Was it intentional?


My double failure. At first I replied to the message received directly 
that lacks List-Post header, while usually I response from the newsgroup 
folder, so simple reply has correct address, then I resent message in a 
such way that original Message-ID was lost. Sorry for that.



Max Nikulin writes:

On 10/06/2022 20:11, Ihor Radchenko wrote:

I imagine browser URLs could also indicate if they have associated Org
notes. Or pdfs.


It seems, most of PDF viewers do not allow decorations added by users.
Even built-in viewers in browsers displays document as privileged
content inaccessible by extensions. A kind of workaround is loading of
the same pdf.js to a regular page, but it is not really convenient. I am
unsure concerning security issues when pdf.js is bundled into an add-on.


AFAIK, https://web.hypothes.is/demos/ somehow works with PDFs in browsers.


If you mean docdrop.org then it likely uploads PDF documents to the 
server, perhaps to convert it to HTML since I have not noticed traces of 
PDF.js. Due to 502 Bad Gateway response I have not seen it in action. 
(Why are they insisting namely on dropping file without a button to open 
file selection dialog?)


I did not try to say that it is impossible since pdf.js may be used by 
regular pages. Serving documents grabbed from various sources requires 
extreme care to avoid security vulnerabilities. Ideally each document 
should be served from a unique domain to be able to enforce available 
measures like Content-Security-Policy. PDF is rather complex format, may 
include JavaScript, there is chance that some may remain active after 
rendering the document as HTML. In another project dedicated to capture 
of web pages I noticed some problems with attacks through JS embedded 
into HTML pages and the author fixed problems that can be exploited. 
https://github.com/danny0838/webscrapbook/


Reading about sioyek I noticed that it is able to recognize text looking 
like references to citations. Several years ago I have heard about 
converting references formatted using wide spread styles into e.g. 
bibtex entry or lookup in online libraries (mendeley?). It requires 
significant efforts to implement, but it would be a killer feature to 
mark entries in the references section if the user have notes related to 
the paper even when the PDF has no active hyperlinks or at least doi.


However at first similar feature should be added to LinkRemark for 
regular HTTP URLs.



Also, did you announce this anywhere outside Org ML?


I have no idea where I should announce it since currently it is useful
mostly with Org mode. Unsure if e.g. API of Joplin app will allow to get
all links of certain kind in all notes.


/r/orgmode I guess.


Frankly speaking I forgot about it. The mail list efficiently utilizes 
my "upstream bandwidth" that I am ready to dedicate to Org, so I do not 
follow discussions there.


I read reddit post mostly when there is no better links in search 
results. Sometimes I see mentions of this site in the context of 
discussions related to dark UI patterns (e.g. forcing users to make 
mobile client more "popular" by blocking some topics in mobile 
browsers). However it is not fair to complain concerning the policy of 
such site in a message sent from gmail about a project hosted at github.


I agree that post on reddit could attract more users since significant 
fraction of people prefer instant messengers and web services while 
hating email. The problem here is that my project deals with email, so 
it should be more probable to meet users here.


Actually I do not mind if someone will mention orco on reddit, but 
unsure if I will join the discussion.



Also I am afraid that I may broke something in Thunderbird internals. It
has some code for custom columns but docs are rather scarce, so I am
unsure if I implemented it properly. It is a reason to take a pause and
to wait if my profile would turn into unusable state.


Part of the benefit of the announcement could be having a feedback and
people trying and reporting if you actually broke something :)
Of course, it does make sense to test things locally first and catch the
most obvious issues.


The threshold for new users should not be too high. Requirement of a 
helper application is a significant obstacle. I have not implemented a 
simple installer. I think, I can cross-compile bURL for windows, but it 
requires some changes in code and, more important, different 
installation procedure I have never tried. After first negative 
impression it may be more hard to convince user to try it again.





Re: [Patch] ob-tangle.el: New value 'ascii' for the header argument ':comments'

2022-06-11 Thread Juan Manuel Macías
Hi, Ihor, thanks for your comments,

Ihor Radchenko writes:

> Wouldn't it be better to supply a customization for
> org-babel-process-comment-text instead?
>
> I do not feel that per-src-block control on the comment type makes much
> sense here.

My first approach was actually to define some options for
org-babel-process-comment. But I noticed that a header with properties,
for example:

* Header
  :PROPERTIES:
  :FOO:  var
  :END:

is interpreted as:

;; Header
;; :FOO: var

I think the culprit is the '(match-end 0)' in
org-babel-tangle-single-block:

...
(comment
  (when (or (string= "both" (cdr (assq :comments params)))
(string= "org" (cdr (assq :comments params
;; From the previous heading or code-block end
(funcall
 org-babel-process-comment-text
 (buffer-substring
  (max (condition-case nil
   (save-excursion
 (org-back-to-heading t) ; Sets match data
 (match-end 0)) ;; <=
 (error (point-min)))
   (save-excursion
 (if (re-search-backward
  org-babel-src-block-regexp nil t)
 (match-end 0)  ;; <=
   (point-min
  (point)
...

So I couldn't think of any other solution than to put the change there,
so as not to break backwards compatibility. But it is a somewhat tricky
solution...

Best regards,

Juan Manuel 



Re: Include LaTeX source and compiled result

2022-06-11 Thread Ihor Radchenko
Denis Maier  writes:

> Am 08.06.2022 um 10:28 schrieb Fraga, Eric:
>> On Wednesday,  8 Jun 2022 at 09:43, Denis Maier wrote:
>>> However, I cannot manage to get this to work:
>> If you want to show the LaTeX, you need to add ":exports code" to the
>> src block, or ":exports both :results file" if you want to show both
>> code and the resulting PDF.
>>
>
> :exports code works. But the problem with the other options is that the 
> compilation fails. But I cannot tell why. It just tells me "Code block 
> produced no output".
>
> How can you diagnose such an issue?

Hmm... Actually, I cannot reproduce the problem using emacs -Q and the
latest main.

Having bug.org:
---
Blabla

#+begin_src latex :file test.pdf
\documentclass{article}
\begin{document}
This is a test
\end{document}
#+end_src

Blabla
---

I ran C-c C-e l o

And got the expected pdf file open.

Best,
Ihor



Re: [PATCH] org-agenda.el: customise outline path in echo area

2022-06-11 Thread Ihor Radchenko
Mikhail Skorzhinskii  writes:

> Thank you for your comments once again. I've changed string= to eq and
> it appears to be working OK.
>
> I've also renamed "title" variable to "title-prop" for better
> readability. The -prop suffix should show the reader that it was
> extracted from the file, and thus cost some CPU/IO.
>
> I've attached an updated version to this email. Would love to hear what
> you think.

Thanks! And sorry for the late reply. Your patch fell through the cracks
in my todo list.

> * lisp/org-agenda.el (org-agenda-show-outline-path): add an option to
> show document title in outline path (instead of file name)
> * lisp/org.el (org-get-title-from-file): a function to collect the
> document title from the org-mode file
> * lisp/org.el (org-display-outline-path): add logic that will collect a
> document title and put it into the outline path if
> org-agenda-show-outline-path set to 'title

It would make sense to document the new customization in ORG-NEWS.

> +(defun org-get-title-from-file (file)
> +  "Collect tilte from the provided `org-mode' FILE."
> +  (let (title)
  ^ typo
> +(when file
> +  (with-current-buffer
> +   (get-file-buffer file)
> + (pcase (org-collect-keywords '("TITLE"))
> +   (`(("TITLE" . ,val))
> +(setq title (car val)
> +  title)))

Note that this function behavior is underfined when FILE buffer does not
exist. It would be better to accept buffer as argument.

Best,
Ihor



Re: New HTML exporter (was a feature request)

2022-06-11 Thread Timothy
Hi Ihor,

>> Not something I have time to investigate now, but in a month or two (or
>> three ) I might take a look.
>
> I am bumping this. Just in case ;)

This definitely needs a bump, however I think the ETA is still “a few months”
with the current projects I’ve got eating my time . Unless somebody might
happen to have a cloning pod available… 

All the best,
Timothy


Re: Custom TODO keywords and org-enforce-todo-dependencies

2022-06-11 Thread Ihor Radchenko
Edmund Potts  writes:

> I have read the manual and searched the list archives but not found an
> answer to this - so apologies if it was in fact covered somewhere.
>
> I make use of the variable org-enforce-todo-dependencies along with the
> :ORDERED: property to have sequentially limited TODO lists.
>
> However I found when experimenting with custom TODO keywords that once they
> were enabled, the blocking functionality did not work. I was able to change
> any of my TODO headers to "DONE", regardless of the state of the TODO item
> immediately preceding them.
>
> Is there a way these two functions can work together? I would appreciate
> any guidance.

Sorry for the late reply. Hope it is still relevant.

ORDERED + org-enforce-todo-depenencies should work with custom TODO
keywords as long as you properly define which keywords mean that a task
is 'done and which keywords mean the opposite.

org-todo-keywords:

Each sequence starts with a symbol, either sequence or type,
indicating if the keywords should be interpreted as a sequence of
action steps, or as different types of TODO items.  The first
keywords are states requiring action - these states will select a headline
for inclusion into the global TODO list Org produces.  If one of the
"keywords" is the vertical bar, "|", the remaining keywords
signify that no further action is necessary.  If "|" is not found,
the last keyword is treated as the only DONE state of the sequence.

Best,
Ihor



Re: New HTML exporter (was a feature request)

2022-06-11 Thread Ihor Radchenko
Timothy  writes:

> Not something I have time to investigate now, but in a month or two (or
> three ) I might take a look.

I am bumping this. Just in case ;)



Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)]

2022-06-11 Thread Ignacio Casso
Hello,

The bug I reported about this to the Emacs devel mailing list
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54399) has now been
closed, and some documentation has been updated in commit 071722e41120.

Basically, the problem is that in order for

  (let ((custom-variable local-value) ...)
  ...
  (defcustom custom-variable standard-value ...)
  ...)

to work as expected with dynamic binding, `defcustom' has to set the
variable with `set-default-toplevel-value'. This way, the code inside
the `let' form uses local-value and the default value is set to
standard-value. If `defcustom' uses `set-default' instead, it overwrites
the local value, so the let-binding is useless, and after the let form
is evaluated the variable is void.

The problem was that `set-default-toplevel-value' is used by default,
but the documentation said that the default was `set-default'. So either
whoever wrote the `org-capture-templates' setter was misguided by the
documentation and used `set-default', or more likely, that setter was
written before the introduction of `set-default-toplevel-value' in
custom.el, and was never updated.

The first thing we should do is finding all uses of `set-default' in the
org `defcustom' setters and replace them with
`set-default-toplevel-value'. This would fix this bug and similar ones
when using dynamic binding, and would not affect any other use case.

Then we should decide if we want to use autoload cookies for custom
variables to make this work also with lexical binding. Otherwise, code
like the snippet above would produce an error in Emacs 29, and in Emacs
27 the let binding would be ignored (although at least the custom setter
would work). I have no opinion regarding this last point since I don't
remember what were the disadvantages of using autoload cookies for
custom variables.

I've prepared a patch for the first point, which I attach at the end of
this email. All changes fall in one of the following cases:

- `set-default' -> `set-default-toplevel-value' (as explained)

- `set' -> `set-default-toplevel-value'

  The same, but in this cases there was another bug: If a buffer set the
  custom variable locally before the feature was autoloaded, the setter
  of the variable would not set the standard value as the default for
  other buffers, and would overwrite the buffer-local value.

- :set 'set-default -> nothing, since it would be already the default

I don't really know what most of the variables whose setter I have
changed do or whether it makes any sense to use them inside a let
binding, but I have made the change for all of them nevertheless, since
it can not harm and could potentially fix a bug. Feel free to restrict
those changes only to those variables where it makes sense, such as
`org-capture-templates', if you want to keep the patch small and simple.

Best regards,

Ignacio

[2. patch --- text/x-diff; 
0001-using-set-default-toplevel-value-in-defcustom-setter.patch]
>From b20e23013329fab574a4d05eb5be8cde1d43dad1 Mon Sep 17 00:00:00 2001
From: Ignacio Casso 
Date: Fri, 10 Jun 2022 12:39:43 +0200
Subject: [PATCH] using `set-default-toplevel-value' in `defcustom' setters

---
 lisp/ob-lilypond.el  |  2 +-
 lisp/ob-shell.el |  2 +-
 lisp/org-capture.el  |  2 +-
 lisp/org-clock.el|  2 +-
 lisp/org-duration.el |  2 +-
 lisp/org-faces.el|  2 +-
 lisp/org-footnote.el |  2 +-
 lisp/org-list.el |  4 ++--
 lisp/org.el  | 23 +++
 lisp/ox-odt.el   |  2 +-
 10 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index df128441a..dc33ebc17 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -107,7 +107,7 @@ you can leave the string empty on this case."
   :package-version '(Org . "8.2.7")
   :set
   (lambda (symbol value)
-(set symbol value)
+(set-default-toplevel-value symbol value)
 (setq
  org-babel-lilypond-ly-command   (nth 0 value)
  org-babel-lilypond-pdf-command  (nth 1 value)
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index c25941a44..4454e3b5d 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -68,7 +68,7 @@ outside the Customize interface."
   :group 'org-babel
   :type '(repeat (string :tag "Shell name: "))
   :set (lambda (symbol value)
-(set-default symbol value)
+(set-default-toplevel-value symbol value)
 (org-babel-shell-initialize)))
 
 (defcustom org-babel-shell-results-defaults-to-output t
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 773234967..948eb8bc6 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -376,7 +376,7 @@ When you need to insert a literal percent sign in the 
template,
 you can escape ambiguous cases with a backward slash, e.g., \\%i."
   :group 'org-capture
   :package-version '(Org . "9.5")
-  :set (lambda (s v) (set s (org-capture-upgrade-templates v)))
+  :set (lambda (s v) (set-default-toplevel-value s 
(org-capture-upgrade-templates v)))
   :type
  

Re: [PATCH] Re: New source block results option for attaching file to node

2022-06-11 Thread Ryan Scott
Had no experience with the :DIR: property or writing unit tests for Org,
but I think I've got both covered now.
The ID creation prompting now only happens if there is no result from
org-attach-dir, which should address the :DIR: case.

Let me know if there's anything about those tests that I should modify.

Thanks,
  -ryan

On Fri, Jun 10, 2022 at 9:31 PM Ihor Radchenko  wrote:

> Ryan Scott  writes:
>
> > I believe I have addressed your feedback, Ihor.
> > Attached is the latest version of the patch.
> >
> >- Merged latest master
> >- :post is now handled correctly (verified with example of :post usage
> >in the example at
> https://orgmode.org/manual/Results-of-Evaluation.html)
> >- Added "(with quotes)" to help make the NEWS entry clearer
> >- Changed the attach directory detection to use a string prefix check
> >
> > Let me know what you think.
>
> Thanks for the updated patch!
>
> > +  ((or '(:dir . attach) '(:dir . "'attach"))
> > +   (unless (org-id-get)
> > + (if (or noninteractive (y-or-n-p (format "Create ID for
> entry \"%s\"?"
> > +  (org-get-heading
> t t t t
> > + (org-id-get-create)
> > +   (error "Can't attach to entry \"%s\". Entry has no ID"
> > +  (org-get-heading t t t t
> > +   (setq params (append
> > + `((:dir . ,(org-attach-dir nil t))
> > +   (:mkdirp . "yes"))
> > + (assq-delete-all :dir (assq-delete-all :mkdir
> params)
>
> Note that entry does not need :ID: property to have an attachment dir.
> There is also :DIR: property.
>
> Also, it would be useful to add a test. See test-ob-core/dir-mkdirp in
> testing/lisp/test-ob.el
>
> Best,
> Ihor
>


org-src-block-results-attach-dir.patch
Description: Binary data


Re: [PATCH] ob-clojure.el: Add support for babashka and nbb backend

2022-06-11 Thread Ihor Radchenko
Daniel Kraus  writes:

> just wanted to bump this thread and ask if I can do anything
> to move this forward?
> I'm using it since a few month and works for me.

Sorry for the late reply.

I am not familiar at all with clojure, so it is hard for me to test the
patch. It would help if you also provide the tests in
testing/lisp/test-ob-clojure.el to check the added functionality.

Best,
Ihor



Re: [BUG] org-element-cache "rx '**' range error" [9.6 (9.6-??-8f50ea2d6 @ /home/samc/.emacs.d/.local/straight/build-27.2/org/)]

2022-06-11 Thread Ihor Radchenko
Samuel Crawford  writes:

> I found a couple of workarounds: adding (org-reload) to my init.el
> (actually config.el as I'm running doom emacs) solves the problem, though
> it does add another second to my load time. Alternatively, I was able to
> load the first set of minor modes without issue by using doom's (after!
> pdf-tools ...). This didn't seem to work for the latter minor modes though.

A cannot deduce anything meaningful out of this info.
If you are still seeing the problem, posting the backtrace would be
helpful.

Best,
Ihor



Re: [BUG] org-copy-subtree in a file with local variables marks buffer as modified [9.5.3 (release_9.5.3-6-gef41f3 @ /home/ignacio/repos/emacs/lisp/org/)]

2022-06-11 Thread Ihor Radchenko
Ignacio Casso  writes:

> What would you think about a change like the following in the definition of
> `org-preserve-local-variables' to solve the issue?
>
> + (let ((modified-before-p) (buffer-modified-p))
> ;; current code that deletes local variables
> +   (unless modified-before-p (set-buffer-modified-p nil))
> ;; current code that executes body
> +   (let ((modified-after-p (buffer-modified-p)))
>   ;; current code that restores local variables
> + (unless modified-after-p (set-buffer-modified-p nil
>
> Could the current code or my proposed change have any more unintended
> consequences, for example in the undo tree or mark ring? Sometimes when
> I undo or jump to the mark, the point moves to the last visible, usually
> folded headline of the file, even if I had not edited it recently, and I
> have always assumed that it's because it wants to go to the end of the
> buffer for some reason I've never been able to come up with or
> debug. Could that have something to do with this?

buffer-modified-p is not the only parameter affected by juggling around
the local variables. There will be undo history,
buffer-chars-modified-tick, before/after-change-hooks triggered by
`org-preserve-local-variables', etc.

However, I do not see any obvious way how your proposed change can
negatively affect all the above. Feel free to propose a patch.

Best,
Ihor




Re: Org.texi (the Org Manual) in ePub format

2022-06-11 Thread Pedro Andres Aranda Gutierrez
Perry Smith writes:

> For Apple losers like me, ePub is so much nicer than PDFs in Apple
Books.  All the features come to life such as book marks, notes,
highlighting, etc.  And they are saved.  Almost like we rocketed into 1990.

You don't have to be an Apple loser to think ePub is nice. There are ePub
reader programs in Linux which allow all you say :-)
And yes, is convenient for almost anything (except printing).
And yes, you can have your ebook reader on the side, almost as you had the
printed programming manuals in times passed.

To get from texinfo to ePub, the easiest way is, I guess, to converto to
split (x)HTML files, pack the result in a 'sofisticated' ZIP
file,(sophisticated in the sense that you have to add a couple more XML
files to it) and rename it to .epub

Wouldn't be too difficult to come up with a smallish program to do that...

Best, /PA

-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log (and in real life):
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet