Suspected bug: example block in a footnote doesn't fold if starts with 2 blank lines

2022-08-30 Thread Alain . Cochard


Hello.  When I visit an org buffer containing only:

  foo[fn:1]

  [fn:1] bar
  #+begin_example


  x
  #+end_example

then, hitting  when the cursor is on either '#' does nothing
(i.e., no folding).

Tested with 'emacs -Q' and the following combinations:

GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
3.24.30, cairo version 1.17.4) of 2021-08-07 Org mode version 9.4.4
(release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)

GNU Emacs 28.1 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.17.4) of 2022-08-16 Org mode version 9.5.2
(release_9.5.2-25-gaf6f12 @
/home/cochard/usr/local/emacs-28.1/lisp/org/)

GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.17.4) of 2022-08-22 Org mode version 9.5.4
(release_9.5.4-17-g6e991f @
/home/cochard/usr/local/emacs-29/lisp/org/)

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.coch...@unistra.fr
5 rue René Descartes   [bureau 106]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France | [ slot available for rent ]




Re: [PATCH] org-agenda.el: agenda*: add lost argument

2022-08-30 Thread Mikhail Skorzhisnkii
This patch is no longer needed, as the bug was fixed in other commit.

Ihor Radchenko  writes:

> Mikhail Skorzhinskii  writes:
>
>> * lisp/org-agenda.el (org-agenda): add lost argument for agenda*
>
> Thanks! I am not able to apply your patch onto main. Could you resend,
> preferably adding the patch as an attachment and adding TINYCHANGE
> cookie (you do not seem to have the copyright assignment)?
>
> See 
>
> Best,
> Ihor


Re: [PATCH] org-refile.el: show refile targets with doc. title

2022-08-30 Thread Mikhail Skorzhisnkii
I have signed the FSF papers. However for the simplicity I will send renewed 
patch in different thread. You may consider this thread to be closed.q

E-Mail thread I am going to use is: 


  Thanks,
  Mikhail Skorzhinskii

Ihor Radchenko  writes:

> Mikhail Skorzhinskii  writes:
>
>> Thank you for reviewing the changes. Sorry for the sloppy patch, I’ve
>> retested everything and added a few additional fixes, there were more
>> problems.
>
> Thanks! And sorry for the slow review. Your email was lost near the tail
> of the todo list.
>
>> I’ve added a couple of test cases too. (BTW, test framework is awesome
>> and really easy to use!)
>
> Great!
>
>> * lisp/org-refile.el (org-refile-use-outline-path): add an option ’title
>> * lisp/org-refile.el (org-refile-get-targets): start refile target
>> outline with document title (#+title) instead of file name
>
> Note that changes like this should be detailed in etc/ORG-NEWS
>
>> -  (const :tag “Start with buffer name” buffer-name)))
>> +  (const :tag “Start with buffer name” buffer-name)
>> +  (const :tag “Start with document title” title)))
>
> You also need to document the new option in the docstring.
>
>> +  ;; When `org-refile-use-outline-path’ is `title’ and document do not
>> +  ;; have an extracted document title, return just the file name
>> +  (should
>> +   (org-test-with-temp-text-in-file “* H1”
>> + (let* ((filename (buffer-file-name))
>> +(org-refile-use-outline-path ’title)
>> +(org-refile-targets `(((,filename) :level . 1
>> +   (member (file-name-nondirectory filename)
>> +   (mapcar #’car (org-refile-get-targets)))
>
> It would also make sense to add a test when document is a temporary
> buffer without filename and also does not contain a title.
>
> Finally, your patch is exceeding 15LOC. You need to do copyright
> paperwork to get the patch merged. See
> 
>
> Best,
> Ihor


Re: [PATCH] ox-icalendar.el: customizable vevent summary prefix

2022-08-30 Thread Mikhail Skorzhisnkii
I have signed FSF papers. Attaching a rebased patch with additional changes to
ORG-NEWS

Ihor Radchenko  writes:

> “Mikhail Skorzhinskiy”  writes:
>
>> Thanks for review, Ihor. I have sent a copyright assignment request. Will
>> resubmit the patches as soon as I complete the process.
>
> Thanks! Note that FSF clerk should reply within 5 working days. If not,
> please let us know.
>
> Best,
> Ihor
>From ceb6c9836032c92a792bf58aab91d74141664f50 Mon Sep 17 00:00:00 2001
From: Mikhail Skorzhinskii 
Date: Sat, 12 Sep 2020 18:10:05 +0200
Subject: [PATCH 1/2] org-agenda.el: customize outline path in echo area

* lisp/org-agenda.el (org-agenda-show-outline-path): add an option to
show document title in outline path (instead of file name)
* lisp/org.el (org-get-title-from-buffer): a function to collect the
document title from the org-mode buffer
* lisp/org.el (org-display-outline-path): add logic that will collect a
document title and put it into the outline path if
org-agenda-show-outline-path set to 'title
---
 etc/ORG-NEWS   | 10 ++
 lisp/org-agenda.el | 11 ---
 lisp/org.el| 25 ++---
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 7dae03dc6..4405489bb 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -290,6 +290,12 @@ level used for top level headings, much like how
 headings in HTML export.
 
 ** New options
+*** A new option for custom setting =org-agenda-show-outline-path= to show document title
+
+Settings =org-agenda-show-outline-path=  to ='title= will show title instead of
+the file name at the beginning of the outline. The title of the
+document can be set by special keyword =#+title:=.
+
 *** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers
 
 Previously, all the drawers were always folded when opening an Org
@@ -320,6 +326,10 @@ event time when the alarm time is set to 0.  The default value is
 nil -- do not create alarms at the event time.
 
 ** New functions and changes in function arguments
+*** New function ~org-get-title-from-buffer~ to get ~#+TITLE:~ property
+
+A function to collect the document title from the org-mode buffer.
+
 *** ~org-fold-show-entry~ does not fold drawers by default anymore
 
 ~org-fold-show-entry~ now accepts an optional argument HIDE-DRAWERS.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b98041ea8..f308f8f76 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1058,9 +1058,14 @@ current item's tree, in an indirect buffer."
   :type 'boolean)
 
 (defcustom org-agenda-show-outline-path t
-  "Non-nil means show outline path in echo area after line motion."
+  "Non-nil means show outline path in echo area after line motion.
+
+If set to 'title, show document title."
   :group 'org-agenda-startup
-  :type 'boolean)
+  :type '(choice
+	  (const :tag "Don't show outline path in agenda view." nil)
+	  (const :tag "Show outline path with prepended file name." t)
+	  (const :tag "Show outline path with prepended document title. Fallback to file name is no title is present." title)))
 
 (defcustom org-agenda-start-with-entry-text-mode nil
   "The initial value of entry-text-mode in a newly created agenda window."
@@ -9424,7 +9429,7 @@ When called with a prefix argument, include all archive files as well."
 	   (org-agenda-tree-to-indirect-buffer nil)
 	 (org-agenda-show)))
   (and org-agenda-show-outline-path
-	   (org-with-point-at m (org-display-outline-path t))
+	   (org-with-point-at m (org-display-outline-path org-agenda-show-outline-path))
 
 (defun org-agenda-show-tags ()
   "Show the tags applicable to the current item."
diff --git a/lisp/org.el b/lisp/org.el
index 858123e67..fd76af48a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7396,10 +7396,24 @@ the default is \"/\"."
 	(setf (substring fpath (- width 2)) "..")))
 fpath))
 
-(defun org-display-outline-path (&optional file current separator just-return-string)
+(defun org-get-title-from-buffer (&optional buffer)
+  "Collect title from the provided `org-mode' BUFFER."
+  (let* ((buffer (or buffer (current-buffer)))
+ (buffer (or (buffer-base-buffer buffer)
+ buffer))
+ title)
+(with-current-buffer buffer
+  (pcase (org-collect-keywords '("TITLE"))
+(`(("TITLE" . ,val))
+ (setq title (car val)
+title))
+
+(defun org-display-outline-path (&optional file-or-title current separator just-return-string)
   "Display the current outline path in the echo area.
 
-If FILE is non-nil, prepend the output with the file name.
+If FILE-OR-TITLE is 'title, prepend outline with file title.  If
+it is non-nil or title is not present in document, prepend
+outline path with the file name.
 If CURRENT is non-nil, append the current heading to the output.
 SEPARATOR is passed through to `org-format-outline-path'.  It separates
 the different parts of the path and defaults to \"/\".
@@ -7407,6 +

Re: [PATCH] org-agenda.el: customise outline path in echo area

2022-08-30 Thread Mikhail Skorzhisnkii
I have signed the FSF papers now and we can continue the review of this work 
now.

I am attaching updated and rebased patch for this and another e-mail thread, 
since these two patches are depend on each other. I have additionally tested 
the functionality of these changes by verifying that it works as expected on my 
setup;

• Tried to use org-agenda on buffers with and without title property set
• Tried to call org-refile and see if refiling will happen
• `make test' passes

I have *not* tried to see if it will work on buffers without file 
representation, but the component tests for refile should cover that.

Let me know what you think.

  Thanks,
  Mikhail Skorzhinskii

Ihor Radchenko  writes:

> Mikhail Skorzhinskii  writes:
>
>> Thank you for your comments once again. I’ve changed string= to eq and
>> it appears to be working OK.
>>
>> I’ve also renamed “title” variable to “title-prop” for better
>> readability. The -prop suffix should show the reader that it was
>> extracted from the file, and thus cost some CPU/IO.
>>
>> I’ve attached an updated version to this email. Would love to hear what
>> you think.
>
> Thanks! And sorry for the late reply. Your patch fell through the cracks
> in my todo list.
>
>> * lisp/org-agenda.el (org-agenda-show-outline-path): add an option to
>> show document title in outline path (instead of file name)
>> * lisp/org.el (org-get-title-from-file): a function to collect the
>> document title from the org-mode file
>> * lisp/org.el (org-display-outline-path): add logic that will collect a
>> document title and put it into the outline path if
>> org-agenda-show-outline-path set to ’title
>
> It would make sense to document the new customization in ORG-NEWS.
>
>> +(defun org-get-title-from-file (file)
>> +  “Collect tilte from the provided `org-mode’ FILE.”
>> +  (let (title)
>   ^ typo
>> +(when file
>> +  (with-current-buffer
>> +  (get-file-buffer file)
>> +(pcase (org-collect-keywords ’(“TITLE”))
>> +  (`((“TITLE” . ,val))
>> +   (setq title (car val)
>> +  title)))
>
> Note that this function behavior is underfined when FILE buffer does not
> exist. It would be better to accept buffer as argument.
>
> Best,
> Ihor
>From 646af66fa88fbcc2b1f2848a14dd5c262763ef98 Mon Sep 17 00:00:00 2001
From: Mikhail Skorzhinskii 
Date: Mon, 21 Sep 2020 14:53:13 +0200
Subject: [PATCH 2/2] org-refile.el: show refile targets with doc. title

* lisp/org-refile.el (org-refile-use-outline-path): add an option 'title
* lisp/org-refile.el (org-refile-get-targets): start refile target
outline with document title (#+title) instead of file name
---
 etc/ORG-NEWS |  4 
 lisp/org-refile.el   | 16 +---
 testing/lisp/test-org.el | 37 -
 3 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4405489bb..df2c882bb 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -290,6 +290,10 @@ level used for top level headings, much like how
 headings in HTML export.
 
 ** New options
+*** A new option for custom setting =org-refile-use-outline-path= to show document title in refile targets
+
+Setting =org-refile-use-outline-path= to ='title= will show title instead of the file name in refile targets. If the documen do not have a title, the filename will be used, similar to ='file= option.
+
 *** A new option for custom setting =org-agenda-show-outline-path= to show document title
 
 Settings =org-agenda-show-outline-path=  to ='title= will show title instead of
diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 01f0dfa46..14bd81a2b 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -158,7 +158,8 @@ When `buffer-name', use the buffer name."
 	  (const :tag "Yes" t)
 	  (const :tag "Start with file name" file)
 	  (const :tag "Start with full file path" full-file-path)
-	  (const :tag "Start with buffer name" buffer-name)))
+	  (const :tag "Start with buffer name" buffer-name)
+	  (const :tag "Start with document title" title)))
 
 (defcustom org-outline-path-complete-in-steps t
   "Non-nil means complete the outline path in hierarchical steps.
@@ -317,6 +318,9 @@ converted to a headline before refiling."
 		 (push (list (and (buffer-file-name (buffer-base-buffer))
   (file-truename (buffer-file-name (buffer-base-buffer
  f nil nil) tgs))
+	   (when (eq org-refile-use-outline-path 'title)
+		 (push (list (or (org-get-title-from-buffer)
+ (and f (file-name-nondirectory f))) f nil nil) tgs))
 	   (org-with-wide-buffer
 		(goto-char (point-min))
 		(setq org-outline-path-cache nil)
@@ -343,7 +347,13 @@ converted to a headline before refiling."
(and (buffer-file-name (buffer-base-buffer))
 (file-name-nondirectory

Re: Suspected bug: example block in a footnote doesn't fold if starts with 2 blank lines

2022-08-30 Thread Ihor Radchenko
alain.coch...@unistra.fr writes:

> Hello.  When I visit an org buffer containing only:
>
>   foo[fn:1]
>
>   [fn:1] bar
>   #+begin_example
>
>
>   x
>   #+end_example
>
> then, hitting  when the cursor is on either '#' does nothing
> (i.e., no folding).

This is not a bug. Just unintuitive syntax:

https://orgmode.org/manual/Creating-Footnotes.html#Creating-Footnotes
>> A footnote is started by a footnote marker in square brackets in
>> column 0, no indentation allowed. It ends at the next footnote
>> definition, headline, or after two consecutive empty lines. The
>> footnote reference is simply the marker in square brackets, inside
>> text. Markers always start with ‘fn:’.

The important part is:
It ends at the next footnote definition, headline, or after two consecutive 
empty lines.

So, your example is

foo[fn:1]

[fn:1] bar
#+begin_example ;; <- this is not considered an example block because no
major org elements can be inside a footnote definition.



x
#+end_example


-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: [#C] Story behind priorities in org-mode?

2022-08-30 Thread Ihor Radchenko
Ypo  writes:

> Reading this web, 
> https://christopherfin.com/emacs/programmer_priorities.html made me 
> think about the syntax of priorities in org-mode.
>
> What is the story behind [#A], etc?

It dates back to Org version 4.12, which is the first commit in our
public Git repo.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: [PATCH] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)

2022-08-30 Thread Ihor Radchenko
Sébastien Miquel  writes:

> I've implemented this proposal in the patch attached.
>
> Does it look good to you ?

Thanks! The patch looks mostly fine.

Applied onto main via 72f66ca0b.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=72f66ca0b9d336e0da61b17cbe8ce183eef364dd

A small side effect of the patch is that name[] will also work for
lists:

#+name: test
- one
- two
- three


#+begin_src emacs-lisp :var x=test[]
  (message "%S" x)
#+end_src

#+RESULTS:
: (("one") ("two") ("three"))

which is not intentional, but does not break anything and also somewhat
logical.

#+begin_src emacs-lisp :var x=test[1:2]
  (message "%S" x)
#+end_src

#+RESULTS:
: (("two") ("three"))

worked in the past anyway, despite not being documented.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92