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

2020-08-30 Thread Ihor Radchenko


> I wouldn't dismiss plain text insertion too easily, either. It also
> includes external tools. What happens if an external tool automatically
> insert notes?
>
> The feature you are requesting could make sense if notes had a clear
> syntax. This would bring some interesting features, too (e.g., being
> able to list all notes in an entry, accurately). But it would also raise
> new problems, as any syntax change (backward compatibility with old
> documents, external tools...). 

I would not call defining syntax for notes "a syntax change". Rather
addition to syntax. Since there was no formal definition of notes in the
past, introducing formal syntax for notes should not break any existing
tool. If anything, it should make it easier for those tools to deal with
notes.

For the compatibility, we can reuse the frequently used (at least,
because it is built-in) syntax used by `org-add-note' (see below).


> This is more realistic, but you are then binding the tool
> (`org-add-note') to the syntax ("[!]"), which is a step in the wrong
> direction. We must not assume Org mode is the only tool writing Org
> documents.

Good point.

Instead of linking to the function, we can define the format used by
`org-add-note' as a formal format for notes. Currently `org-add-note'
uses the following format:

-  \\
  

The  is taken from `org-log-note-headings'.

Notably, this syntax is partially used in org, despite lack of formal
definition. For example, `org-habit-parse-todo' assumes that state
change notes were added by `org-add-note' using format defined in
`org-log-note-headings'. All the external tools dealing with state
change statistics already have to consider this syntax.

Also, it can nicely play with the existing built-in
`org-element-plain-list-parser' with note being a special kind of list
element.

Best,
Ihor

Nicolas Goaziou  writes:

> Ihor Radchenko  writes:
>
>> I feel that my understand of "note" in context of org is different from
>> yours. Is there a formal definition of "note" in org?
>
> As I stated in my first post a few hours ago:
>
>Notes are mostly free-form; there is no syntax describing them.
>
>> However, we can formalise the "last note taken" to "last note taken
>> using org-add-note".
>
> This is more realistic, but you are then binding the tool
> (`org-add-note') to the syntax ("[!]"), which is a step in the wrong
> direction. We must not assume Org mode is the only tool writing Org
> documents.
>
>> org-add-note is the only way I am aware about (except plain text,
>> indeed). That's why I wrote the function saving the last note taken
>> using org-add-note into SUMMARY. The property is only used here for
>> convenient retrieval, not because I implied showing a property value.
>
> I understand the property was used for convenience, but showing its
> value is the only problem your can really claim solving at the moment.
>
>> May I know what are the other ways to add note via interactive function
>> in Org?
>
> Capture is certainly one way. In fact, `org-add-note' could (should ?)
> be rewritten using Capture library.
>
> I wouldn't dismiss plain text insertion too easily, either. It also
> includes external tools. What happens if an external tool automatically
> insert notes?
>
> The feature you are requesting could make sense if notes had a clear
> syntax. This would bring some interesting features, too (e.g., being
> able to list all notes in an entry, accurately). But it would also raise
> new problems, as any syntax change (backward compatibility with old
> documents, external tools...). 
>
> Regards,



[PATCH] Re: Re: Re: org-forward-heading-same-level and the invisible-ok argument

2020-08-30 Thread D
> Probably, it is easier if you just use seq-every-p instead of
> mapcar on (number-sequence max-pos min-pos -1). The result of
> seq-every-p will be inverse of the currently used expression.

Oh yeah, that's much nicer.  I also made the predicate check
right-to-left, which just causes it to check the text bit of a heading
first, which is useful for the cases where the predicate returns t and
makes no difference otherwise.  I again ran the tests and it seems ready
to go.

Cheers,
D.
>From 9ae3dd4b73b2b9b41244bb7f9c610ed3f4777398 Mon Sep 17 00:00:00 2001
From: "D. Williams" 
Date: Sun, 30 Aug 2020 23:58:55 +0200
Subject: [PATCH] org.el: let heading navigation check the entire heading for
 visibility

* org.el (org-forward-heading-same-level): check complete heading instead of the first char

TINYCHANGE
---
 lisp/org.el | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 71dbc611e..f44f94ec4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20478,6 +20478,14 @@ entry."
 		((looking-at-p re) (forward-line))
 		(t (throw 'exit t
 
+(defun org--line-visible-p ()
+  "Return t if the current line is partially visible."
+  (not
+   (seq-every-p #'org-invisible-p
+		(number-sequence (1- (line-end-position))
+ (line-beginning-position)
+ -1
+
 (defun org-forward-heading-same-level (arg  invisible-ok)
   "Move forward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading.
@@ -20499,8 +20507,7 @@ non-nil it will also look at invisible ones."
 	(cond ((< l level) (setq count 0))
 		  ((and (= l level)
 			(or invisible-ok
-			(not (org-invisible-p
-  (line-beginning-position)
+			(org--line-visible-p)))
 		   (cl-decf count)
 		   (when (= l level) (setq result (point)))
 	(goto-char result))
-- 
2.26.2



how to create next, previous, and up navigation links when exporting to html

2020-08-30 Thread Christopher W. Ryan
how do I create next, previous, and up navigation links when exporting
to html, like in the org mode manual:

https://orgmode.org/manual/HTML-specific-export-settings.html

Thanks.

--Chris Ryan



Re: [PATCH] ob-plantuml: Support for plantuml as well as the current java+jar solution

2020-08-30 Thread Terje Larsen
Did this look okay? I've had to rebase this once again due to some
conflicts in the ORG-NEWS.

Find the latest patch attached.

Best regards
Terje

On Tue, Jun 9, 2020 at 8:53 AM Terje Larsen  wrote:
>
> Thank you Bastien,
>
> I didn't get what the updated patch with shorter lines meant, the only
> thing I could see difference between that patch and my previous patch
> was the line breaks using CR LF instead of LF. I generate my patch
> with git format-patch
>
> Here is the updated patch using mapconcat.
>
> Best regards
> Terje
>
> On Mon, Jun 1, 2020 at 4:00 PM Bastien  wrote:
> >
> > Hello Terje,
> >
> > > I have now signed the FSF papers. Here is the updated patch on top of
> > > current master.
> >
> > Great, thanks.
> >
> > > Let me know if all looks good or if I need to make further changes or
> > > need to provide something else.
> >
> > It looks good -- here is an updated patch with shorter lines.
> >
> > The last change you need to make is to use mapconcat instead
> > of string-join, which would require us to load subr-x.el.
> >
> > Once this is done I'll apply your patch.
> >
> > Thanks,
> >
> > --
> >  Bastien
>
>
>
> --
> // Terje Larsen



-- 
// Terje Larsen
From d2d73cd6dce1576d7396f734c70657f9a9e1806f Mon Sep 17 00:00:00 2001
From: Terje Larsen 
Date: Fri, 8 Nov 2019 10:25:49 +0100
Subject: [PATCH] ob-plantuml: Add support for plantuml executable

* lisp/ob-plantuml (org-babel-variable-assignments:plantuml): Support
using plantuml executable instead of jar.

Some systems come with an executable for plantuml instead of a specific
JAR file. This adds support for two different modes:
- jar :: using java together with a JAR (previous behavior)
- plantuml :: using a PlantUML executable

The PlantUML executable can be configured via
`org-plantuml-executable-path` and also the arguments that will be given
via `org-plantuml-executable-args`.
---
 etc/ORG-NEWS|  7 
 lisp/ob-plantuml.el | 94 +
 2 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 10658a970..87c5696d8 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -266,6 +266,13 @@ can now be inserted with this prefix argument.
 Source code block header argument =:file-mode= can set file
 permissions if =:file= argument is provided.
 
+*** =ob-plantuml=: now supports using PlantUML executable to generate diagrams
+
+Set =org-plantuml-exec-mode= to ='plantuml= in order to use the
+executable instead of JAR. When using an executable it is also
+possible to configure executable location as well as arguments via:
+=org-plantuml-executable-path= and =org-plantuml-executable-args=.
+
 ** New commands
 *** ~org-table-header-line-mode~
 
diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index 0e1d4eda2..4d10a68f4 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -31,7 +31,7 @@
 ;;; Requirements:
 
 ;; plantuml | http://plantuml.sourceforge.net/
-;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file
+;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file (when exec mode is `jar')
 
 ;;; Code:
 (require 'ob)
@@ -46,6 +46,31 @@
   :version "24.1"
   :type 'string)
 
+(defcustom org-plantuml-exec-mode 'jar
+  "Method to use for PlantUML diagram generation.
+`jar' means to use java together with the JAR.
+The JAR can be configured via `org-plantuml-jar-path'.
+
+`plantuml' means to use the PlantUML executable.
+The executable can be configured via `org-plantuml-executable-path'.
+You can also configure extra arguments via `org-plantuml-executable-args'."
+  :group 'org-babel
+  :package-version '(Org . "9.4")
+  :type 'symbol
+  :options '(jar plantuml))
+
+(defcustom org-plantuml-executable-path "plantuml"
+  "File name of the PlantUML executable."
+  :group 'org-babel
+  :package-version '(Org . "9.4")
+  :type 'string)
+
+(defcustom org-plantuml-executable-args (list "-headless")
+  "The arguments passed to plantuml executable when executing PlantUML."
+  :group 'org-babel
+  :package-version '(Org . "9.4")
+  :type '(repeat string))
+
 (defun org-babel-variable-assignments:plantuml (params)
   "Return a list of PlantUML statements assigning the block's variables.
 PARAMS is a property list of source block parameters, which may
@@ -83,40 +108,41 @@ This function is called by `org-babel-execute-src-block'."
 	 (cmdline (cdr (assq :cmdline params)))
 	 (in-file (org-babel-temp-file "plantuml-"))
 	 (java (or (cdr (assq :java params)) ""))
+	 (executable (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-path)
+			   (t "java")))
+	 (executable-args (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-args)
+((string= "" org-plantuml-jar-path)
+ (error "`org-plantuml-jar-path' is not set"))
+((not (file-exists-p org-plantuml-jar-path))
+ (error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
+(t (list java
+	 "-jar"
+	 

Re: [PATCH] Expanded ob-python results handling and plotting

2020-08-30 Thread Jack Kamm
After taking another look at my patch, I realized that I was not quite
converting dictionaries to proper alists.

Attached is a tweak to do this properly. The printing of dictionaries is
not quite as pretty, in particular it's not a table anymore:

#+begin_src python
  return {"a": 1, "b": 2}
#+end_src

#+RESULTS:
: ((a . 1) (b . 2))

But, it feels like the right thing to do, since the result handling code
works by converting the result to an elisp value, before passing it to
org-mode to decide how to render it. And the proper elisp conversion of
a dict should be an alist or a plist.

Ideally I wouldn't have to do this from the Python code, and could let
org-babel-script-escape convert the dict objects. It would also be
useful for other languages with similar dictionaries, like
javascript. But it seems fairly complex to implement this from the elisp
side, and I'm not sure I'm up for it.

I also noticed that I had left a couple docstrings as TODOs -- I'll fix
those before finalizing the patch over the next couple weeks.

>From 76a1ad4d50e6638244d9aa17e45895b8b38b3cd0 Mon Sep 17 00:00:00 2001
From: Jack Kamm 
Date: Sun, 30 Aug 2020 08:51:04 -0700
Subject: [PATCH 2/2] Convert dictionary output to a proper alist

Note: to be squashed with the previous patch before merging
---
 lisp/ob-python.el | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index fb8fe380e..08c1c48e9 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -239,9 +239,14 @@ (defconst org-babel-python--def-format-value "\
 else:
 if not set(result_params).intersection(\
 ['scalar', 'verbatim', 'raw']):
+class alist(dict):
+def __str__(self):
+return '({})'.format(' '.join(['({} . {})'.format(repr(k), repr(v)) for k, v in self.items()]))
+def __repr__(self):
+return self.__str__()
 def dict2alist(res):
 if isinstance(res, dict):
-return [(k, dict2alist(v)) for k, v in res.items()]
+return alist({k: dict2alist(v) for k, v in res.items()})
 elif isinstance(res, list) or isinstance(res, tuple):
 return [dict2alist(x) for x in res]
 else:
-- 
2.28.0



Re: [PATCH] Expanded ob-python results handling and plotting

2020-08-30 Thread Jack Kamm
Hi Kyle,

Thanks for the comments, I'm attaching an updated patch.

Kyle Meyer  writes:

> ModuleNotFoundError wasn't added until Python 3.6, so I think it'd be
> better to use its parent class, ImportError.

I did not know this, thanks for the tip.

> Should handling of Series also be added?

Yes, I've done so now. I'm not sure whether it's better to treat it like
a row or column vector, but since it has an "index", which are the row
names in a DataFrame, I decided to treat it as a column.

>From 40db6b5497de78a9e69de219f4686b405db10c81 Mon Sep 17 00:00:00 2001
From: Jack Kamm 
Date: Tue, 25 Aug 2020 21:57:24 -0700
Subject: [PATCH] ob-python: Add results handling for dicts, dataframes,
 arrays, plots

* lisp/ob-python.el (org-babel-execute:python): Parse graphics-file
from params.
(org-babel-python--def-format-value): Python code for formatting
value results before returning.
(org-babel-python--output-graphics-wrapper): Python code for handling
output graphics results.
(org-babel-python--nonsession-value-wrapper): Replaces
org-babel-python-wrapper-method, org-babel-python-pp-wrapper-method.
(org-babel-python--session-output-wrapper): Renamed from
org-babel-python--exec-tmpfile.
(org-babel-python--session-value-wrapper): Renamed and modified from
org-babel-python--eval-ast.
(org-babel-python-evaluate-external-process): New parameter for
graphics file.
(org-babel-python-evaluate-session): New parameter for graphics file.

Added results handling for dictionaries, Pandas and numpy tables, and
matplotlib plots.
---
 etc/ORG-NEWS  |  17 ++-
 lisp/ob-python.el | 126 +++---
 2 files changed, 100 insertions(+), 43 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 10658a970..75c945572 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -66,8 +66,8 @@ to switch to the new signature.
 *** Python session return values must be top-level expression statements
 
 Python blocks with ~:session :results value~ header arguments now only
-return a value if the last line is a top-level expression statement.
-Also, when a None value is returned, "None" will be printed under
+return a value if the last line is a top-level expression statement,
+otherwise the result is None. Also, None will now show up under
 "#+RESULTS:", as it already did with ~:results value~ for non-session
 blocks.
 
@@ -235,6 +235,19 @@ Screen blocks now recognize the =:screenrc= header argument and pass
 its value to the screen command via the "-c" option. The default
 remains =/dev/null= (i.e. a clean screen session)
 
+*** =ob-python.el=: Support for more result types and plotting
+
+=ob-python= now recognizes dictionaries, numpy arrays, and pandas
+dataframes/series, and will convert them to org-mode tables when
+appropriate.
+
+When the header argument =:results graphics= is set, =ob-python= will
+use matplotlib to save graphics. The behavior depends on whether value
+or output results are used. For value results, the last line should
+return a matplotlib Figure object to plot. For output results, the
+current figure (as returned by =pyplot.gcf()=) is cleared before
+evaluation, and then plotted afterwards.
+
 *** =RET= and =C-j= now obey ~electric-indent-mode~
 
 Since Emacs 24.4, ~electric-indent-mode~ is enabled by default.  In
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 44e1b63e0..fb8fe380e 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -79,6 +79,8 @@ (defun org-babel-execute:python (body params)
 	  org-babel-python-command))
 	 (session (org-babel-python-initiate-session
 		   (cdr (assq :session params
+	 (graphics-file (and (member "graphics" (assq :result-params params))
+			 (org-babel-graphical-output-file params)))
  (result-params (cdr (assq :result-params params)))
  (result-type (cdr (assq :result-type params)))
 	 (return-val (when (and (eq result-type 'value) (not session))
@@ -89,7 +91,8 @@ (defun org-babel-execute:python (body params)
 	   (concat body (if return-val (format "\nreturn %s" return-val) ""))
 	   params (org-babel-variable-assignments:python params)))
  (result (org-babel-python-evaluate
-		  session full-body result-type result-params preamble)))
+		  session full-body result-type result-params preamble
+		  graphics-file)))
 (org-babel-reassemble-table
  result
  (org-babel-pick-name (cdr (assq :colname-names params))
@@ -225,67 +228,104 @@ (defun org-babel-python-initiate-session ( session _params)
 (org-babel-python-session-buffer
  (org-babel-python-initiate-session-by-key session
 
-(defconst org-babel-python-wrapper-method
-  "
-def main():
+(defconst org-babel-python--def-format-value "\
+def __org_babel_python_format_value(result, result_file, result_params):
+with open(result_file, 'w') as f:
+if 'graphics' in result_params:
+result.savefig(result_file)
+elif 'pp' in result_params:
+import pprint
+

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

2020-08-30 Thread Eric Abrahamsen
Nicolas Goaziou  writes:

> Ihor Radchenko  writes:
>
>> I feel that my understand of "note" in context of org is different from
>> yours. Is there a formal definition of "note" in org?
>
> As I stated in my first post a few hours ago:
>
>Notes are mostly free-form; there is no syntax describing them.
>
>> However, we can formalise the "last note taken" to "last note taken
>> using org-add-note".
>
> This is more realistic, but you are then binding the tool
> (`org-add-note') to the syntax ("[!]"), which is a step in the wrong
> direction. We must not assume Org mode is the only tool writing Org
> documents.
>
>> org-add-note is the only way I am aware about (except plain text,
>> indeed). That's why I wrote the function saving the last note taken
>> using org-add-note into SUMMARY. The property is only used here for
>> convenient retrieval, not because I implied showing a property value.
>
> I understand the property was used for convenience, but showing its
> value is the only problem your can really claim solving at the moment.
>
>> May I know what are the other ways to add note via interactive function
>> in Org?
>
> Capture is certainly one way. In fact, `org-add-note' could (should ?)
> be rewritten using Capture library.
>
> I wouldn't dismiss plain text insertion too easily, either. It also
> includes external tools. What happens if an external tool automatically
> insert notes?
>
> The feature you are requesting could make sense if notes had a clear
> syntax. This would bring some interesting features, too (e.g., being
> able to list all notes in an entry, accurately). But it would also raise
> new problems, as any syntax change (backward compatibility with old
> documents, external tools...). 

FWIW I'd be very happy to see a formalized note syntax. I make heavy use
of arbitrary notes and state-change notes -- what needs to be done NEXT,
how long has a todo been in WAIT state -- and would love to be able to
build more tools on top of that.




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

2020-08-30 Thread Ihor Radchenko
> Again, on a given document, you can only guess what is the "last note".
> This is not reliable enough to extend the syntax.

I feel that my understand of "note" in context of org is different from
yours. Is there a formal definition of "note" in org?

If no, there is indeed no reliable way to capture "last note". However,
we can formalise the "last note taken" to "last note taken using
org-add-note".

> This implementation is only tangentially related to a "last note". You
> want to introduce some syntax to display the value a given property,
> here SUMMARY. But `org-add-note' is not the only way to add a note. 

org-add-note is the only way I am aware about (except plain text,
indeed). That's why I wrote the function saving the last note taken
using org-add-note into SUMMARY. The property is only used here for
convenient retrieval, not because I implied showing a property value.

May I know what are the other ways to add note via interactive function
in Org?

Best,
Ihor

Nicolas Goaziou  writes:

> Ihor Radchenko  writes:
>
>> I was mainly referring to org-add-note. The last note taken with
>> org-add-note can be found quite reliably.
>>
>> I am using the following code saving the last note into :SUMMARY:
>> property upon exiting the note buffer. Though it may be an overkill, not
>> sure how easy would it be to parse the note syntax for notes created by
>> org-add-note.
>
> You cannot reliably.
>
>> (defvar yant/last-note-taken ""
>>   "Text of the last note taken.")
>>
>> (define-advice org-store-log-note (:before ( args) 
>> yant/org-store-last-note)
>>   "Store the last saved note into `yant/last-note-taken'."
>>   (let ((txt (buffer-string)))
>> (while (string-match "\\`# .*\n[ \t\n]*" txt)
>>   (setq txt (replace-match "" t t txt)))
>> (when (string-match "\\s-+\\'" txt)
>>   (setq txt (replace-match " " t t txt)))
>> (when (string-match "\n" txt)
>>   (setq txt (replace-match " " t t txt)))
>> (if (not (seq-empty-p txt))
>>  (setq yant/last-note-taken txt
>>
>> (define-advice org-store-log-note (:after ( args) 
>> yant/org-save-last-note-into-summary-prop)
>>   "Save the last saved note into SUMMARY property."
>>   (when (and (not org-note-abort) (not (seq-empty-p yant/last-note-taken)))
>> (if (eq major-mode 'org-agenda-mode)
>>  (org-with-point-at-org-buffer
>>   (org-set-property "SUMMARY" (or yant/last-note-taken "")))
>>   (org-set-property "SUMMARY" (or yant/last-note-taken "")))
>> (setq yant/last-note-taken nil)))
>
> This implementation is only tangentially related to a "last note". You
> want to introduce some syntax to display the value a given property,
> here SUMMARY. But `org-add-note' is not the only way to add a note. 
>
> Again, on a given document, you can only guess what is the "last note".
> This is not reliable enough to extend the syntax.
>
> Regards,



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

2020-08-30 Thread Nicolas Goaziou
Ihor Radchenko  writes:

> I feel that my understand of "note" in context of org is different from
> yours. Is there a formal definition of "note" in org?

As I stated in my first post a few hours ago:

   Notes are mostly free-form; there is no syntax describing them.

> However, we can formalise the "last note taken" to "last note taken
> using org-add-note".

This is more realistic, but you are then binding the tool
(`org-add-note') to the syntax ("[!]"), which is a step in the wrong
direction. We must not assume Org mode is the only tool writing Org
documents.

> org-add-note is the only way I am aware about (except plain text,
> indeed). That's why I wrote the function saving the last note taken
> using org-add-note into SUMMARY. The property is only used here for
> convenient retrieval, not because I implied showing a property value.

I understand the property was used for convenience, but showing its
value is the only problem your can really claim solving at the moment.

> May I know what are the other ways to add note via interactive function
> in Org?

Capture is certainly one way. In fact, `org-add-note' could (should ?)
be rewritten using Capture library.

I wouldn't dismiss plain text insertion too easily, either. It also
includes external tools. What happens if an external tool automatically
insert notes?

The feature you are requesting could make sense if notes had a clear
syntax. This would bring some interesting features, too (e.g., being
able to list all notes in an entry, accurately). But it would also raise
new problems, as any syntax change (backward compatibility with old
documents, external tools...). 

Regards,



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

2020-08-30 Thread Nicolas Goaziou
Ihor Radchenko  writes:

> I was mainly referring to org-add-note. The last note taken with
> org-add-note can be found quite reliably.
>
> I am using the following code saving the last note into :SUMMARY:
> property upon exiting the note buffer. Though it may be an overkill, not
> sure how easy would it be to parse the note syntax for notes created by
> org-add-note.

You cannot reliably.

> (defvar yant/last-note-taken ""
>   "Text of the last note taken.")
>
> (define-advice org-store-log-note (:before ( args) 
> yant/org-store-last-note)
>   "Store the last saved note into `yant/last-note-taken'."
>   (let ((txt (buffer-string)))
> (while (string-match "\\`# .*\n[ \t\n]*" txt)
>   (setq txt (replace-match "" t t txt)))
> (when (string-match "\\s-+\\'" txt)
>   (setq txt (replace-match " " t t txt)))
> (when (string-match "\n" txt)
>   (setq txt (replace-match " " t t txt)))
> (if (not (seq-empty-p txt))
>   (setq yant/last-note-taken txt
>
> (define-advice org-store-log-note (:after ( args) 
> yant/org-save-last-note-into-summary-prop)
>   "Save the last saved note into SUMMARY property."
>   (when (and (not org-note-abort) (not (seq-empty-p yant/last-note-taken)))
> (if (eq major-mode 'org-agenda-mode)
>   (org-with-point-at-org-buffer
>(org-set-property "SUMMARY" (or yant/last-note-taken "")))
>   (org-set-property "SUMMARY" (or yant/last-note-taken "")))
> (setq yant/last-note-taken nil)))

This implementation is only tangentially related to a "last note". You
want to introduce some syntax to display the value a given property,
here SUMMARY. But `org-add-note' is not the only way to add a note. 

Again, on a given document, you can only guess what is the "last note".
This is not reliable enough to extend the syntax.

Regards,



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

2020-08-30 Thread Ihor Radchenko
> Notes are free-form; there is no syntax describing them. Org cannot tell
> what is a "note". As a consequence, pointing to "the last note taken" is
> not reliable, syntax wise.

> Of course, under some assumptions (e.g., notes setup is fixed, you never
> write notes by hand, ...), you could guess what the last note taken is.
> But again, this is not reliable, and not portable.

I was mainly referring to org-add-note. The last note taken with
org-add-note can be found quite reliably.

I am using the following code saving the last note into :SUMMARY:
property upon exiting the note buffer. Though it may be an overkill, not
sure how easy would it be to parse the note syntax for notes created by
org-add-note.

(defvar yant/last-note-taken ""
  "Text of the last note taken.")

(define-advice org-store-log-note (:before ( args) 
yant/org-store-last-note)
  "Store the last saved note into `yant/last-note-taken'."
  (let ((txt (buffer-string)))
(while (string-match "\\`# .*\n[ \t\n]*" txt)
  (setq txt (replace-match "" t t txt)))
(when (string-match "\\s-+\\'" txt)
  (setq txt (replace-match " " t t txt)))
(when (string-match "\n" txt)
  (setq txt (replace-match " " t t txt)))
(if (not (seq-empty-p txt))
(setq yant/last-note-taken txt

(define-advice org-store-log-note (:after ( args) 
yant/org-save-last-note-into-summary-prop)
  "Save the last saved note into SUMMARY property."
  (when (and (not org-note-abort) (not (seq-empty-p yant/last-note-taken)))
(if (eq major-mode 'org-agenda-mode)
(org-with-point-at-org-buffer
 (org-set-property "SUMMARY" (or yant/last-note-taken "")))
  (org-set-property "SUMMARY" (or yant/last-note-taken "")))
(setq yant/last-note-taken nil)))

Best,
Ihor






Nicolas Goaziou  writes:

> Hello,
>
> 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?
>
> Notes are free-form; there is no syntax describing them. Org cannot tell
> what is a "note". As a consequence, pointing to "the last note taken" is
> not reliable, syntax wise.
>
> Of course, under some assumptions (e.g., notes setup is fixed, you never
> write notes by hand, ...), you could guess what the last note taken is.
> But again, this is not reliable, and not portable.
>
> Regards,
> -- 
> Nicolas Goaziou



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

2020-08-30 Thread Nicolas Goaziou
Hello,

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?

Notes are free-form; there is no syntax describing them. Org cannot tell
what is a "note". As a consequence, pointing to "the last note taken" is
not reliable, syntax wise.

Of course, under some assumptions (e.g., notes setup is fixed, you never
write notes by hand, ...), you could guess what the last note taken is.
But again, this is not reliable, and not portable.

Regards,
-- 
Nicolas Goaziou



Re: [PATCH] ob-core: Avoid table conversion warning for empty results

2020-08-30 Thread Colin Baxter
Dear Kyle,

> Kyle Meyer  writes:

>> Kyle Meyer writes:
>>> Thanks for reporting.  The _display_ of this warning starts with
>>> my 14878f3f9 (ob-core: Display warning on failure to read
>>> results, 2020-05-21).  Here's the associated thread on the
>>> mailing list:
>>> .
>>> 
>>> On that commit's parent (eecee2266), the error is triggered and
>>> caught in the same way, but "Error reading results:
>>> (beginning-of-buffer)" is buried in the messages buffer rather
>>> than being displayed as a warning.
>>> 
>>> I'll need to take a closer look at what's going on, though I
>>> wouldn't be surprised if it's been around for a long time.

>> This patch would squelch the inappropriate warning you report
>> while not hiding other warnings.

> Thank you. I'll apply the patch to my org-mode and report back.

I have now applied the patch to my local org-mode git repository and it
works with no reported errors. Thanks again.

Best wishes,

Colin Baxter.


Colin Baxter
URL: http://www.Colin-Baxter.com
-
GnuPG fingerprint: 68A8 799C 0230 16E7 BF68  2A27 BBFA 2492 91F5 41C8
-