[BUG] Updating first subheading checkbox cookie resets parent cookie

2024-06-16 Thread Bruno Cardoso


Hello everyone,

Consider the following tree:

* Task [1/3]
** TODO test1 [/]
- [x] a
- [ ] b  
** DONE test2
** TODO test3 [/]
- [X] x
- [ ] y

With point at the "test1" heading cookie ("[/]"), after =C-c C-c=, it gets 
updated to "[1/2]", but it also resets its parent's "Task" cookie to "[0/0]".

This only happens with the first heading of a subtree (updating the "task3" 
cookie works as expected).

Org mode version 9.8-pre (release_9.7.3-73-g96d149)


Best,

Bruno.




Re: [PATCH] Add support for shortdoc link type

2024-06-06 Thread Bruno Cardoso


On 2024-06-06, 11:53 +, Ihor Radchenko  wrote:
>
> Thanks!
> Applied, onto main, with amendments.
> I re-worded the manual and news entries, moved the news entry to new
> features, addressed compiler warnings, and added a FIXME marking the
> Emacs version check for removal when we drop Emacs 27 support.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=55e8068d6
>
> I also added you to our contributor list.
> https://git.sr.ht/~bzg/worg/commit/392644ae

Thank you!



Re: [BUG] org-capture: %\N template expansion

2024-06-05 Thread Bruno Cardoso


On 2024-06-05, 11:29 +, Ihor Radchenko  wrote:

> See the attached tentative patch.
>
> I introduced a new placeholder - %\*N. It refers to _all_ the prompts,
> unlike %\N. If you have better ideas about syntax, please share.
>

Thank you, Ihor! I tested it both from `org-capture-templates' and from an Org 
template file and the patch worked as expected. I'm fine with the proposed 
syntax.

Best,

Bruno.



Re: [PATCH] Add support for shortdoc link type

2024-06-05 Thread Bruno Cardoso

On 2024-06-05, 22:37 +0700, Max Nikulin  wrote:
>
> A couple of notes that unlikely affect real life usage.
>
>> +  (defun org-link--store-shortdoc ( _interactive?)
>> +"Store \"shortdoc\" type link."
>> +(when (eq major-mode 'shortdoc-mode)
>
> `derived-mode-p' is more reliable in general.

Fixed.

The attached patch is now rebased to new Org version.

>From 43de471e577d530ea76dc48460efea12864b5675 Mon Sep 17 00:00:00 2001
From: bruno 
Date: Wed, 5 Jun 2024 19:14:36 -0300
Subject: [PATCH] Add support for shortdoc link type

ol.el: Add support for `shortdoc' link type

* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.

---
 doc/org-manual.org | 11 +++
 etc/ORG-NEWS   |  5 +
 lisp/ol.el | 41 +
 3 files changed, 57 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 170eea506..e931e1cc1 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3393,6 +3393,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ shows all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3434,6 +3443,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4b0b77ca8..a8f3a37f6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -40,6 +40,11 @@ all the references are resolved in the generated png.
 
 # This also includes changes in function behavior from Elisp perspective.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** Miscellaneous
 
 * Version 9.7
diff --git a/lisp/ol.el b/lisp/ol.el
index 20f1b89c0..4cda0cb60 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,47 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (and str
+(eq ?# (string-to-char str))
+(intern-soft (substring str 1)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(and str (not fn) (search-forward str nil t)))
+(error (user-error "Unknown shortdoc group or malformed link: `%s'"
+   path)
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (derived-mode-p 'org-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc (intern-soft group) shortdoc--groups))
+(org-link-store-props :type "shortdoc"
+  :link (format "shortdoc:%s" group)
+  :description nil)
+  (user-error "Unknown shortdoc group: %s" group)
+
+  (defun org-link--complete-shortdoc ()
+"Create a \"shortdoc\" link using completion."
+(concat "shortdoc:"
+(completing-read "Shortdoc summary for functions in: "
+ (mapcar #'car shortdoc--groups
+
+  (org-link-set-parameters "shortdoc"
+   :follow 

Re: [PATCH] Add support for shortdoc link type

2024-06-04 Thread Bruno Cardoso


On 2024-05-17, 11:55 -0300, Bruno Cardoso  wrote:

> On 2024-05-16, 17:58 +0700, Max Nikulin  wrote:
>>
>> Thank you. Now your patch can be applied on my side as well.
>>
>> Please, proceed with the copyright agreement form.
>
> Thank you very much, Max. Just sent the form.

Hi all. My copyright assignment with the FSF is complete.





Re: [BUG] org-capture: %\N template expansion

2024-05-23 Thread Bruno Cardoso


On 2024-05-23, 11:13 +, Ihor Radchenko  wrote:

> That's because you can only use %\N placeholder for %^{prompt} but not
> for %^{prompt}X.
> ...
> We can probably improve the error and the docstring to clarify this.

Thanks for the explanation, Ihor. I expected it to work in both cases, as the 
property prompt with value completion is very useful. I feel the error and the 
docstring can be confusing in this regard.

> We may also make %^{prompt}X expansions to work with %\N, but it can
> break the existing templates that are tuned to the current behaviour.

I see. Would it make sense to have another placeholder for '%^{prompt}X'?





[BUG] org-capture: %\N template expansion

2024-05-22 Thread Bruno Cardoso


Hi all,

I'm having trouble expanding the '%\N' template in org-capture.

For example, with the following template:

(add-to-list 'org-capture-templates
 '("t" "TEST" entry
   (file+headline "~/org/test.org" "TEST")
   "** TODO %?
:PROPERTIES:
:TITLE:%^{TITLE}
:AUTHOR:   %^{AUTHOR}p
:END:
%\1 %\2"))

The properties are read correctly, but "%\1 %\2" expands to "%^A %^B".

Either escaping the backslashes ("%\\1 %\\2") or reading the template above 
from a file throws an error:

: org-capture: Capture abort: Wrong type argument: stringp, nil


Org mode version 9.7-pre (release_9.6.29-1474-g1c5492)


Best,

Bruno.



Re: [PATCH] Add support for shortdoc link type

2024-05-17 Thread Bruno Cardoso


On 2024-05-16, 17:58 +0700, Max Nikulin  wrote:
>
> Thank you. Now your patch can be applied on my side as well.
>
> Please, proceed with the copyright agreement form.

Thank you very much, Max. Just sent the form.



Re: [PATCH] Add support for shortdoc link type

2024-05-13 Thread Bruno Cardoso

On 2024-05-13, 18:14 +0700, Max Nikulin  wrote:

> Sorry, but did you manually edit the patch?

I didn't. I generated it again and applied without errors.

> If you wish to use `user-error' as in earlier revisions then you may use
>
>  (error (user-error "Unknown shortdoc group or malformed link: `%s'"
>  path)

Thanks, changed it.

> An alternative might be something like (feel free to ignore)
>
>(condition-case err
> ;; ...
>  (error (signal 'user-error (cdr err ; more )
>
> to preserve message generated by `shortdoc-display-group'.

The error message generated by `shortdoc-display-group' may be vague when group 
is empty ("No such documentation group "), which might be the result of a 
malformed link.

>From beceb1b17d1c019cfeb987276e5a234c8f280e6b Mon Sep 17 00:00:00 2001
From: Bruno Cardoso 
Date: Mon, 13 May 2024 09:42:19 -0300
Subject: [PATCH] Add support for shortdoc link type

ol.el: Add support for `shortdoc' link type

* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.
---
 doc/org-manual.org | 11 +++
 etc/ORG-NEWS   |  5 +
 lisp/ol.el | 41 +
 3 files changed, 57 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index e3a2c9b70..c4873a79b 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ shows all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3432,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index ff58833d7..910f534ac 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1467,6 +1467,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 3d64b41b0..5468a1939 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,47 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (and str
+(eq ?# (string-to-char str))
+(intern-soft (substring str 1)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(and str (not fn) (search-forward str nil t)))
+(error (user-error "Unknown shortdoc group or malformed link: `%s'"
+   path)
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc

Re: [PATCH] Add support for shortdoc link type

2024-05-11 Thread Bruno Cardoso

On 2024-05-10, 18:09 +0700, Max Nikulin  wrote:

> Thank you for the explanation. Reading "lists all" I expected something 
> like list of all info manuals in the case of M-x info RET when there are 
> no info buffers yet.

I see. I replaced the term "lists all" with "shows all" to avoid this confusion.

> The following garbage in - garbage out case is a bit confusing:
> 
> => "No such documentation group "

Fixed the error handling and the error message.

> Bruno, has you signed the copyright form? This patch is above the 
> TINYCHANGE limit.
> <https://orgmode.org/worg/org-contribute.html#copyright>

I haven't yet. Will be glad to.

> It will be a bit less work for the maintainer if you attach result of 
> "git format-patch" command. It adds email-like headers allowing to 
> properly set commit author.

The attached patch is now in this format.

>From 57ab6be64e227fcab24ad4c5b84873ed4e946cff Mon Sep 17 00:00:00 2001
From: Bruno Cardoso 
Date: Sat, 11 May 2024 13:42:56 -0300
Subject: [PATCH] Add support for shortdoc link type

ol.el: Add support for `shortdoc' link type

* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.
---
 doc/org-manual.org | 11 +++
 etc/ORG-NEWS   |  5 +
 lisp/ol.el | 41 +
 3 files changed, 57 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f9d4c9a3f..8e99652b5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ shows all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3432,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 36eeddda1..9b7ba96ba 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1428,6 +1428,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 3d64b41b0..6b84957f4 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,7 +1582,47 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (and str
+(eq ?# (string-to-char str))
+(intern-soft (substring str 1)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(and str (not fn) (search-forward str nil t)))
+(error (message "Unknown shortdoc group or malformed link: `%s'"
+path)
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq m

Re: [PATCH] Add support for shortdoc link type

2024-05-08 Thread Bruno Cardoso

On 2024-05-08, 18:20 +0700, Max Nikulin  wrote:

> I have not managed to get all known groups with `shortdoc-display-group' 
> in Emacs-28. Is it a feature of `shortdoc' in Emacs-29?

In Emacs-29 `shortdoc' is an alias for `shortdoc-display-group'. Interactvely, 
it prompts the user for a group from `shortdoc--groups' (that's what I meant by 
"all known groups"). I'm unsure if `shortdoc-display-group' behaves differently 
in Emacs-28.

> Likely it is better to not allow empty group or function, so "+" instead 
> of "*"
>
> "\\`\\([^:]+\\)\\(?:::\\(.+\\)\\'\\)?"
>
> since  is hardly a valid link. However it might be 
> search text link in the list of all groups (Emacs-29+ only?).
>
> It is related to corner cases, so I do not insist.

`shortdoc-display-group' already handles empty group or function. Replacing "*" 
by "+" will throw an "Args out of range" error in the corner case you mentioned 
("shortdoc:::file"). So I think it's fine to keep "*" there.

> Nitpick, feel free to ignore:
> - `when' is redundant here due to `and' inside its condition.
> - `string-patch-p' would not affect match groups, so it is a bit cheaper.
> - Since it is already known that first character is "#", `substring' 
> instead of `string-remove-prefix' is an extra step in microoptimization

Noted.

Thank you for all your comments and suggestions, Max!

ol.el: Add support for `shortdoc' link type

* lisp/ol.el: Add support for storing and inserting links to `shortdoc'
documentation groups for Emacs Lisp functions.

* doc/org-manual.org (External Links): Add shortdoc link type
documentation.

* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.

---
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1feb5ed60..8894f4231 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ lists all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3432,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 99dd8839c..1623873c0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1405,6 +1405,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index bc9682e4a..928db29e1 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,46 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (and str
+(eq ?# (string-to-char str))
+(intern-soft (substring str 1)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(and str (not fn) (search-forward str nil t)))
+(user-error "Unknown shortdoc group: %s" group
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group 

Re: [PATCH] Add support for shortdoc link type

2024-05-07 Thread Bruno Cardoso

On 2024-05-06, 17:55 +0700, Max Nikulin  wrote:

> It seems my comments have led mostly to confusion rather than 
> improvements. I am sorry for that. I have in mind 2 kind of links:
> -  that may be handled solely by 
> `shortdoc-display-group' with second argument.
> -  that should cause
>(shortdoc-display-group group)
>(search-forward fn nil t) ; or (word-search-forward fn nil t)

I'm sure the confusion is mostly my fault :)

The following now work as expected:

- [[shortdoc:string]]
- [[shortdoc:string::#try-completion]]
- [[shortdoc:string::identical contents]]

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1feb5ed60..8894f4231 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ lists all known
+  documentation groups.
+
+  For more information, see [[info:emacs#Name Help][Name Help]]
+  and [[info:elisp#Documentation Groups][Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3432,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 99dd8839c..1623873c0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1405,6 +1405,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index bc9682e4a..ab6cb497a 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,46 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\).*\\'\\)?" path)
+(let* ((group (match-string 1 path))
+   (str (match-string 2 path))
+   (fn (when (and str (string-match "^#" str))
+ (intern-soft (string-remove-prefix "#" str)
+  (condition-case nil
+  (progn
+(shortdoc-display-group group fn)
+(when (and str (not fn))
+  (search-forward str nil t)))
+(user-error "Unknown shortdoc group: %s" group
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc (intern-soft group) shortdoc--groups))
+(org-link-store-props :type "shortdoc"
+  :link (format "shortdoc:%s" group)
+  :description nil)
+  (user-error "Unknown shortdoc group: %s" group)
+
+  (defun org-link--complete-shortdoc ()
+"Create a \"shortdoc\" link using completion."
+(concat "shortdoc:"
+(completing-read "Shortdoc summary for functions in: "
+ (mapcar #'car shortdoc--groups
+
+  (org-link-set-parameters "shortdoc"
+   :follow #'org-link--open-shortdoc
+   :store #'org-link--store-shortdoc
+   :complete #'org-link--complete-shortdoc))
+
  "http", "https", "mailto", "ftp", and "news" link types
 (dolist (scheme '("ftp" "http" "https" "mailto" "news"))
   (org-link-set-parameters scheme


Re: [PATCH] Add support for shortdoc link type

2024-05-05 Thread Bruno Cardoso

On 2024-05-05, 18:01 +0700, Max Nikulin  wrote:

> I would consider explicit mention that it is related to Emacs Lisp and 
> perhaps that the origin of its name is the ~shortdoc-display-group~ user 
> command.  might be a better link.
>
> This line is rather long though I do not have a link where formatting 
> conventions are documented.

I expanded the description on `org-manual.org' and 'ORG-NEWS'.

>> + "shortdoc" link type
>> +(when (version< "27" emacs-version)
>
> Is it correct?
>
> 2a7488d42d8 2020-10-11 05:51:16 +0200 Lars Ingebrigtsen: Add support for 
> displaying short documentation for function groups
>
> git tag --contains 2a7488d42d8
> emacs-28.0.90

Fixed.

> I think, it is enough to use [^:] since next group is started from "::". 
> You may use use non-capturing group \\(?:::# ...\\) (requires update of 
> next index below) unless you are going add search code back. I am unsure 
> concerning your intentions. You dropped search code, but "#" after "::" 
> is still optional.

Thanks. I updated the regexp.

I had dropped the search code because I wasn't considering the search option 
properly. If I understand correctly, both "::" and "::#" should match a 
function OR a search string? (e.g.: `shortdoc:text-properties::#pos-property' 
will also search for "pos-property" in the shortdoc buffer). This is the 
current behavior in the attached patch.

> I do not have strong opinion what is better here: `user-error' (used in 
> earlier revisions) or `error'. However I do not see the point of 
> capturing original error and signalling another one if it is not 
> `user-error'.

Agreed. I replaced it with `user-error'.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1feb5ed60..dd4cb6cd0 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3382,6 +3382,13 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ lists all known
+  documentation groups. For more information, see [[info:emacs#Name Help]]
+  and [[info:elisp#Documentation Groups]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3423,6 +3430,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 99dd8839c..1623873c0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1405,6 +1405,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= documentation
+groups for Emacs Lisp functions.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index bc9682e4a..ff0b56378 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,44 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version<= "28.0.90" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name, \"group::#function\" or \"group::search_string\"."
+(string-match "\\`\\([^:]*\\)\\(?:::#?\\(.*\\)\\)?\\'" path)
+(let ((group (match-string 1 path))
+  (fn (match-string 2 path)))
+  (condition-case nil
+  (progn
+  (shortdoc-display-group group (intern-soft fn))
+  (unless (intern-soft fn)
+(re-search-forward fn nil t)))
+(user-error "Unknown shortdoc group: %s" group
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc (intern-soft group) shortdoc--groups))
+(org-link-store-props :type "shortdoc"
+  :link (format 

Re: [PATCH] Add support for shortdoc link type

2024-05-04 Thread Bruno Cardoso

On 2024-05-04, 14:38 +0700, Max Nikulin  wrote:

> It is necessary to maintain backward compatibility for `ol-info'. I do 
> not know what kind of separator was added earlier: "::" or "#". I 
> suppose, for new link type, rules more close to file: links may be used, see
> (info "(org) Search Options")
> https://orgmode.org/manual/Search-Options.html
>
> That is why I suggested shortdoc:GROUP::#FUNCTION. This way 
> shrotdoc:GROUP::SEARCH_STRING is possible as well.

I see, thanks for pointing it out. I modified the regexp to match this pattern.

> Notice that `shortdoc-display-group' has optional FUNCTION argument.

Yes, I completely missed that. I updated the patch to use the optional function 
argument instead.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index d66d95a22..61ee0c63d 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3372,6 +3372,10 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+Link to short documentation summary for a function group.  For more information, see [[info:emacs#Name Help][Help by Command or Variable Name]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3413,6 +3417,8 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
+|| =shortdoc:text-properties::#get-pos-property=  |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ebed751..f90c59ed3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1369,6 +1369,10 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= groups.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index bc9682e4a..19ec7a32a 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1582,6 +1582,41 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+(when (version< "27" emacs-version)
+  (defun org-link--open-shortdoc (path _)
+"Open a \"shortdoc\" type link.
+PATH is a group name or \"group::#function\"."
+(string-match "\\`\\([^#:]*\\)\\(::#?\\(.*\\)\\)?\\'" path)
+(let ((group (match-string 1 path))
+  (fn (match-string 3 path)))
+  (condition-case nil
+  (shortdoc-display-group group (intern-soft fn))
+(error (message "Unknown shortdoc group: %s" group)
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc (intern-soft group) shortdoc--groups))
+(org-link-store-props :type "shortdoc"
+  :link (format "shortdoc:%s" group)
+  :description nil)
+  (user-error "Unknown shortdoc group: %s" group)
+
+  (defun org-link--complete-shortdoc ()
+"Create a \"shortdoc\" link using completion."
+(concat "shortdoc:"
+(completing-read "Shortdoc summary for functions in: "
+ (mapcar #'car shortdoc--groups
+
+  (org-link-set-parameters "shortdoc"
+   :follow #'org-link--open-shortdoc
+   :store #'org-link--store-shortdoc
+   :complete #'org-link--complete-shortdoc))
+
  "http", "https", "mailto", "ftp", and "news" link types
 (dolist (scheme '("ftp" "http" "https" "mailto" "news"))
   (org-link-set-parameters scheme


Re: [PATCH] Add support for shortdoc link type

2024-05-03 Thread Bruno Cardoso


On 2024-05-02, 17:41 +0700, Max Nikulin  wrote:

> `condition-case' may help to avoid the internal `shortdoc--groups' 
> variable here. As to completion, it is better to ask for public API. 
> However emacs developers likely will decline such request.
>
> Consider the following just as ideas.
>
> - Support of search options. Buttons in help pages move point to 
> specific functions.
>
> 
>
> - At first I considered adding shortdoc to help links that may call 
> either `describe-function' or `describe-variable', but it is unlikely 
> possible.

Hi Max,

Thanks for your suggestions. Indeed `condition-case' might be better there.

I implemented the search option by borrowing the regexp from `ol-info':

(defun org-link--open-shortdoc (path _)
  "Open a \"shortdoc\" type link.
PATH is a group name or \"group::#function\"."
  (string-match "\\`\\([^#:]*\\)\\(?:[#:]:?\\(.*\\)\\)?\\'" path)
  (let ((group (match-string 1 path))
(fn (match-string 2 path)))
(condition-case nil
(progn
  (shortdoc-display-group group)
  (when fn
(re-search-forward (concat "^(" (string-remove-prefix "#" fn))
   nil t)
(beginning-of-line)))
  (error (message "Unknown shortdoc group: %s" group)

It works, but I'm not quite sure if this is the best approach.

It curently matches all the cases below, as I got confused about the correct 
link syntax:

shortdoc:text-properties:get-pos-property
shortdoc:text-properties::get-pos-property
shortdoc:text-properties#get-pos-property
shortdoc:text-properties:#get-pos-property
shortdoc:text-properties::#get-pos-property


Best,

Bruno.



Re: [PATCH] Add support for shortdoc link type

2024-05-01 Thread Bruno Cardoso

On 2024-05-01, 17:55 +, Ihor Radchenko  wrote:

> Bruno Cardoso  writes:
>
>> Thanks for your comments. See attached the updated patch.
>
> Thanks for the update!
>
>> +- =shortdoc= ::
>> +
>> +  Link to short documentation summary for a function group.
>
> Might be useful to throw a link to Emacs manual here - [[info:emacs#Name 
> Help]]
>
>> +*** =ol.el=: Support for ~shortdoc~ link type
>> +Add support for storing and inserting links to ~shortdoc~ groups.
>
> =shortdoc= I think. It is not ~code~, but rather =verbatim=.
>
>> +  (defun org-link--store-shortdoc ( _interactive?)
>> +(when (eq major-mode 'shortdoc-mode)
>> +  (let* ((buffer (buffer-name))
>> + (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
>> +  (match-string 1 buffer
>> +(when (assoc (intern group) shortdoc--groups)
>
> This will err when GROUP is nil (string-match does not match).
>
>> +  (org-link-set-parameters "shortdoc"
>> +   :follow #'org-link--open-shortdoc
>> +   :store #'org-link--store-shortdoc))
>
> Maybe also implement :complete parameter? It should be relatively easy.
>

Thanks Ihor, here is the updated patch.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index d66d95a22..15b79ae21 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3372,6 +3372,10 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+Link to short documentation summary for a function group.  For more information, see [[info:emacs#Name Help][Help by Command or Variable Name]].
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3413,6 +3417,7 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8dbc3292d..b0f4cb287 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1357,6 +1357,10 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for =shortdoc= link type
+
+Add support for storing and inserting links to =shortdoc= groups.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index f6d656982..dd95f5d4c 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1597,6 +1597,37 @@ PATH is a symbol name, as a string."
 (org-link-set-parameters "help"
  :follow #'org-link--open-help
  :store #'org-link--store-help)
+ "shortdoc" link type
+(when (version< "27" emacs-version)
+  (defun org-link--open-shortdoc (group _)
+"Open a \"shortdoc\" type link.
+GROUP is a symbol name."
+(if (assoc (intern group) shortdoc--groups)
+(shortdoc-display-group group)
+  (user-error "Unknown shortdoc group: %s" group)))
+
+  (defun org-link--store-shortdoc ( _interactive?)
+"Store \"shortdoc\" type link."
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(if (and group (assoc (intern group) shortdoc--groups))
+(org-link-store-props :type "shortdoc"
+  :link (format "shortdoc:%s" group)
+  :description nil)
+  (user-error "Unknown shortdoc group: %s" group)
+
+  (defun org-link--complete-shortdoc ()
+"Create a \"shortdoc\" link using completion."
+(concat "shortdoc:"
+(completing-read "Shortdoc summary for functions in: "
+ (mapcar #'car shortdoc--groups
+
+  (org-link-set-parameters "shortdoc"
+   :follow #'org-link--open-shortdoc
+   :store #'org-link--store-shortdoc
+   :complete #'org-link--complete-shortdoc))
 
  "http", "https", "mailto", "ftp", and "news" link types
 (dolist (scheme '("ftp" "http" "https" "mailto" "news"))


Re: [PATCH] Add support for shortdoc link type

2024-05-01 Thread Bruno Cardoso

Hi Ihor,

Thanks for your comments. See attached the updated patch.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index d66d95a22..c9e307c94 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3372,6 +3372,10 @@ Here is the full set of built-in link types:
 
   Execute a shell command upon activation.
 
+- =shortdoc= ::
+
+  Link to short documentation summary for a function group.
+
 
 For =file:= and =id:= links, you can additionally specify a line
 number, or a text search string, separated by =::=.  In Org files, you
@@ -3413,6 +3417,7 @@ options:
 | irc| =irc:/irc.com/#emacs/bob=  |
 | help   | =help:org-store-link=  |
 | info   | =info:org#External links=  |
+| shortdoc   | =shortdoc:text-properties= |
 | shell  | =shell:ls *.org=   |
 | elisp  | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate)   |
 || =elisp:org-agenda= (interactive Elisp command) |
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8dbc3292d..cfe894448 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1357,6 +1357,10 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for ~shortdoc~ link type
+
+Add support for storing and inserting links to ~shortdoc~ groups.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index f6d656982..b7b988581 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1598,6 +1598,30 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+
+(when (version< "27" emacs-version)
+  (defun org-link--open-shortdoc (group _)
+"Open a \"shortdoc\" type link.
+GROUP is a symbol name."
+(if (assoc (intern group) shortdoc--groups)
+(shortdoc-display-group group)
+  (user-error "Unknown shortdoc group: %s" group)))
+
+  (defun org-link--store-shortdoc ( _interactive?)
+(when (eq major-mode 'shortdoc-mode)
+  (let* ((buffer (buffer-name))
+ (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+  (match-string 1 buffer
+(when (assoc (intern group) shortdoc--groups)
+  (org-link-store-props :type "shortdoc"
+:link (format "shortdoc:%s" group)
+:description nil)
+
+  (org-link-set-parameters "shortdoc"
+   :follow #'org-link--open-shortdoc
+   :store #'org-link--store-shortdoc))
+
  "http", "https", "mailto", "ftp", and "news" link types
 (dolist (scheme '("ftp" "http" "https" "mailto" "news"))
   (org-link-set-parameters scheme


On 2024-05-01, 11:00 +, Ihor Radchenko  wrote:

> Bruno Cardoso  writes:
>
>> This patch adds support for "shortdoc:" links.
>
> Thanks!
>
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>
> You also need to document the new built-in link type in the manual.
>
>> +(defun org-link--open-shortdoc (group _)
>> +  "Open a \"shortdoc\" type link.
>> +GROUP is a symbol name."
>> +  (if (assoc (intern group) shortdoc--groups)
>> +  (shortdoc group)
>> +(user-error "Unknown shortdoc group: %s" group)))
>
> `shortdoc' function was only introduced in Emacs 29.
> In Emacs 28, there is only `shortdoc-display-group'.
> Please use the latter function, when `shortdoc' is not available.
>
> In Emacs 27, shortdoc library is not yet present. So, please avoid
> defining shortdoc: link type in Emacs <28.
>
> -- 
> Ihor Radchenko // yantar92,
> 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>


[PATCH] Add support for shortdoc link type

2024-04-30 Thread Bruno Cardoso

Hi all,

This patch adds support for "shortdoc:" links.

Best,

Bruno.

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8dbc3292d..cfe894448 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1357,6 +1357,10 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing.
 =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=.
 The old name is obsolete.
 
+*** =ol.el=: Support for ~shortdoc~ link type
+
+Add support for storing and inserting links to ~shortdoc~ groups.
+
 ** New functions and changes in function arguments
 *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~
 
diff --git a/lisp/ol.el b/lisp/ol.el
index f6d656982..f0088ae5f 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1598,6 +1598,29 @@ PATH is a symbol name, as a string."
  :follow #'org-link--open-help
  :store #'org-link--store-help)
 
+ "shortdoc" link type
+
+(defun org-link--open-shortdoc (group _)
+  "Open a \"shortdoc\" type link.
+GROUP is a symbol name."
+  (if (assoc (intern group) shortdoc--groups)
+  (shortdoc group)
+(user-error "Unknown shortdoc group: %s" group)))
+
+(defun org-link--store-shortdoc ( _interactive?)
+  (when (eq major-mode 'shortdoc-mode)
+(let* ((buffer (buffer-name))
+   (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
+(match-string 1 buffer
+  (when (assoc (intern group) shortdoc--groups)
+(org-link-store-props :type "shortdoc"
+  :link (format "shortdoc:%s" group)
+  :description nil)
+
+(org-link-set-parameters "shortdoc"
+ :follow #'org-link--open-shortdoc
+ :store #'org-link--store-shortdoc)
+
  "http", "https", "mailto", "ftp", and "news" link types
 (dolist (scheme '("ftp" "http" "https" "mailto" "news"))
   (org-link-set-parameters scheme


[BUG] Unable to unfold new LOGBOOK drawer

2024-04-05 Thread Bruno Cardoso


Hi all,

In an Org file with:

#+TODO: TODO(t) | DONE(d!)

and

(setopt org-log-into-drawer t)

After marking a heading as DONE, the newly created :LOGBOOK: can't be unfolded.

This is similar to 
https://lists.gnu.org/archive/html/emacs-orgmode/2024-03/msg00338.html

Org mode version 9.7-pre (release_9.6.25-1345-gb45b39)


Best,

Bruno.



Re: Things got very slow: profiler output

2024-03-17 Thread Bruno Cardoso



On 2024-03-16, 21:14 +, Ihor Radchenko  wrote:
>
> It is a few times faster. And the profiler shows no slowdown, AFAIU.
> Is the problem solved?
>

Hi Ihor. I accidentally cut out part of my last reply, sorry.

Yes, it looks like the situation greatly improved on latest main. I guess the 
problem is solved on my side. Thank you very much!

Best,

Bruno.




Re: Things got very slow: profiler output

2024-03-16 Thread Bruno Cardoso

On 2024-03-16, 15:56 +, Ihor Radchenko  wrote:

> Ok.
> Then, what about the latest main?

Updated and tested again on Emacs -Q.

org-fold-core--property-symbol-get-create  145790  0.5319647139  
3.648...e-06

GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.40, cairo 
version 1.18.0)
Org mode version 9.7-pre (release_9.6.21-1289-gae50b9)


[profiler-profile "28.1" cpu #s(hash-table size 65 test equal rehash-size 1.5 
rehash-threshold 0.8125 data ([display-buffer-use-some-window display-buffer 
pop-to-buffer switch-to-buffer-other-window 
profiler-report-profile-other-window profiler-report-cpu profiler-report progn 
elisp--eval-last-sexp eval-last-sexp funcall-interactively command-execute nil 
nil nil nil] 3 [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil 
nil] 111 [line-move next-line funcall-interactively command-execute nil nil nil 
nil nil nil nil nil nil nil nil nil] 24 [next-line funcall-interactively 
command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 
[redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil nil] 2 [font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil] 7 
[timer-inc-time timer-event-handler nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil] 4 [eval redisplay_internal\ \(C\ function\) nil nil nil nil nil 
nil nil nil nil nil nil nil nil nil] 2 [progn elisp--eval-last-sexp 
eval-last-sexp funcall-interactively command-execute nil nil nil nil nil nil 
nil nil nil nil nil] 7 [Automatic\ GC] 12)) (26101 65122 534040 823000) nil]


Re: Things got very slow: profiler output

2024-03-16 Thread Bruno Cardoso

On 2024-03-16, 08:56 +, Ihor Radchenko  wrote:

> Bruno Cardoso  writes:
>
> What if you try the following version of `org-activate-folds'?
>
> (defun org-activate-folds (limit)
>   "Arrange trailing newlines after folds to inherit face before the fold."
>   (let ((next-unfolded-newline (search-forward "\n" limit 'move)))
> (while (and next-unfolded-newline (org-fold-folded-p) (not (eobp)))
>   (goto-char (org-fold-core-next-visibility-change nil limit 'only-folds))
>   (setq next-unfolded-newline (search-forward "\n" limit 'move)))
> (when next-unfolded-newline
>   (org-with-wide-buffer
>(when (and (> (match-beginning 0) (point-min))
>   (org-fold-folded-p (1- (match-beginning 0)))
>   (not (org-fold-folded-p (1- (match-beginning 0)) 
> 'org-link)))
>  (put-text-property
>   (match-beginning 0) (match-end 0)
>   'face
>   (get-text-property
>(org-fold-previous-visibility-change
> (1- (match-beginning 0)))
>'face)))
>t
>

It makes almost no difference.


[profiler-profile "28.1" cpu #s(hash-table size 145 test equal rehash-size 1.5 
rehash-threshold 0.8125 data ([nil nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil] 736 [line-move previous-line funcall-interactively 
command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 4 
[org-eldoc-documentation-function eldoc-documentation-default 
eldoc--invoke-strategy eldoc-print-current-symbol-info "#" apply 
timer-event-handler nil nil nil nil nil nil nil nil nil] 2 
[org-fold-core--property-symbol-get-create org-fold-core-get-region-at-point 
org-fold-core--fix-folded-region "#" apply 
org-self-insert-command funcall-interactively command-execute nil nil nil nil 
nil nil nil nil] 63 [org-fold-core--property-symbol-get-create 
org-fold-core-get-folding-spec org-fold-folded-p and while let 
org-activate-folds font-lock-fontify-keywords-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil] 332 
[org-fold-core--property-symbol-get-create org-fold-core-get-folding-spec 
org-fold-folded-p and if save-restriction save-excursion progn if let 
org-activate-folds font-lock-fontify-keywords-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions] 322 
[org-fold-core--property-symbol-get-create "#" mapcar 
org-fold-core-next-folding-state-change org-fold-core-get-regions 
org-fold-region org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil] 235 
[jit-lock-fontify-now jit-lock-function redisplay_internal\ \(C\ function\) nil 
nil nil nil nil nil nil nil nil nil nil nil nil] 27 [org-at-table-p "#" apply org-self-insert-command funcall-interactively 
command-execute nil nil nil nil nil nil nil nil nil nil] 5 
[org-fold-core--check-spec mapc org-fold-core-next-folding-state-change 
org-fold-core-get-regions org-fold-region org-unfontify-region 
font-lock-unfontify-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil] 8 
[org-fold-core--property-symbol-get-create "#" mapcar 
org-fold-core-next-folding-state-change org-fold-core--fix-folded-region 
"#" apply org-self-insert-command 
funcall-interactively command-execute nil nil nil nil nil nil] 21 
[org-fold-core--property-symbol-get-create org-fold-core-get-folding-spec 
org-fold-core-get-regions org-fold-region org-unfontify-region 
font-lock-unfontify-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil] 225 
[font-lock-extend-jit-lock-region-after-change jit-lock-after-change "#" apply org-self-insert-command funcall-interactively 
command-execute nil nil nil nil nil nil nil nil nil] 4 
[font-lock-fontify-keywords-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil] 105 
[org-fold-check-before-invisible-edit-maybe apply org-self-insert-command 
funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil 
nil] 1 [org-fold-region org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-

Re: Things got very slow: profiler output

2024-03-15 Thread Bruno Cardoso


On 2024-03-15, 17:18 +, Ihor Radchenko  wrote:

> Bruno Cardoso  writes:
>
> May you do the following:
>
> 1. (require 'elp)
> 2. (elp-instrument-function #'org-fold-core--property-symbol-get-create)
> 3. Do actions in Org file
> 4. (elp-results)
> 5. See *ELP Profiling Results*
> 6. (elp-restore-all)
>
> For me, the result is
>
> Function Name  Call Count  Elapsed Time  Average 
> Time
> org-fold-core--property-symbol-get-create  27361   0.5646422580  
> 2.063...e-05
>
> (the time numbers are not real because instrumenting itself makes
> function a lot slower, but we can compare the call count)
>

My call count is in fact higher:

org-fold-core--property-symbol-get-create  196278  3.2828460320  
1.672...e-05




Re: Things got very slow: profiler output

2024-03-15 Thread Bruno Cardoso

On 2024-03-15, 14:24 +, Ihor Radchenko  wrote:
>
> May you share the full profile via M-x profiler-report-write-profile then?

Hi Ihor,

See attached the profiler-report in emacs -Q and Org mode version 9.7-pre 
(release_9.6.20-1281-gfb61e8).

In a new org file I created some headings, fold/unfold, and did some typing 
while recording.


[profiler-profile "28.1" cpu #s(hash-table size 145 test equal rehash-size 1.5 
rehash-threshold 0.8125 data ([nil nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil] 908 [font-lock-default-fontify-region font-lock-fontify-region 
"#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil nil nil 
nil nil nil] 310 [org-fold-core--property-symbol-get-create 
org-fold-core-get-folding-spec org-fold-core-get-regions org-fold-region 
org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil] 340 
[org-fold-core--property-symbol-get-create org-fold-core-get-folding-spec 
org-activate-folds font-lock-fontify-keywords-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil nil] 846 
[org-fold-core-get-folding-spec org-activate-folds 
font-lock-fontify-keywords-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil nil nil nil] 67 
[org-fold-core--property-symbol-get-create "#" mapcar 
org-fold-core-next-folding-state-change org-fold-core-get-regions 
org-fold-region org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function line-move-visual line-move] 14 [mapcar 
org-fold-core-next-folding-state-change org-fold-core-get-regions 
org-fold-region org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function line-move-visual line-move previous-line 
funcall-interactively] 3 [org-fold-core-get-folding-spec 
org-fold-core-get-regions org-fold-region org-unfontify-region 
font-lock-unfontify-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil nil] 49 [line-move 
previous-line funcall-interactively command-execute nil nil nil nil nil nil nil 
nil nil nil nil nil] 8 [if eval redisplay_internal\ \(C\ function\) nil nil nil 
nil nil nil nil nil nil nil nil nil nil] 6 [org-fontify-drawers 
font-lock-fontify-keywords-region font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function 
redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil] 41 
[previous-line funcall-interactively command-execute nil nil nil nil nil nil 
nil nil nil nil nil nil nil] 3 [font-lock-default-fontify-region 
font-lock-fontify-region "#" 
jit-lock--run-functions jit-lock-fontify-now jit-lock-function line-move 
previous-line funcall-interactively command-execute nil nil nil nil nil nil] 3 
[font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function line-move-visual line-move previous-line 
funcall-interactively command-execute nil nil nil nil nil] 3 
[org-fold-core--property-symbol-get-create "#" mapcar 
org-fold-core-next-folding-state-change org-fold-core-get-regions 
org-fold-region org-unfontify-region font-lock-unfontify-region 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil] 367 
[org-element--parse-to org-element-at-point org-element-at-point-no-context 
org-indent-line indent-according-to-mode 
electric-indent-post-self-insert-function newline org--newline "#" apply org-return funcall-interactively command-execute 
nil nil nil] 3 [font-lock-extend-region-wholelines 
font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now 
jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil nil nil 
nil nil] 6 [org-fold-core-get-folding-spec org-fold-core--fix-folded-region 
self-insert-command "#" apply 
org-self-insert-command funcall-interactively command-execute nil nil nil nil 
nil nil nil nil] 1 [org-fold-core--property-symbol-get-create 
org-fold-core-get-region-at-point org-fold-core--fix-folded-region 
self-insert-command "#" apply 
org-self-insert-command funcall-interactively command-execute nil nil nil nil 
nil nil nil] 45 

Re: Things got very slow: profiler output

2024-03-14 Thread Bruno Cardoso


On 2024-03-14, 21:23 +, Ihor Radchenko  wrote:

>
> That's a different bug.
> Fixed on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fb61e83f2
>
> You can try to run
> M-: (benchmark-run 1 (org-fold-core--property-symbol-get-create 'outline 
> nil t)) 
> from inside Org mode buffer.
>
> I am getting (0.178426995 0 0.0) as a result - takes almost no CPU time.
>

Thanks Ihor. Indeed I get a similar result from benchmark-run. 




Re: Things got very slow: profiler output

2024-03-14 Thread Bruno Cardoso


On 2024-03-14, 07:34 +, Gerard Vermeulen  
wrote:

>
> I see this too and my work-around is calling org-fold-show-all to read 
> the
> newly created property drawer.
>

Hello Gerard,

Yes, this work-around also does work for me. I often do S-TAB to cycle the Org 
file visibility and then I'm able to fold/unfold the new drawer again.


> I am running
> GNU Emacs 30.0.50 (build 15, x86_64-apple-darwin20.6.0, NS 
> appkit-2202.70 Version 11.7.1 (Build 20G918)) of 2024-03-14
> with a yesterday's Org main.
>
> I am using the default theme (light background) and do not do any font 
> tweaking.

I forgot to mention my Emacs version: GNU Emacs 29.2 (build 1, 
x86_64-pc-linux-gnu, GTK+ Version 3.24.40, cairo version 1.18.0). Its the 
'emacs-nativecomp' package from Arch repository.


Best,

Bruno.



Re: Things got very slow: profiler output

2024-03-14 Thread Bruno Cardoso


On 2024-03-14, 01:17 +, William Denton  wrote:

>
> I don't have that problem, if I understand your description right, but like 
> you Ihor's tweak didn't get things back to normal for me.  I'm now using 
> Emacs from the development tree and its Org (which doesn't yet have commit 
> 5d186b499dde97f5 from 25 February) and it's back to normal for now.
>

Hello William,

I haven't tried to revert to it yet, but I guess it was in fact after the 
commit/date you mentioned when I started noticing this behavior.


> Could it be something our systems or configurations have in common, Bruno?  
> My Org configuration is here, if you want to compare:
>
> https://github.com/wdenton/.emacs.d/blob/master/init.org#org
>

I looked into your config and couldn't spot anything special we have in common. 
I have these settings in my config regarding org fold and fontify:

(setq org-fold-catch-invisible-edits 'smart  ;; default is 'smart
  org-fontify-done-headline  t   ;; default is t
  org-fontify-quote-and-verse-blocks t   ;; default is nil
  org-fontify-whole-heading-line t)  ;; default is nil

However I get the slow-down in a clean init.el with just `(straight-use-package 
'org)'.


Best,

Bruno.



Re: Things got very slow: profiler output

2024-03-13 Thread Bruno Cardoso


On 2024-03-12, 12:43 +, Ihor Radchenko  wrote:

>
> Profiler data does not make sense here.
> In any case, I tried to make fontifying newlines after folds slightly
> faster on the latest main:
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c9b655f27
>
> If you are lucky, it should help.
>

Hello,

For me this improved the situation a bit, but I still get significant 
slow-downs as before.

I don't know if it is related, but if I set a property (C-c C-x p) in a new 
heading with no drawers, I'm unable to unfold the newly created drawer (TAB 
over it does nothing), although I am able to fold/unfold other already existent 
drawers as expected. This also happens in `emacs -Q' (org-version 9.7-pre 
release_9.6.20-1280-g7653e5).

Besides the profiler, which still blames 
`org-fold-core--property-symbol-get-create' for the slow-down, is there some 
debugging configuration I should try out? I tried setting

(setq org-element--cache-self-verify 'backtrace)
(setq org-element--cache-self-verify-frequency 1.0)

but it does not signal any error.


Best,

Bruno.



Re: Emacs slow-down

2024-03-07 Thread Bruno Cardoso


On 2024-03-07, 13:23 +, Ihor Radchenko  wrote:

> This is strange. `org-fold-core--property-symbol-get-create' should be
> very fast normally.
>
> A blind guess: do you have `org-fold-core-style' set to 'text-properties?
>

Hi Ihor,

No, `org-fold-core-style' is set to 'overlays.




Re: Emacs slow-down

2024-03-07 Thread Bruno Cardoso


Hello,

I also did noticed some slow-down in the most recent org. This is the CPU 
profiler report after typing some words in an org-file I'm working on:

6493  71% - redisplay_internal (C function)
6372  70%  - jit-lock-function
6323  69%   - jit-lock-fontify-now
6257  68%- jit-lock--run-functions
6257  68% - #
6246  68%  - font-lock-fontify-region
6191  68%   - font-lock-default-fontify-region
3300  36%- font-lock-fontify-keywords-region
2448  26% - org-activate-folds
2122  23%  - org-fold-core-get-folding-spec
2035  22% org-fold-core--property-symbol-get-create
 217   2%  + org-fold-previous-visibility-change
 178   1% - org-activate-links
 178   1%  - org-activate-links--overlays
   3   0%   - org-element-link-parser
   3   0%  org-link-expand-abbrev

Best,

Bruno.


On 2024-03-07, 08:23 +0100, Pedro Andres Aranda Gutierrez  
wrote:

> Hi
>
> is it just me, or have other people also noticed hiccups when editing org
> files with org-mode (main from savannah). The moment I revert to the
> org-mode shipped with emacs master, editing returns to normal (and fluid).
>
> Would it make sense to take a closer look at this?
>
> Best, /PA
> --
> Fragen sind nicht da, um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>
> Headaches with a Juju log:
> unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
> a leader-deposed hook here, but we can't yet



Re: [TASK] Please help updating blog generator list on https://orgmode.org/tools.html

2024-01-11 Thread Bruno Cardoso


On 2024-01-11, 14:55 +, Ihor Radchenko  wrote:

> Hello,
>
> Org mode website has a page listing various third-party tools that work
> with Org mode.
>
> However, that page is now severely outdated. There is a number of dead
> links and projects last updated 10+ years ago.
>
> For example, o-blog is no longer maintained.
>
> If you know any actively developed working blog generators for Org mode,
> please share them.
>
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 

Hello,

I have in my notes this list of Static Site Generators projects, along with 
their own descriptions:

- https://github.com/bastibe/org-static-blog :: A static site generator using 
org-mode

- https://gitlab.com/sctlib/emacs-ssg :: A static site generator using emacs 
and org-mode with some defaults

- https://gitlab.com/mbork_mbork_pl/org-clive :: a simple and minimalistic 
Org-based static weblog generator

- https://github.com/tonyaldon/one.el :: one.el a simple Static Site Generator 
for Emacs Lisp programmers and org-mode users.

- https://github.com/novoid/lazyblorg :: Blogging with Org-mode for very lazy 
people

- https://github.com/dangom/writefreely.el :: Frictionless blogging with Org 
Mode. No setup required.


Best,

Bruno.



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Bruno Cardoso


On 2023-07-03, 13:00 +, Fionn Stephens  wrote:

> Hi,
>
> I think support for screenplay formatting would be a useful feature to add. 
> Like to how comments or quotes are done, it could be in between the tags: 
> #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
> Fountain would make the most sense.
>
> For example, a section could look like:
>
> #+BEGIN_SCREENPLAY
> INT./EXT. BLOOM HOUSE - (PRESENT) DAY
>
> The front door opens to reveal Will and Josephine on the porch with their 
> bags. REVERSE to Will's mother Sandra (53), surprised and a little annoyed.
>
> SANDRA
> How did you get here?
>
> WILL
> We swam. The Atlantic, it's not that big really.
> #+END_SCREENPLAY
>
> Thanks,Fionn Stephens

Hi. You can use org-blocks like this with fountain-mode:

- https://github.com/rnkn/fountain-mode

#+begin_src fountain
INT./EXT. BLOOM HOUSE - (PRESENT) DAY

The front door opens to reveal Will and Josephine on the porch with their bags. 
REVERSE to
Will's mother Sandra (53), surprised and a little annoyed.

SANDRA
How did you get here?

WILL
We swam. The Atlantic, it's not that big really.
#+end_src


Best,

Bruno.



Re: [BUG] lisp/org-eldoc.el: Eldoc does not work in org source blocks

2023-05-29 Thread Bruno Cardoso


Sure, fair enough. I am aware this is just a workaround, not an actual 
solution. Thanks!

Bruno.


On 2023-05-29, 07:42 +, Ihor Radchenko  wrote:

> Bruno Cardoso  writes:
>
>> The Eldoc interface `eldoc-print-current-symbol-info' works everywhere just 
>> fine for me (Emacs
>> 28.2), but it does not work inside org source blocks for elisp code. Yet, 
>> reverting to the
>> obsolete `elisp-eldoc-documentation-function' in org-eldoc's
>> `org-eldoc-documentation-function' works (see below). I tested it both in my 
>> own config and
>> "emacs -Q" with same results.
>
> Note that org-eldoc is not a part of Org. We only provide a minimal
> maintenance until someone takes over it. See
> https://orgmode.org/worg/org-orphanage.html
>
> Your change to obsolete function is questionable. So, this change is at
> least non-trivial. Unfortunately, this falls beyond the level of
> maintenance we can offer here.
>
> -- 
> Ihor Radchenko // yantar92,
> 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>



[BUG] lisp/org-eldoc.el: Eldoc does not work in org source blocks

2023-05-28 Thread Bruno Cardoso


Hello everyone.

The Eldoc interface `eldoc-print-current-symbol-info' works everywhere just 
fine for me (Emacs
28.2), but it does not work inside org source blocks for elisp code. Yet, 
reverting to the
obsolete `elisp-eldoc-documentation-function' in org-eldoc's
`org-eldoc-documentation-function' works (see below). I tested it both in my 
own config and
"emacs -Q" with same results.

---
 lisp/org-eldoc.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-eldoc.el b/lisp/org-eldoc.el
index 7137c46..24f0aa3 100644
--- a/lisp/org-eldoc.el
+++ b/lisp/org-eldoc.el
@@ -156,7 +156,8 @@
(fboundp 'elisp-eldoc-funcall))
   (let ((eldoc-documentation-functions
  '(elisp-eldoc-var-docstring elisp-eldoc-funcall)))
-(eldoc-print-current-symbol-info)))
+;;(eldoc-print-current-symbol-info)))
+(elisp-eldoc-documentation-function)))
  ((fboundp 'elisp-eldoc-documentation-function)
   (elisp-eldoc-documentation-function))
  (t; Emacs<25
-- 
2.40.1


Is this in fact a bug or should I have configured something else?

Best,

Bruno.



Re: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations

2023-05-22 Thread Bruno Cardoso

On 2023-05-22, 10:49 +, Ihor Radchenko  wrote:

> Thanks!
> May you also update the docstring of `org-return-follows-link' and add
> etc/ORG-NEWS entry?

Hi Ihor, here's the updated patch as suggested.

Best,

Bruno.

>From 436cd212507cc948af8de6f9e57b5e14e29f23dd Mon Sep 17 00:00:00 2001
From: bruno 
Date: Sun, 21 May 2023 15:53:42 -0300
Subject: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on
 citations

* lisp/org.el (org-return): When `org-return-follows-link' is non-nil
and point is over an org-cite citation or citation reference, call `org-open-at-point'.

TINYCHANGE
---
 etc/ORG-NEWS | 5 +
 lisp/org-keys.el | 3 ++-
 lisp/org.el  | 9 +
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6b40198b5..ddf1e9110 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -221,6 +221,11 @@ Running shell blocks with the ~:session~ header freezes Emacs until
 execution completes.  The new ~:async~ header allows users to continue
 editing with Emacs while a ~:session~ block executes.
 
+*** ~org-return~ now acts on citations at point
+
+When ~org-return-follows-link~ is non-nil and cursor is over an
+org-cite citation, ~org-return~ will call ~org-open-at-point~.
+
 ** Miscellaneous
 *** =org-crypt.el= now applies initial visibility settings to decrypted entries
 
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index c62d62a1d..5f3ea8da3 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -299,7 +299,8 @@ implementation is bad."
 
 (defcustom org-return-follows-link nil
   "Non-nil means on links RET will follow the link.
-In tables, the special behavior of RET has precedence."
+In tables, the special behavior of RET has precedence.
+On a timestamp or a citation, call `org-open-at-point'."
   :group 'org-link-follow
   :type 'boolean
   :safe #'booleanp)
diff --git a/lisp/org.el b/lisp/org.el
index 866af624e..8eab3ed22 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17774,8 +17774,8 @@ When optional INDENT argument is non-nil, call
 and INTERACTIVE.
 
 When `org-return-follows-link' is non-nil and point is on
-a timestamp or a link, call `org-open-at-point'.  However, it
-will not happen if point is in a table or on a \"dead\"
+a timestamp, a link or a citation, call `org-open-at-point'.
+However, it will not happen if point is in a table or on a \"dead\"
 object (e.g., within a comment).  In these case, you need to use
 `org-open-at-point' directly."
   (interactive "i\nP\np")
@@ -17795,8 +17795,8 @@ object (e.g., within a comment).  In these case, you need to use
 	  (insert "\n")
 	(org-table-justify-field-maybe)
 	(call-interactively #'org-table-next-row)))
- ;; On a link or a timestamp, call `org-open-at-point' if
- ;; `org-return-follows-link' allows it.  Tolerate fuzzy
+ ;; On a link, a timestamp or a citation, call `org-open-at-point'
+ ;; if `org-return-follows-link' allows it.  Tolerate fuzzy
  ;; locations, e.g., in a comment, as `org-open-at-point'.
  ((and org-return-follows-link
 	   (or (and (eq 'link element-type)
@@ -17808,6 +17808,7 @@ object (e.g., within a comment).  In these case, you need to use
 			(> (point) origin
 	   (org-in-regexp org-ts-regexp-both nil t)
 	   (org-in-regexp org-tsr-regexp-both nil  t)
+   (org-element-lineage context '(citation citation-reference))
 	   (org-in-regexp org-link-any-re nil t)))
   (call-interactively #'org-open-at-point))
  ;; Insert newline in heading, but preserve tags.
-- 
2.40.1



[PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations

2023-05-22 Thread Bruno Cardoso

Hello everyone.

This patch is a tiny change that allows `org-return' to call 
`org-open-at-point' when cursor is over org-cite citations.

Best,

Bruno.

>From 19409cbf70958aa1d7f508cd7151f36a92212341 Mon Sep 17 00:00:00 2001
From: bruno 
Date: Sun, 21 May 2023 15:53:42 -0300
Subject: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on
 citations

* lisp/org.el (org-return): When `org-return-follows-link' is non-nil
and point is over an org-cite citation or citantion reference, call `org-open-at-point'.

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

diff --git a/lisp/org.el b/lisp/org.el
index 866af624e..8eab3ed22 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17774,8 +17774,8 @@ When optional INDENT argument is non-nil, call
 and INTERACTIVE.
 
 When `org-return-follows-link' is non-nil and point is on
-a timestamp or a link, call `org-open-at-point'.  However, it
-will not happen if point is in a table or on a \"dead\"
+a timestamp, a link or a citation, call `org-open-at-point'.
+However, it will not happen if point is in a table or on a \"dead\"
 object (e.g., within a comment).  In these case, you need to use
 `org-open-at-point' directly."
   (interactive "i\nP\np")
@@ -17795,8 +17795,8 @@ object (e.g., within a comment).  In these case, you need to use
 	  (insert "\n")
 	(org-table-justify-field-maybe)
 	(call-interactively #'org-table-next-row)))
- ;; On a link or a timestamp, call `org-open-at-point' if
- ;; `org-return-follows-link' allows it.  Tolerate fuzzy
+ ;; On a link, a timestamp or a citation, call `org-open-at-point'
+ ;; if `org-return-follows-link' allows it.  Tolerate fuzzy
  ;; locations, e.g., in a comment, as `org-open-at-point'.
  ((and org-return-follows-link
 	   (or (and (eq 'link element-type)
@@ -17808,6 +17808,7 @@ object (e.g., within a comment).  In these case, you need to use
 			(> (point) origin
 	   (org-in-regexp org-ts-regexp-both nil t)
 	   (org-in-regexp org-tsr-regexp-both nil  t)
+   (org-element-lineage context '(citation citation-reference))
 	   (org-in-regexp org-link-any-re nil t)))
   (call-interactively #'org-open-at-point))
  ;; Insert newline in heading, but preserve tags.
-- 
2.40.1