Re: [PATCH] org-table: Add mode flag to enable Calc units simplification mode

2020-11-24 Thread Daniele Nicolodi
Thank you for the review, Kyle.

Another updated patch set is attached.

Cheers,
Dan


On 24/11/2020 06:35, Kyle Meyer wrote:
> Daniele Nicolodi writes:
> 
>> Subject: [PATCH 1/3] org-table: Remove unused org-tbl-calc-modes variable
>>  declaration
> 
> Looks good.
> 
>> Subject: [PATCH 2/3] org-table: Simplify mode string parsing
>> and reduce scope of local variables.
> [...]
>> -  (if (string-match ";" formula)
>> -  (let ((tmp (org-split-string formula ";")))
>> -(setq formula (car tmp)
>> -  fmt (concat (cdr (assoc "%" org-table-local-parameters))
>> -  (nth 1 tmp)))
>> +  (if (string-match "\\(.*\\);\\(.*\\)" formula)
>> +  (progn
>> +(setq fmt (concat (match-string-no-properties 2 formula)
>> +  (cdr (assoc "%" org-table-local-parameters
> 
> Hmm, the concat arguments are getting swapped.  Intentional?
> 
> The rest looks good.
> 
>> Subject: [PATCH 3/3] org-table: Add mode flag to enable Calc units
>>  simplification mode
>>
>> * org-table.el (org-table-eval-formula): Add the `u` mode flag to
>> enable Calc's units simplification mode.
>>
>> * test-org-table.el (test-org-table/mode-string-u): Add Unit test for
>> the new mode flag.
>>
>> * org-manual.org: Document new mode flag.
>> ---
>>  doc/org-manual.org |  8 
>>  etc/ORG-NEWS   |  7 ++-
>>  lisp/org-table.el  |  5 +++--
>>  testing/lisp/test-org-table.el | 12 
>>  4 files changed, 29 insertions(+), 3 deletions(-)
> 
> Thanks for the additions.
> 
>> diff --git a/doc/org-manual.org b/doc/org-manual.org
>> index be69996d5..70b748fc7 100644
>> --- a/doc/org-manual.org
>> +++ b/doc/org-manual.org
>> @@ -2075,6 +2075,14 @@ variable ~org-calc-default-modes~.
>>  
>>Fraction and symbolic modes of Calc.
>>  
>> +- =u= ::
>> +
>> +  Units simplification mode of Calc. Calc is also a symbolic
> 
> convention nit: two spaces after a period
> 
>> +  calculator and is capable of working with values having an unit
>> +  (numerals followed by an unit string in Org table cells). This mode
>> +  instructs Calc to simplify the units in the computed expression
>> +  before returning the result.
>> +
>>  - =T=, =t=, =U= ::
>>  
>>Duration computations in Calc or Lisp, [[*Durations and time values]].
>> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
>> index 889eb4aab..6f6db8e43 100644
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>> @@ -60,7 +60,7 @@ relative links within a project as follows:
>>  #+end_src
>>  
>>  ** New features
>> -*** =ob-python= improvements to =:return= header argument 
>> +*** =ob-python= improvements to =:return= header argument
> 
> unrelated space change
> 
>>  The =:return= header argument in =ob-python= now works for session
>>  blocks as well as non-session blocks.  Also, it now works with the
>> @@ -112,6 +112,11 @@ package, to convert pandas Dataframes into orgmode 
>> tables:
>>  | 2 | 3 | 6 |
>>  #+end_src
>>  
>> +*** New =u= table formula flag to enable Calc units simplification mode
>> +
>> +A new =u= mode flat for Calc formulas in Org tables has been added to
>> +enable Calc units simplification mode.
> 
> s/flat/flag/
> 

From d2ab4d06e19620c0347425861e4534cde8656543 Mon Sep 17 00:00:00 2001
From: Daniele Nicolodi 
Date: Mon, 23 Nov 2020 23:44:51 +0100
Subject: [PATCH 1/3] org-table: Remove unused org-tbl-calc-modes variable
 declaration

* org-table.el (org-tbl-calc-modes): Remove variable declaration as
the varialble is used only within `org-table-eval-formula'.

* org-table.el (org-table-eval-formula): Rename `org-tbl-calc-modes`
local variable without the `org-tbl-` prefix and use the gained screen
real estate to avoid indirection through covenience macro. This
requires moving the mode lookup table from `org-table--set-calc-mode`
to here.

* org-table.el (org-table--set-calc-mode): Drop convenience macro.
Note that the macro was not working as intended when the caller tried
to add a new entry in the plist as in this case the macro would create
a new plist with the added entry but return the old one.
---
 lisp/org-table.el | 42 +++---
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 112b1e171..a3b73a828 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -676,8 +676,6 @@ Will be filled automatically during use.")
 ("_" . "Names for values in row below this one.")
 ("^" . "Names for values in row above this one.")))
 
-(defvar org-tbl-calc-modes nil)
-
 (defvar org-pos nil)
 
 
@@ -721,18 +719,6 @@ Field is restored even in case of abnormal exit."
 (org-table-goto-column ,column)
 (set-marker ,line nil)
 
-(defsubst org-table--set-calc-mode (var &optional value)
-  (if (stringp var)
-  (setq var (assoc var '(("D" calc-angle-mode deg)
-("R" calc-angle-mode rad)
-("F" calc-prefer-

Org 9.3.8 for Emacs 27.2?

2020-11-24 Thread Kévin Le Gouguec
Hi Org,

It seems the Emacs maintainers are gearing up for the release of 27.2,
the first bugfix version of Emacs 27[1][2].

27.1 ships with Org 9.3, which has seen its last bugfix release with
9.3.8.  Is there any way we[3] can help bring 9.3.8 into the emacs-27
branch in time for 27.2?

Thanks for your time.


[1] bug-gnu-em...@gnu.org <83k0ubvppt@gnu.org>
https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-11/msg01630.html

[2] bug-gnu-em...@gnu.org 

https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-11/msg01649.html

[3] Read: users with no commit access to any repository, and no
first-hand experience with the synchronization process.



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Ihor Radchenko  [2020-11-23 08:43]:
> >> I am wondering what you mean by Org's philosophy. Why would it have 
> >> anything to do with directories?
> >
> > Org's philosophy is to have one or a handful of directories without
> > nesting of directories.  Users are not expected to have their Org
> > files in a deeply nested tree.  Org also prefers big files with large
> > trees rather than lots of little files.
> >
> > By philosophy, I mean the dev consensus on the correct way to do
> > things, and coded configuration and usability biases.
> 
> I believe that org support all possibilities. The user can decide to
> keep many (possibly nested) org files, a few large org files, or
> anywhere in between. There are several parallel feature sets allowing to
> work in a single file as well as with a bunch of smaller files.

Yes, sure, and I guess you mentioned some people have problems with
many files. And I have no problem at all with many files as they are
per subject separated, per person or per subject separated. They are
not hyperlinked to each other, it is me who make system to hyperlink
to files.

Searching for Joe Doe, F4 and I am in Org file for Joe Doe. My
personal TODO list need not really show the tasks assigned to Joe Doe,
I could show only * TODO Joe Doe and when I click there then I can get
all tasks for Joe Doe as new Org file.

It means I am accessing hundreds of Org files from the meta level by
using conceptual location backed by the database.

Some people maybe access multiple Org files through Agenda, me I
don't. Some items are "non existent" and I do not know how to ask
agenda to refresh itself. This is not big deal as I do not access
items throgh Agenda, though I find it very useful. 

org-agenda is trying to put all tasks and notes from various files
into one list and that is of course not so easy task considering that
files can be anywhere on the file system and that they need to be
"remembered". 

> For a single file, the user can search headings with org-goto (without a
> need to explicitly travel through all the nesting headline levels),
> reveal only headings satisfying certain keyword/tag/any other search
> criteria with org-sparse-tree, or built agenda views restricted to a
> single file (or even subtree).

M-x org-goto is useful feature to find headlines. And I never use it,
just standard Emacs search is enough within a file. Meanings I am
searching are often inside of the headline. And it is not my perosnal
way locating things.

Personally, I am using parts of Org, like specific headling to export
it and to send to remote person, or to print the file as project and
to bind it nicely.

When I see repetitive action, for example that I have to send "Daily
Report" template to a person by email, than I just bookmark that in
Emacs with {C-x r m} under something that I think is the meaning of
it. Then I forget about it. Next time when I need to send report, I am
{C-x r b} and quickly completing it and then I am exporting and
inserting into the email.

In general I speak of subsets or sub-lists among lists. List of Org
files is one list, list of headings within Org file is other list, and
list of specific subject related headings or bookmarks to such is
third subset of lists.

> For multiple files located anywhere in the filesystem, there is always
> org-refile capable of filing the information to proper place
> searching deeply nested headlines with ease regardless of the file the
> information is physically located in. Headlines from multiple files can
> be grouped using agenda views for any given search criteria (showing
> todo items or items for a single day/week is just a tiny subset of what
> agenda can do).

That may be useful for those who find it while my use case is
different, here is how it is for me:

** TODO Heading [1/2] [50%]

1) [X] Do this
2) [ ] Do that

that is my personal use case. I do not do things like:

** TODO Do this

Description of the task

And so far I know org-refile works on headings. It does not work on
list items.

Sometimes the task describes something that belongs to other file, I
just kill and yank to other file. And I keep RCS revision control
system of files.

As user may have many various sparse tasks to do or notes that require
action and attention in soonest future it is best to consolidate tasks
into one centralized system.

Such system should encompass all tasks or notes that require attention
or action in soonest future and should offer constant reminders to
user on what has to be done and when and which people are related to
the task.

When I mentioned "sparse tasks" I refer to my usage and handling of
mess:

1) Bunch of Org files, org-agenda and Org mode tries to accommodate me
   by consolidating everything into lists

2) There are hundreds of such tasks all over, Org tries to consolidate
   it.

3) There are various tasks and actions to do that are not recorded in
   Org files, those cannot be handled by Org.

4) There are database based Tasks

Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Gerardo Moro
Hi,

See org-store-link and org-insert-link. org-store-link stores link in a
> link ring and the link/links can be later inserted using
> org-insert-link.
>

org-store-link would work only within Emacs, not for the case of copying
http links in the browser, right?


org-store-link


Re: One vs many directories

2020-11-24 Thread Eric S Fraga
On Tuesday, 24 Nov 2020 at 12:00, Jean Louis wrote:
> Can I automated the execution of Babel code upon opening of the Org
> file?

You can, by using file local variables.  For instance, for some files, I
do this:

#+begin_src org
  ,* local variables :noexport:
  # Local Variables:
  # eval: (org-sbe "startup")
  # End:
#+end_src

which will evaluate the named src block "startup" when file is opened.

Note that this is a potential security hole so only do this for files
you trust!

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-118-g2a4578.dirty



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread John Sturdy
I've got a rather specialized version of that at
https://github.com/hillwithsmallfields/JCGS-emacs/blob/master/special-setups/tasks/org-agenda-kiosk.el

It's aimed at navigating a collection of org-mode files via the numeric
keypad only, and I wrote it to go with some custom hardware I made (a
screen and keypadded embedded in a corkboard, so I can keep all my "things
to do" lists together, whether on paper or on the computer), hence it
having mappings for a keypad rotated 90degrees!

__John

On Sun, Nov 22, 2020 at 10:02 AM Gerardo Moro 
wrote:

> Basically that :)
> I'm looking for some setup that allows me to open a menu with a list of
> files and shortcut access keys to open them.
>
> Probably somebody has done this before.
>
> Thank you,
> GM
>


Re: One vs many directories

2020-11-24 Thread Jean Louis
* Eric S Fraga  [2020-11-24 12:46]:
> On Tuesday, 24 Nov 2020 at 12:00, Jean Louis wrote:
> > Can I automated the execution of Babel code upon opening of the Org
> > file?
> 
> You can, by using file local variables.  For instance, for some files, I
> do this:
> 
> #+begin_src org
>   ,* local variables :noexport:
>   # Local Variables:
>   # eval: (org-sbe "startup")
>   # End:
> #+end_src
> 
> which will evaluate the named src block "startup" when file is opened.
> 
> Note that this is a potential security hole so only do this for files
> you trust!

For me is fine, as I do that for files I create.

When I have opened this email i was also asked to set local variables,
imagine. So that could maybe also mean that one could send email that
is constructed as Org file and if user answers YES, one could inject
malicious stuff.

--- the text above ---
still asks me if I like to allow eval: (org-sbe "startup")

So I think this is bug in Emacs as Local-variables should be on the
end of the file.



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Ihor Radchenko
> org-store-link would work only within Emacs, not for the case of copying
> http links in the browser, right?

Indeed. If you want to copy "[[url][title]]" string directly from
browser, you should probably write a simple bookmarklet. I have seen
someone sharing it in reddit, but cannot find the comment anymore.
In any case, you might look at
https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
for ideas how to do it.

Also, you can capture webpage as a heading using org-capture +
org-protocol:
1. https://addons.mozilla.org/en-US/firefox/addon/org-capture/
2. 
https://chrome.google.com/webstore/detail/org-capture/kkkjlfejijcjgjllecmnejhogpbcigdc
3. https://seds.nl/notes/orgmode-firefox-bookmark/
4. https://github.com/yantar92/org-capture-ref (shameless plug)

Or you can write a custom org-capture handler that invokes org-store-link

Best,
Ihor

Gerardo Moro  writes:

> Hi,
>
> See org-store-link and org-insert-link. org-store-link stores link in a
>> link ring and the link/links can be later inserted using
>> org-insert-link.
>>
>
> org-store-link would work only within Emacs, not for the case of copying
> http links in the browser, right?
>
>
> org-store-link



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Detlef Steuer
Am Tue, 24 Nov 2020 09:53:15 +
schrieb John Sturdy :

> It's aimed at navigating a collection of org-mode files via the
> numeric keypad only, and I wrote it to go with some custom hardware I
> made (a screen and keypadded embedded in a corkboard, so I can keep
> all my "things to do" lists together, whether on paper or on the
> computer), hence it having mappings for a keypad rotated 90degrees!


Would you mind to share a picture? Or two?

Detlef



Re: One vs many directories

2020-11-24 Thread Eric S Fraga
On Tuesday, 24 Nov 2020 at 12:51, Jean Louis wrote:
> So I think this is bug in Emacs as Local-variables should be on the
> end of the file.

"end of file" is a rather loose term when it comes to local variables...
-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-118-g2a4578.dirty



Differentiate source blocks in export?

2020-11-24 Thread Joost Kremers
Hi all,

I was wondering if there's a way to distinguish between different kind of source
code blocks when exporting to HTML.

Specifically, I would like a way to mark certain code blocks in my Org file so
that those code blocks get a specific class in the HTML export. I can then style
them with some CSS to make them stand out visually. I know I can use special
blocks to get divs with a custom class, but I don't want to lose all the
benefits of code blocks...

I tried Google and the Org manual but I haven't been able to find anything on
this.

TIA

-- 
Joost Kremers
Life has its moments



Re: ob-python: import local package into a session

2020-11-24 Thread Maxim Nikulin

2020-11-23 Joost Kremers wrote:


I can include packages installed in
`site-packages` and have them available in all code blocks. But is there a way
to import my own packages into a session? In particular, packages I haven't
installed system-wide?


I do not have a recipe ready for using with org mode, and maybe you have 
already tried the following instruments:


1. Besides system-wide site-packages directory, there is similar ones 
for users, used by e.g. `pip install` (unless it is disabled accordingly 
to some recommendations).


2. It seems that *recommended* and more flexible way is per-project 
(per-version) virtual environments: venv in python3, similar thing were 
called virtualenv in python2: 
https://docs.python.org/3/tutorial/venv.html Maybe there is a convenient 
way to choose and switch venv's directly from emacs. In simple cases 
venv could be activated before starting emacs.


3. The Hitchhiker's Guide to Python have a couple of related sections. 
They might be a bit outdated but could be a source for convincing 
arguments to use venv's or for some usage patterns.

https://docs.python-guide.org/dev/virtualenvs/
https://docs.python-guide.org/dev/pip-virtualenv/




Re: One vs many directories

2020-11-24 Thread Diego Zamboni
>
> So I think this is bug in Emacs as Local-variables should be on the
> end of the file.


According to the manual (
https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables
):

The start of the local variables list should be no more than 3000
> characters from the end of the file


Given the length of the email, I guess this is why Emacs saw the variables
as being within the correct range.

--Diego


On Tue, Nov 24, 2020 at 12:57 PM Eric S Fraga  wrote:

> On Tuesday, 24 Nov 2020 at 12:51, Jean Louis wrote:
> > So I think this is bug in Emacs as Local-variables should be on the
> > end of the file.
>
> "end of file" is a rather loose term when it comes to local variables...
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4-118-g2a4578.dirty
>
>


Re: ob-python: import local package into a session

2020-11-24 Thread Joost Kremers


On Tue, Nov 24 2020, Maxim Nikulin wrote:
> 2. It seems that *recommended* and more flexible way is per-project 
> (per-version) virtual environments: venv in python3, similar thing were 
> called virtualenv in python2: 
> https://docs.python.org/3/tutorial/venv.html Maybe there is a convenient 
> way to choose and switch venv's directly from emacs. In simple cases 
> venv could be activated before starting emacs.

Yes, I'm using virtual environments. Took me a while to get that figured out,
though. Python-the-language is nice enough, but Python-the-ecosystem is quite a
different thing... (Who said there should only be one way to do something?)

I haven't really considered the option to install the utility functions as a
package in the virtual environment, because I expect to change and develop those
functions together with the rest of the project. If it were a separate package,
I'd need to reinstall it every time I make changes to it, which will probably
happen often.

-- 
Joost Kremers
Life has its moments



Re: ob-python: import local package into a session

2020-11-24 Thread Jack Kamm
Joost Kremers  writes:

> I haven't really considered the option to install the utility functions as a
> package in the virtual environment, because I expect to change and develop 
> those
> functions together with the rest of the project. If it were a separate 
> package,
> I'd need to reinstall it every time I make changes to it, which will probably
> happen often.

If you install the package using either "python setup.py develop", or
"pip install -e", then Python will install your code via symlinks
instead of copying, so then you don't have to worry about reinstalling
every time you make an edit.

To switch between venv's in emacs, I use pyvenv:
https://github.com/jorgenschaefer/pyvenv



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Diego Zamboni  [2020-11-24 16:13]:
> >
> > So I think this is bug in Emacs as Local-variables should be on the
> > end of the file.
> 
> 
> According to the manual (
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables
> ):
> 
> The start of the local variables list should be no more than 3000
> > characters from the end of the file

I see and I wonder. I was thinking that not every prefix or comment
will be considered and that such must be really on the end of the file.



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Jean Louis
* Detlef Steuer  [2020-11-24 13:07]:
> Am Tue, 24 Nov 2020 09:53:15 +
> schrieb John Sturdy :
> 
> > It's aimed at navigating a collection of org-mode files via the
> > numeric keypad only, and I wrote it to go with some custom hardware I
> > made (a screen and keypadded embedded in a corkboard, so I can keep
> > all my "things to do" lists together, whether on paper or on the
> > computer), hence it having mappings for a keypad rotated 90degrees!
> 
> 
> Would you mind to share a picture? Or two?

I wanted to tell the same. I think that concept of various keys
separate from main keyboard is great.



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Jean Louis
* John Sturdy  [2020-11-24 12:54]:
> I've got a rather specialized version of that at
>
https://github.com/hillwithsmallfields/JCGS-emacs/blob/master/special-setups/tasks/org-agenda-kiosk.el

> It's aimed at navigating a collection of org-mode files via the numeric
> keypad only, and I wrote it to go with some custom hardware I made (a
> screen and keypadded embedded in a corkboard, so I can keep all my "things
> to do" lists together, whether on paper or on the computer), hence it
> having mappings for a keypad rotated 90degrees!

How does that work to keep paper and computer stuff together?




Re: Differentiate source blocks in export?

2020-11-24 Thread John Kitchin
I think you would have to use some kind of filter to look either for an
#+attr_html or src-header argument, and modify the html output for that.

John

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



On Tue, Nov 24, 2020 at 7:16 AM Joost Kremers 
wrote:

> Hi all,
>
> I was wondering if there's a way to distinguish between different kind of
> source
> code blocks when exporting to HTML.
>
> Specifically, I would like a way to mark certain code blocks in my Org
> file so
> that those code blocks get a specific class in the HTML export. I can then
> style
> them with some CSS to make them stand out visually. I know I can use
> special
> blocks to get divs with a custom class, but I don't want to lose all the
> benefits of code blocks...
>
> I tried Google and the Org manual but I haven't been able to find anything
> on
> this.
>
> TIA
>
> --
> Joost Kremers
> Life has its moments
>
>


Re: Differentiate source blocks in export?

2020-11-24 Thread Marvin ‘quintus’ Gülker
Hi!

Am Dienstag, dem 24. November 2020 schrieb Joost Kremers:
> I was wondering if there's a way to distinguish between different kind of 
> source
> code blocks when exporting to HTML.
>
> Specifically, I would like a way to mark certain code blocks in my Org file so
> that those code blocks get a specific class in the HTML export.

You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML
DIV tag around your target code block. Try this:

Wrapped code block in a div with a custom class:

#+BEGIN_EXPORT html

#+END_EXPORT

#+BEGIN_SRC c
#include 
int main(int argc, char* argv[])
{
printf("This is wrapped in the div\n");
return 0;
}
#+END_SRC

#+BEGIN_EXPORT html

#+END_EXPORT

Normal codeblock without:

#+BEGIN_SRC c
#include 
int main(int argc, char* argv[])
{
printf("This is not wrapped in anything unusual\n");
return 0;
}
#+END_SRC

Note how one of the EXPORT blocks wraps the opening tag of the DIV and
the other one wraps the closing tag.

  -quintus

-- 
Dipl.-Jur. M. Gülker | https://mg.guelker.eu |For security:
Passau, Germany  | kont...@guelker.eu| () Avoid HTML e-mail
European Union   | PGP: see homepage | /\ http://asciiribbon.org



Re: Differentiate source blocks in export?

2020-11-24 Thread John Kitchin
Nice! Here is a little more compact way to do that I think:

@@html:@@
#+BEGIN_SRC python
print(5)
#+END_SRC
@@html:@@


John

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



On Tue, Nov 24, 2020 at 11:08 AM Marvin ‘quintus’ Gülker <
post+orgmod...@guelker.eu> wrote:

> Hi!
>
> Am Dienstag, dem 24. November 2020 schrieb Joost Kremers:
> > I was wondering if there's a way to distinguish between different kind
> of source
> > code blocks when exporting to HTML.
> >
> > Specifically, I would like a way to mark certain code blocks in my Org
> file so
> > that those code blocks get a specific class in the HTML export.
>
> You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML
> DIV tag around your target code block. Try this:
>
> Wrapped code block in a div with a custom class:
>
> #+BEGIN_EXPORT html
> 
> #+END_EXPORT
>
> #+BEGIN_SRC c
> #include 
> int main(int argc, char* argv[])
> {
> printf("This is wrapped in the div\n");
> return 0;
> }
> #+END_SRC
>
> #+BEGIN_EXPORT html
> 
> #+END_EXPORT
>
> Normal codeblock without:
>
> #+BEGIN_SRC c
> #include 
> int main(int argc, char* argv[])
> {
> printf("This is not wrapped in anything unusual\n");
> return 0;
> }
> #+END_SRC
>
> Note how one of the EXPORT blocks wraps the opening tag of the DIV and
> the other one wraps the closing tag.
>
>   -quintus
>
> --
> Dipl.-Jur. M. Gülker | https://mg.guelker.eu |For security:
> Passau, Germany  | kont...@guelker.eu| () Avoid HTML e-mail
> European Union   | PGP: see homepage | /\ http://asciiribbon.org
>
>


Re: Differentiate source blocks in export?

2020-11-24 Thread Diego Zamboni
And even (a bit) shorter:

#+html:
#+BEGIN_SRC python
print(5)
#+END_SRC
#+html:

--Diego

On Tue, Nov 24, 2020 at 5:16 PM John Kitchin 
wrote:

> Nice! Here is a little more compact way to do that I think:
>
> @@html:@@
> #+BEGIN_SRC python
> print(5)
> #+END_SRC
> @@html:@@
>
>
> John
>
> ---
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Tue, Nov 24, 2020 at 11:08 AM Marvin ‘quintus’ Gülker <
> post+orgmod...@guelker.eu> wrote:
>
>> Hi!
>>
>> Am Dienstag, dem 24. November 2020 schrieb Joost Kremers:
>> > I was wondering if there's a way to distinguish between different kind
>> of source
>> > code blocks when exporting to HTML.
>> >
>> > Specifically, I would like a way to mark certain code blocks in my Org
>> file so
>> > that those code blocks get a specific class in the HTML export.
>>
>> You can use the BEGIN_EXPORT/END_EXPORT pair to include a literal HTML
>> DIV tag around your target code block. Try this:
>>
>> Wrapped code block in a div with a custom class:
>>
>> #+BEGIN_EXPORT html
>> 
>> #+END_EXPORT
>>
>> #+BEGIN_SRC c
>> #include 
>> int main(int argc, char* argv[])
>> {
>> printf("This is wrapped in the div\n");
>> return 0;
>> }
>> #+END_SRC
>>
>> #+BEGIN_EXPORT html
>> 
>> #+END_EXPORT
>>
>> Normal codeblock without:
>>
>> #+BEGIN_SRC c
>> #include 
>> int main(int argc, char* argv[])
>> {
>> printf("This is not wrapped in anything unusual\n");
>> return 0;
>> }
>> #+END_SRC
>>
>> Note how one of the EXPORT blocks wraps the opening tag of the DIV and
>> the other one wraps the closing tag.
>>
>>   -quintus
>>
>> --
>> Dipl.-Jur. M. Gülker | https://mg.guelker.eu |For security:
>> Passau, Germany  | kont...@guelker.eu| () Avoid HTML e-mail
>> European Union   | PGP: see homepage | /\ http://asciiribbon.org
>>
>>


Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Jean Louis
* Ihor Radchenko  [2020-11-24 12:59]:
> > org-store-link would work only within Emacs, not for the case of copying
> > http links in the browser, right?
> 
> Indeed. If you want to copy "[[url][title]]" string directly from
> browser, you should probably write a simple bookmarklet. I have seen
> someone sharing it in reddit, but cannot find the comment anymore.
> In any case, you might look at
> https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
> for ideas how to do it.

Yes, thank you for pointers.

What I would like to do is to execute external program from browser as
such program will give me more than just capturing the TITLE and URL,
data that browser has, because I need external data that browser does
not have such as annotation or a note to the bookmark.

So I could maybe use org-capture as you said. Then I could annotate
the bookmark in description and later by one click move everything
into Hyperscope database.

> Also, you can capture webpage as a heading using org-capture +
> org-protocol:
> 1. https://addons.mozilla.org/en-US/firefox/addon/org-capture

I think this one could work. But it does not work on iceweasel-uxp
from fully free OS Hyperbola GNU/Linux-libre. It could be installed on
the GNU IceCat. Firefox I am not using directly within the OS due to
its problematic tradeark issues and I like GNU IceCat as it has by
default some good features like quickly disabling Javascript and
taking care of non-free Software.

I have tried, now I am getting error:

Greedy org-protocol handler.  Killing client.

e.

After more setups insights, I could make it work. It works quite nice!

Now I hope that I can use org-capture to invoke other functions from
external programs.

> 2. 
> https://chrome.google.com/webstore/detail/org-capture/kkkjlfejijcjgjllecmnejhogpbcigdc

Chrome is no go here as I do not like getting tracked by Google. But
it is similar extension

> 3. https://seds.nl/notes/orgmode-firefox-bookmark/

That is yet another tip how to capture, and I can use it probably with
the other add on, or basically without add on, how I understand.

> 4. https://github.com/yantar92/org-capture-ref (shameless plug)

Even more enhancements there. That is great. 

> Or you can write a custom org-capture handler that invokes
> org-store-link

I would like to use org-capture to get data while invoking some
Elisp, that I can capture into database. Do you think that is
possible straight somehow?

That capture does not go into Org but that I can redirect it to other
elisp function?



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Diego Zamboni  [2020-11-24 16:15]:
> >
> > So I think this is bug in Emacs as Local-variables should be on the
> > end of the file.
> 
> 
> According to the manual (
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables
> ):
> 
> The start of the local variables list should be no more than 3000
> > characters from the end of the file
> 
> 
> Given the length of the email, I guess this is why Emacs saw the variables
> as being within the correct range.

Yes thank you. I was thinking Emacs will do that only in files where
it recognizes some comments or no comments and that variables need
to be pretty down in the file, on the bottom. Now I learn it is not
so.

That is security issue.



Re: Differentiate source blocks in export?

2020-11-24 Thread Eric S Fraga
On Tuesday, 24 Nov 2020 at 17:22, Diego Zamboni wrote:
> And even (a bit) shorter:
>
> #+html:

Or, if you want a more org-like feel to your special constructs, and
something that would in principle work to other export engines:

#+begin_src org
  ,#+begin_myclass
  ,#+begin_src octave
  y = 3 * x + 5
  ,#+end_src
  ,#+end_myclass
#+end_src

using special blocks which translate to divs on HTML export.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-118-g2a4578.dirty



Bug report: remote file python src output gives FileNotFound (+ suggested fix)

2020-11-24 Thread paul
When working remotely, a python SRC block with a session and :results set to 
output will return a FileNotFoundError.
To reproduce this bug:
1. Open a .org file remotely
2. Insert the following
#+BEGIN_SRC python :results output :session check
print("a")
#+END_SRC
3. org-ctrl-c-ctrl-c in the code block

I already figured out how to fix it:
In ob-python.el.gz, the function org-babel-python-evaluate-session the 
let-variable tmp-src-file is made, which contains tramp-prefix when working 
remotely. But the tramp-prefix is still there here:
(format org-babel-python--exec-tmpfile tmp-src-file)
which causes the remotely executed command to still contain the prefix, and 
hence it cannot find it.
To fix, the line above could be replaced with
(format org-babel-python--exec-tmpfile (or (file-remote-p tmp-src-file 
'localname) tmp-src-file))

Hope this helps :) (and many many thanks for org-mode)



Bug: org-link-descriptive and org-toggle-link-display [9.4 (9.4-44-g5272d9-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20201123/)]

2020-11-24 Thread Gustavo Barros

Hi All,

there is a scope mismatch in `org-toggle-link-display' between text 
(visibility) properties and the setting of `org-link-descriptive'.  The 
text properties are set for the buffer with either 
`remove-from-invisibility-spec' or `add-to-invisibility-spec', but the 
value of `org-link-descriptive` is set globally with `(setq 
org-link-descriptive (not org-link-descriptive))'.  It is not a big 
deal, but it does lead to a glitch in `org-toggle-link-display'.


It is easy to generate an ECM to trigger the glitch:

- Start `emacs -Q'
- Load the latest:
 #+begin_src emacs-lisp
 (add-to-list 'load-path "~/.emacs.d/elpa/org-plus-contrib-20201123")
 #+end_src

- Open two Org buffers "*Buffer 1*" with contents:
 #+begin_src org
 [[https://orgmode.org/][Org mode for Emacs]]
 #+end_src
- And "*Buffer 2*" with contents:
 #+begin_src org
 [[https://orgmode.org/worg/][Hello Worg, the Org-Mode Community!]]
 #+end_src
- It's probably easier to visualize if you have both windows in view in 
 a split frame, but it should not change the result whatever you do.
- The initial state, as per defaults, is that links are invisible in 
 both buffers.


- Go to "*Buffer 1*" and `M-x org-toggle-link-display', and links are 
 made visible in that buffer, but not in "*Buffer 2*".


- Now, go to "*Buffer 2*" and call `M-x org-toggle-link-display' there. 
 It doesn't work.  Call it again.  Now it does.


What's happening is that, when we call `org-toggle-link-display' in 
"*Buffer 1*" we set `org-link-descriptive' to nil globally, so that when 
we move to "*Buffer 2*", Org thinks the links are visible, and when we 
call `org-toggle-link-display' then, Org will try to "re-hide" the links 
that are already invisible, with no apparent effect.  But, in doing so, 
it also sets `org-link-descriptive' to t again, also globally.  And so a 
second call will work.


I don't know if it's better to make `org-link-descriptive' buffer-local, 
or to simply use `setq-local' in `org-toggle-link-display'.  Either way, 
it is a low hanging one.


Best regards,
Gustavo.




Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.20, cairo version 1.16.0)

of 2020-08-11
Package: Org mode version 9.4 (9.4-44-g5272d9-elpaplus @ 
/home/gustavo/.emacs.d/elpa/org-plus-contrib-20201123/)


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-link-descriptive nil
org-mode-hook '(#[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-eldoc-load)

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-babel-pre-tangle-hook '(save-buffer)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)

org-agenda-loop-over-headlines-in-active-region nil
org-src-lang-modes '(("redis" . redis) ("php" . php) ("arduino" 
. arduino) ("C" . c) ("C++" . c++)
		  ("asymptote" . asy) ("bash" . sh) ("beamer" 
		  . latex) ("calc" . fundamental) ("cpp" . c++)
		  ("ditaa" . artist) ("dot" . fundamental) ("elisp" 
		  . emacs-lisp) ("ocaml" . tuareg)
		  ("screen" . shell-script) ("shell" . sh) ("sqlite" 
		  . sql))

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-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-bib

is org-export-preserve-breaks incompatible with org verse blocks?

2020-11-24 Thread mousebot
hi org,

i use verse blocks to export to odt in a way that preserves whitespace. if i 
enable org-export-preserve-breaks, whitespace in verse blocks is not preserved: 
any spaces used to indent text from the left margin are reduced to a single 
space. is this intended behavior? i had hoped to be able to use both features 
in my document.

example:

#+begin_verse
here you are,
doing your
darned
  best
to export
#+end_verse

will export as

here you are
 doing your
 darned
 best
to export

i tested this by loading emacs -Q, evaluating (setq org-export-preserve-breaks 
t), then using the normal org export dispatch, with no template.

best 
m



Re: ob-python: import local package into a session

2020-11-24 Thread Tom Gillespie
I have also been dissatisfied with the current options for making
local python libraries accessible in certain org files. The amount of
setup that is required outside the org file itself was too large,
especially if you want someone else who is not intimately familiar
with python to be able to use it. My old solution was to modify the
PYTHONPATH environment variable for the whole Emacs process. However,
after a bit of digging inspired by this thread I now have a solution
that is entirely local: advise ~org-babel-execute:python~ to set a new
PYTHONPATH via the ~process-environment~ dynamic variable and set that
from a buffer local variable for the local additions to PYTHONPATH
along with getenv PYTHONPATH. A working example below. Best!
Tom

#+name: orgstrap
#+begin_src elisp :results none :noweb noexport
(defvar-local local-python-path nil)

(defun advise--obe-python-path (command &rest args)
  (let ((process-environment
 (or (and local-python-path
  (cons
   (format
"PYTHONPATH=%s"
(concat local-python-path (getenv "PYTHONPATH")))
   process-environment))
 process-environment)))
(apply command args)))

(advice-add #'org-babel-execute:python :around
#'advise--obe-python-path)

(setq-local local-python-path (concat default-directory "code:"))
#+end_src

On Tue, Nov 24, 2020 at 9:26 AM Jack Kamm  wrote:
>
> Joost Kremers  writes:
>
> > I haven't really considered the option to install the utility functions as a
> > package in the virtual environment, because I expect to change and develop 
> > those
> > functions together with the rest of the project. If it were a separate 
> > package,
> > I'd need to reinstall it every time I make changes to it, which will 
> > probably
> > happen often.
>
> If you install the package using either "python setup.py develop", or
> "pip install -e", then Python will install your code via symlinks
> instead of copying, so then you don't have to worry about reinstalling
> every time you make an edit.
>
> To switch between venv's in emacs, I use pyvenv:
> https://github.com/jorgenschaefer/pyvenv
>



Re: One vs many directories

2020-11-24 Thread Dr. Arne Babenhauserheide

Jean Louis  writes:

> Some people maybe access multiple Org files through Agenda, me I
> don't. Some items are "non existent" and I do not know how to ask
> agenda to refresh itself.

Simply press the letter g.

For my own setup I run code in a hook to update the agenda whenever I
change a TODO state, clock in or clock out, but that has performance
problems when I do it while the Agenda is shown.

(defvar todo-modified-from-agenda nil "Indicates whether org-mode todo 
state changes were triggered from the agenda. Check this to avoid trying to 
propagate the change back into the agenda")
;; continuously update agenda view, from 
http://thomasf.github.io/solarized-css/test/org-hacks.html
(defun kiwon/org-agenda-redo-in-other-window ()
  "Call org-agenda-redo function even in the non-agenda buffer."
  (interactive)
  (when (not (and (boundp 'todo-modified-from-agenda) 
todo-modified-from-agenda)) ; org-state non-nil means we’re coming from the 
org-after-todo-state-change-hook, which would throw when changing todo states 
from agenda due to a circular action
(let ((agenda-window (get-buffer-window (or (and (boundp 
'org-agenda-buffer-name) org-agenda-buffer-name) "plan.org") t)))
  (when agenda-window
(with-selected-window agenda-window
  (org-agenda-redo))
;; advice agenda todo to avoid redo, thanks to 
http://nullprogram.com/blog/2013/01/22/
(defadvice org-agenda-todo (before org-agenda-disable-redo activate)
  (setq todo-modified-from-agenda t))
(defadvice org-agenda-todo (after org-agenda-enable-redo activate)
  (setq todo-modified-from-agenda nil))

(add-hook 'org-clock-in-hook 'kiwon/org-agenda-redo-in-other-window)
(add-hook 'org-clock-out-hook 'kiwon/org-agenda-redo-in-other-window)
(add-hook 'org-after-todo-state-change-hook 
'kiwon/org-agenda-redo-in-other-window)


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: One vs many directories

2020-11-24 Thread Dr. Arne Babenhauserheide

Jean Louis  writes:
>> The start of the local variables list should be no more than 3000
>> > characters from the end of the file
>> 
>> 
>> Given the length of the email, I guess this is why Emacs saw the variables
>> as being within the correct range.
>
> Yes thank you. I was thinking Emacs will do that only in files where
> it recognizes some comments or no comments and that variables need
> to be pretty down in the file, on the bottom. Now I learn it is not
> so.
>
> That is security issue.

Why is it a security issue? The variables do need to be close to the end
— 3000 characters is only about 50 lines.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: One vs many directories

2020-11-24 Thread Tom Gillespie
> > That is security issue.
>
> Why is it a security issue? The variables do need to be close to the end
> — 3000 characters is only about 50 lines.

It isn't a security issue by itself. Emacs never automatically runs
eval file local variables unless you have tampered with
enable-local-eval, in which case the tamperin is the security issue
not the existence of the local variables list.

Thus it is only a security issue if you permanently accept that eval
file local variable and then open random org files that use it with a
malicious startup block. An eval file local variable like that which
blindly executes an org babel block should never be permanently
accepted

Best,
Tom



Re: One vs many directories

2020-11-24 Thread Tim Cross


Tom Gillespie  writes:

>> > That is security issue.
>>
>> Why is it a security issue? The variables do need to be close to the end
>> — 3000 characters is only about 50 lines.
>
> It isn't a security issue by itself. Emacs never automatically runs
> eval file local variables unless you have tampered with
> enable-local-eval, in which case the tamperin is the security issue
> not the existence of the local variables list.
>
> Thus it is only a security issue if you permanently accept that eval
> file local variable and then open random org files that use it with a
> malicious startup block. An eval file local variable like that which
> blindly executes an org babel block should never be permanently
> accepted
>

Quite right Tom.

If people are really concerned about security, they should look first at
their use of repositories like MELPA. There is no formal review or
analysis of packages in these repositories, yet people will happily
select some package and install it.


--
Tim Cross



Re: Differentiate source blocks in export?

2020-11-24 Thread Joost Kremers


On Tue, Nov 24 2020, Diego Zamboni wrote:
> And even (a bit) shorter:
>
> #+html:
> #+BEGIN_SRC python
> print(5)
> #+END_SRC
> #+html:

Thanks everyone for your suggestions. I tried this one and it works great.
=myclass= of course ends up containing the =src= class, but as I just found out,
that's not a problem.

-- 
Joost Kremers
Life has its moments



Re: Differentiate source blocks in export?

2020-11-24 Thread Joost Kremers


On Tue, Nov 24 2020, Eric S Fraga wrote:
> On Tuesday, 24 Nov 2020 at 17:22, Diego Zamboni wrote:
>> And even (a bit) shorter:
>>
>> #+html:
>
> Or, if you want a more org-like feel to your special constructs, and
> something that would in principle work to other export engines:
>
> #+begin_src org
>   ,#+begin_myclass
>   ,#+begin_src octave
>   y = 3 * x + 5
>   ,#+end_src
>   ,#+end_myclass
> #+end_src
>
> using special blocks which translate to divs on HTML export.

That, unfortunately, seems to make it impossible to edit the source block as
Octave (or in my case Python) code. Pressing =C-c '= in this source block gives
me an Org buffer.

-- 
Joost Kremers
Life has its moments



Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia)

2020-11-24 Thread Tim Landscheidt
With Emacs 27.1/org-mode 9.3, "(org) Environment of a Code
Block" ends with:

| Inserting headers and footers
| -

| The ‘prologue’ header argument is for appending to the top of the code
| block for execution, like a reset instruction.  For example, you may use
| ‘:prologue "reset"’ in a Gnuplot code block or, for every such block:
|
|  (add-to-list 'org-babel-default-header-args:gnuplot
|   '((:prologue . "reset")))

|Likewise, the value of the ‘epilogue’ header argument is for
| appending to the end of the code block for execution.

However it appears as if :prologue and :epilogue are ignored
in ob-sql code blocks:

| #+NAME: test-for-ob-sql
| #+BEGIN_SRC sql :engine postgresql :results verbatim :prologue "SELECT 1;" 
:epilogue "SELECT 5;" :cmdline --no-psqlrc -P format=aligned -P footer=on
|   SELECT 2;
|   SELECT 3;
|   SELECT 4;
| #+END_SRC

| #+RESULTS: test-for-ob-sql
| #+begin_example
|  ?column?
| --
| 2
| (1 Zeile)

|  ?column?
| --
| 3
| (1 Zeile)

|  ?column?
| --
| 4
| (1 Zeile)

| #+end_example

It seems that :prologue and :epilogue are only honoured in
languages that use org-babel-expand-body:generic and a
(very) few others; especially, the following languages prob-
ably ignore them (untested):

| [tim@passepartout ~/src/emacs]$ find lisp/org -type f -name ob-\*.el \
| > -not -exec fgrep -q 'org-babel-expand-body:generic' {} \; \
| > -not -exec fgrep -q ':prologue' {} \; \
| > -print
| lisp/org/ob-C.el
| lisp/org/ob-J.el
| lisp/org/ob-abc.el
| lisp/org/ob-awk.el
| lisp/org/ob-calc.el
| lisp/org/ob-clojure.el
| lisp/org/ob-comint.el
| lisp/org/ob-css.el
| lisp/org/ob-ditaa.el
| lisp/org/ob-dot.el
| lisp/org/ob-ebnf.el
| lisp/org/ob-emacs-lisp.el
| lisp/org/ob-eval.el
| lisp/org/ob-exp.el
| lisp/org/ob-fortran.el
| lisp/org/ob-hledger.el
| lisp/org/ob-latex.el
| lisp/org/ob-ledger.el
| lisp/org/ob-lisp.el
| lisp/org/ob-lob.el
| lisp/org/ob-makefile.el
| lisp/org/ob-matlab.el
| lisp/org/ob-mscgen.el
| lisp/org/ob-org.el
| lisp/org/ob-picolisp.el
| lisp/org/ob-ref.el
| lisp/org/ob-sed.el
| lisp/org/ob-shen.el
| lisp/org/ob-sql.el
| lisp/org/ob-sqlite.el
| lisp/org/ob-table.el
| lisp/org/ob-stan.el
| lisp/org/ob-vala.el



Re: Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia)

2020-11-24 Thread Tom Gillespie
Tim,
Thank for the report, and the digging for ob-langs that might be
affected. The underlying issue is that prologue and epilogue are part
of both the user facing parts of org babel as well as the internal
language implementation facing code. This is a fundamental design flaw
in org babel that needs to be fixed. I have been working on writing up
and diagraming a potential solution for community feedback, but it is
not quite ready yet. Thus, I'm filing this thread along with the
others that I have been compiling about org babel issues. Best!
Tom

On Tue, Nov 24, 2020 at 6:40 PM Tim Landscheidt  wrote:
>
> With Emacs 27.1/org-mode 9.3, "(org) Environment of a Code
> Block" ends with:
>
> | Inserting headers and footers
> | -
>
> | The ‘prologue’ header argument is for appending to the top of the code
> | block for execution, like a reset instruction.  For example, you may use
> | ‘:prologue "reset"’ in a Gnuplot code block or, for every such block:
> |
> |  (add-to-list 'org-babel-default-header-args:gnuplot
> |   '((:prologue . "reset")))
>
> |Likewise, the value of the ‘epilogue’ header argument is for
> | appending to the end of the code block for execution.
>
> However it appears as if :prologue and :epilogue are ignored
> in ob-sql code blocks:
>
> | #+NAME: test-for-ob-sql
> | #+BEGIN_SRC sql :engine postgresql :results verbatim :prologue "SELECT 1;" 
> :epilogue "SELECT 5;" :cmdline --no-psqlrc -P format=aligned -P footer=on
> |   SELECT 2;
> |   SELECT 3;
> |   SELECT 4;
> | #+END_SRC
>
> | #+RESULTS: test-for-ob-sql
> | #+begin_example
> |  ?column?
> | --
> | 2
> | (1 Zeile)
>
> |  ?column?
> | --
> | 3
> | (1 Zeile)
>
> |  ?column?
> | --
> | 4
> | (1 Zeile)
>
> | #+end_example
>
> It seems that :prologue and :epilogue are only honoured in
> languages that use org-babel-expand-body:generic and a
> (very) few others; especially, the following languages prob-
> ably ignore them (untested):
>
> | [tim@passepartout ~/src/emacs]$ find lisp/org -type f -name ob-\*.el \
> | > -not -exec fgrep -q 'org-babel-expand-body:generic' {} \; \
> | > -not -exec fgrep -q ':prologue' {} \; \
> | > -print
> | lisp/org/ob-C.el
> | lisp/org/ob-J.el
> | lisp/org/ob-abc.el
> | lisp/org/ob-awk.el
> | lisp/org/ob-calc.el
> | lisp/org/ob-clojure.el
> | lisp/org/ob-comint.el
> | lisp/org/ob-css.el
> | lisp/org/ob-ditaa.el
> | lisp/org/ob-dot.el
> | lisp/org/ob-ebnf.el
> | lisp/org/ob-emacs-lisp.el
> | lisp/org/ob-eval.el
> | lisp/org/ob-exp.el
> | lisp/org/ob-fortran.el
> | lisp/org/ob-hledger.el
> | lisp/org/ob-latex.el
> | lisp/org/ob-ledger.el
> | lisp/org/ob-lisp.el
> | lisp/org/ob-lob.el
> | lisp/org/ob-makefile.el
> | lisp/org/ob-matlab.el
> | lisp/org/ob-mscgen.el
> | lisp/org/ob-org.el
> | lisp/org/ob-picolisp.el
> | lisp/org/ob-ref.el
> | lisp/org/ob-sed.el
> | lisp/org/ob-shen.el
> | lisp/org/ob-sql.el
> | lisp/org/ob-sqlite.el
> | lisp/org/ob-table.el
> | lisp/org/ob-stan.el
> | lisp/org/ob-vala.el
>



Bug: org-highlight-latex-and-related script breaks tag fontification [9.3 (release_9.3 @ c:/tools/msys64/mingw64/share/emacs/27.1/lisp/org/)]

2020-11-24 Thread Gennady Uraltsev
Hello,

Setting the variable "org-highlight-latex-and-related" to include "script"
breaks fontification of tags with un underscore. To reproduce make a .emacs
file that contains only:

(setq org-highlight-latex-and-related '(script))

and open an org file containing

* Heading 1 :test:

* Heading 2 :test_case:

* Heading 3
 :test_case_2:

Notice that that the parts of the tag "test" is fontified (info obtained
using describe-char) using the faces:
(org-tag org-level-1)
while the "_case" string is fontified (info obtained using describe-char)
using the faces:
(org-latex-and-related org-tag org-level-1)
The first face should not be there.

I am actually not sure for what the "script" does
in org-highlight-latex-and-related but I am configuring my org mode now so
I'll figure it out...

Thanks!

Gennady

Emacs  : GNU Emacs 27.1 (build 1, x86_64-w64-mingw32)
 of 2020-08-11
Package: Org mode version 9.3 (release_9.3 @
c:/tools/msys64/mingw64/share/emacs/27.1/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-mode-hook '(#[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-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-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
  org-babel-header-arg-expand)
 org-highlight-latex-and-related '(script)
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees
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-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-open-link :export
org-attach-export-link :complete
org-attach-complete-link)
   ("id" :follow org-id-open)
   ("eww" :follow eww :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
#[257 "\301\300\302 Q!\207" ["news" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("mailto" :follow
#[257 "\301\300\302 Q!\207" ["mailto" browse-url ":"]
  5 "\n\n(fn URL)"]
)
   ("https" :follow
#[257 "\301\300\302 Q!\207" ["https" browse-url ":"]
  5 "\n\n(fn URL)"]
)
   ("http" :follow
#[257 "\301\300\302 Q!\207" ["http" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("ftp" :follow
#[257 "\301\300\302 Q!\207" ["ftp" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("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-link-elisp-confirm-function 'yes-or-no-p
 )

--
Gennady Uraltsev

(https://guraltsev.gitlab.io) 


Re: [PATCH] org-table: Add mode flag to enable Calc units simplification mode

2020-11-24 Thread Kyle Meyer
Daniele Nicolodi writes:

> Thank you for the review, Kyle.
>
> Another updated patch set is attached.

Thank you for the update.

Applied, tweaking the manual entry to use "a unit" rather than "an
unit".

1:  bd7e16ca2 = 1:  bd7e16ca2 org-table: Remove unused org-tbl-calc-modes 
variable declaration
2:  abd994943 = 2:  abd994943 org-table: Simplify mode string parsing
3:  cb77e7a46 ! 3:  15469774d org-table: Add mode flag to enable Calc units 
simplification mode
@@ doc/org-manual.org: *** Formula syntax for Calc
 +- =u= ::
 +
 +  Units simplification mode of Calc.  Calc is also a symbolic
-+  calculator and is capable of working with values having an unit,
-+  represented with numerals followed by an unit string in Org table
++  calculator and is capable of working with values having a unit,
++  represented with numerals followed by a unit string in Org table
 +  cells.  This mode instructs Calc to simplify the units in the
 +  computed expression before returning the result.
 +



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Ihor Radchenko
> Now I hope that I can use org-capture to invoke other functions from
> external programs.

In general, you can define your own protocols. See
org-protocol-protocol-alist docstring for details how to define custom
protocols executing arbitrary elisp code.

> I would like to use org-capture to get data while invoking some
> Elisp, that I can capture into database. Do you think that is
> possible straight somehow?
>
> That capture does not go into Org but that I can redirect it to other
> elisp function?

You can add your own function to org-capture-prepare-finalize-hook and
do whatever you want with the captured text, like passing it to external
program. Once done, you can just call (org-capture-kill) to abort the
capture and not save the data to org.

> Chrome is no go here as I do not like getting tracked by Google. But
> it is similar extension

I just listed the possibilities. I personally use qutebrowser where I
can directly call external scripts.

> That is yet another tip how to capture, and I can use it probably with
> the other add on, or basically without add on, how I understand.

Sure, bookmarklet should be the most universal solution working with
pretty much all browsers.

Best,
Ihor

Jean Louis  writes:

> * Ihor Radchenko  [2020-11-24 12:59]:
>> > org-store-link would work only within Emacs, not for the case of copying
>> > http links in the browser, right?
>> 
>> Indeed. If you want to copy "[[url][title]]" string directly from
>> browser, you should probably write a simple bookmarklet. I have seen
>> someone sharing it in reddit, but cannot find the comment anymore.
>> In any case, you might look at
>> https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
>> for ideas how to do it.
>
> Yes, thank you for pointers.
>
> What I would like to do is to execute external program from browser as
> such program will give me more than just capturing the TITLE and URL,
> data that browser has, because I need external data that browser does
> not have such as annotation or a note to the bookmark.
>
> So I could maybe use org-capture as you said. Then I could annotate
> the bookmark in description and later by one click move everything
> into Hyperscope database.
>
>> Also, you can capture webpage as a heading using org-capture +
>> org-protocol:
>> 1. https://addons.mozilla.org/en-US/firefox/addon/org-capture
>
> I think this one could work. But it does not work on iceweasel-uxp
> from fully free OS Hyperbola GNU/Linux-libre. It could be installed on
> the GNU IceCat. Firefox I am not using directly within the OS due to
> its problematic tradeark issues and I like GNU IceCat as it has by
> default some good features like quickly disabling Javascript and
> taking care of non-free Software.
>
> I have tried, now I am getting error:
>
> Greedy org-protocol handler.  Killing client.
>
> e.
>
> After more setups insights, I could make it work. It works quite nice!
>
> Now I hope that I can use org-capture to invoke other functions from
> external programs.
>
>> 2. 
>> https://chrome.google.com/webstore/detail/org-capture/kkkjlfejijcjgjllecmnejhogpbcigdc
>
> Chrome is no go here as I do not like getting tracked by Google. But
> it is similar extension
>
>> 3. https://seds.nl/notes/orgmode-firefox-bookmark/
>
> That is yet another tip how to capture, and I can use it probably with
> the other add on, or basically without add on, how I understand.
>
>> 4. https://github.com/yantar92/org-capture-ref (shameless plug)
>
> Even more enhancements there. That is great. 
>
>> Or you can write a custom org-capture handler that invokes
>> org-store-link
>
> I would like to use org-capture to get data while invoking some
> Elisp, that I can capture into database. Do you think that is
> possible straight somehow?
>
> That capture does not go into Org but that I can redirect it to other
> elisp function?



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Dr. Arne Babenhauserheide  [2020-11-24 21:51]:
> 
> Jean Louis  writes:
> >> The start of the local variables list should be no more than 3000
> >> > characters from the end of the file
> >> 
> >> 
> >> Given the length of the email, I guess this is why Emacs saw the variables
> >> as being within the correct range.
> >
> > Yes thank you. I was thinking Emacs will do that only in files where
> > it recognizes some comments or no comments and that variables need
> > to be pretty down in the file, on the bottom. Now I learn it is not
> > so.
> >
> > That is security issue.
> 
> Why is it a security issue? The variables do need to be close to the end
> — 3000 characters is only about 50 lines.

Emacs users, Org users on our mailing lists are not so private. Their
names and email addresses are in the public database. Spammer can
construct phishing type of an email, including something like Org news
or something and send such email to users. Among let us say 3000
people there will be percentage of users that will say Y to invoke the
local variables due to lack of knowing what is it doing to computer.

After that, anything becomes possible, including intrusion into
computer, capturing all email addresses, passwords, sending spam
emails from computer and so on.



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Dr. Arne Babenhauserheide  [2020-11-24 21:48]:
> 
> Jean Louis  writes:
> 
> > Some people maybe access multiple Org files through Agenda, me I
> > don't. Some items are "non existent" and I do not know how to ask
> > agenda to refresh itself.
> 
> Simply press the letter g.

What function is on g on your side?

I press g and I get error: invalid key g

> For my own setup I run code in a hook to update the agenda whenever I
> change a TODO state, clock in or clock out, but that has performance
> problems when I do it while the Agenda is shown.

That sounds that it will use computing power. Thank you. I have plan
to switch anything action related to database system and use Org to
view tasks, not to handle or store them.



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Jean Louis
* Ihor Radchenko  [2020-11-24 12:59]:
> > org-store-link would work only within Emacs, not for the case of copying
> > http links in the browser, right?
> 
> Indeed. If you want to copy "[[url][title]]" string directly from
> browser, you should probably write a simple bookmarklet. I have seen
> someone sharing it in reddit, but cannot find the comment anymore.
> In any case, you might look at
> https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
> for ideas how to do it.
> 
> Also, you can capture webpage as a heading using org-capture +
> org-protocol:
> 1. https://addons.mozilla.org/en-US/firefox/addon/org-capture/
> 2. 
> https://chrome.google.com/webstore/detail/org-capture/kkkjlfejijcjgjllecmnejhogpbcigdc
> 3. https://seds.nl/notes/orgmode-firefox-bookmark/
> 4. https://github.com/yantar92/org-capture-ref (shameless plug)
> 
> Or you can write a custom org-capture handler that invokes
> org-store-link

Those references were very helpful.

Org has already some nice capturing abilities, like rmail, one can
capture (I guess) the link to message ID, or URL in eww and so on.

I hope now that org-protocol is generic and does not only do stuff for
Org that I can capture other things too.

But in general I wonder how does that bookmarklet work. I was looking
inside and I think it works by converting or redirecting the page to
new protocol like http:// only this time org-protocol:// and then
based on that protocol it is opening a handler. If somebody knows if
this is correct, let me know.

As this feature then can be used then that I make protocol for myself,
that I can capture into the database, only not with org-protocol.

After inspection I can see that org-protocol.el have been made
generic! Bingo!

Hide Org Protocol Protocol Alist:
INS
State : STANDARD.
   Register custom handlers for org-protocol. Hide

So that means that little different captures can be made into anything
and not only to Org.

Thank you for hints, without it I would not soon find out about that.

Jean



Re: [PATCH] doc/org-manual.org: Extend table formulas Lisp form documentation

2020-11-24 Thread Kyle Meyer
Daniele Nicolodi writes:

> Hello,
>
> I always found the description of Lisp forms in Org table formulas not
> extremely clear, especially in regard to the use of mode flags. The
> attached patch tries to clarify the manual a bit.

Thanks.

> Would it be worth to mention org-sbe in the same section of the manual?

Yeah, it looks like there's no mention of org-sbe in the manual, so I
think so (as a separate patch).

> Subject: [PATCH] doc/org-manual.org: Extend table formulas Lisp form
>  documentation
>
> Be more explicit about how fields are interpolated into the Lisp
> forms, clarify the use of mode flags, and add a cuple more examples.

s/cuple/couple/

Typically a manual change will get a "* doc/org-manual.org ():"
entry in the commit message.

> ---
>  doc/org-manual.org | 60 +++---
>  1 file changed, 36 insertions(+), 24 deletions(-)
[...]
> +By default, references are interpolated as literal Lisp strings: the
> +field content is replaced in the Lisp form stripped of leading and
> +trailing white space and surrounded in double-quotes.  For example:
>  
> -Here are a few examples---note how the =N= mode is used when we do
> -computations in Lisp:
> +: '(concat $1 $2)
>  
> -- ='(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))= ::
> +concatenates the content of columns 1 and column 2.

This and similar spots in this patch produce incorrect indentation in
the info output:

  trailing white space and surrounded in double-quotes.  For example:
  
   '(concat $1 $2)
  
 concatenates the content of columns 1 and column 2.

Adding "#+texinfo: @noindent" above the line would prevent that.  To
check the result, you can generate the info output with `make info' and
then visit it with `C-u C-h i doc/org'.

Aside from that, the changes here look like an improvement to me.  As
far as "interpolated" goes, this patch adds one more instance to a
section that carries 4 of the 5 occurrences in the code base, so I'd say
it's fine to leave as is.  I think the "replaced" or "substituted"
suggestions by Tim Cross are good ones, though, if anyone cares to send
a follow-up patch.



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Tom Gillespie  [2020-11-24 23:11]:
> > > That is security issue.
> >
> > Why is it a security issue? The variables do need to be close to the end
> > — 3000 characters is only about 50 lines.
> 
> It isn't a security issue by itself. Emacs never automatically runs
> eval file local variables unless you have tampered with
> enable-local-eval, in which case the tamperin is the security issue
> not the existence of the local variables list.
> 
> Thus it is only a security issue if you permanently accept that eval
> file local variable and then open random org files that use it with a
> malicious startup block. An eval file local variable like that which
> blindly executes an org babel block should never be permanently
> accepted

I do understand conditions.

But I can say that I did not understand conditions for one decade and
a half, as I was not aware that Emacs has a "real programming language
" built-in, and I have been spending my time with outside languages
that I was invoking from Emacs.

Yes, I did read that Emacs has Emacs Lisp. I was configuring Emacs but
I have not been thinkin that it is Lisp. I could figure out those
settings without reading manual.

As I am programming in Emacs Lisp for years I am aware of it. Before I
was thinking that local variables belong somewhere and that I should
enable it, despite all the warnings. There was lack of understanding
despite the information in front of me.

Some files opened asked me to enable local variables, so many times I
did so without thinking. My personal behavior to enable local
variables that other authors have written is probable not isolated
case. So that is security issue as number of users among thousands are
weak on this.

When I say security issue I do not think myself, you or majority of
people currently, but that there are probably millions of people who
can be affected by this. I also know spammers are harvesting mailing
lists.



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Tim Cross  [2020-11-24 23:40]:
> > Thus it is only a security issue if you permanently accept that eval
> > file local variable and then open random org files that use it with a
> > malicious startup block. An eval file local variable like that which
> > blindly executes an org babel block should never be permanently
> > accepted
> >
> 
> Quite right Tom.
> 
> If people are really concerned about security, they should look first at
> their use of repositories like MELPA. There is no formal review or
> analysis of packages in these repositories, yet people will happily
> select some package and install it.

That is analogous to enabling local variables because user has been
asked. Popping up a window with question is often a dialogue that
users are asked in other software. Dialogues are often not read, just
as I was not reading it for years and I did click YES many times.

Using such variables is unsafe and the default should be not to
execute it without any question. Only when user enables local
variables then user should be asked to execute it. That would mean
that aware user knows why that is needed. Such will be able to answer
questions YES or NO.

Unaware users must answer something. To be aware one has to know Emacs
Lisp and deeper functions of Emacs.  In beginning years it was just
fine to assume so due to general computing interests and people being
interested in every detail, today there are even more users of Emacs
who will not know what is going on.

I do not know for you, but when computer asks me anything YES or NO,
my tendency is to answer YES regardless if I have read it or not. This
same tendency may be with thousands of other users.

If I have invoked something on computer and I get asked anything, I
have tendency to approve whatever comes on me as I approved it by
invoking some action. Not that I am doing it every time yet I have the
tendency of doing it.

Observing users who are asked questions upon invokation of other
software I can say that many times users just click one of the
options, either YES or NO, but without real regard to the
meanings. The purpose to click either YES or NO is to continue one
step forward and randomity decides later what happens.





consistent behavior across babel languages

2020-11-24 Thread ian martins
Something I've found challenging is the inconsistency between babel
languages. It makes it difficult for a babel user to get a source
block to do what they want, or for a babel developer to even know what
correct behavior is.

I'm not sure if anything can be done since changes will likely break
existing behavior, but it's good to at least know what the rule is and
where the exceptions to the rule are. To that end I started a page on
worg [1] to document current behavior for actions taken across babel
languages.

[1] https://orgmode.org/worg/org-contrib/babel/languages/lang-compat.html



Re: One vs many directories

2020-11-24 Thread Jean Louis
* Tim Cross  [2020-11-24 23:40]:
> If people are really concerned about security, they should look first at
> their use of repositories like MELPA. There is no formal review or
> analysis of packages in these repositories, yet people will happily
> select some package and install it.

Interesting that you are one who mentions that. There are just few
people ever mentioned it.

I am still in process of the review of MELPA packages and its
system. There are many security issues.

Package signing is one example. It does not offer much of security
when packages are signed automatically, but it raises level of
security.

MELPA packages and archive-contents are not PGP signed, while GNU ELPA
packages are signed.

Licensing issues are also a problem with MELPA as it becomes unclear
if I have got the license or not when author does not have a proper
name. It is not relevant if majority of people do not think or are not
aware of licensing as I have to think of it for software that I may
re-use, distribute, modify. Did I really get the license if user is
named "nick-abc" and have no possible contact information? In some
cases for subset of MELPA packages there is no way to verify who
really wrote piece of software and if I have received the license
legally. Due diligence is on my side. I cannot just claim "But he gave
me license" will not help if I have not done proper due diligence,
court would not be on my side.

Other issue is that MELPA philosophy is to accept any kind of software
even if software has been made to drive or control proprietary
software.

For that reason there is now non-GNU ELPA being developed where useful
packages will be distributed from.




Re: One vs many directories

2020-11-24 Thread Tim Cross


Jean Louis  writes:

> Observing users who are asked questions upon invokation of other
> software I can say that many times users just click one of the
> options, either YES or NO, but without real regard to the
> meanings. The purpose to click either YES or NO is to continue one
> step forward and randomity decides later what happens.

You cannot prevent people from making bad decisions. Saying yes to
something when you don't know what it means is like using the same
weak password for everything. There has been massive amounts of
communication and education out there to let people know about the
risks. If they choose to ignore it or follow practices which are unsafe,
it is their tough luck.

We need to encourage people to take more responsibility for their
actions, not less. One important component of this is allowing the
consequences for bad decisions to occur and not spend endless resources
protecting people from themselves.

If your asked to do something and your clearly told that doing so might
be unsafe and your given an option not to do it which is just as easy to
perform and you still decide to do it, that decision is on you.

The alternative is to remove extremely useful functionality from many
responsible users because of an unknown number of others who make poor
decisions.

Furthermore, keep in mind that this ability in Emacs has been around for
longer than many users have been alive. I've been using it for nearly 30
years and have participated in many forums over that time. I have yet to
hear of a single security incident occurring because of local variables.
That doesn't mean such incidents have not occurred, but it does likely
mean they are rare.

--
Tim Cross



Re: Behavior of links

2020-11-24 Thread Kyle Meyer
Julian L writes:

> Hi!
>
> Following this github issue in org-roam
> , I would like to ask
> about the behavior of links in org mode. More specifically, let's say I
> have this headline:
>
> * my heading
> :PROPERTIES:
> :GOAL: I want to be able to say [[file:something.org]]
> :END:
>
> :RELATED:
> [[file:language.org]]
> :END:
>
>
> According to the issue, links in the properties drawer aren't considered
> links by org mode (even though I can click on them and they work fine), but
> on the other hand links on a separate drawer like RELATED are considered
> links.

Right, according to Org syntax, file:something.org is not a link.  With
point on it, org-element-context returns

  (node-property
(:key "GOAL" :value "I want to be able to say [[file:something.org]]" ...))

Compare that to file:language.org:

  (link (:type "file" :path "language.org"  ...))

Here are some links that might be helpful:

  https://orgmode.org/worg/dev/org-syntax.html
  https://orgmode.org/list/87d2i5pt39@gmail.com/
  https://orgmode.org/list/87bm1e56gx@nicolasgoaziou.fr/

> How stable is this behavior? Is it expected to change in the future?

As far as I know, it's been around since org-element.el was introduced
in core (2012), and I'm aware of no plans to change it.



Re: [PATCH] org-protocol: Make org protocol defaults work on windows

2020-11-24 Thread Kyle Meyer
Robert writes:

> Hei,
>
> Attached a little patch to make the default org-protocol handlers work on 
> windows.
>
> Tested with Windows 10 and emacs 27.1

Thank you for the patch.

Any org-protocol and/or Windows users out there that can provide
feedback?



Re: One vs many directories

2020-11-24 Thread Tim Cross


Jean Louis  writes:

> * Dr. Arne Babenhauserheide  [2020-11-24 21:51]:
>>
>> Jean Louis  writes:
>> >> The start of the local variables list should be no more than 3000
>> >> > characters from the end of the file
>> >>
>> >>
>> >> Given the length of the email, I guess this is why Emacs saw the variables
>> >> as being within the correct range.
>> >
>> > Yes thank you. I was thinking Emacs will do that only in files where
>> > it recognizes some comments or no comments and that variables need
>> > to be pretty down in the file, on the bottom. Now I learn it is not
>> > so.
>> >
>> > That is security issue.
>>
>> Why is it a security issue? The variables do need to be close to the end
>> — 3000 characters is only about 50 lines.
>
> Emacs users, Org users on our mailing lists are not so private. Their
> names and email addresses are in the public database. Spammer can
> construct phishing type of an email, including something like Org news
> or something and send such email to users. Among let us say 3000
> people there will be percentage of users that will say Y to invoke the
> local variables due to lack of knowing what is it doing to computer.
>
> After that, anything becomes possible, including intrusion into
> computer, capturing all email addresses, passwords, sending spam
> emails from computer and so on.

this is just baseless fear mongering based on nothing but speculation.

Of your suggested 3000 users, only a very small percentage use Emacs as
their mail client. Of those, only an even smaller number will have their
mail client configured to render messages with a mode that supports
local variables and even a smaller number of those would say yes to
executing the code. In fact, anyone who has gone to the extent of
configuring their Emacs email client to open messages with a mime type
of x-org (or even just based on an attachment with *.org in the file
name) is more than likely to be sufficiently technically aware not to
say yes when asked.

Few, if any user, is going to download some random attachment in an
email message, open it in emacs and then say yes to a message warning
them that doing so might be dangerous. Such ill-informed users have been
pretty much weeded out by all the other scam phishing out there by now.
To convince them to go through such steps would require some pretty
convincing content - a simple org news attachment or similar is unlikely
to do it.

Even if you do get them to say yes, they are still a long way from being
able to compromise the computer Emacs is running on. Gaining some level
of access is one thing, actually being able to do something with that
access is another. Trying to compromise a computer, which these days
typically involves privilege escalation, would be extremely difficult to
achieve with elisp. The best you could hope for would be to install a
trojan or back door what would allow the attacker to install other
tools. Could be possible, but is definitely non-trivial.

This ability has been around in Emacs for a very long time - more than
30 years, possibly even longer. There has not been a single recorded
incident of large number of users being compromised as a result of this
feature. I've not even heard of small numbers being compromised as a
result of this feature.

I'm sure you will disagree. My suggestion is that if you believe this is
a security issue, you put together a proof of concept to demonstrate the
vulnerability - this is how such security issues get resolved.
Demonstrate how the security issue can be exploited with actual proof of
concept code rather than mere speculation and that will provide
something concrete which can be dealt with. I suspect you will find it
much harder to achieve once you actually try to make it work.

--
Tim Cross



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Jean Louis
* Ihor Radchenko  [2020-11-25 06:43]:
> > Now I hope that I can use org-capture to invoke other functions from
> > external programs.
> 
> In general, you can define your own protocols. See
> org-protocol-protocol-alist docstring for details how to define custom
> protocols executing arbitrary elisp code.

Thank you Ihor. I know this all could be in the manual, and I read
manuals all the time but never read it fully. Without these references
I would not easily discover those useful functions.

When there is reference such as URL, I am actually following it and
researching the subject. Few minutes research here and then are
sparing me time on repetitive tasks in futures. 

> > I would like to use org-capture to get data while invoking some
> > Elisp, that I can capture into database. Do you think that is
> > possible straight somehow?
> >
> > That capture does not go into Org but that I can redirect it to other
> > elisp function?
> 
> You can add your own function to org-capture-prepare-finalize-hook and
> do whatever you want with the captured text, like passing it to external
> program. Once done, you can just call (org-capture-kill) to abort the
> capture and not save the data to org.
> 
> > Chrome is no go here as I do not like getting tracked by Google. But
> > it is similar extension
> 
> I just listed the possibilities. I personally use qutebrowser where I
> can directly call external scripts.

While I did use qutebrowser many times, did not know about the
scripts. Please state some examples how you call those external
scripts. I am interested if:

- qutebrowser, once HTML is loaded or any file, can transmit this file
  in a script to external program to parse it, collect meta data and
  index it somewhere

- in particular I would be interested if qutebrowser could be used to
  convert the HTML on the fly to OPML by using external script so to
  get chunks finely grained such as paragraphs, headings of course are
  included making HTML better outlined and structured for further
  import into both Org files and yet private Hyperscope database.

You think that could work?

Any examples how you use qutebrowser with external scripts?



Re: One vs many directories

2020-11-24 Thread Texas Cyberthal
Hi Jean,

> Now, what is exomind?

https://cyberthal-docs.nfshost.com/cyborganize/exomind/

What you described is not how you think, it is how you wish your CRM
info retrieval system to perform conveniently.  Almost nobody has a
formal thought algorithm, because brains have ADD compared to
computers.

Textmind is a tool for general human text thoughts.  It's unspecialized.

If you have a huge number of incoming text of a special type, such as
customer leads, who are just cogs that you don't genuinely ponder,
then Textmind is the wrong tool for that job.  You need SME CRM
software.

Just common sense.  Combine harvester works "better" than a push
lawnmower, but everyone still needs a push lawnmower.

Ok, Textmind feels more like a riding lawnmower to me, because so
comfy, but also better detail work, like a wheedwhacker... and the
analogy falls apart.

> Contract signed between your company 123 and person ABC?

I might like a separate Textmind for a company.  If separate, then
file under ~/1-Mansort/1-Textmind/2-Linked/7-Name/2-Flat/Doe-John~.
Otherwise, sounds like something a relational database should handle.

> Image on which there is only your family member, not you, which has its date?

Same path, but ~/Surname-/Given-name~, and binaries are stored in Binmind.

> Image of you, with the date?

Same path, but ~/2-Me~.

- Image without date in the file name and not embedded?

Depends on image content.

- Software git tree related to mailing things?

~/1-Mansort/1-Textmind/2-Linked/2-Codex/~

Large physical keyboards are the best human to computer input device
for work and nothing on the horizon challenges that.  Keyboards are
spreading to more enterprise contexts, such as keyboards in cop cars,
as software eats everything.

> The other complete thought algorithm is Pubmind, for longform content.
> But it doesn't work without Textmind.

https://cyberthal-docs.nfshost.com/cyborganize/pubmind/

I suppose it takes Textmind+Pubmind to make a complete thought
algorithm.  Pubmind terminates in publications rather than action.
Pubmind is only necessary once Textmind starts growing clogged with
publications that no longer belong inside one's personal exomind.



Re: One vs many directories

2020-11-24 Thread Tim Cross


Jean Louis  writes:

> * Tim Cross  [2020-11-24 23:40]:
>> If people are really concerned about security, they should look first at
>> their use of repositories like MELPA. There is no formal review or
>> analysis of packages in these repositories, yet people will happily
>> select some package and install it.
>
> Interesting that you are one who mentions that. There are just few
> people ever mentioned it.
>
> I am still in process of the review of MELPA packages and its
> system. There are many security issues.
>
> Package signing is one example. It does not offer much of security
> when packages are signed automatically, but it raises level of
> security.
>
> MELPA packages and archive-contents are not PGP signed, while GNU ELPA
> packages are signed.
>

IMO signing of packages is irrelevant when there is no formal review
process or even any formal process to verify the credentials of
signatures. In fact, just adding signing would likely be
coutner-productive as it would give the impression of some sort of
security where there is none.

Basically, anyone can upload anything to MELPA. The only way anyone
would find out that an uploaded package has malicious code is if someone
does a code review and spots the malicious payload. Even once they find
that, there is little chance of being able to attribute the actions to
any individual because no real identity vetting is conducted. MELPA is
the wild west.

The new non-GNU repository has bene setup precisely due to both the
licensing issue and the fact many MELPA packages recommend/encourage the
use of non-free software/services. While non-GNU will improve this
situation, I don't believe there are any plans to actively review the
code in the packages. So, like MELPA, all you really have to go on is
package reputation. You cannot have any high level of confidence a
package does not contain malicious code other than an expectation that
if it is used by a sufficiently large enough number of users, it is
unlikely.

this is not an issue unique to Emacs. You only have to look at the
issues both Google's play store and Apples app store have had in the
past to see what the risks are. Both Google and Apple have put large
amounts of resources into trying to ensure their repository content is
safe and yet they still have failures. Something like GNU Emacs has
nowhere near the same resources, so is unlikely to come even close to
the same level of security.



Re: consistent behavior across babel languages

2020-11-24 Thread Tim Cross


ian martins  writes:

> Something I've found challenging is the inconsistency between babel
> languages. It makes it difficult for a babel user to get a source
> block to do what they want, or for a babel developer to even know what
> correct behavior is.
>
> I'm not sure if anything can be done since changes will likely break
> existing behavior, but it's good to at least know what the rule is and
> where the exceptions to the rule are. To that end I started a page on
> worg [1] to document current behavior for actions taken across babel
> languages.
>
> [1] https://orgmode.org/worg/org-contrib/babel/languages/lang-compat.html


this is a great initiative Ian. First step in addressing inconsistencies
is documenting them. I will try to allocate time on the weekend to
review what you have and see if there are any I know of which you have
not included.


--
Tim Cross



Re: Bring up a screen giving option to open a series of orgmode files

2020-11-24 Thread Ihor Radchenko
> Thank you Ihor. I know this all could be in the manual, and I read
> manuals all the time but never read it fully. Without these references
> I would not easily discover those useful functions.

Yeah. It is even worth re-reading manuals from time to time as you use
the corresponding tool. With growing experience, many initially
unnoticed features can be discovered and used efficiently.

>> I just listed the possibilities. I personally use qutebrowser where I
>> can directly call external scripts.
>
> While I did use qutebrowser many times, did not know about the
> scripts. Please state some examples how you call those external
> scripts. I am interested if:

- https://www.qutebrowser.org/doc/userscripts.html
- 
https://github.com/qutebrowser/experiments/blob/83c2e32bca05023026578ac9b64f7a5938772e9d/misc/userscripts/README.md

> - qutebrowser, once HTML is loaded or any file, can transmit this file
>   in a script to external program to parse it, collect meta data and
>   index it somewhere

.html version of the current page is always available to userscripts via
$QUTE_HTML variable.

I use it in my capture package:
https://github.com/yantar92/org-capture-ref#qute_integration

> - in particular I would be interested if qutebrowser could be used to
>   convert the HTML on the fly to OPML by using external script so to
>   get chunks finely grained such as paragraphs, headings of course are
>   included making HTML better outlined and structured for further
>   import into both Org files and yet private Hyperscope database.

Since you have access to the html file, you can pass it to any app in
your system. For example, you might convert the page to any other format
with pandoc or parse it with beautifulsoap in python. However, the file
will not contain the multimedia content - only bare html.

Best,
Ihor

Jean Louis  writes:

> * Ihor Radchenko  [2020-11-25 06:43]:
>> > Now I hope that I can use org-capture to invoke other functions from
>> > external programs.
>> 
>> In general, you can define your own protocols. See
>> org-protocol-protocol-alist docstring for details how to define custom
>> protocols executing arbitrary elisp code.
>
> Thank you Ihor. I know this all could be in the manual, and I read
> manuals all the time but never read it fully. Without these references
> I would not easily discover those useful functions.
>
> When there is reference such as URL, I am actually following it and
> researching the subject. Few minutes research here and then are
> sparing me time on repetitive tasks in futures. 
>
>> > I would like to use org-capture to get data while invoking some
>> > Elisp, that I can capture into database. Do you think that is
>> > possible straight somehow?
>> >
>> > That capture does not go into Org but that I can redirect it to other
>> > elisp function?
>> 
>> You can add your own function to org-capture-prepare-finalize-hook and
>> do whatever you want with the captured text, like passing it to external
>> program. Once done, you can just call (org-capture-kill) to abort the
>> capture and not save the data to org.
>> 
>> > Chrome is no go here as I do not like getting tracked by Google. But
>> > it is similar extension
>> 
>> I just listed the possibilities. I personally use qutebrowser where I
>> can directly call external scripts.
>
> While I did use qutebrowser many times, did not know about the
> scripts. Please state some examples how you call those external
> scripts. I am interested if:
>
> - qutebrowser, once HTML is loaded or any file, can transmit this file
>   in a script to external program to parse it, collect meta data and
>   index it somewhere
>
> - in particular I would be interested if qutebrowser could be used to
>   convert the HTML on the fly to OPML by using external script so to
>   get chunks finely grained such as paragraphs, headings of course are
>   included making HTML better outlined and structured for further
>   import into both Org files and yet private Hyperscope database.
>
> You think that could work?
>
> Any examples how you use qutebrowser with external scripts?



Re: [PATCH] org-table: Add mode flag to enable Calc units simplification mode

2020-11-24 Thread Christian Moe


Great! Thanks for following through on this, Dan!

Yours,
Christian

Kyle Meyer writes:

> Daniele Nicolodi writes:
>
>> Thank you for the review, Kyle.
>>
>> Another updated patch set is attached.
>
> Thank you for the update.
>
> Applied, tweaking the manual entry to use "a unit" rather than "an
> unit".
>
> 1:  bd7e16ca2 = 1:  bd7e16ca2 org-table: Remove unused org-tbl-calc-modes 
> variable declaration
> 2:  abd994943 = 2:  abd994943 org-table: Simplify mode string parsing
> 3:  cb77e7a46 ! 3:  15469774d org-table: Add mode flag to enable Calc units 
> simplification mode
> @@ doc/org-manual.org: *** Formula syntax for Calc
>  +- =u= ::
>  +
>  +  Units simplification mode of Calc.  Calc is also a symbolic
> -+  calculator and is capable of working with values having an unit,
> -+  represented with numerals followed by an unit string in Org table
> ++  calculator and is capable of working with values having a unit,
> ++  represented with numerals followed by a unit string in Org table
>  +  cells.  This mode instructs Calc to simplify the units in the
>  +  computed expression before returning the result.
>  +




Local variables issue - Re: One vs many directories

2020-11-24 Thread Jean Louis
* Tim Cross  [2020-11-25 08:54]:
> 
> Jean Louis  writes:
> 
> > Observing users who are asked questions upon invokation of other
> > software I can say that many times users just click one of the
> > options, either YES or NO, but without real regard to the
> > meanings. The purpose to click either YES or NO is to continue one
> > step forward and randomity decides later what happens.
> 
> You cannot prevent people from making bad decisions. Saying yes to
> something when you don't know what it means is like using the same
> weak password for everything. There has been massive amounts of
> communication and education out there to let people know about the
> risks. If they choose to ignore it or follow practices which are unsafe,
> it is their tough luck.

I do agree only that it is too general to apply here. That is specific
case of showing a dialogue with potential dangers to users who did not
specify those local variables and probably do not need such!

If you personally specify local variables you need them and know what
it is. That is fine.

It is general design that was meant for hackers in beginning stages of
Emacs development. Today many people use Emacs who may not be
hackers. Subset of those people will say YES to anything.

It is possible to prevent people to make bad decisions and it is easy,
simply don't ask them with the option to make bad decision. Disabling
local variables by default would be better decision.

I think that it is not possible today to change the default. Design is
flawed. From a view point of text editor should not ask user to
execute anything by default. User should enable "Local variables
detection" when user wish to get asked about executions.

> We need to encourage people to take more responsibility for their
> actions, not less.

I do fully agree on that statement, only it is too general and not
specific. I have presented my specific case how I have been answering
YES to that dialogue by thinking it is something necessary to read the
file properly. I had misunderstandings. Since some time I have the
general rule to answer NO on such dialogues. Would there be some
malicious intention in those years the intruder would be quite
successful.

One could fetch the external program and call it "general Emacs
enhancement" and open up a backdoor shell into the system.

To encourage people to take more responsibility is not necessarily
general principle for GNU Emacs.

And to encourage them alone will never work. To gain any
responsibility person needs knowledge or information. Driving car
without knowledge is impossible.

Thus pushing some kinds of responsibilities to user, coercing user to
decide on something that user does not understand itself lacks
one part of responsibility.

If user is informed what are local variables or is using them already
or reads manual and understands dangers, then user has acquired
knowledge to be able to reason when such dialogue pops up with YES or
NO. In general the answer YES can ruin your data and computing, and
users are not aware of it.

When somebody is not aware of what is doing that is not condition of
encouragement, rather condition of lack of responsibility.

> One important component of this is allowing the consequences for bad
> decisions to occur and not spend endless resources protecting people
> from themselves.

The YES/NO dialogue was invented by programmers and not by users. So
it was never an initial decision of the user who reads file from other
person, to be asked in the first place if something in that text file
should get executed.

It may also negatively impact Emacs's image as software:
https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=emacs

> If your asked to do something and your clearly told that doing so might
> be unsafe and your given an option not to do it which is just as easy to
> perform and you still decide to do it, that decision is on you.

Problem is with the assumption that user is "clearly told". I have
used Emacs since 1999 and I was all the time in scratch buffers and
did not really know it is for Emacs Lisp. I have been putting my notes
there. And I have ignored many functions of Emacs and used it to
program in other programming languages. Despite that I did read the
manual I did not clearly get information that there is programming
language built-in and it could execute any code. Despite knowing about
packages and installing them I did not know how it works. That is my
personal reality. I was playing tetris and I did not know it is
program that is loaded and executed. For me that was a built-in
feature, something that Richard Stallman and others invented and
built-in.

> The alternative is to remove extremely useful functionality from
> many responsible users because of an unknown number of others who
> make poor decisions.

Review that statement of yours again as you said what I am saying:
unknown number of others who make poor decisions.

Functionality need not be removed from Emacs to have or to des