Re: Bug: incorrect timestamps with :time-prompt and datetrees

2021-01-17 Thread Kyle Meyer
Richard Lawrence writes:

> Hi everyone,
>
> Richard Lawrence  writes:
>
>> I can now confirm that this is the problem. It looks like what is happening 
>> here
>> is that the regex is meant to match a time range, but ends up matching
>> the date: thus a string like "12-31 13:00" gets mangled to "12 13:00"
>> and sent into org-read-date-analyze.
>
>> So I guess the solution is...a better regex is needed to cause this
>> branch to fire only in the intended case, namely, a time range. 
>
> Here is a patch for this issue. It uses a narrower regex to match a time
> range. This regex requires time ranges to have ":MM" or an AM/PM
> specification in the end time, to prevent mangling strings that are
> interpreted as dates, like "11-12".

Thanks for the detailed analysis and the patch.

> This patch is a minimal change that gets the code working in the way
> that seems to have been intended, so it seems worth applying to maint.

Yes, seems so.  The original change came in b61ff117b (org-capture.el:
Set a correct time value with file+datetree+prompt, 2012-09-24), and I
believe the related thread is
.

I'm okay with the minimal fix to the regexp, though I wonder if we can
avoid the follow-up call to org-read-date-analyze entirely.  I'm running
out of time to test thoroughly tonight, but perhaps something like this
(ignoring the potential cond->if cleanup):

--8<---cut here---start->8---
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 038b24312..04e56d655 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1026,27 +1026,19 @@ (defun org-capture-set-target-location ( 
target)
  ((or (org-capture-get :time-prompt)
   (equal current-prefix-arg 1))
   ;; Prompt for date.
-  (let* ((org-end-time-was-given nil)
+   (let* ((org-time-was-given nil)
+  (org-end-time-was-given nil)
   (prompt-time (org-read-date
nil t nil "Date for tree entry:")))
 (org-capture-put
  :default-time
- (cond ((and (or (not (boundp 'org-time-was-given))
- (not org-time-was-given))
+  (cond ((and (or (not org-time-was-given))
  (not (= (time-to-days prompt-time) (org-today
 ;; Use 00:00 when no time is given for another
 ;; date than today?
 (apply #'encode-time 0 0
org-extend-today-until
(cl-cdddr (decode-time prompt-time
-   ((string-match "\\([^ ]+\\)-[^ ]+[ ]+\\(.*\\)"
-  org-read-date-final-answer)
-;; Replace any time range by its start.
-(apply #'encode-time
-   (org-read-date-analyze
-(replace-match "\\1 \\2" nil nil
-   org-read-date-final-answer)
-prompt-time (decode-time prompt-time
(t prompt-time)))
 (time-to-days prompt-time)))
  (t
--8<---cut here---end--->8---

> However, the way the code is intended to work doesn't seem right to me,
> because it simply throws away time range information at the time prompt.
> If you enter a time range like "13:00-14:00" at the time prompt, you
> will get a timestamp with "13:00" for the time when the %T template is
> expanded. (This is because org-capture-set-target-location uses the
> beginning of the entered time range to set :default-time, which must be
> an encoded time value, and there is no obvious way to set a time range.)
> This is a surprising contrast with the behavior of %^T, which preserves
> the time range information in the timestamp entered. But fixing this
> will be a larger change and possibly requires some discussion.

Hmm, I haven't wrapped my head around that enough to know what I think,
but perhaps the thread I pointed to above is relevant, at least for
historical context.

> Subject: [PATCH] org-capture: fix expansion of %T when capturing to a datetree
>
> * org-capture.el (org-capture-set-target-location): Use a narrower
> regular expression to replace a time range by its start time when
> setting :default-time, so that dates do not get mangled.
>
> TINYCHANGE
> ---
>  lisp/org-capture.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index f40f2b335..df0eccdbb 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -1038,12 +1038,12 @@ Store them in the capture property list."
>(apply #'encode-time 0 0
> 

Why are (UU)IDs limited to the headline level?

2021-01-17 Thread arozbiz
I'm just getting into Emacs/Org-Mode. It's clearly an amazing system and
the linking via UUID is very useful. My question is: why is linking by UUID
(and, more generally, the creation of properties drawers) limited to
headlines, and not to sub-elements like list elements or paragraphs?
Doesn't all the necessary structural information exist to assign UUIDs to
everything?

The reason I'm asking is that getting into Org-Roam, the linking for which
relies on Org UUIDs for headlines. If UUIDs were available for all elements
of an Org file, that will allow for more granular linking behavior.

Thanks,
Alan


Re: Feature request

2021-01-17 Thread Ihor Radchenko
Raoul Comninos  writes:

> With your permission can I post your solution to stack-exchange,
> crediting you?

Sure. The public message URL is
https://orgmode.org/list/87sg70vsvy.fsf@localhost/

Best,
Ihor




Re: Custom Bulk Functions With Prompt

2021-01-17 Thread Kevin Foley
Ihor Radchenko  writes:

> Note that attachment in the previous email appears to be empty. Can you
> resend? I will take a look then.

My mistake, populated file is attached. Thanks.

Kevin

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..1df99ec79 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -10487,7 +10487,12 @@ (defun org-agenda-bulk-action ( arg)
 
 	(action
 	 (pcase (assoc action org-agenda-bulk-custom-functions)
-	   (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
+	   (`(,_ ,f)
+(when (listp f)
+  (let ((args (funcall (nth 1 f)))
+(func (nth 0 f)))
+(setq f (apply #'apply-partially func args
+(setq cmd f) (setq redo-at-end t))
 	   (_ (user-error "Invalid bulk action: %c" action)
 
   ;; Sort the markers, to make sure that parents are handled


Re: Feature request

2021-01-17 Thread Ihor Radchenko
Raoul Comninos  writes:

> It works now and its awesome! I cannot believe that they had this
> feature and removed it. I am a very happy man and I cannot thank you enough.

This feature creates a lot of junk text when attachment folder gets very
large. For example, I keep my travel photos as attachments. There can be
hundreds of photos in a single attachment folder. Showing all the photo
names in a property would be not very useful.

On the other hand, if more people are interested, this feature can be
resurrected as a user-option (disabled by default).

Best,
Ihor




Re: Custom Bulk Functions With Prompt

2021-01-17 Thread Ihor Radchenko
Kevin Foley  writes:

> I took a look this morning and came up with the attached patch.
> Essentially if the custom function is a list then the first element is
> the bulk function and the second is the argument function.
>
> If that looks reasonable I can add some documentation and submit a
> proper patch.
>
> Kevin Foley

That sounds like a reasonable option.

Note that attachment in the previous email appears to be empty. Can you
resend? I will take a look then.

Best,
Ihor





Re: [feature request] A new cookie type [!] showing the last note taken

2021-01-17 Thread Ihor Radchenko
Christopher Miles  writes:

> I think this is possible through read last note text in logbook, then display 
> it
> in headline through text-property overlay.
>
> That's what I did in this package 
> [[https://github.com/stardiviner/org-link-beautify]]
>
> Should not be that hard to implement it.

Thanks for the suggestion. However, I think that it would be more
consistent to keep the same approach with other cookie types in org.
They do not use overlays, but change text directly.

Best,
Ihor



Re: Feature request

2021-01-17 Thread Raoul Comninos
Ihor Radchenko  writes:

> Raoul Comninos  writes:
>
>> I have copied the code to my dot Emacs, but now when I try to add an 
>> attachment now, it generates this error:
>>
>> run-hook-with-args: Wrong number of arguments: (lambda nil "Save list of
>> attachments to ORG_ATTACH_FILES property." (when-let* ((dir
>> (org-attach-dir)) (files (org-attach-file-list dir))) (org-set-property
>> "ORG_ATTACH_FILES" (mapconcat #'identity files ", ", 1
>>
>> Can you help me with this?
>
> You can try:
>
> (defun org-attach-save-file-list-to-property (dir)
>   "Save list of attachments to ORG_ATTACH_FILES property."
>   (when-let* ((files (org-attach-file-list dir)))
> (org-set-property "ORG_ATTACH_FILES" (mapconcat #'identity files ", "
> (add-hook 'org-attach-after-change-hook 
> #'org-attach-save-file-list-to-property)
>
> Also, note that the list of files will only be updated if you
> attach/delete files calling org-attach. If you change the attachment
> folder manually, you will need to run M-x org-attach-sync.
>
> Best,
> Ihor

With your permission can I post your solution to stack-exchange,
crediting you?

Kindest regards,
Raoul Comninos 



Re: self-referencing babel shell code blocks

2021-01-17 Thread John Kitchin
see
https://stackoverflow.com/questions/3139970/open-a-file-at-line-with-filenameline-syntax

there are also ways to make fancier org-links, but I think you will find
what you need in that link.

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 Sun, Jan 17, 2021 at 7:33 PM HJ  wrote:

>
> Dear Mr Kitchin,
>
>you are a genius !!
>
> A BIG THANK YOU!!!
>
>Wow. I couldn't imagine someone might be able to do this so quickly
> and perfectly. Wow.
>
> thank you so much
>
>  HJ
>
> PS: Now I'm off to figure out how to invoke emacs to tell it to open up
> the window and show this file at the place where this-block block
> appears ...
>
>
> On 1/18/21 1:12 AM, John Kitchin wrote:
> > I guess this is what you mean:
> >
> >
> > * heading L1_12
> > ** heading L2_37
> >
> > #+name: this-block
> > #+header: :var VAR1=(getenv "HOSTNAME")
> > #+header: :var VAR2=(message user-login-name)
> > #+header: :var VAR3=(buffer-file-name)
> > #+header: :var VAR4=(org-element-property :name (org-element-context))
> > #+header: :var VAR5=(org-no-properties (org-display-outline-path nil t))
> > #+header: :var VAR5a=(line-number-at-pos (org-element-property :begin
> > (org-element-context)))
> > #+header: :var VAR6=(s-trim (shell-command-to-string "git rev-parse
> > HEAD"))
> > #+header: :var VAR7=(s-trim (shell-command-to-string "git branch
> > --show-current"))
> > #+BEGIN_SRC sh :results raw
> > echo Run by $VAR2 from $VAR3
> > echo In a src-block named $VAR4 in $VAR5 at line $VAR5a
> > echo on commit $VAR6 in git branch $VAR7
> > #+END_SRC
> >
> > #+RESULTS: this-block
> > Run by jkitchin from
> > /Users/jkitchin/Dropbox/emacs/journal/2021/01/17/2021-01-17.org
> > 
> > In a src-block named this-block in heading L1_12/heading L2_37 at line
> 140
> > on commit a07475addc3fdf557fb46a72b1100cf1c9c0805a in git branch master
> >
> >
> >
> > 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 Sun, Jan 17, 2021 at 4:42 PM HJ  > > wrote:
> >
> >
> >   hi,
> >
> >I'm  trying to figure out how to write a block , header,
> > PROPERTY or
> > whatever is necessary so the output of a command in babel source
> > block
> > identifies it own position - the line (or block or something) in
> > buffer
> > (or at least the file) in which it is written. ( Plus the checked out
> > git revision / branch. )
> >
> >
> >   I've been experimenting with the following, so far without much
> > luck ...
> >
> >   Which of these pieces of information (see the "echo" line below)
> > is it
> > possible to get? Which is easy? (variables VAR[0345] are most
> > critical)
> > How would one write a snippet which provides (some of) this
> > information?
> >
> >   Is it much harder with command 1 being SSH to a remote machine?
> > Would
> > ":dir user@remotemachine:/some/dir" work better? Or at all?
> >
> >   Perhaps I would know how to find out VAR6 and VAR7 by running first
> > some `git cmd1` and `git cmd2` locally in a " command 0 " - but is
> > there
> > a way to get that info from magit somehow?
> >
> >   But what I am most desperate for is how to cause orgmode block
> > to set
> > VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to
> > use the
> > combination of VAR[0345] do open / recall the file onto the screen
> >
> >   Thanks a million for helping me out here ...
> >
> > HJ
> >
> >
> > This is the sample file :
> >
> >
> > * heading L1_12
> >Hello and welcome, this is a file with self-referencing shell
> > babel source code blocks
> >...
> > ** heading L2_37
> >...
> > #+NAME: block220
> > #+BEGIN_SRC  bash  :session sess9
> >: command 0 ;  cd
> > _how-do-I-find-the-dir-of-currently-edited-file_ ; VAR6=`git cmd1`
> > ; VAR7=`git cmd2`
> >: command 1 ;  ssh -o "SetEnv VAR1=machine VAR2=user VAR3=..."
> >   targetUser@targetMachine
> > #+END_SRC
> >
> >
> > ...
> >
> > #+NAME: block225
> > #+BEGIN_SRC  bash  :session sess9
> >: command 2 ; : do some computation on targetMachine
> >: command 3 ; echo This code has been launched from emacs
> > process VAR0:_EMACS_SESSION_ID_ \
> >  on computer $VAR1:_SRC_HOSTNAME_ \
> >  run by user $VAR2:_USER_ \
> >  from file $VAR3:_FILENAME_ \
> >  code block named $VAR4:block225 \
> >  in this file positioned 

Re: self-referencing babel shell code blocks

2021-01-17 Thread HJ



Dear Mr Kitchin,

  you are a genius !!

   A BIG THANK YOU!!!

  Wow. I couldn't imagine someone might be able to do this so quickly 
and perfectly. Wow.


   thank you so much

    HJ

PS: Now I'm off to figure out how to invoke emacs to tell it to open up 
the window and show this file at the place where this-block block 
appears ...



On 1/18/21 1:12 AM, John Kitchin wrote:

I guess this is what you mean:


* heading L1_12
** heading L2_37

#+name: this-block
#+header: :var VAR1=(getenv "HOSTNAME")
#+header: :var VAR2=(message user-login-name)
#+header: :var VAR3=(buffer-file-name)
#+header: :var VAR4=(org-element-property :name (org-element-context))
#+header: :var VAR5=(org-no-properties (org-display-outline-path nil t))
#+header: :var VAR5a=(line-number-at-pos (org-element-property :begin 
(org-element-context)))
#+header: :var VAR6=(s-trim (shell-command-to-string "git rev-parse 
HEAD"))
#+header: :var VAR7=(s-trim (shell-command-to-string "git branch 
--show-current"))

#+BEGIN_SRC sh :results raw
echo Run by $VAR2 from $VAR3
echo In a src-block named $VAR4 in $VAR5 at line $VAR5a
echo on commit $VAR6 in git branch $VAR7
#+END_SRC

#+RESULTS: this-block
Run by jkitchin from 
/Users/jkitchin/Dropbox/emacs/journal/2021/01/17/2021-01-17.org 


In a src-block named this-block in heading L1_12/heading L2_37 at line 140
on commit a07475addc3fdf557fb46a72b1100cf1c9c0805a in git branch master



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 Sun, Jan 17, 2021 at 4:42 PM HJ > wrote:



  hi,

   I'm  trying to figure out how to write a block , header,
PROPERTY or
whatever is necessary so the output of a command in babel source
block
identifies it own position - the line (or block or something) in
buffer
(or at least the file) in which it is written. ( Plus the checked out
git revision / branch. )


  I've been experimenting with the following, so far without much
luck ...

  Which of these pieces of information (see the "echo" line below)
is it
possible to get? Which is easy? (variables VAR[0345] are most
critical)
How would one write a snippet which provides (some of) this
information?

  Is it much harder with command 1 being SSH to a remote machine?
Would
":dir user@remotemachine:/some/dir" work better? Or at all?

  Perhaps I would know how to find out VAR6 and VAR7 by running first
some `git cmd1` and `git cmd2` locally in a " command 0 " - but is
there
a way to get that info from magit somehow?

  But what I am most desperate for is how to cause orgmode block
to set
VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to
use the
combination of VAR[0345] do open / recall the file onto the screen

  Thanks a million for helping me out here ...

    HJ


This is the sample file :


* heading L1_12
   Hello and welcome, this is a file with self-referencing shell
babel source code blocks
   ...
** heading L2_37
   ...
#+NAME: block220
#+BEGIN_SRC  bash  :session sess9
   : command 0 ;  cd
_how-do-I-find-the-dir-of-currently-edited-file_ ; VAR6=`git cmd1`
; VAR7=`git cmd2`
   : command 1 ;  ssh -o "SetEnv VAR1=machine VAR2=user VAR3=..." 
  targetUser@targetMachine
#+END_SRC


...

#+NAME: block225
#+BEGIN_SRC  bash  :session sess9
   : command 2 ; : do some computation on targetMachine
   : command 3 ; echo This code has been launched from emacs
process VAR0:_EMACS_SESSION_ID_ \
     on computer $VAR1:_SRC_HOSTNAME_ \
     run by user $VAR2:_USER_ \
     from file $VAR3:_FILENAME_ \
     code block named $VAR4:block225 \
     in this file positioned under headings: $VAR5:heading
L1_12/heading L2_37/ \
     which is checked out from $VAR6:_GIT_COMMIT_ID_ \
     on branch $VAR7:_GIT_BRANCH_
   : command 3 continues ; echo To display the buffer which
launched this code on the screen of the running emacs session, run
the following command :    emacs _What_the_heck_do_I_put_here?_  '&'
#+END_SRC











Re: self-referencing babel shell code blocks

2021-01-17 Thread John Kitchin
I guess this is what you mean:


* heading L1_12
** heading L2_37

#+name: this-block
#+header: :var VAR1=(getenv "HOSTNAME")
#+header: :var VAR2=(message user-login-name)
#+header: :var VAR3=(buffer-file-name)
#+header: :var VAR4=(org-element-property :name (org-element-context))
#+header: :var VAR5=(org-no-properties (org-display-outline-path nil t))
#+header: :var VAR5a=(line-number-at-pos (org-element-property :begin
(org-element-context)))
#+header: :var VAR6=(s-trim (shell-command-to-string "git rev-parse HEAD"))
#+header: :var VAR7=(s-trim (shell-command-to-string "git branch
--show-current"))
#+BEGIN_SRC sh :results raw
echo Run by $VAR2 from $VAR3
echo In a src-block named $VAR4 in $VAR5 at line $VAR5a
echo on commit $VAR6 in git branch $VAR7
#+END_SRC

#+RESULTS: this-block
Run by jkitchin from /Users/jkitchin/Dropbox/emacs/journal/2021/01/17/
2021-01-17.org
In a src-block named this-block in heading L1_12/heading L2_37 at line 140
on commit a07475addc3fdf557fb46a72b1100cf1c9c0805a in git branch master



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 Sun, Jan 17, 2021 at 4:42 PM HJ  wrote:

>
>   hi,
>
>I'm  trying to figure out how to write a block , header, PROPERTY or
> whatever is necessary so the output of a command in babel source block
> identifies it own position - the line (or block or something) in buffer
> (or at least the file) in which it is written. ( Plus the checked out
> git revision / branch. )
>
>
>   I've been experimenting with the following, so far without much luck ...
>
>   Which of these pieces of information (see the "echo" line below) is it
> possible to get? Which is easy? (variables VAR[0345] are most critical)
> How would one write a snippet which provides (some of) this information?
>
>   Is it much harder with command 1 being SSH to a remote machine? Would
> ":dir user@remotemachine:/some/dir" work better? Or at all?
>
>   Perhaps I would know how to find out VAR6 and VAR7 by running first
> some `git cmd1` and `git cmd2` locally in a " command 0 " - but is there
> a way to get that info from magit somehow?
>
>   But what I am most desperate for is how to cause orgmode block to set
> VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to use the
> combination of VAR[0345] do open / recall the file onto the screen
>
>   Thanks a million for helping me out here ...
>
> HJ
>
>
> This is the sample file :
>
>
> * heading L1_12
>Hello and welcome, this is a file with self-referencing shell babel
> source code blocks
>...
> ** heading L2_37
>...
> #+NAME: block220
> #+BEGIN_SRC  bash  :session sess9
>: command 0 ;  cd _how-do-I-find-the-dir-of-currently-edited-file_ ;
> VAR6=`git cmd1` ; VAR7=`git cmd2`
>: command 1 ;  ssh -o "SetEnv VAR1=machine VAR2=user VAR3=..."
> targetUser@targetMachine
> #+END_SRC
>
>
> ...
>
> #+NAME: block225
> #+BEGIN_SRC  bash  :session sess9
>: command 2 ; : do some computation on targetMachine
>: command 3 ; echo This code has been launched from emacs process
> VAR0:_EMACS_SESSION_ID_ \
>  on computer $VAR1:_SRC_HOSTNAME_ \
>  run by user $VAR2:_USER_ \
>  from file $VAR3:_FILENAME_ \
>  code block named $VAR4:block225 \
>  in this file positioned under headings: $VAR5:heading L1_12/heading
> L2_37/ \
>  which is checked out from $VAR6:_GIT_COMMIT_ID_ \
>  on branch $VAR7:_GIT_BRANCH_
>: command 3 continues ; echo To display the buffer which launched this
> code on the screen of the running emacs session, run the following command
> :emacs  _What_the_heck_do_I_put_here?_  '&'
> #+END_SRC
>
>
>
>
>
>
>
>


"Invalid version syntax" with 9.4.4

2021-01-17 Thread Hanns Mattes
Hi,

as mentioned in the subject I ran into this error after upgrading from
9.4 to 9.4.4.

With 9.4 org-version reports:

,
| Org mode version 9.4 (9.4-elpa @ /home/hanns/.emacs.d/elpa/org-9.4/)
`

With 9.4.4:

,
| Org mode version  ( @ /home/hanns/.emacs.d/elpa/org-9.4.4/)
`

resulting in "version-to-list: Invalid version syntax: ‘’ (must start
with a number)" when using org-caldav for example

It's GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9,
cairo version 1.14.6) of 2020-09-19 on Ubuntu 16.04 LTS

I don't have any idea where to start searching, any hints appreciated.

Regards Hanns



Re: na=\"nil\" in ob-R.elo

2021-01-17 Thread Brett Presnell


I can verify that the :post work-around suggested by Chuck and
implemented by Jeremie works as advertised.

FWIW, I would certainly prefer to see the implementation
org-babel-R-write-object-command changed so that the work-around
wouldn't be necessary.

Thank you to both Chuck and Jeremie for looking into this.


Jeremie Juste  writes:

> [External Email]
>
> Hello,
>
> Thanks for the feedback
>
> || On Saturday, 16 Jan 2021 at 00:19, Berry, Charles" via "General 
> discussions about Org-mode. wrote:
>> You can use a :post header to customize outputs like this to make them
>> more pleasing. Or just use your own
>> `org-babel-R-write-object-command'.
>
>
> As a quick work around you can use
>
> #+name: remove-nil
> #+begin_src emacs-lisp :var tbl=""
>(mapcar (lambda (row)
>  (mapcar (lambda (cell)
>(if (equal "nil" cell)
>""
> cell))
>  row))
>tbl)
>
> #+end_src
>
>
>
> #+BEGIN_SRC R  :results value :colnames yes :post remove-nil[:colnames 
> yes](*this*)
> data.frame(A=c(NA,1,1,1,1),B=c(1,2,NA,4,4))
> #+end_src
>
> #+RESULTS:
> | A | B |
> |---+---|
> |   | 1 |
> | 1 | 2 |
> | 1 |   |
> | 1 | 4 |
> | 1 | 4 |
>
>
>
>>> Probably a silly question, but in ob-R.el, what is the reason for
>>> setting na=\"nil\" when defining org-babel-R-write-object-command?  Is
>>> this an elisp compatibility thing?
>>>
>>
>> I don't get it either. The value corresponding to the NA becomes a string in 
>> emacs-lisp whether \"nil\" or \"\" is used.
>> So when passed to elisp via a :post header referencing an emacs-lisp
>> src block, its treated as a string.
>
> Thanks Chuck for pointing this out. R users are used to handle NA but in
> this particular case where empty string and NA are treated
> the same, I'm not sure the nil feature is very useful. If it does not break
> anything else I will consider removing it.
>
>
> Best regards,




self-referencing babel shell code blocks

2021-01-17 Thread HJ



 hi,

  I'm  trying to figure out how to write a block , header, PROPERTY or 
whatever is necessary so the output of a command in babel source block 
identifies it own position - the line (or block or something) in buffer 
(or at least the file) in which it is written. ( Plus the checked out 
git revision / branch. )



 I've been experimenting with the following, so far without much luck ...

 Which of these pieces of information (see the "echo" line below) is it 
possible to get? Which is easy? (variables VAR[0345] are most critical) 
How would one write a snippet which provides (some of) this information?


 Is it much harder with command 1 being SSH to a remote machine? Would 
":dir user@remotemachine:/some/dir" work better? Or at all?


 Perhaps I would know how to find out VAR6 and VAR7 by running first 
some `git cmd1` and `git cmd2` locally in a " command 0 " - but is there 
a way to get that info from magit somehow?


 But what I am most desperate for is how to cause orgmode block to set 
VAR0, VAR3, VAR4 and VAR5, and - also fairly important - how to use the 
combination of VAR[0345] do open / recall the file onto the screen


 Thanks a million for helping me out here ...

   HJ


This is the sample file :


* heading L1_12
  Hello and welcome, this is a file with self-referencing shell babel source 
code blocks
  ...
** heading L2_37
  ...
#+NAME: block220
#+BEGIN_SRC  bash  :session sess9
  : command 0 ;  cd _how-do-I-find-the-dir-of-currently-edited-file_ ; 
VAR6=`git cmd1` ; VAR7=`git cmd2`
  : command 1 ;  ssh -o "SetEnv VAR1=machine VAR2=user VAR3=..."
targetUser@targetMachine
#+END_SRC


...

#+NAME: block225
#+BEGIN_SRC  bash  :session sess9
  : command 2 ; : do some computation on targetMachine
  : command 3 ; echo This code has been launched from emacs process 
VAR0:_EMACS_SESSION_ID_ \
on computer $VAR1:_SRC_HOSTNAME_ \
run by user $VAR2:_USER_ \
from file $VAR3:_FILENAME_ \
code block named $VAR4:block225 \
in this file positioned under headings: $VAR5:heading L1_12/heading L2_37/ \
which is checked out from $VAR6:_GIT_COMMIT_ID_ \
on branch $VAR7:_GIT_BRANCH_
  : command 3 continues ; echo To display the buffer which launched this code on 
the screen of the running emacs session, run the following command :emacs  
_What_the_heck_do_I_put_here?_  '&'
#+END_SRC









Re: org-publish error with java hook

2021-01-17 Thread Colin Baxter
> Tim Cross  writes:

> Colin Baxter  writes:

>> Hi Tim,
>> 
>> Thanks for you quick reply.
>>> Tim Cross  writes:
>> 
>> > Colin Baxter  writes:
>> 
>> >> Hello,
>> >>
>> >> In the last few days org-publish no loner works for me, giving
>> a >> lisp error: (void-function conkeror-minor-mode). The source
>> of >> the problem is the line '(add-hook 'js-mode-hook >>
>> 'conkeror-minor-mode)' in my init file. If I comment out the >>
>> line, the error disappears.
>> >>
>> >> I've tried reverting a couple of recent commits in org-mode,
>> but >> to no avail. I'd appreciate pointers as to the issue.
>> >>
>> >> I'm using emacs-27.1 with Org mode version 9.4.4 >>
>> (release_9.4.4-186-g7fa817).
>> >>
>> 
>> > I suspect that is something related to your local configuration
>> - > specifically in your Javascript setup hook. I don't think it
>> has > anything to do with org. When org publish does its thing,
>> it must > be loading js mode and that is triggering the error.
>> 
>> > Emacs has deprecated conkeror support in the browse-url library
>> > ecently (Emacs 28 I think), which has probably resulted in some
>> > other packages removing conkeror support. My guess would be
>> that > you have been using a package which adds conkeror support
>> when > editing Javascript code (you could test this by opening a
>> JS file > outside of org mode and see if you get the same error).
>> 
>> I don't get this error editing a js outside of org-mode,
>> unfortunately. In fact, conkeror-minor-mode-el still works. Ok,
>> all it does is to send a js script to be evaluate by conkeror,
>> but it still does exactly that.
>> 
>> I intend to check - when I get time - if the CDATA @license-end
>> stuff that org publish inserts is not responsible.
>> 

> My guess would be that something has changed in your
> configuration.  Possibly something was previously doing a require
> for conkeror-minor-mode.el before org is loaded which is no longer
> there.  You could try adding a (require 'conkeror-minor-mode) in
> your customisation before org is loaded (or before org-publish is
> loaded).

I have now discovered the problem. You are correct. I had changed
recently my init file, with the effect that conkeror-minor-mode was no
longer loaded when I ran org publish, even though the hook was still
present. I had changed things thinking it was a "simplification". I had
forgotten "if it works don't touch it".

Thanks for your help - sorry about the non-issue.

Best wishes,

Colin.
 

-- 
Colin Baxter
URL: http://www.Colin-Baxter.com



Re: org-publish error with java hook

2021-01-17 Thread Tim Cross


Colin Baxter  writes:

> Hi Tim,
>
> Thanks for you quick reply.
>> Tim Cross  writes:
>
> > Colin Baxter  writes:
>
> >> Hello,
> >>
> >> In the last few days org-publish no loner works for me, giving a
> >> lisp error: (void-function conkeror-minor-mode). The source of
> >> the problem is the line '(add-hook 'js-mode-hook
> >> 'conkeror-minor-mode)' in my init file. If I comment out the
> >> line, the error disappears.
> >>
> >> I've tried reverting a couple of recent commits in org-mode, but
> >> to no avail. I'd appreciate pointers as to the issue.
> >>
> >> I'm using emacs-27.1 with Org mode version 9.4.4
> >> (release_9.4.4-186-g7fa817).
> >>
>
> > I suspect that is something related to your local configuration -
> > specifically in your Javascript setup hook. I don't think it has
> > anything to do with org. When org publish does its thing, it must
> > be loading js mode and that is triggering the error.
>
> > Emacs has deprecated conkeror support in the browse-url library
> > ecently (Emacs 28 I think), which has probably resulted in some
> > other packages removing conkeror support. My guess would be that
> > you have been using a package which adds conkeror support when
> > editing Javascript code (you could test this by opening a JS file
> > outside of org mode and see if you get the same error).
>
> I don't get this error editing a js outside of org-mode,
> unfortunately. In fact, conkeror-minor-mode-el still works. Ok, all it
> does is to send a js script to be evaluate by conkeror, but it still does
> exactly that.
>
> I intend to check - when I get time - if the CDATA @license-end stuff
> that org publish inserts is not responsible.
>

My guess would be that something has changed in your configuration.
Possibly something was previously doing a require for
conkeror-minor-mode.el before org is loaded which is no longer there.
You could try adding a (require 'conkeror-minor-mode) in your
customisation before org is loaded (or before org-publish is loaded).

You could also try loading a JS file by hand and then load an org file
and try to run org-publish. I suspect it will work, which would confirm
the issue is that nothing has loaded conkeror-minor-mode at the time you
try to do org-publish.

--
Tim Cross



Re: org-publish error with java hook

2021-01-17 Thread Colin Baxter
Hi Tim,

Thanks for you quick reply.
> Tim Cross  writes:

> Colin Baxter  writes:

>> Hello,
>> 
>> In the last few days org-publish no loner works for me, giving a
>> lisp error: (void-function conkeror-minor-mode). The source of
>> the problem is the line '(add-hook 'js-mode-hook
>> 'conkeror-minor-mode)' in my init file. If I comment out the
>> line, the error disappears.
>> 
>> I've tried reverting a couple of recent commits in org-mode, but
>> to no avail. I'd appreciate pointers as to the issue.
>> 
>> I'm using emacs-27.1 with Org mode version 9.4.4
>> (release_9.4.4-186-g7fa817).
>> 

> I suspect that is something related to your local configuration -
> specifically in your Javascript setup hook. I don't think it has
> anything to do with org. When org publish does its thing, it must
> be loading js mode and that is triggering the error.

> Emacs has deprecated conkeror support in the browse-url library
> ecently (Emacs 28 I think), which has probably resulted in some
> other packages removing conkeror support. My guess would be that
> you have been using a package which adds conkeror support when
> editing Javascript code (you could test this by opening a JS file
> outside of org mode and see if you get the same error).

I don't get this error editing a js outside of org-mode,
unfortunately. In fact, conkeror-minor-mode-el still works. Ok, all it
does is to send a js script to be evaluate by conkeror, but it still does
exactly that.

I intend to check - when I get time - if the CDATA @license-end stuff
that org publish inserts is not responsible.

Best wishes,

Colin.


Colin Baxter



Re: org-publish error with java hook

2021-01-17 Thread Tim Cross


Colin Baxter  writes:

> Hello,
>
> In the last few days org-publish no loner works for me, giving a lisp
> error: (void-function conkeror-minor-mode). The source of the problem is
> the line '(add-hook 'js-mode-hook 'conkeror-minor-mode)' in my init
> file. If I comment out the line, the error disappears.
>
> I've tried reverting a couple of recent commits in org-mode, but to no
> avail. I'd appreciate pointers as to the issue.
>
> I'm using emacs-27.1 with Org mode version 9.4.4
> (release_9.4.4-186-g7fa817).
>

I suspect that is something related to your local configuration -
specifically in your Javascript setup hook. I don't think it has
anything to do with org. When org publish does its thing, it must be
loading js mode and that is triggering the error.

Emacs has deprecated conkeror support in the browse-url library ecently
(Emacs 28 I think), which has probably resulted in some other packages
removing conkeror support. My guess would be that you have been using a
package which adds conkeror support when editing Javascript code (you
could test this by opening a JS file outside of org mode and see if you
get the same error).

Review the packages you have which provide JS editing support and you
will likely find the culprit.

--
Tim Cross



org-publish error with java hook

2021-01-17 Thread Colin Baxter
Hello,

In the last few days org-publish no loner works for me, giving a lisp
error: (void-function conkeror-minor-mode). The source of the problem is
the line '(add-hook 'js-mode-hook 'conkeror-minor-mode)' in my init
file. If I comment out the line, the error disappears.

I've tried reverting a couple of recent commits in org-mode, but to no
avail. I'd appreciate pointers as to the issue.

I'm using emacs-27.1 with Org mode version 9.4.4
(release_9.4.4-186-g7fa817).

Best wishes,

Colin Baxter.




Re: Custom Bulk Functions With Prompt

2021-01-17 Thread Kevin Foley
Ihor Radchenko  writes:

> Instead of advice, you can also provide a simple patch implementing the
> described functionality in org-agenda-bulk-action. I do support adding
> this functionality to org.

I took a look this morning and came up with the attached patch.
Essentially if the custom function is a list then the first element is
the bulk function and the second is the argument function.

If that looks reasonable I can add some documentation and submit a
proper patch.

Kevin Foley


Re: [feature request] A new cookie type [!] showing the last note taken

2021-01-17 Thread Christopher Miles

I think this is possible through read last note text in logbook, then display it
in headline through text-property overlay.

That's what I did in this package 
[[https://github.com/stardiviner/org-link-beautify]]

Should not be that hard to implement it.

Ihor Radchenko  writes:

> Over the years of using Org I often have a need to add a short note
> about how to proceed with some task:
>
> * REVIEW check again, subscribe | sindresorhus/awesome:  Awesome lists 
> about all kinds of interesting topics :BOOKMARK:
> :PROPERTIES:
> :CREATED: [2020-03-15 Sun 18:59]
> :Source: https://github.com/sindresorhus/awesome
> :END:
> :LOGBOOK:
> CLOCK: [2020-03-17 Tue 16:18]--[2020-03-17 Tue 17:46] =>  1:28
> CLOCK: [2020-03-17 Tue 16:03]--[2020-03-17 Tue 16:18] =>  0:15
> - Refiled on [2020-03-16 Mon 23:59]
> :END:
>
> In the above example, the short note is "check again, subscribe".
> The note is not fixed, but changes as I progress with completing the
> task.
>
> This is even more useful for delegated or HOLD tasks where I often need
> to add a short note why the task is delegated or put on hold:
>
> ** HOLD Finish the text prop org-mode | make babel support org file links in 
> header args (:file or :dir) 
> [[id:468e0645-68aa-4e14-86de-e5ce153538e3][[2017-09-22 Fri] 
> CuNbARBshearstrength]] :HOLD:
> :PROPERTIES:
> :CREATED: [2020-07-20 Mon 16:53]
> :SHOWFROMDATE: 2020-08-15
> :END:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> Seeing this note directly in the headline without a need to dig into the
> task body / LOGBOOK drawer is really handy.
>
> In this last example, I had to duplicate the note taken using built-in
> note mechanism into headline, which was inconvenient. It would be handy
> if I could simply add a [!] cookie (similar to [/] or [%] cookies) to
> the headline to show the last note taken for this task. Then, I could
> easily see the reason why the task is blocked or what I am supposed to
> do with the task right in agenda view or in the folded headline.
> Something like the following
>
> ** HOLD [!] make babel support org... :HOLD:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> The cookie would be replaced by the last note text, according to
> user-defined format (say, "[%s] |"):
>
> ** HOLD [Finish the text prop org-mode] | make babel support org... :HOLD:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> What do you think?
>
> Best,
> Ihor


-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature


How to not include newlines in strip-export?

2021-01-17 Thread General discussions about Org-mode.
I'm using the following snippet for saving the plot  in python snippets

#+NAME: save-file
#+BEGIN_SRC python :results silent :var filename="filename" plt="plt" :exports 
none
return f"\nfname = 'assets/' + filename + '.png'\nplt.savefig(fname)\nfname"
#+END_SRC

Using it like so
#+BEGIN_SRC python :var fig=1 filename="some-filename" :noweb strip-export 
:results file :session t :exports both :cache yes
import matplotlib.pyplot as plt

plt.plot(1, 1)

<>
#+END_SRC

The issue is that `save-file` adds some extra newlines in export which I would 
rather omit. What am I doing wrong?

Best Regards,
Karol Wójcik


Re: Feature request

2021-01-17 Thread Raoul Comninos
Ihor Radchenko  writes:

> Raoul Comninos  writes:
>
>> I have copied the code to my dot Emacs, but now when I try to add an 
>> attachment now, it generates this error:
>>
>> run-hook-with-args: Wrong number of arguments: (lambda nil "Save list of
>> attachments to ORG_ATTACH_FILES property." (when-let* ((dir
>> (org-attach-dir)) (files (org-attach-file-list dir))) (org-set-property
>> "ORG_ATTACH_FILES" (mapconcat #'identity files ", ", 1
>>
>> Can you help me with this?
>
> You can try:
>
> (defun org-attach-save-file-list-to-property (dir)
>   "Save list of attachments to ORG_ATTACH_FILES property."
>   (when-let* ((files (org-attach-file-list dir)))
> (org-set-property "ORG_ATTACH_FILES" (mapconcat #'identity files ", "
> (add-hook 'org-attach-after-change-hook 
> #'org-attach-save-file-list-to-property)
>
> Also, note that the list of files will only be updated if you
> attach/delete files calling org-attach. If you change the attachment
> folder manually, you will need to run M-x org-attach-sync.
>
> Best,
> Ihor

It works now and its awesome! I cannot believe that they had this
feature and removed it. I am a very happy man and I cannot thank you enough.

If you have time please add your answer and function to the original
post. I feel others will make use of it too.

https://emacs.stackexchange.com/questions/62761/seeing-file-names-in-todo-entries-when-using-org-attach/62792#62792

Kindest regards,
Raoul Comninos 




Re: Feature request

2021-01-17 Thread Ihor Radchenko
Raoul Comninos  writes:

> I have copied the code to my dot Emacs, but now when I try to add an 
> attachment now, it generates this error:
>
> run-hook-with-args: Wrong number of arguments: (lambda nil "Save list of
> attachments to ORG_ATTACH_FILES property." (when-let* ((dir
> (org-attach-dir)) (files (org-attach-file-list dir))) (org-set-property
> "ORG_ATTACH_FILES" (mapconcat #'identity files ", ", 1
>
> Can you help me with this?

You can try:

(defun org-attach-save-file-list-to-property (dir)
  "Save list of attachments to ORG_ATTACH_FILES property."
  (when-let* ((files (org-attach-file-list dir)))
(org-set-property "ORG_ATTACH_FILES" (mapconcat #'identity files ", "
(add-hook 'org-attach-after-change-hook #'org-attach-save-file-list-to-property)

Also, note that the list of files will only be updated if you
attach/delete files calling org-attach. If you change the attachment
folder manually, you will need to run M-x org-attach-sync.

Best,
Ihor




Re: Feature request

2021-01-17 Thread Raoul Comninos
Ihor Radchenko  writes:

> I think something like the following will do (untested):
>
> (defun org-attach-save-file-list-to-property ()
>   "Save list of attachments to ORG_ATTACH_FILES property."
>   (when-let* ((dir (org-attach-dir))
> (files (org-attach-file-list dir)))
> (org-set-property "ORG_ATTACH_FILES" (mapconcat #'identity files ", "
> (add-hook 'org-attach-after-change-hook 
> #'org-attach-save-file-list-to-property)
>
> Best,
> Ihor

I have copied the code to my dot Emacs, but now when I try to add an attachment 
now, it generates this error:

run-hook-with-args: Wrong number of arguments: (lambda nil "Save list of
attachments to ORG_ATTACH_FILES property." (when-let* ((dir
(org-attach-dir)) (files (org-attach-file-list dir))) (org-set-property
"ORG_ATTACH_FILES" (mapconcat #'identity files ", ", 1

Can you help me with this?

Kind regards,
Raoul Comninos