Re: [PATCH] Re: org-bibtex does not recognise @Comment

2021-08-28 Thread Colin Baxter
> Ihor Radchenko  writes:

> Colin Baxter  writes:
>> > Well. It will import the files. However, org-bibtex-write will
>> > indeed fail. If I got it wrong, please provide more details.
>> 
>> > Confirmed
>> 
>> > The fix is attached.
>> 
>> I've applied your patch to my local git branch of org-mode and it
>> works very nicely. I can live with the write fail you mentioned.

> Let me clarify. On my side, org-bibtex-read-file did not throw any
> error on a .bib file with comment. Is it any different for you?

Sorry, my first reply was garbled. No there is no difference,
org-bibtex-read-file and org-bibtex-import-from-file now do not give any
errors for me.

Thanks again.



Re: [PATCH] Re: org-bibtex does not recognise @Comment

2021-08-28 Thread Ihor Radchenko
Colin Baxter  writes:

> > Well. It will import the files. However, org-bibtex-write will
> > indeed fail. If I got it wrong, please provide more details.
>
> > Confirmed
>
> > The fix is attached.
>
> I've applied your patch to my local git branch of org-mode and it works
> very nicely. I can live with the write fail you mentioned.

Let me clarify. On my side, org-bibtex-read-file did not throw any error
on a .bib file with comment. Is it any different for you?

The patch is supposed to fix org-bibtex-write -- the only problem I was
able to see following your email.

> Will you apply it to the master branch of org-mode?

Nope. We need to wait for the maintainers with write access to apply it.

Best,
Ihor



Re: [PATCH] Re: org-bibtex does not recognise @Comment

2021-08-28 Thread Colin Baxter
Hello Ihor,

> Ihor Radchenko  writes:

> Colin Baxter  writes:
>> I've noticed that "org-bibtex-import-from-file" will not import
>> from bib files which begin with the standard bibtex mode-line
>> heading of
>> 
>> @Comment -*- mode: bibtex; -*-

> Well. It will import the files. However, org-bibtex-write will
> indeed fail. If I got it wrong, please provide more details.

> Confirmed

> The fix is attached.

I've applied your patch to my local git branch of org-mode and it works
very nicely. I can live with the write fail you mentioned. Will you
apply it to the master branch of org-mode?

Thank you.

Best wishes,

Colin.



Re: ob-lilypond.el doesn't generate midi files

2021-08-28 Thread Michael Maurer
On Sat, 28 Aug 2021 at 15:09, Jonathan Gregory  wrote:
>
> Hi Michael
>
> On 28 Aug 2021, Michael Maurer wrote:
>
> > So out of curiosity I changed the entry for midi-player to
> > random gibberish, and the same message pops up, "no midi file
> > generated so can't play". Toggling arrange-mode has no effect. I
> > can play the generated midi-file from the command line using vlc
> > just fine.
>
> What variable are you using to change the midi command? It should
> be org-babel-lilypond-commands. You may also have to restart emacs
> after you've made the changes. BTW I'm using timidity and it works
> fine.
>

I use M-x customize, search for lilypond and then get the config panel
for org-babel-lilypond-commands.
Btw I've set up timidity, checked if it works correctly and then
change the value from vlc to timidity, but same result.

Aaah wait, I'm currently looking at ob-lilypond.el, and it's looking
for a file that ends with *.midi, but lilypond on Windows generates
*.mid files.
Ok I'll see if that's it after dinner.



[PATCH] Re: org-bibtex does not recognise @Comment

2021-08-28 Thread Ihor Radchenko
Colin Baxter  writes:

> I've noticed that "org-bibtex-import-from-file" will not import from bib files
> which begin with the standard bibtex mode-line heading of
>
> @Comment -*- mode: bibtex; -*-

Well. It will import the files. However, org-bibtex-write will indeed
fail. If I got it wrong, please provide more details.

Confirmed

The fix is attached.

Best,
Ihor

>From 248a594fb89820a6ee2ca5782f98502851c9a315 Mon Sep 17 00:00:00 2001
Message-Id: <248a594fb89820a6ee2ca5782f98502851c9a315.1630157370.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Sat, 28 Aug 2021 21:23:43 +0800
Subject: [PATCH] org-bibtex-read: Do not add nil when there is no entry at
 point

* lisp/ol-bibtex.el (org-bibtex-read): Previously, when there is no
entry at point, `nil' would be added to `org-bibtex-entries' causing
errors later, i.e. upon calling org-bibtex-write.  Now, nil is never
pushed to `org-bibtex-entries'.

Fixes https://orgmode.org/list/874kd3288n@yandex.com
---
 lisp/ol-bibtex.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 4970be9c4..e70d847b4 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -677,7 +677,8 @@ (defun org-bibtex-read ()
(_ field)))
(funcall clean-space (funcall strip-delim (cdr pair)
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
-  org-bibtex-entries)))
+  org-bibtex-entries)
+(unless (car org-bibtex-entries) (pop org-bibtex-entries
 
 (defun org-bibtex-read-buffer (buffer)
   "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
-- 
2.31.1



Re: Bug: org-edit-special indents inline latex [9.5 (nil @ /home/david/.emacs.d/.local/straight/build-27.2/org-mode/)]

2021-08-28 Thread Ihor Radchenko
Dávid Jakab  writes:

> When using org-edit-special to edit inline latex, i.e., equations 
> between \( and \), in an org-mode buffer, a number of
> spaces may get inserted before \( after the latex editing minibuffer is 
> closed.

Confirmed

Recipe:

1. Insert the following into a new Org mode buffer (note the indentation):

   \(x^{2}+3=\frac{2}{1}\)

2. Move point to the equation
3. M-x org-edit-special 
4. M-x org-edit-src-exit 
5. Observe the equation indented twice more

Best,
Ihor



Re: ob-lilypond.el doesn't generate midi files

2021-08-28 Thread Jonathan Gregory

Hi Michael

On 28 Aug 2021, Michael Maurer wrote:

So out of curiosity I changed the entry for midi-player to 
random gibberish, and the same message pops up, "no midi file 
generated so can't play". Toggling arrange-mode has no effect. I 
can play the generated midi-file from the command line using vlc 
just fine.


What variable are you using to change the midi command? It should 
be org-babel-lilypond-commands. You may also have to restart emacs 
after you've made the changes. BTW I'm using timidity and it works 
fine.


--
Jonathan



Re: ob-lilypond.el doesn't generate midi files

2021-08-28 Thread Michael Maurer
On Fri, 27 Aug 2021 at 21:55, Nick Dokos  wrote:
>
> Michael Maurer  writes:
>
> > On Thu, 26 Aug 2021 at 21:54, Nick Dokos  wrote:
>
> >>
> >> Michael Maurer  writes:
> >>
> >> > On Thu, 26 Aug 2021 at 15:03, Jonathan Gregory  
> >> > wrote:
> >> >>
> >> >> Hi
> >> >>
> >> >> On 26 Aug 2021, Michael Maurer wrote:
> >> >>
> >> >> > I've installed lilypond and customized ob-lilypond to use the
> >> >> > appropriate helper programs, but although it generates & shows
> >> >> > pdfs just fine, generating a midi file it does not. I execute
> >> >> > tangle on the codeblock, and all I get is "No midi file
> >> >> > generated so can't play!". org-version 9.4.6 emacs 27.2 Win 10
> >> >>
> >> >> Can you also send a MWE of the code you're using to generate the
> >> >> score?
> >> >>
> >> >
> >> > I used a test file I copied over from Frescobaldi
> >> >
> >> > #+begin_src lilypond :file test.pdf
> >> > \version "2.18.2"
> >> > \score {
> >> > \drums {
> >> >   \time 2/4
> >> >   sn16 sn8 sn16 sn8 sn8:32 ~
> >> >   sn8 sn8 sn4:32 ~
> >> >   sn4 sn8 sn16 sn16
> >> >   sn4 r4
> >> > }
> >> >   \layout { }
> >> >   \midi { }
> >> > }
> >> > #+end_src
> >> >
> >> > In Frescobaldi this gets me both midi-output and pdf. In Emacs with
> >> > org it does say "Midi output to test.midi", but then there's that "no
> >> > midi file generated" message.
> >> >
> >>
> >> What happens if you save the contents of the source block into a file
> >> and run lilypond on the file from the command line?
> >>
> >
> > Both pdf and midi files get generated. Btw, ob-lilypond does generate
> > the midi file as well, it just doesn't want to play it/recognize it.
> > Maybe it's related to what helper app I've configured to open it? (but
> > why that doesn't make sense, it's vlc btw).
> >
> >
>
> Oh, I thought that it did not generate a midi file at all. So you are
> saying that the midi file *is* produced and you *can* play it from the
> command line with vlc, correct?
>
> If that's the case, check the value of the variable
> `org-babel-lilypond-midi-command' and see what happens when you invoke
> that command on the midi file. In my case, the command is `xdg-open'
> (I'm using Gnome on Fedora 33) and it opens Banshee to play it which
> fails because of missing codecs. I installed the missing codecs and
> `xdg-open foo.midi' sends the file to Banshee which can play it fine.
>
> Also check if `org-babel-lilypond-arrange-mode' is t or nil: behavior
> is very different depending on that.

So out of curiosity I changed the entry for midi-player to random
gibberish, and the same message pops up, "no midi file generated so
can't play". Toggling arrange-mode has no effect. I can play the
generated midi-file from the command line using vlc just fine.



Re: Org table: numeric locale

2021-08-28 Thread Maxim Nikulin

On 28/08/2021 14:07, Jarmo Hurri wrote:


I wonder if it is possible to get org table formulas to respect numeric
locale.


Even to add some functions to Emacs that respect numeric locales, it is 
necessary to use e.g. dynamic modules (warning: do not try to change 
global locale by setlocale(3), almost certainly something in Emacs will 
be broken, a library that allows local locale objects is strongly 
preferred).

https://www.gnu.org/software/emacs/manual/html_node/elisp/Writing-Dynamic-Modules.html


Emacs documentation says that Emacs uses the value of LC_NUMERIC:

https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html


It is a confusing statement, see:
- https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29645
  #29645 Feature Request: Locale aware formatting
  Date: Sun, 10 Dec 2017 15:05:02 UTC
- https://lists.gnu.org/archive/html/emacs-devel/2021-06/msg00327.html
  https://lists.gnu.org/archive/html/emacs-devel/2021-06/msg00139.html

The state of numeric locales in Emacs is a little worse than just 
unsupported. Mostly "C" is forced for LC_NUMERIC, so e.g. grouping is 
not used. However if your locale uses comma "," as decimal separator,

you may be confused by calc results:

M-x calc RET dg RET 123456
123,456




Re: Smart quotes for Greek (questions for a possible patch)

2021-08-28 Thread Protesilaos Stavrou
On 2021-08-16, 00:28 +0300, mvar  wrote:

> Juan Manuel Macías  writes:
>
>> Hi,
>>
>> I would like to submit a patch to add smart quotes for Greek in
>> `org-export-smart-quotes-alist', but I have a couple of questions.
>>
>> First of all, I am not a native speaker of Greek but of Spanish, so I
>> would also like to have the opinion of some Greek native speaker, to see
>> if my solutions are correct.
>>
>> The second question concerns the second-level quotation marks for Greek.
>> The first level ones are the same as the Spanish or French quotes
>> (without the extra space of French): «», so no problem. I follow here
>> the rule that Yannis Haralambous explains in "From Unicode to
>> Typography, a Case Study: the Greek Script" (1999, p. 20:
>> http://web.archive.org/web/20120229131933/http://omega.enstb.org/yannis/pdf/boston99.pdf).
>>
>> According to Haralambous, on the second-level quotation marks (the
>> emphases are mine):
>>
>> #+begin_quote
>>
>> Also interesting is the case of the second level quotes. Here, quotes of
>> the size and shape of the English ones are used, but the opening quotes
>> are inverted, similar in form to raised small round guillemets [...].
>> Fortunately these quotes are provided by the Unicode standard (*U+201F*
>> and U+201D, the latter being the same closing double quotes as in
>> English); *the author knows no other language in which this combination
>> of double quotes might be used*.
>>
>> #+end_quote
>>
>>
>> So the problem is in the character U+201F (assuming Haralambous is
>> right). For the keywords `:utf8' and `html' no problem. But I don't know
>> what to put in `:latex' or in `:texinfo':
>>
>> #+begin_src emacs-lisp
>> (secondary-opening :utf-8 "‟" :html "‟;" :latex "??" :texinfo "??")
>> #+end_src
>>
>> In fact, I think latex2e has no command or shorthand predefined for this
>> character (see https://ibb.co/ZBGmwYP). There would be no problem with
>> LuaTeX and XeTeX. But this character would be difficult to obtain in
>> pdfTeX even using inputenc with the utf8 option.
>>
>> Best regards,
>>
>> Juan Manuel
>
> hi Juan,
>
> i can confirm the «» characters are the proper ones for the first level
> of quoting..Now about second level, personally i haven't seen such nesting in
> ages but IIRC they should be the ones (or *very* similar) in the linked image 
> you posted ->
> \textquotedblleft and \textquotedblright. I've no idea how these
> translate to UTF. Note that the standard greek keyboards & keymaps do not have
> any of these characters mapped by default (not even «» ), most people use the 
> standard
> english double/single quotes, at least in electronic writing (articles,
> daily communication etc).
> Protesilaos (cc) might have a better view on this matter.
>
> cheers,
> Michalis

Hello Michalis, Juan Manuel,

[ I had no access to a computer and could not get to you sooner.  Expect
  timely replies from now on. ]

The first level quotes are indeed «».  For the other two, I have to rely
on what I have encountered before, namely, that the second level is
denoted with double curly quotes “” and third with single curly quotes
‘’.

I have come across those in EU documents.  There is a style guide for
the European Institutions.[1][2][3]

I do not know latex notation to help you with the technicalities.
Here are the unicode points:

| « | U+00AB |
| » | U+00BB |
| “ | U+201C |
| ” | U+201D |
| ‘ | U+2018 |
| ’ | U+2019 |

All the best,
Protesilaos

[1] Quotes: .
[2] General info: .
[3] Main portal: .


-- 
Protesilaos Stavrou
https://protesilaos.com


Re: ob-lilypond.el doesn't generate midi files

2021-08-28 Thread Maxim Nikulin

On 28/08/2021 02:54, Nick Dokos wrote:


Also check if `org-babel-lilypond-arrange-mode' is t or nil: behavior
is very different depending on that.

Final thought: `xdg-open' starts whatever app it is supposed to run
in the background and returns immediately. That may cause problems with
babel.


To be precise, xdg-open is merely a wrapper. It does not decide whether 
a viewer should be started in background or in foreground, it just 
delegates decision concerning particular application and a way to start 
it to desktop environment (if any is running). Gnome's gio open and 
kde-open5 launch appropriate viewer in background. In my opinion they 
are free to do so.


It is a decade-old problem that emacs kills such processes. I disagree 
that it is e.g. Gnome bug.

https://lists.gnu.org/archive/html/emacs-devel/2009-07/msg00279.html

ob-lilypond.el suffers from this problem in its original form, and it 
should be fixed.


Approach taken in Org mode for compatibility reasons:
https://code.orgmode.org/bzg/org-mode/commit/869b7a21b94ed112f6640c8f2711c2a68b661dea
Emacs mailcap:
http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/net/mailcap.el#n1180

Pipe process instead of pty one is not a really robust way. The sour 
truth is that emacs API does allow reliable "shoot and forget" approach 
for external applications. Currently viewers might make Emacs CPU hungry 
for no reason (unsure if applications with such behavior exist in real 
world however). Eli Zaretskii suspects some incompatibility due to 
switching from pty to pipe processes, but he refused to provide details

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=12972#38




Org table: numeric locale

2021-08-28 Thread Jarmo Hurri


Greetings.

I wonder if it is possible to get org table formulas to respect numeric
locale.

Emacs documentation says that Emacs uses the value of LC_NUMERIC:

https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html

However, even though I have a value of LC_NUMERIC which specifies comma
as a decimal separator, I get dot as a decimal separator when formatting
a floating point value in both elisp and in org table formula. So yes, I
am aware that the source of the issue is likely to be in Emacs, but I
only need a solution for org only.

The example at the end of this message tries to illustrate all aspects:
what my environment variables are, what Emacs sees and does, what org
does, and how to force locale in another language (C++).

Have fun and stay safe,

Jarmo

# -
* My relevant locale variables in shell
  #+begin_src sh
echo "LANG: ${LANG}"
echo "LC_ALL: ${LC_ALL}"
echo "LC_NUMERIC: ${LC_NUMERIC}"
  #+end_src

  #+RESULTS:
  | LANG:   | en_GB.UTF-8 |
  | LC_ALL: | |
  | LC_NUMERIC: | fi_FI.UTF-8 |

* What emacs sees and does
  Emacs uses dot, not comma, as decimal separator.
  #+begin_src elisp
(let ((env (mapconcat 'getenv (list "LANG" "LC_ALL" "LC_NUMERIC") " "))
  (str (format "%.2f" (/ 1.0 3
  (concat env "\n" str "\n" (emacs-version)))
  #+end_src

  #+RESULTS:
  : en_GB.UTF-8  fi_FI.UTF-8
  : 0.33
  : GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.30, 
cairo version 1.17.4)
  :  of 2021-08-07

* What Org table does
  Org table also uses dot, not comma, as decimal separator.
  | 0.33 |
  #+TBLFM: @1$1=1.0/3;%.2f

* C++ version (for comparison)
  #+begin_src C++ :results raw
#include 
#include 
#include 

int main (int argc, char* argv[])
{
// I have to set locale, it is not obtained automatically from
// shell environment
setlocale (LC_NUMERIC, getenv ("LC_NUMERIC"));

printf ("%.2f", 1.0 / 3);
exit (0);
}
  #+end_src

  #+RESULTS:
  0,33
# -