Re: Bug: org-archive-subtree-save-file-p results in data loss [9.3.6 (release_9.3.6-432-g73bd24 @ /home/n/.emacs.d/straight/build/org/)]

2020-04-05 Thread Kyle Meyer
No Wayman  writes:

> I'm bumping this because it's bitten me several times.
> The default value of 'from-org is not covered in the saving logic 
> in org-archive-subtree:
>
> https://lists.gnu.org/archive/html/emacs-orgmode/2020-03/msg9.html

I've responded in the original thread.  While bumping threads that
didn't receive attention after some time is appreciated, IMO it'd be
much preferable to do so within the original thread, keeping the
discussion in a single place.



Re: Bug: org-archive-subtree-save-file-p logic [9.3.6 (release_9.3.6-399-ge6df03 @ /home/n/.emacs.d/straight/build/org/)]

2020-04-05 Thread Kyle Meyer
No Wayman  writes:

> The logic for saving the archive buffer in org-archive-subtree 
> does not consider the (default) value  of 'from-org for 
> org-archive-subtree-save-file-p.

Hmm, indeed, the change from 3d0282ef8 (New option
`org-archive-subtree-save-file-p', 2020-01-31) looks incomplete.

> While patching this, I realized I'm not sure I understand the 
> intended logic of each value for org-archive-subtree-save-file-p.

>From digging a bit, I think the history went like this:

  * All the way back in 4be4c5623 (version 4.12a, 2008-01-31),
org-archive-subtree saved the archive buffer, except when it was the
current buffer.

  [ The next two aren't relevant for the save part, but I'm noting
because we should cleaned them up. ]

  * As of bf09955fe (Bugfix for `org-archive-subtree', 2008-03-01), the
buffer was killed after being saved.

  * 343f3c478 (Keep archive buffer after archiving something to it,
2009-10-28) reverted the killing, though it left behind a stale
comment saying the buffer will be killed.

  * 63f6e851b (Do not save target buffer after archiving subtree,
2017-11-25) stopped saving the buffer for performance reasons.

  * Some users preferred the older behavior.  An associated Debian bug
was opened.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=887332
https://yhetil.org/orgmode/f74fce15-c2ea-048e-b2ef-7ad40e717...@arfer.net/

In response, Bastien committed 3d0282ef8 to offer more control over
when saving happens.

> When setting it to 't', the defcustom :tag string claims "Always 
> save the archive buffer".
> This is not the case if archiving from within the current buffer. 
> Perhaps a clearer :tag string?
>
> #+begin_src emacs-lisp
> (defcustom org-archive-subtree-save-file-p 'from-org
>   ;;...
>   (const :tag "Save the archive buffer unless it is the current 
>   buffer" t)
>   ;;...
>   ))
> #+end_src

Yeah, I'd say that's an improvement, though the same "unless it is the
current buffer" would be true for from-org as well, were it wired up.

> The value 'from-org also still saves the archive buffer when 
> archiving from a buffer that is not in Org mode.

I'm confused by this statement.  To me it looks like save-buffer will
_never_ be called when org-archive-subtree-save-file-p is from-org:

(unless (eq this-buffer buffer)
  (when (or (eq org-archive-subtree-save-file-p t)
(and (boundp 'org-archive-from-agenda)
 (eq org-archive-subtree-save-file-p 'from-agenda)))
(save-buffer)))

> I'm not entirely sure of its purpose. If the intent is to allow an 
> option that prevents saving only when archiving from the agenda,
> I suggest a single option excluding that case and saving for 
> other, non-nil values:

Based on the history above, I believe the main purpose is to give users
a way to reverse the "no saving" behavior made in 63f6e851b (Do not save
target buffer after archiving subtree, 2017-11-25).  I'm _guessing_
that, on top of that, the idea adding a from-agenda value was that some
users may want to save only when archiving from the agenda, because in
that case they're a bit removed from the buffer and might not think to
save it, or something along those lines.

> #+begin_src emacs-lisp
> (defcustom org-archive-subtree-save-file-p 'unless-agenda
>   "Conditionally save the archive file after archiving a subtree.
> The value 'unless-agenda prevents saving from the agenda-view.
> Other non-nil values save the archive buffer unless it is the 
> current buffer."
>   :group 'org-archive
>   :package-version '(Org . "9.4")
>   :type '(choice
>   (const :tag "Do not save archive buffer when archiving 
>   from an agenda view" unless-agenda)
>   (const :tag "Save the archive buffer unless it is the 
>   current buffer" t)
>   (const :tag "Do not save the archive buffer")))
> #+end_src
>
> Then the saving logic in org-archive-subtree becomes:
>
> #+begin_src emacs-lisp
> (when org-archive-subtree-save-file-p
>   (unless (or (eq buffer this-buffer)
>   (and (eq org-archive-subtree-save-file-p 
>   'unless-agenda)
>;;bound when called from org-agenda.el
>(boundp 'org-archive-from-agenda)))
> (save-buffer)))
> #+end_src

Assuming what I said above is true, I think what you propose here loses
the ability to save only when archiving from the agenda.  And more
importantly, users would not be able to give a blanket "don't save" in
order to retain the behavior introduced by 63f6e851b (Do not save target
buffer after archiving subtree, 2017-11-25).



negative values for EFFORT result in error when switching to column view

2020-04-05 Thread Heiko Schmidt

Hi everybody.

When planning projects I estimate the amount of time for tasks by
filling the property EFFORT with an amount of time.


#+begin_src org
    ,*** Projekt
            :PROPERTIES:
            :COLUMNS:  %30ITEM %8EFFORT{:}
            :END:
    , effort planned/estimated
             :PROPERTIES:
             :EFFORT:   10 h
             :END:
#+end_src

After acceptance of this planned time the project will be executed and
I sum the amount of time I really needed.

#+begin_src org
    , first effort done
             :PROPERTIES:
             :EFFORT:   -2 h
             :END:
    , secon effort done
             :PROPERTIES:
             :EFFORT:   -3 h
             :END:
#+end_src

When M-x org-columns I'd like to see column view with the balanced sum
of the hours planned and the hours really worked, but I get an error

cond: Invalid duration format: "-2 h"

I know I'm using old versions but this problem is also on newer versions.

org-version: 9.2
GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)
 of 2017-09-12 on hullmann, modified by Debian

I'm wondering why this doesn't work - many people are planning their
whole life with org mode (as I'm doing as well), is any help available?




Re: ob-calc duplicate stack-element issue

2020-04-05 Thread Heiko Schmidt

On 18.03.20 16:50, Eric S Fraga wrote:


Indeed hackish.  But it does beg the question: why does ob-calc pop the
stack?  I cannot see any use case given that the stack is essentially
infinite and can be safely ignored (in most if not all cases).

Could the solution be to simply remove the =(calc-pop 1)= line at the
end of =org-babel-execute:calc= function?

Just a thought.


After removing

(calc-pop 1)

 from =org-babel-execute:calc= the problem is perfectly solved.

Thanks a lot.





Re: ob-calc duplicate stack-element issue

2020-04-05 Thread Heiko Schmidt

Hi Marco,


On 18.03.20 15:47, Marco Wahl wrote:

Okay. I take here the "any advice is appreciated" part.
AFAICS at the org babel calc evaluation the last value of the calc stack
gets dropped.

So your workaround is okay, I think.  You can just write any dummy
element at the bottom of each block e.g. just 0.  No need of
duplication.  Looks a bit hackish to me but so what?
Oh no. You're completely right. This simplifying clarification is 
already quite helpful. Just putting 0 on top of stack is enough. 
Terrifying simple.

Another approach could be "noweb".  Example (you would just evaluate the
block at the bottom):

--8<---cut here---start->8---
Number of cars (PKW) in germany:

#+name: numcars
#+begin_src calc :exports both
45e6
#+end_src

Yearly mileage in [km/y]

#+name: mileage
#+begin_src calc :exports both
15000
#+end_src

Calculate amount of complete km per year

#+begin_src calc :noweb yes
<>
<>
'*
#+end_src
--8<---cut here---end--->8---


HTH,
-- Marco

From my point of view "variablizing" distracts me to much. I'd prefer 
more to comment via "literate" description of the numbers.




Re: Why is `org-element-affiliated-keywords' a var when `org-element--affiliated-re' is a const?

2020-04-05 Thread Johan Tolö

Nicolas Goaziou  writes:

snip

Syntax is not meant to be changed by users. Also,
`org-element-affiliated-keywords' is a defconst.


Oh, yes you are of course right. Somehow I got the definition 
mixed up, must have been looking at the definition in 
'org-pcomplete.el' or something. Sorry about that.




You might abuse #+header: affiliated keyword to add a reference.


OK, thanks. I will give it a try.


--
Johan



Re: help with sexp in org-capture-template

2020-04-05 Thread Kyle Meyer
Hi Bala,

Bala Ramadurai  writes:

> I am working on a org-capture-template and one of the entries is a date (30
> days later) I want in European format.
>
> My solution is this:
> | *Due Date*: %(concat (substring (org-read-date nil nil "+30d") 8 10) "-"
> (substring(org-read-date nil nil "+30d") 5 7) "-" (substring(org-read-date
> nil nil "+30d") 0 4)) |
>
> Although this does the job, it is extremely inelegant and only reflects my
> poor knowledge in elisp.
>
> Can any of you please help me in making this code better?

Does the job is the important part :)  One thing you could do that'd
make it a little nicer to my eyes is let-binding

  (org-read-date nil nil "+30d")

result to avoid calling it three times.

Here's another approach:

(format-time-string "%d-%m-%Y" (time-add (days-to-time 30) nil))



Re: tangling from multiple files

2020-04-05 Thread Berry, Charles



> On Apr 4, 2020, at 11:08 AM, David Bremner  wrote:
> 
> "Berry, Charles"  writes:
> 
>> Oops. Correction below.
>> 
>>> On Mar 18, 2020, at 7:38 PM, Berry, Charles  wrote:
>>> 
>>> 
>>> Right. It does not work directly for tangling. So also use 
>>> 
>>> #+export_file_name: b2.org
>>> 
>>> (say)
>>> 
>>> Then load ox-ob.el,
>> 
>> load ox-org.el, rather.
>> 
>>> export as C-c C-e O o (org-org-export-to-org),  visit b2.org and tangle 
>>> from there. 
> 
> I finally got around to trying this. In a broad sense it works, but
> (at least with default settings) it loses the keywords on individual
> source blocks.


I see.

It looks like you are back to `org-babel-lob-ingest'.

Maybe the issue you raised at the start of having to re-ingest after changes 
could be addressed by a function in `org-babel-pre-tangle-hook'.

HTH,

Chuck








Re: R session and plotting in x11 window

2020-04-05 Thread Berry, Charles



> On Apr 4, 2020, at 4:27 PM, Matt Price  wrote:
> 
> Does anyone know much about the difference between an R session opened by 
> typing M-x R, and the R session opened by org-babel?


Short answer: almost none.

Long answer: what `org-babel-R-initite-session' and friends do.

> 
> I'm just learning R and my usual method for learning a language is to keep a 
> kind of notebook in org with code snippets they I can execute and iterate on 
> rapidly as I learn. This works great in R when I'm just doing math.  When I 
> am working on plots, it would be nice to have them open up quickly either in 
> emacs or in the standard x11 window that R session opened switch M-x R opens 
> up.  
> 
> I know I can set the src block headers to produ e a file, but when I'm just 
> iterating rapidly I often switch back and forth between a data output and a 
> graphical output, and typing/erasing those headers is clunky and slow. It 
> would be easier to just paste the plot command into the console and have it 
> pop open the window... But that doesn't seem to work. Anyone know if I can 
> tweak something to make that possible?
> 


I sam really puzzled by this. Do you have an ECM that illustrates this?

Working interactively on my Mac (Quartz - X11 is the device), I routinely do 
what you describe - usually working from the src edit buffer - and the plots 
are displayed (and older plots are available via clover-left or some such).

If I had to guess, I'd say that you are opening an R session, but not using it. 
If you execute a src block, but it does not have a `:session' header, a new 
instance of R will create a plot file and then exit. If you look in the default 
directory, you would see `Rplots.pdf' or some such.

The only other thing that comes to mind is that you opened a device that is 
holding on to all your plots. Try `dev.cur()' in R immediately before and after 
you create a plot and see what the result is.

HTH,

Chuck





Re: Why is `org-element-affiliated-keywords' a var when `org-element--affiliated-re' is a const?

2020-04-05 Thread Nicolas Goaziou
Hello,

Johan Tolö  writes:

> Dear all,
>
> I want to add my own org-element affiliated keyword "REF" in order 
> to provide a reference to some other part of an org mode document 
> (or another document) for a link.
>
> For example:
>
> #+NAME: a-figure
> #+REF: [[file:another_document.org]]
>
> [[file:a-figure.png]]
>
> I want to use `org-element-context' to get the link element and 
> use `org-element-property' to get the `REF' property.
>
> I tried changing `org-element-affiliated-keywords' in order to 
> define my own keyword. This is never picked up by 
> `org-element-context' since it uses `org-element--affiliated-re' 
> which is defined as a const and thus is never updated to reflect 
> the change to `org-element-affiliated-keywords'. The help text for 
> `org-element--affiliated-re' even mentions changing 
> `org-element-affiliated-keywords'.
>
> Is this an oversight or am I trying to use this is a way that is 
> not intended?

Syntax is not meant to be changed by users. Also,
`org-element-affiliated-keywords' is a defconst.

You might abuse #+header: affiliated keyword to add a reference.

Regards,

-- 
Nicolas Goaziou



Re: "Wrong number of arguments: nil, 0" error when exporting a table with caption to ODT

2020-04-05 Thread Kyle Meyer
Perl Ancar  writes:

> On Sun, Apr 5, 2020 at 12:16 PM Kyle Meyer  wrote:
>
>> > Any pointer?
>>
>> If upgrading doesn't work for you (or you'd just like to investigate),
>> doing "M-x toggle-debug-on-error" and getting a backtrace could be a
>> good place to start.
>>
>
> Unfortunately after M-x toggle-debug-on-error I'm not getting relevant
> additional messages in the *Messages* buffer (I read that messages will
> appear in the *Warnings* buffer, but I see that there is no *Warnings*
> buffer created):

Ah, sorry for the unhelpful suggestion.  It looks like that error is
being caught (which I should have guessed from the "OpenDocument ..."
prefix):


  (defmacro org-odt--export-wrap (out-file  body)
[...]
   (condition-case err
   [...]
 (error
  ;; Cleanup work directory and work files.
  (funcall --cleanup-xml-buffers)
  (message "OpenDocument export failed: %s"
   (error-message-string err)

So to see the error, you could either remove that error handling or
tweak it to re-throw it:

(signal (car err) (cdr err))



Scrolling through features on website doesn't work properly

2020-04-05 Thread Janek F
Hey,

Trying to scroll through the features of org mode on 
https://orgmode.org/features.html# with the buttons didn't work for me, neither 
on Firefox nor Chromium.
On other subpages, such as https://orgmode.org/#docs, it did work.

Regards,
Janek

Why is `org-element-affiliated-keywords' a var when `org-element--affiliated-re' is a const?

2020-04-05 Thread Johan Tolö

Dear all,

I want to add my own org-element affiliated keyword "REF" in order 
to provide a reference to some other part of an org mode document 
(or another document) for a link.


For example:

#+NAME: a-figure
#+REF: [[file:another_document.org]]
[[file:a-figure.png]]

I want to use `org-element-context' to get the link element and 
use `org-element-property' to get the `REF' property.


I tried changing `org-element-affiliated-keywords' in order to 
define my own keyword. This is never picked up by 
`org-element-context' since it uses `org-element--affiliated-re' 
which is defined as a const and thus is never updated to reflect 
the change to `org-element-affiliated-keywords'. The help text for 
`org-element--affiliated-re' even mentions changing 
`org-element-affiliated-keywords'.


Is this an oversight or am I trying to use this is a way that is 
not intended?


Johan

--
Johan



Additonal slashes in URI sent to org-protocol

2020-04-05 Thread Ferdinand Pieper

Hi everyone,

I was trying to set up org-protocol with Firefox (version 74.0) running under 
Windows 10. Unfortunately there seems to be an issue with additional slashes 
added to the URI so org-protocol can not parse it.

I setup a bookmark as mentioned in [1]. I changed the bookmark content to the 
new style of org-protocol links as described in [2], resulting in:

--8<---cut here---start->8---
javascript:location.href='org-protocol://capture?template=L='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())
--8<---cut here---end--->8---

To setup the forwarding to Emacs running inside WSL I used a registry entry as 
described on the same page:

--8<---cut here---start->8---
REGEDIT4

[HKEY_CLASSES_ROOT\org-protocol]
@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@="\"C:\\Windows\\System32\\wsl.exe\" emacsclient \"%1\""
--8<---cut here---end--->8---

Somehow Firefox adds another slash inbetween ~capture~ and the questionmark, so 
that Emacs receives this call, which I extracted from a Backtrace:

--8<---cut here---start->8---
* org-protocol-check-filename-for-protocol("/mnt/c/Windows/system32/org-protocol:/capture/?template=L=https%3A%2F%2Forgmode.org%2F=Org%20mode%20for%20Emacs%20–%20Your%20Life%20in%20Plain%20Text=" (("/mnt/c/Windows/system32/org-protocol:/capture/?template=L=https%3A%2F%2Forgmode.org%2F=Org%20mode%20for%20Emacs%20–%20Your%20Life%20in%20Plain%20Text=")) #<68>>)

--8<---cut here---end--->8---

The format ~org-protocol:/capture/?template=L...~ still seems to be within the 
HTML spec. But the additional slash makes the function 
~org-protocol-check-filename-for-protocol~ fail to recognize the URI as a 
capture call. See also the discussion in [3].
I also tried the same bookmark in Chromium (version 83.0) but it also adds the 
additional slash.
I attached a proposed patch to allow URIs with and without the slash.

I'd be happy to know if anybody has a working setup using the bookmark above or 
similar or if there are other solutions which do not require this patch. 
Otherwise please let me know what is left to do to get this patch applied.

Thanks!


Footnotes:
[1]  https://orgmode.org/worg/org-contrib/org-protocol.html#org120a44e

[2]  https://orgmode.org/Changes_old.html#org18864d9

[3] 
https://github.com/sprig/org-capture-extension/issues/41#issuecomment-578499266

>From a476821ebecd9649b2c88a86a0562c757bb2c3a0 Mon Sep 17 00:00:00 2001
From: fpi 
Date: Fri, 3 Apr 2020 19:12:01 +0200
Subject: [PATCH] org-protocol: Allow slashes after sub-protocol

This change lets org-protocol handle URIs with additional slashes
before the start of the query string, e.g.

org-protocol:/capture/?template=...

instead of

org-protocol:/capture?template=...
---
 lisp/org-protocol.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 55a534d0d..8fbff9611 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -617,13 +617,13 @@ CLIENT is ignored."
 (let ((proto
 		   (concat the-protocol
 			   (regexp-quote (plist-get (cdr prolist) :protocol))
-			   "\\(:/+\\|\\?\\)")))
+			   "\\(:/+\\|/*\\?\\)")))
   (when (string-match proto fname)
 (let* ((func (plist-get (cdr prolist) :function))
(greedy (plist-get (cdr prolist) :greedy))
(split (split-string fname proto))
(result (if greedy restoffiles (cadr split)))
-		   (new-style (string= (match-string 1 fname) "?")))
+		   (new-style (string-match (match-string 1 fname) "/*?")))
   (when (plist-get (cdr prolist) :kill-client)
 		(message "Greedy org-protocol handler.  Killing client.")
 		(server-edit))
-- 
2.25.0



Bug: org-shiftright etc. do not respect org-support-shift-select [9.3.6 (9.3.6-elpa @ /home/vladimir/.emacs.d/elpa/org-9.3.6/)]

2020-04-05 Thread vladimir


I have org-support-shift-select set to 'always. As such, when editing
tables, I expect that Shift + arrow keys to enable Emacs shift
selection. Instead, it moves table cells around.

This behavior did not exist in Org 9.1.9.

The documentation of org-support-shift-select should also be updated to
include tables in the list of contexts where shifted cursor keys execute
Org commands.

Emacs  : GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll 
bars)
 of 2019-09-07
Package: Org mode version 9.3.6 (9.3.6-elpa @ 
/home/vladimir/.emacs.d/elpa/org-9.3.6/)

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-blank-before-new-entry '((heading . auto) (plain-list-item))
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-reveal-start-hook '(org-decrypt-entry)
 org-calc-default-modes '(calc-language c calc-internal-prec 12 
calc-float-format
  (float 8) calc-angle-mode deg calc-prefer-frac nil
  calc-symbolic-mode nil calc-date-format
  ( "-" MM "-" DD " " Www (" " hh ":" mm))
  calc-display-working-message t)
 org-mode-hook '(cs/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
 #[0 "\301\211\207"
   [imenu-create-index-function org-imenu-get-tree] 2]
 )
 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-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-support-shift-select 'always
 org-speed-command-hook '(org-speed-command-activate
  org-babel-speed-command-activate)
 org-return-follows-link t
 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\302Q!\207" ["news" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("mailto" :follow
#[257 "\301\300\302Q!\207" ["mailto" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("https" :follow
#[257 "\301\300\302Q!\207" ["https" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("http" :follow
#[257 "\301\300\302Q!\207" ["http" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("ftp" :follow
#[257 "\301\300\302Q!\207" ["ftp" browse-url ":"] 5
  "\n\n(fn URL)"]
)

Re: Do something useful with ".+" and hours repeaters

2020-04-05 Thread Kyle Meyer
Nicolas Goaziou  writes:

> WDYT?

Makes sense to me.  I have one nitpick on the actual change:

> +   ;; Shift starting date to today, or now if
> +   ;; repeater is by hours.
> +   (if (equal what "h")
> +   (org-timestamp-change
> +(floor (/ (- (org-time-stamp-to-now ts t)) 60))
> +'minute)

You could use floor's DIVISOR argument:

(floor (- (org-time-stamp-to-now ts t)) 60)

Many such spots in Emacs's tree have been adjusted by Paul Eggert, and
the ones touching Org files have been ported back.



Re: Emacs-orgmode Digest, Vol 170, Issue 5

2020-04-05 Thread No Wayman



Someone on #org-mode (sorry, I cannot remember the nickname) 
reported
that ".+" repeater style was not handling properly (not handling 
at all,

actually) hours spans.

As a reminder, ".+" means "repeat, starting from today as the 
base
date". With hours, it seems logical to "repeat, starting from 
now as the

base date". The attached patch does that.

WDYT?


Great idea! IIUC, this would allow habits to be repeated within a 
day. May use cases spring to mind: stretching, walking, hydration, 
medication, etc.




RE: [Bug] org-store-link should not insert a document level ID property

2020-04-05 Thread Gustav Wikström
Hi again,

Patch is attached. It's not applied yet as it doesn't include anything about 
user-configuration yet. @Matt Lundin, care to elaborate what you had in mind in 
terms of that?

With this patch a link before first headline is stored with the filename (no 
path) as description. Following the link does what you'd expect. Tests ran fine 
with the patch applied.

Regards
Gustav

> Hi,
> 
> > -Original Message-
> > From: Matt Lundin 
> > Sent: den 5 april 2020 00:13
> > To: Org Mode List 
> > Cc: Gustav Wikström 
> > Subject: [Bug] org-store-link should not insert a document level ID property
> >
> > The introduction of document-level property drawers (commit
> > 1bdff9f73dc1e7ff625a90e3e61350bdea99f29c from May 2019) introduced
> > inconsistencies in the behavior of org-id and org-store-link.
> >
> > If org-id-link-to-org-use-id is set to t or 'create-if-interactive,
> > calling org-store-link above the first headline in an org file will
> > insert a PROPERTY drawer and an ID at top of the file, so that the file
> > (call it "~/test.org") looks like this:
> >
> > --8<---cut here---start->8---
> > :PROPERTIES:
> > :ID:   1f43e860-9e7b-4c8f-82b9-6ed3352e589f
> > :END:
> >
> > * First headline
> > --8<---cut here---end--->8---
> >
> > However, the link that Org actually stores is "[[file:~/test.org]]", so
> > the ID is irrelevant.
> >
> > In addition, a link to a document-level ID does not work. Following
> > "[[id:1f43e860-9e7b-4c8f-82b9-6ed3352e589f]]" results in this error:
> >
> > user-error: Before first headline at position 14 in buffer test.org
> >
> > So either:
> >
> > 1. org-id and org-store-link/org-open-link should support document level
> >ids in a user-configurable way, or
> > 2. org-id-get-create should detect whether it is above the first heading
> >and should not create an id
> >
> > Option #2 would obviously be the easier fix.
> >
> > Gustav: were IDs within the scope of your initial thinking about
> > document level properties? Or are these largely irrelevant?
> 
> Yes, they were in scope and ID should mean something also before first
> headline. I'll have a look to see what can be done. Thanks for finding this!
> 
> >
> > Best,
> > Matt


0001-Allow-storing-and-following-ID-links-before-first-he.patch
Description: 0001-Allow-storing-and-following-ID-links-before-first-he.patch


Additonal slashes in URI sent to org-protocol

2020-04-05 Thread Ferdinand Pieper

Hi everyone,

I was trying to set up org-protocol with Firefox (version 74.0) running under 
Windows 10. Unfortunately there seems to be an issue with additional slashes 
added to the URI so org-protocol can not parse it.

I setup a bookmark as mentioned in [1]. I changed the bookmark content to the 
new style of org-protocol links as described in [2], resulting in:

--8<---cut here---start->8---
javascript:location.href='org-protocol://capture?template=L='+encodeURIComponent(location.href)+'='+encodeURIComponent(document.title)+'='+encodeURIComponent(window.getSelection())
--8<---cut here---end--->8---

To setup the forwarding to Emacs running inside WSL I used a registry entry as 
described on the same page:

--8<---cut here---start->8---
REGEDIT4

[HKEY_CLASSES_ROOT\org-protocol]
@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@="\"C:\\Windows\\System32\\wsl.exe\" emacsclient \"%1\""
--8<---cut here---end--->8---

Somehow Firefox adds another slash inbetween ~capture~ and the questionmark, so 
that Emacs receives this call, which I extracted from a Backtrace:

--8<---cut here---start->8---
* org-protocol-check-filename-for-protocol("/mnt/c/Windows/system32/org-protocol:/capture/?template=L=https%3A%2F%2Forgmode.org%2F=Org%20mode%20for%20Emacs%20–%20Your%20Life%20in%20Plain%20Text=" (("/mnt/c/Windows/system32/org-protocol:/capture/?template=L=https%3A%2F%2Forgmode.org%2F=Org%20mode%20for%20Emacs%20–%20Your%20Life%20in%20Plain%20Text=")) #<68>>)

--8<---cut here---end--->8---

The format ~org-protocol:/capture/?template=L...~ still seems to be within the 
HTML spec. But the additional slash makes the function 
~org-protocol-check-filename-for-protocol~ fail to recognize the URI as a 
capture call. See also the discussion in [3].
I also tried the same bookmark in Chromium (version 83.0) but it also adds the 
additional slash.
I attached a proposed patch to allow URIs with and without the slash.

I'd be happy to know if anybody has a working setup using the bookmark above or 
similar or if there are other solutions which do not require this patch. 
Otherwise please let me know what is left to do to get this patch applied.

Thanks!


Footnotes:
[1]  https://orgmode.org/worg/org-contrib/org-protocol.html#org120a44e

[2]  https://orgmode.org/Changes_old.html#org18864d9

[3] 
https://github.com/sprig/org-capture-extension/issues/41#issuecomment-578499266

>From a476821ebecd9649b2c88a86a0562c757bb2c3a0 Mon Sep 17 00:00:00 2001
From: fpi 
Date: Fri, 3 Apr 2020 19:12:01 +0200
Subject: [PATCH] org-protocol: Allow slashes after sub-protocol

This change lets org-protocol handle URIs with additional slashes
before the start of the query string, e.g.

org-protocol:/capture/?template=...

instead of

org-protocol:/capture?template=...
---
 lisp/org-protocol.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 55a534d0d..8fbff9611 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -617,13 +617,13 @@ CLIENT is ignored."
 (let ((proto
 		   (concat the-protocol
 			   (regexp-quote (plist-get (cdr prolist) :protocol))
-			   "\\(:/+\\|\\?\\)")))
+			   "\\(:/+\\|/*\\?\\)")))
   (when (string-match proto fname)
 (let* ((func (plist-get (cdr prolist) :function))
(greedy (plist-get (cdr prolist) :greedy))
(split (split-string fname proto))
(result (if greedy restoffiles (cadr split)))
-		   (new-style (string= (match-string 1 fname) "?")))
+		   (new-style (string-match (match-string 1 fname) "/*?")))
   (when (plist-get (cdr prolist) :kill-client)
 		(message "Greedy org-protocol handler.  Killing client.")
 		(server-edit))
-- 
2.25.0



Do something useful with ".+" and hours repeaters

2020-04-05 Thread Nicolas Goaziou
Hello,

Someone on #org-mode (sorry, I cannot remember the nickname) reported
that ".+" repeater style was not handling properly (not handling at all,
actually) hours spans.

As a reminder, ".+" means "repeat, starting from today as the base
date". With hours, it seems logical to "repeat, starting from now as the
base date". The attached patch does that.

WDYT?

-- 
Nicolas Goaziou
>From 19ee311eb35bc4cde08e61bc485a679df2d584dd Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou 
Date: Sun, 5 Apr 2020 15:47:45 +0200
Subject: [PATCH] Handle ".+" repeater style for hours

* lisp/org.el (org-auto-repeat-maybe): Handle ".+" repeater style for
hours.
* doc/org-manual.org (Repeated tasks): Add an example.
---
 doc/org-manual.org |  4 
 lisp/org.el| 11 ---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 5f55e9bd5..ee054a744 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -6337,6 +6337,10 @@ special repeaters =++= and =.+=.  For example:
 ,** TODO Check the batteries in the smoke detectors
DEADLINE: <2005-11-01 Tue .+1m>
Marking this DONE will shift the date to one month after today.
+
+,** TODO Play a major third while pushing the bird through the door
+   DEADLINE: <2019-04-05 08:00 Sun .+1h>
+   Marking this DONE shifts the date to exactly one hour from now.
 #+end_example
 
 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
diff --git a/lisp/org.el b/lisp/org.el
index 06891b8bd..b9742514d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10146,9 +10146,14 @@ This function is run automatically after each state change to a DONE state."
 			(repeater-type (match-string 1 ts)))
 		(cond
 		 ((equal "." repeater-type)
-		  ;; Shift starting date to today.
-		  (org-timestamp-change (- (org-today) (time-to-days time))
-	'day))
+		  ;; Shift starting date to today, or now if
+		  ;; repeater is by hours.
+		  (if (equal what "h")
+			  (org-timestamp-change
+			   (floor (/ (- (org-time-stamp-to-now ts t)) 60))
+			   'minute)
+			(org-timestamp-change (- (org-today) (time-to-days time))
+	  'day)))
 		 ((equal "+" repeater-type)
 		  (let ((nshiftmax 10)
 			(nshift 0))
-- 
2.26.0



Re: modify frame title in beamer export

2020-04-05 Thread Nicolas Goaziou
Hello,

"Gürtler, Martin"  writes:

> I'd like to modify the frame title in beamer export based on
> properties or priority as this is possible in latex export.
>
> In latex export, one can set the variable
> org-latex-format-headline-function to the name of a function that
> creates the content of the headline. I was able to use this in
> latex export.
>
> As beamer export is derived from latex export I had hoped that this
> would automatically work for beamer export as well, but this
> is not the case, the headlines in beamer export are not modified.
>
> A second question is, whether one could also use properties to
> format the headlines. The arguments of the user supplied function
> include tags, but not properties. 

I suggest to create a function modifying the headline element in the
parse tree, and add it to `org-export-filter-parse-tree-functions'. This
way, you have access to all properties and what not, and can replace the
headline by whatever you need. E.g., (untested):

(defun my-beamer-frame-title-filter (ast backend info)
  (cond
   ((not (org-export-derived-backend-p 'beamer)) ast)
   (t
(org-element-map ast 'headline
  (lambda (h)
(when (equal (org-export-get-node-property :A h) "foo")
  (org-element-put-property h :title "FOO!")))
  info)
ast)))

HTH,

-- 
Nicolas Goaziou



bug#35419: [O] [Proposal] Buffer Lenses and the Case of Org-Mode (also, Jupyter)

2020-04-05 Thread Dmitrii Korobeinikov
Thank you for the insight and the references! Quite useful to learn
about this stuff.

вс, 5 апр. 2020 г. в 07:46, Dmitry Gutov :
>
> Hi!
>
> Some late clarifications about mmm-mode.
>
> On 26.04.2019 00:00, Dmitrii Korobeinikov wrote:
> >  > A lot of the functionality of MMM Mode---that which makes the major mode
> >  > appear to change---is implemented by saving and restoring the values of
> >  > local variables, or pseudo-variables.
> >
> > What I don't understand is where the modes of the submode region run and
> > when they are turned on.
>
> They are run in an empty temporary buffer, see mmm-update-mode-info.
> That is true for all the "submodes" in a buffer. The primary major mode
> is run in the context of that buffer (IIRC). After any of them runs, the
> code responsible for it collects the values of a certain number of known
> variables and associates that map with the major mode (this is a bit of
> a simplification).
>
> > Are necessary modes just allowed to run at the right time for the whole
> > buffer?
>
> When you move between the "chunks", no major mode functions are called.
> Instead, the values of variables are swapped in. Including the value of
> the 'major-mode' variable.
>
> > But then, how are they limited in their effect to just the
> > necessary region? Narrowing?
>
> Usually, yes. Especially when we're talking about font-lock and
> syntax-propertize-function. See mmm-fontify-region-list for an example.
>
> > Could, for example, syntax checking be done efficiently that way?
>
> That depends on the combination of modes and how they are used (either
> they can be nested, like in web templates, or it's a flat list where
> chunks are largely independent like in Jupyter). But in most cases, I
> think, you could pick a good strategy. There are no universal ones, though.





Re: "Wrong number of arguments: nil, 0" error when exporting a table with caption to ODT

2020-04-05 Thread Perl Ancar
On Sun, Apr 5, 2020 at 12:16 PM Kyle Meyer  wrote:

> Perl Ancar  writes:
>
> > I tried exporting a document with table that has caption to ODT and it
> > failed with this error message:
> >
> > OpenDocument export failed: Wrong number of arguments: nil, 0
> >
> > Sample document:
> >
> > #+CAPTION: some caption
> > | row1 |
>
> Trying with the latest release of Org (9.3.6), I exported this without
> hitting the above error, so upgrading will likely resolve the issue for
> you.
>
> > Any pointer?
>
> If upgrading doesn't work for you (or you'd just like to investigate),
> doing "M-x toggle-debug-on-error" and getting a backtrace could be a
> good place to start.
>

Unfortunately after M-x toggle-debug-on-error I'm not getting relevant
additional messages in the *Messages* buffer (I read that messages will
appear in the *Warnings* buffer, but I see that there is no *Warnings*
buffer created):

Debug on Error enabled globally
Debug (ox-odt): Searching for OpenDocument styles files...
Debug (ox-odt): Trying /usr/share/emacs/25.2/etc/styles/... [2 times]
Debug (ox-odt): Trying /usr/share/emacs/25.2/lisp/org/etc/styles/...
Debug (ox-odt): Trying /usr/share/emacs/25.2/etc/org/...
Debug (ox-odt): Using styles under /usr/share/emacs/25.2/etc/org/
Debug (ox-odt): Searching for OpenDocument schema files...
Debug (ox-odt): Trying /usr/share/emacs/25.2/etc/schema/...
Debug (ox-odt): No OpenDocument schema files installed
LaTeX to MathML converter not available.
Formatting LaTeX using verbatim
OpenDocument export failed: Wrong number of arguments: nil, 0
You can run the command ‘org-odt-export-to-odt’ with M-x -od-t RET

However, when trying to upgrade org, I try exporting under "emacs -q" and
this error does not happen. So I'll need to comb through my years-old
~/.emacs to try to figure out what causes this error.


modify frame title in beamer export

2020-04-05 Thread Gürtler , Martin

Hi,

I'd like to modify the frame title in beamer export based on
properties or priority as this is possible in latex export.

In latex export, one can set the variable
org-latex-format-headline-function to the name of a function that
creates the content of the headline. I was able to use this in
latex export.

As beamer export is derived from latex export I had hoped that 
this

would automatically work for beamer export as well, but this
is not the case, the headlines in beamer export are not modified.

A second question is, whether one could also use properties to
format the headlines. The arguments of the user supplied function
include tags, but not properties. 


Thanks,

Martin


signature.asc
Description: PGP signature


Bug: org-shiftright etc. do not respect org-support-shift-select [9.3.6 (9.3.6-elpa @ /home/vladimir/.emacs.d/elpa/org-9.3.6/)]

2020-04-05 Thread Vladimir Panteleev
Hello,

I have org-support-shift-select set to 'always. As such, when editing
tables, I expect that Shift + arrow keys to enable Emacs shift
selection. Instead, it moves table cells around.

This behavior did not exist in Org 9.1.9.

The documentation of org-support-shift-select should also be updated
to include tables in the list of contexts where shifted cursor keys
execute Org commands.

Thanks!

Emacs  : GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw
scroll bars) of 2019-09-07
Package: Org mode version 9.3.6 (9.3.6-elpa @
/home/vladimir/.emacs.d/elpa/org-9.3.6/)

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-blank-before-new-entry '((heading . auto) (plain-list-item))
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-reveal-start-hook '(org-decrypt-entry)
 org-calc-default-modes '(calc-language c calc-internal-prec 12
calc-float-format
  (float 8) calc-angle-mode deg calc-prefer-frac nil
  calc-symbolic-mode nil calc-date-format
  ( "-" MM "-" DD " " Www (" " hh ":" mm))
  calc-display-working-message t)
 org-mode-hook '(cs/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
 #[0 "\301\211\207"
   [imenu-create-index-function org-imenu-get-tree] 2]
 )
 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-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-support-shift-select 'always
 org-speed-command-hook '(org-speed-command-activate
  org-babel-speed-command-activate)
 org-return-follows-link t
 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\302Q!\207" ["news" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("mailto" :follow
#[257 "\301\300\302Q!\207" ["mailto" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("https" :follow
#[257 "\301\300\302Q!\207" ["https" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("http" :follow
#[257 "\301\300\302Q!\207" ["http" browse-url ":"] 5
  "\n\n(fn URL)"]
)
   ("ftp" :follow
#[257 "\301\300\302Q!\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
 )